pub enum SparsePattern {
Local {
window_size: usize,
},
Strided {
stride: usize,
window_size: usize,
},
Dilated {
max_dilation: usize,
window_size: usize,
},
Random {
sparsity_ratio: f32,
},
BlockSparse {
block_size: usize,
global_blocks: usize,
random_blocks: usize,
},
Longformer {
window_size: usize,
global_tokens: Vec<usize>,
},
Linformer {
projection_dim: usize,
},
Reformer {
num_hashes: usize,
bucket_size: usize,
},
Custom {
mask: SparseAttentionMask,
},
}Expand description
Sparse attention pattern types
Variants§
Local
Local sliding window attention
Strided
Strided attention with fixed stride
Dilated
Dilated attention with increasing dilation
Random
Random sparse attention
BlockSparse
Block sparse attention (BigBird style)
Longformer
Longformer-style attention (sliding window + global)
Linformer
Linformer-style linear attention
Reformer
Reformer-style LSH attention
Custom
Custom sparse pattern with explicit mask
Fields
§
mask: SparseAttentionMaskTrait Implementations§
Source§impl Clone for SparsePattern
impl Clone for SparsePattern
Source§fn clone(&self) -> SparsePattern
fn clone(&self) -> SparsePattern
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 SparsePattern
impl RefUnwindSafe for SparsePattern
impl Send for SparsePattern
impl Sync for SparsePattern
impl Unpin for SparsePattern
impl UnsafeUnpin for SparsePattern
impl UnwindSafe for SparsePattern
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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