Files
pytorch/docs/cpp/source/api/stable/operators.md
T
Svetlana Karslioglu 19da3da3d3 Restructure C++ docs (#174096)
The fix-cpp-build branch is a major restructuring that:

- Drops Exhale (which auto-generated API docs but caused OOM in CI) in favor of hand-written RST pages using Breathe directives
- Reorganizes notes into a hierarchical API reference with proper categories
- Adds new content: XPU docs, stable ABI docs, DeviceGuard/Stream docs
- Always runs Doxygen instead of gating on an env var

Pull Request resolved: https://github.com/pytorch/pytorch/pull/174096
Approved by: https://github.com/janeyx99, https://github.com/seemethere, https://github.com/albanD
2026-04-07 17:24:38 +00:00

3.8 KiB

myst
myst
html_meta
description keywords
Stable ABI operator API in PyTorch C++ — StableLibrary and boxed kernel registration. PyTorch, C++, stable ABI, StableLibrary, operator, boxed kernel

Stable Operators

The stable API provides tensor operations that maintain binary compatibility across PyTorch versions.

Tensor Class

:members:
:undoc-members:

Example:

torch::stable::Tensor tensor = torch::stable::empty({3, 4}, ...);
float* data = tensor.data_ptr<float>();
auto shape = tensor.sizes();

Device Class

:members:
:undoc-members:

Example:

torch::stable::Device cpu_device(torch::headeronly::DeviceType::CPU);
torch::stable::Device cuda_device(torch::headeronly::DeviceType::CUDA, 0);

Tensor Creation

Example:

auto tensor = torch::stable::empty(
    {3, 4},
    torch::headeronly::ScalarType::Float,
    torch::headeronly::Layout::Strided,
    torch::stable::Device(torch::headeronly::DeviceType::CUDA, 0),
    false,
    torch::headeronly::MemoryFormat::Contiguous);

Tensor Manipulation

Device and Type Conversion

In-place Operations

Mathematical Operations