docs/cpp/source/api/stable/operators.md
The stable API provides tensor operations that maintain binary compatibility across PyTorch versions.
:members:
:undoc-members:
Example:
torch::stable::Tensor tensor = torch::stable::empty({3, 4}, ...);
float* data = tensor.data_ptr<float>();
auto shape = tensor.sizes();
:members:
:undoc-members:
Example:
torch::stable::Device cpu_device(torch::headeronly::DeviceType::CPU);
torch::stable::Device cuda_device(torch::headeronly::DeviceType::CUDA, 0);
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);