3 #include <c10/core/impl/InlineDeviceGuard.h> 148 guard_.reset_device(device);
153 guard_.reset_device(device, impl);
158 return guard_.original_device();
164 return guard_.current_device();
DeviceGuard(Device device)
Set the current device to the passed Device.
void set_index(DeviceIndex index)
Sets the device index to the given one.
optional< Device > original_device() const
Returns the device that was set at the time the guard was constructed.
void set_index(DeviceIndex index)
Sets the device index to the given one.
Device original_device() const
Returns the device that was set at the time the most recent reset_device(), or otherwise the device a...
OptionalDeviceGuard(optional< Device > device)
Initialize the guard if a Device is passed; otherwise leave the guard uninitialized.
DeviceGuard()=delete
No default constructor; see Note [Omitted default constructor from RAII].
OptionalDeviceGuard(Device device)
Initialize the guard, setting the current device to the passed Device.
TensorOptions device(Device device)
Convenience function that returns a TensorOptions object with the device set to the given one...
void reset_device(at::Device device)
Sets the device to the given one.
Represents a a compute device on which a tensor is located.
int16_t DeviceIndex
An index representing a specific device; e.g., the 1 in GPU 1.
Device original_device() const
Returns the device that was set at the time the guard was constructed.
A OptionalDeviceGuard is an RAII class that sets a device to some value on initialization, and resets the device to its original value on destruction.
optional< Device > current_device() const
Returns the most recent device that was set using this device guard, either from construction, or via set_device.
void reset_device(at::Device device, const impl::DeviceGuardImplInterface *impl)
For testing only.
To register your own kernel for an operator, do in one (!) cpp file: C10_REGISTER_KERNEL(OperatorHand...
RAII guard that sets a certain default device in its constructor, and changes it back to the device t...
Device current_device() const
Returns the most recent device that was set using this device guard, either from construction, or via set_device/reset_device/set_index.
OptionalDeviceGuard()
Create an uninitialized guard. Set the guard later using set_device.
std::enable_if<!std::is_same< U, VirtualGuardImpl >::value >::type reset_device(at::Device device)
Resets the currently set device to its original device, and then sets the current device to the passe...
void reset_device(at::Device device, const impl::DeviceGuardImplInterface *impl)
This method is for testing only.
DeviceGuard(Device device, const impl::DeviceGuardImplInterface *impl)
This constructor is for testing only.
OptionalDeviceGuard(Device device, const impl::DeviceGuardImplInterface *impl)
Constructor for testing only.
Device current_device() const
Returns the most recent device that was set using this device guard, either from construction, or via set_device.
DeviceGuardImplInterface represents the virtual interface which provides functionality to provide an ...
void reset_device(at::Device device)
Sets the device to the given one.