pub struct UnifiedSparseTensor { /* private fields */ }
Expand description
Unified sparse tensor that can hold any sparse format
Implementations§
Source§impl UnifiedSparseTensor
impl UnifiedSparseTensor
Sourcepub fn new(inner: Box<dyn SparseTensor + Send + Sync>) -> Self
pub fn new(inner: Box<dyn SparseTensor + Send + Sync>) -> Self
Create a new unified sparse tensor
Sourcepub fn from_sparse<T: SparseTensor + Send + Sync + 'static>(tensor: T) -> Self
pub fn from_sparse<T: SparseTensor + Send + Sync + 'static>(tensor: T) -> Self
Create from any sparse tensor type
Sourcepub fn inner(&self) -> &dyn SparseTensor
pub fn inner(&self) -> &dyn SparseTensor
Get the underlying sparse tensor
Sourcepub fn metadata_mut(&mut self) -> &mut TensorMetadata
pub fn metadata_mut(&mut self) -> &mut TensorMetadata
Get mutable access to metadata
Sourcepub fn operation_history(&self) -> &[OperationRecord]
pub fn operation_history(&self) -> &[OperationRecord]
Get operation history
Sourcepub fn to_dense_cached(&mut self) -> TorshResult<Arc<Tensor>>
pub fn to_dense_cached(&mut self) -> TorshResult<Arc<Tensor>>
Get or compute dense representation with caching
Sourcepub fn clear_dense_cache(&mut self)
pub fn clear_dense_cache(&mut self)
Clear dense cache to free memory
Sourcepub fn optimize_format(&mut self) -> TorshResult<bool>
pub fn optimize_format(&mut self) -> TorshResult<bool>
Convert to optimal format based on access patterns and performance hints
Sourcepub fn suggest_optimal_format(&self) -> TorshResult<SparseFormat>
pub fn suggest_optimal_format(&self) -> TorshResult<SparseFormat>
Suggest optimal format based on current metadata
Sourcepub fn update_access_pattern(
&mut self,
operation: &str,
region: Option<(usize, usize, usize, usize)>,
)
pub fn update_access_pattern( &mut self, operation: &str, region: Option<(usize, usize, usize, usize)>, )
Update access patterns based on operation
Sourcepub fn matmul_optimized(
&mut self,
other: &mut UnifiedSparseTensor,
) -> TorshResult<UnifiedSparseTensor>
pub fn matmul_optimized( &mut self, other: &mut UnifiedSparseTensor, ) -> TorshResult<UnifiedSparseTensor>
Perform matrix multiplication with optimization
Sourcepub fn memory_stats(&self) -> MemoryStats
pub fn memory_stats(&self) -> MemoryStats
Get memory usage statistics
Sourcepub fn optimization_report(&self) -> OptimizationReport
pub fn optimization_report(&self) -> OptimizationReport
Generate optimization report
Trait Implementations§
Source§impl SparseTensor for UnifiedSparseTensor
Implement SparseTensor trait for UnifiedSparseTensor
impl SparseTensor for UnifiedSparseTensor
Implement SparseTensor trait for UnifiedSparseTensor
Source§fn format(&self) -> SparseFormat
fn format(&self) -> SparseFormat
Get the sparse format used by this tensor Read more
Source§fn device(&self) -> DeviceType
fn device(&self) -> DeviceType
Get the device where the tensor is stored Read more
Source§fn to_csr(&self) -> TorshResult<CsrTensor>
fn to_csr(&self) -> TorshResult<CsrTensor>
Convert to CSR (Compressed Sparse Row) format Read more
Auto Trait Implementations§
impl Freeze for UnifiedSparseTensor
impl !RefUnwindSafe for UnifiedSparseTensor
impl Send for UnifiedSparseTensor
impl Sync for UnifiedSparseTensor
impl Unpin for UnifiedSparseTensor
impl !UnwindSafe for UnifiedSparseTensor
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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