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§
Sourcefn preallocate(
&self,
shape: &[usize],
dtype: DataType,
device: &Device,
) -> Result<TensorRef>
fn preallocate( &self, shape: &[usize], dtype: DataType, device: &Device, ) -> Result<TensorRef>
Pre-allocate tensor of given shape for reuse
Sourcefn clear(&self, tensor: &TensorRef) -> Result<()>
fn clear(&self, tensor: &TensorRef) -> Result<()>
Clear tensor data (set to zeros) without deallocation
Sourcefn memory_stats(&self) -> TensorMemoryStats
fn memory_stats(&self) -> TensorMemoryStats
Get memory usage statistics