pub struct SparseMask {
pub size: usize,
pub row_ptr: Vec<usize>,
pub col_idx: Vec<usize>,
pub values: Vec<f32>,
}Expand description
Sparse mask in CSR (Compressed Sparse Row) format.
Efficient storage for sparse attention masks.
Fields§
§size: usizeNumber of rows/columns
row_ptr: Vec<usize>Row pointers (size + 1 elements)
col_idx: Vec<usize>Column indices
values: Vec<f32>Non-zero values
Implementations§
Source§impl SparseMask
impl SparseMask
Sourcepub fn from_dense(dense: &[Vec<f32>], threshold: f32) -> Self
pub fn from_dense(dense: &[Vec<f32>], threshold: f32) -> Self
Create from dense mask, keeping values above threshold.
Sourcepub fn from_toroidal(mask: &ToroidalMask, threshold: f32) -> Self
pub fn from_toroidal(mask: &ToroidalMask, threshold: f32) -> Self
Create from ToroidalMask with threshold.
Sourcepub fn memory_bytes(&self) -> usize
pub fn memory_bytes(&self) -> usize
Memory usage in bytes (approximate).
Trait Implementations§
Source§impl Clone for SparseMask
impl Clone for SparseMask
Source§fn clone(&self) -> SparseMask
fn clone(&self) -> SparseMask
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 SparseMask
impl RefUnwindSafe for SparseMask
impl Send for SparseMask
impl Sync for SparseMask
impl Unpin for SparseMask
impl UnsafeUnpin for SparseMask
impl UnwindSafe for SparseMask
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