#[repr(C)]pub struct DLDevice {
pub device_type: DLDeviceType,
pub device_id: i32,
}Expand description
A Device for Tensor and operator.
Fields§
§device_type: DLDeviceTypeThe device type used in the device.
device_id: i32The device index. For vanilla CPU memory, pinned memory, or managed memory, this is set to 0.
Implementations§
Source§impl DLDevice
impl DLDevice
Sourcepub const fn cuda(device_id: i32) -> Self
pub const fn cuda(device_id: i32) -> Self
Get a CUDA GPU device (kDLCUDA) with the given device_id.
Sourcepub const fn cuda_host() -> Self
pub const fn cuda_host() -> Self
Get a pinned CUDA CPU memory device (kDLCUDAHost) allocated by cudaMallocHost.
Sourcepub const fn opencl(device_id: i32) -> Self
pub const fn opencl(device_id: i32) -> Self
Get an OpenCL device (kDLOpenCL) with the given device_id.
Sourcepub const fn vulkan(device_id: i32) -> Self
pub const fn vulkan(device_id: i32) -> Self
Get a Vulkan device (kDLVulkan) with the given device_id for next generation graphics.
Sourcepub const fn metal(device_id: i32) -> Self
pub const fn metal(device_id: i32) -> Self
Get a Metal device (kDLMetal) with the given device_id for Apple GPUs.
Sourcepub const fn vpi(device_id: i32) -> Self
pub const fn vpi(device_id: i32) -> Self
Get a VPI device (kDLVPI) with the given device_id for Verilog simulator buffers.
Sourcepub const fn rocm(device_id: i32) -> Self
pub const fn rocm(device_id: i32) -> Self
Get a ROCm device (kDLROCM) with the given device_id for AMD GPUs.
Sourcepub const fn rocm_host() -> Self
pub const fn rocm_host() -> Self
Get a pinned ROCm CPU memory device (kDLROCMHost) allocated by hipMallocHost.
Sourcepub const fn ext_dev(device_id: i32) -> Self
pub const fn ext_dev(device_id: i32) -> Self
Get a reserved extension device (kDLExtDev) with the given device_id.
Sourcepub const fn cuda_managed() -> Self
pub const fn cuda_managed() -> Self
Get a CUDA managed/unified memory device (kDLCUDAManaged) allocated by
cudaMallocManaged, the device_id is always 0.
Sourcepub const fn oneapi() -> Self
pub const fn oneapi() -> Self
Get a oneAPI device (kDLOneAPI) for unified shared memory on a
non-partitioned device, the device_id is always 0.
Sourcepub const fn webgpu(device_id: i32) -> Self
pub const fn webgpu(device_id: i32) -> Self
Get a WebGPU device (kDLWebGPU) with the given device_id for the next
generation standard.
Sourcepub const fn hexagon(device_id: i32) -> Self
pub const fn hexagon(device_id: i32) -> Self
Get a Qualcomm Hexagon DSP device (kDLHexagon) with the given device_id.