Skip to main content

TensorMemoryManager

Trait TensorMemoryManager 

Source
pub trait TensorMemoryManager: Send + Sync {
    // Required methods
    fn preallocate(
        &self,
        shape: &[usize],
        dtype: DataType,
        device: &Device,
    ) -> Result<TensorRef>;
    fn clear(&self, tensor: &TensorRef) -> Result<()>;
    fn memory_stats(&self) -> TensorMemoryStats;
    fn gc(&self) -> Result<()>;
}
Expand description

Device-specific tensor memory management

Required Methods§

Source

fn preallocate( &self, shape: &[usize], dtype: DataType, device: &Device, ) -> Result<TensorRef>

Pre-allocate tensor of given shape for reuse

Source

fn clear(&self, tensor: &TensorRef) -> Result<()>

Clear tensor data (set to zeros) without deallocation

Source

fn memory_stats(&self) -> TensorMemoryStats

Get memory usage statistics

Source

fn gc(&self) -> Result<()>

Force garbage collection of unused tensors

Implementors§