Files
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

1.8 KiB

myst
myst
html_meta
description keywords
Device and DeviceType in PyTorch C++ — c10::Device for specifying CPU, CUDA, XPU, and other backends. PyTorch, C++, Device, DeviceType, CPU, CUDA, XPU, MPS, c10

Device and DeviceType

PyTorch provides device abstractions for writing code that works across CPU, CUDA, and other backends.

Device

:members:
:undoc-members:

Example:

c10::Device cpu_device(c10::kCPU);
c10::Device cuda_device(c10::kCUDA, 0);  // CUDA device 0

if (cuda_device.is_cuda()) {
    std::cout << "Using CUDA device " << cuda_device.index() << std::endl;
}

DeviceType


Enumeration of supported device types.

CPU device.

NVIDIA CUDA GPU.

AMD HIP GPU.

XLA / TPU.

Vulkan GPU.

Apple Metal GPU.

Intel XPU GPU.

Apple Metal Performance Shaders.

Meta tensors (shape only, no data).

Habana HPU.

Lazy tensors.

Graphcore IPU.

Meta training and inference accelerator.

Custom backend registered via `c10::register_privateuse1_backend()`.

Convenience constants:

  • c10::kCPU, c10::kCUDA, c10::kHIP
  • c10::kXLA, c10::kVulkan, c10::kMetal
  • c10::kXPU, c10::kMPS, c10::kMeta
  • c10::kHPU, c10::kLazy, c10::kIPU, c10::kMTIA
  • c10::kPrivateUse1