mirror of
https://github.com/pytorch/pytorch.git
synced 2026-10-28 18:56:51 +08:00
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
1.8 KiB
1.8 KiB
myst
| myst | ||||||
|---|---|---|---|---|---|---|
|
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::kHIPc10::kXLA,c10::kVulkan,c10::kMetalc10::kXPU,c10::kMPS,c10::kMetac10::kHPU,c10::kLazy,c10::kIPU,c10::kMTIAc10::kPrivateUse1