Title: Torch Stable API — PyTorch main documentation
Description: PyTorch Stable ABI C++ API — binary-compatible operator registration across PyTorch versions.
Keywords:
Domain: docs.pytorch.org
{
"@context": "https://schema.org",
"@type": "Article",
"name": "Torch Stable API",
"headline": "Torch Stable API",
"description": "PyTorch Stable ABI C++ API \u2014 binary-compatible operator registration across PyTorch versions.",
"url": "/api/stable/index.html",
"articleBody": "Torch Stable API# The PyTorch Stable C++ API provides a binary-compatible interface for calling tensor operations and utilities that is guaranteed to remain stable across PyTorch versions. This enables ahead-of-time compiled extensions that don\u2019t need recompilation when PyTorch is updated. When to use the Stable API: When building extensions that must work across multiple PyTorch versions When distributing pre-compiled binaries When binary compatibility is more important than access to the latest features When writing custom operators for production deployment Basic usage: #include \u003ctorch/csrc/stable/library.h\u003e #include \u003ctorch/csrc/stable/ops.h\u003e // Create a tensor using stable API auto tensor = torch::stable::empty( {3, 4}, torch::headeronly::ScalarType::Float, torch::headeronly::Layout::Strided, torch::stable::Device(torch::headeronly::DeviceType::CPU), false, torch::headeronly::MemoryFormat::Contiguous); // Register operators with stable ABI STABLE_TORCH_LIBRARY(myops, m) { m.def(\"my_op(Tensor input) -\u003e Tensor\"); } STABLE_TORCH_LIBRARY_IMPL(myops, CPU, m) { m.impl(\"my_op\", TORCH_BOX(\u0026my_cpu_kernel)); } For more information on the stable ABI, see the Stable ABI notes. Header Files# torch/csrc/stable/library.h - Stable library registration torch/csrc/stable/ops.h - Stable operator definitions torch/csrc/stable/tensor.h - Stable tensor structures torch/csrc/stable/device.h - Stable device structures torch/csrc/stable/accelerator.h - Accelerator support torch/csrc/stable/macros.h - Stable API macros Stable API Categories# Library Registration Macros Stable Operators Utilities See Also# Torch Library API - For standard (non-stable) operator registration Stable ABI documentation",
"author": {
"@type": "Organization",
"name": "PyTorch Contributors",
"url": "https://pytorch.org"
},
"image": "https://pytorch.org/docs/stable/_static/img/pytorch_seo.png",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "/api/stable/index.html"
},
"datePublished": "2023-01-01T00:00:00Z",
"dateModified": "2023-01-01T00:00:00Z"
}
| docsearch:language | en |
| llm:site-type | documentation |
| llm:framework | PyTorch |
| llm:description | PyTorch Stable ABI C++ API — binary-compatible operator registration across PyTorch versions. |
| llm:navigation-file | https://pytorch.org/docs/stable/llms.txt |
| llm:sitemap | https://pytorch.org/docs/stable/sitemap.xml |
| llm:version | main |
| llm:project | PyTorch |
| llm:page-type | documentation |
| og:image | https://docs.pytorch.org/docs/stable/_static/img/pytorch_seo.png |
| None | 2 |
Links:
Viewport: width=device-width, initial-scale=1