pub struct SparseSelection { /* private fields */ }Expand description
Selected indices for sparse attention.
Implementations§
Source§impl SparseSelection
impl SparseSelection
Sourcepub fn new(
batch: usize,
num_heads: usize,
query_len: usize,
selected_kv_count: usize,
indices: Vec<usize>,
) -> Self
pub fn new( batch: usize, num_heads: usize, query_len: usize, selected_kv_count: usize, indices: Vec<usize>, ) -> Self
Create a new sparse selection result.
Sourcepub fn selected_kv_count(&self) -> usize
pub fn selected_kv_count(&self) -> usize
Number of KV tokens selected per query.
Sourcepub fn indices_for(&self, batch: usize, head: usize, query: usize) -> &[usize]
pub fn indices_for(&self, batch: usize, head: usize, query: usize) -> &[usize]
Slice of indices for a (batch, head, query) triplet.
Sourcepub fn flat_indices(&self) -> &[usize]
pub fn flat_indices(&self) -> &[usize]
Flat view of all indices.
Trait Implementations§
Source§impl Clone for SparseSelection
impl Clone for SparseSelection
Source§fn clone(&self) -> SparseSelection
fn clone(&self) -> SparseSelection
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 SparseSelection
impl RefUnwindSafe for SparseSelection
impl Send for SparseSelection
impl Sync for SparseSelection
impl Unpin for SparseSelection
impl UnwindSafe for SparseSelection
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