pub trait TensorStorage:
Send
+ Sync
+ Debug {
// Required methods
fn data_ptr(&self) -> *const u8;
fn data_ptr_mut(&mut self) -> *mut u8;
fn size_bytes(&self) -> usize;
fn device(&self) -> &Device;
fn to_device(&self, device: &Device) -> Result<Arc<dyn TensorStorage>>;
fn clone_storage(&self) -> Arc<dyn TensorStorage> ⓘ;
// Provided method
fn as_candle_tensor(&self) -> Option<&CandleTensor> { ... }
}Expand description
Tensor storage trait - abstracts how data is actually stored
Required Methods§
Sourcefn data_ptr_mut(&mut self) -> *mut u8
fn data_ptr_mut(&mut self) -> *mut u8
Get mutable data pointer (for unsafe operations)
Sourcefn size_bytes(&self) -> usize
fn size_bytes(&self) -> usize
Get data size in bytes
Sourcefn to_device(&self, device: &Device) -> Result<Arc<dyn TensorStorage>>
fn to_device(&self, device: &Device) -> Result<Arc<dyn TensorStorage>>
Copy data to another device
Sourcefn clone_storage(&self) -> Arc<dyn TensorStorage> ⓘ
fn clone_storage(&self) -> Arc<dyn TensorStorage> ⓘ
Clone the storage
Provided Methods§
Sourcefn as_candle_tensor(&self) -> Option<&CandleTensor>
fn as_candle_tensor(&self) -> Option<&CandleTensor>
Try to get the underlying Candle tensor (if this is CandleStorage)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".