Extending TorchScript with Custom C++ Operators — PyTorch Tutorials 1.13.1+cu117 documentation
The PyTorch 1.0 release introduced a new programming model to PyTorch called TorchScript. TorchScript is a subset of the Python programming language which can be parsed, compiled and optimized by the TorchScript compiler. Further, compiled TorchScript models have the option of being serialized into an on-disk file format, which you can subsequently load and run from pure C++ (as well as Python) for inference. TorchScript supports a large subset of operations provided by the torch package, allowing you to express many kinds of complex models purely as a series of tensor operations from PyTorch’s “standard library”. Nevertheless, there may be times where you find yourself in need of extending TorchScript with a custom C++ or CUDA function. While we recommend that you only resort to this option if your idea cannot be expressed (efficiently enough) as a simple Python function, we do provide a very friendly and simple interface for defining custom C++ and CUDA kernels using ATen, PyTorch’s
<no title> — PyTorch Tutorials 2.13.0+cu130 documentation Skip to main content Back to top Ctrl + K v2.13.0+cu130 Go to pytorch.org Ctrl + K X GitHub Discourse PyPi Rate this Page ★ ★ ★ ★ ★ advanced/torch_script_custom_ops Run in Google Colab Colab Download Notebook Notebook View on GitHub GitHub Warning TorchScript is deprecated, please use torch.export instead. On this page PyTorch Libraries ExecuTorch Helion torchao kineto torchtitan TorchRL torchvision torchaudio tensordict PyTorch on XLA Devices so the DOM is not blocked --> Docs Access comprehensive developer documentation for PyTorch Vi
Explore this link on the map →related reading
- PyTorch internals : ezyang's blogblog.ezyang.com
- UW PLSE | How does torch.compile work?uwplse.org
- TorchScript: Tracing vs. Scripting - Yuxin's Blogppwwyyxx.com
- Learning PyTorch with Examples — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- PyTorch (@PyTorch) / Xx.com
- State of torch.compile for training (August 2025) : ezyang's blogblog.ezyang.com
- PyTorch Inference | onnxruntimeonnxruntime.ai
- GitHub - LaurentMazare/ocaml-torch: OCaml bindings for PyTorch · GitHubgithub.com
- the bug that taught me more about PyTorch than years of using it | Elana Simonelanapearl.github.io
- torch.Tensor — PyTorch 2.12 documentationdocs.pytorch.org
- A friendly introduction to machine learning compilers and optimizershuyenchip.com
- Reddit - Please wait for verificationreddit.com