Struct Device#
Defined inFile Device.h
Struct Documentation#
- structDevice#
Represents a compute device on which a tensor is located.
A device is uniquely identified by a type, which specifies the type of machine it is (e.g. CPU or CUDA GPU), and a device index or ordinal, which identifies the specific compute device when there is more than one of a certain type. The device index is optional, and in its defaulted state represents (abstractly) “the current device”. Further, there are two constraints on the value of the device index, if one is explicitly stored:
A negative index represents the current device, a non-negative index represents a specific, concrete device,
When the device type is CPU, the device index must be zero.
Public Types
- usingType=DeviceType#
Public Functions
- inlineDevice(DeviceTypetype,DeviceIndexindex=-1)#
Constructs a new
Devicefrom aDeviceTypeand an optional device index.
- Device(conststd::string&device_string)#
Constructs a
Devicefrom a string description, for convenience.The string supplied must follow the following schema:
(cpu|cuda)[:<device-index>]wherecpuorcudaspecifies the device type, and:<device-index>optionally specifies a device index.
- inlinebooloperator==(constDevice&other)constnoexcept#
Returns true if the type and index of this
Devicematches that ofother.
- inlinebooloperator!=(constDevice&other)constnoexcept#
Returns true if the type or index of this
Devicediffers from that ofother.
- inlinevoidset_index(DeviceIndexindex)#
Sets the device index.
- inlineDeviceTypetype()constnoexcept#
Returns the type of device this is.
- inlineDeviceIndexindex()constnoexcept#
Returns the optional index.
- inlineboolhas_index()constnoexcept#
Returns true if the device has a non-default index.
- inlineboolis_cuda()constnoexcept#
Return true if the device is of CUDA type.
- inlineboolis_privateuseone()constnoexcept#
Return true if the device is of PrivateUse1 type.
- inlineboolis_mps()constnoexcept#
Return true if the device is of MPS type.
- inlineboolis_hip()constnoexcept#
Return true if the device is of HIP type.
- inlineboolis_ve()constnoexcept#
Return true if the device is of VE type.
- inlineboolis_xpu()constnoexcept#
Return true if the device is of XPU type.
- inlineboolis_ipu()constnoexcept#
Return true if the device is of IPU type.
- inlineboolis_xla()constnoexcept#
Return true if the device is of XLA type.
- inlineboolis_mtia()constnoexcept#
Return true if the device is of MTIA type.
- inlineboolis_hpu()constnoexcept#
Return true if the device is of HPU type.
- inlineboolis_lazy()constnoexcept#
Return true if the device is of Lazy type.
- inlineboolis_vulkan()constnoexcept#
Return true if the device is of Vulkan type.
- inlineboolis_metal()constnoexcept#
Return true if the device is of Metal type.
- inlineboolis_maia()constnoexcept#
Return true if the device is of MAIA type.
- inlineboolis_meta()constnoexcept#
Return true if the device is of META type.
- inlineboolis_cpu()constnoexcept#
Return true if the device is of CPU type.
- inlineboolsupports_as_strided()constnoexcept#
Return true if the device supports arbitrary strides.
- std::stringstr()const#
Same string as returned from operator<<.