pub struct SparseCSRTensor { /* private fields */ }Expand description
Sparse tensor in CSR (Compressed Sparse Row) format.
CSR format is efficient for row-wise operations on 2D sparse matrices:
crow_indices: shape [nrows + 1], dtype I64 — row pointerscol_indices: shape [nnz], dtype I64 — column indices for each non-zerovalues: shape [nnz] — the non-zero values
For row i, the non-zeros are at positions crow_indices[i]..crow_indices[i+1]
in col_indices and values.
Implementations§
Source§impl SparseCSRTensor
impl SparseCSRTensor
Sourcepub fn new(
crow_indices: DenseI64Tensor,
col_indices: DenseI64Tensor,
values: DenseTensor,
shape: [usize; 2],
) -> Result<Self, SparseTensorError>
pub fn new( crow_indices: DenseI64Tensor, col_indices: DenseI64Tensor, values: DenseTensor, shape: [usize; 2], ) -> Result<Self, SparseTensorError>
pub fn id(&self) -> u64
pub fn crow_indices(&self) -> &DenseI64Tensor
pub fn col_indices(&self) -> &DenseI64Tensor
pub fn values(&self) -> &DenseTensor
pub fn shape(&self) -> [usize; 2]
pub fn nrows(&self) -> usize
pub fn ncols(&self) -> usize
pub fn nnz(&self) -> usize
pub fn dtype(&self) -> DType
pub fn device(&self) -> Device
pub fn version(&self) -> u64
Sourcepub fn to_dense(&self) -> Result<DenseTensor, SparseTensorError>
pub fn to_dense(&self) -> Result<DenseTensor, SparseTensorError>
Convert this sparse CSR tensor to a dense tensor.
Trait Implementations§
Source§impl Clone for SparseCSRTensor
impl Clone for SparseCSRTensor
Source§fn clone(&self) -> SparseCSRTensor
fn clone(&self) -> SparseCSRTensor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SparseCSRTensor
impl Debug for SparseCSRTensor
Source§impl PartialEq for SparseCSRTensor
impl PartialEq for SparseCSRTensor
impl StructuralPartialEq for SparseCSRTensor
Auto Trait Implementations§
impl Freeze for SparseCSRTensor
impl RefUnwindSafe for SparseCSRTensor
impl Send for SparseCSRTensor
impl Sync for SparseCSRTensor
impl Unpin for SparseCSRTensor
impl UnsafeUnpin for SparseCSRTensor
impl UnwindSafe for SparseCSRTensor
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