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) — vendor determined by context |
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 moreSource§impl Debug for LogicalMemorySpace
impl Debug for LogicalMemorySpace
Source§impl Hash for LogicalMemorySpace
impl Hash for LogicalMemorySpace
Source§impl PartialEq for LogicalMemorySpace
impl PartialEq for LogicalMemorySpace
impl Copy for LogicalMemorySpace
impl Eq for LogicalMemorySpace
impl StructuralPartialEq for LogicalMemorySpace
Auto Trait Implementations§
impl Freeze for LogicalMemorySpace
impl RefUnwindSafe for LogicalMemorySpace
impl Send for LogicalMemorySpace
impl Sync for LogicalMemorySpace
impl Unpin for LogicalMemorySpace
impl UnwindSafe for LogicalMemorySpace
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more