pub enum SparseTensor {
COO(SparseCOO),
CSR(SparseCSR),
}Expand description
Unified sparse tensor interface supporting multiple formats.
Variants§
Implementations§
Source§impl SparseTensor
impl SparseTensor
Sourcepub fn from_coo(
indices: Vec<Vec<usize>>,
values: Vec<f32>,
shape: Vec<usize>,
) -> Self
pub fn from_coo( indices: Vec<Vec<usize>>, values: Vec<f32>, shape: Vec<usize>, ) -> Self
Creates a sparse tensor from COO data.
Sourcepub fn from_coords(
coords: &[(usize, usize)],
values: &[f32],
shape: &[usize],
) -> Self
pub fn from_coords( coords: &[(usize, usize)], values: &[f32], shape: &[usize], ) -> Self
Creates a 2D sparse tensor from coordinate list.
Sourcepub fn from_dense(tensor: &Tensor<f32>, threshold: f32) -> Self
pub fn from_dense(tensor: &Tensor<f32>, threshold: f32) -> Self
Creates from a dense tensor, keeping only non-zero elements.
Sourcepub fn mul_scalar(&self, scalar: f32) -> Self
pub fn mul_scalar(&self, scalar: f32) -> Self
Element-wise multiplication with a scalar.
Trait Implementations§
Source§impl Clone for SparseTensor
impl Clone for SparseTensor
Source§fn clone(&self) -> SparseTensor
fn clone(&self) -> SparseTensor
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SparseTensor
impl RefUnwindSafe for SparseTensor
impl Send for SparseTensor
impl Sync for SparseTensor
impl Unpin for SparseTensor
impl UnwindSafe for SparseTensor
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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