Class DeviceGuard#
Defined in File accelerator.h
Class Documentation#
-
class DeviceGuard#
A stable ABI version of c10::DeviceGuard.
RAII class that sets the current device to the specified device index on construction and restores the previous device on destruction.
Minimum compatible version: PyTorch 2.9.
Public Functions
-
inline explicit DeviceGuard(DeviceIndex device_index)#
Constructs a DeviceGuard that sets the current device.
Minimum compatible version: PyTorch 2.9.
- Parameters:
device_index – The device index to set as the current device.
-
inline void set_index(DeviceIndex device_index)#
Changes the current device to the specified device index.
Minimum compatible version: PyTorch 2.9.
- Parameters:
device_index – The new device index to set.
-
inline explicit DeviceGuard(DeviceIndex device_index)#