pub enum LogicalMemorySpace {
MainMemory,
PinnedMemory,
GpuMemory {
device_id: usize,
},
ManagedMemory,
}Expand description
Logical memory space where tensor data resides.
Separates the concept of “where data lives” from “which hardware
computes on it”. A tensor on MainMemory
can be processed by any CPU, while a tensor on
GpuMemory can be processed by any
compute device with access to that GPU memory space.
The variants align with DLPack DLDeviceType constants:
| Variant | DLPack device_type |
|---|---|
MainMemory | kDLCPU (1) |
PinnedMemory | kDLCUDAHost (3) / kDLROCMHost (11) |
GpuMemory | kDLCUDA (2) / kDLROCM (10) |
ManagedMemory | kDLCUDAManaged (13) |
Variants§
MainMemory
System main memory (CPU-accessible RAM).
Corresponds to DLPack kDLCPU (device_id = 0).
PinnedMemory
Host memory pinned for fast GPU transfer (cudaMallocHost / hipMallocHost).
Accessible from the CPU but optimized for DMA transfer to/from
a specific GPU. Corresponds to DLPack kDLCUDAHost or kDLROCMHost
(device_id = 0).
GpuMemory
GPU-resident memory identified by a device ID.
Corresponds to DLPack kDLCUDA or kDLROCM with the given device_id.
ManagedMemory
CUDA Unified/Managed memory (cudaMallocManaged).
Accessible from both CPU and all GPUs. The CUDA runtime handles
page migration automatically. Corresponds to DLPack kDLCUDAManaged
(device_id = 0).
Trait Implementations§
Source§impl Clone for LogicalMemorySpace
impl Clone for LogicalMemorySpace
Source§fn clone(&self) -> LogicalMemorySpace
fn clone(&self) -> LogicalMemorySpace
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more