Files
pytorch/docs/cpp/source/api/xpu/utilities.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

1.1 KiB

myst
myst
html_meta
description keywords
XPU utility functions in PyTorch C++ — device count, properties, and stream management for Intel GPUs. PyTorch, C++, XPU, Intel GPU, device_count, utilities

XPU Utility Functions

High-level utility functions for querying and managing XPU devices.

Device Management

Example:

#include <torch/torch.h>

if (torch::xpu::is_available()) {
    size_t num_devices = torch::xpu::device_count();
    std::cout << "Found " << num_devices << " XPU device(s)" << std::endl;

    // Synchronize all streams on device 0
    torch::xpu::synchronize(0);
}

Random Number Generation

Example:

// Set seed for reproducibility on current XPU device
torch::xpu::manual_seed(42);

// Set seed for all XPU devices
torch::xpu::manual_seed_all(42);