Struct DLDevice
#[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§
§impl DLDevice
impl DLDevice
pub const fn cuda(device_id: i32) -> DLDevice
pub const fn cuda(device_id: i32) -> DLDevice
Get a CUDA GPU device (kDLCUDA) with the given device_id.
pub const fn cuda_host() -> DLDevice
pub const fn cuda_host() -> DLDevice
Get a pinned CUDA CPU memory device (kDLCUDAHost) allocated by cudaMallocHost.
pub const fn opencl(device_id: i32) -> DLDevice
pub const fn opencl(device_id: i32) -> DLDevice
Get an OpenCL device (kDLOpenCL) with the given device_id.
pub const fn vulkan(device_id: i32) -> DLDevice
pub const fn vulkan(device_id: i32) -> DLDevice
Get a Vulkan device (kDLVulkan) with the given device_id for next generation graphics.
pub const fn metal(device_id: i32) -> DLDevice
pub const fn metal(device_id: i32) -> DLDevice
Get a Metal device (kDLMetal) with the given device_id for Apple GPUs.
pub const fn vpi(device_id: i32) -> DLDevice
pub const fn vpi(device_id: i32) -> DLDevice
Get a VPI device (kDLVPI) with the given device_id for Verilog simulator buffers.
pub const fn rocm(device_id: i32) -> DLDevice
pub const fn rocm(device_id: i32) -> DLDevice
Get a ROCm device (kDLROCM) with the given device_id for AMD GPUs.
pub const fn rocm_host() -> DLDevice
pub const fn rocm_host() -> DLDevice
Get a pinned ROCm CPU memory device (kDLROCMHost) allocated by hipMallocHost.
pub const fn ext_dev(device_id: i32) -> DLDevice
pub const fn ext_dev(device_id: i32) -> DLDevice
Get a reserved extension device (kDLExtDev) with the given device_id.
pub const fn cuda_managed() -> DLDevice
pub const fn cuda_managed() -> DLDevice
Get a CUDA managed/unified memory device (kDLCUDAManaged) allocated by
cudaMallocManaged, the device_id is always 0.
pub const fn oneapi() -> DLDevice
pub const fn oneapi() -> DLDevice
Get a oneAPI device (kDLOneAPI) for unified shared memory on a
non-partitioned device, the device_id is always 0.
pub const fn webgpu(device_id: i32) -> DLDevice
pub const fn webgpu(device_id: i32) -> DLDevice
Get a WebGPU device (kDLWebGPU) with the given device_id for the next
generation standard.
pub const fn hexagon(device_id: i32) -> DLDevice
pub const fn hexagon(device_id: i32) -> DLDevice
Get a Qualcomm Hexagon DSP device (kDLHexagon) with the given device_id.