pub struct SparseAttentionGraphConfig {
pub base_attention: AttentionConfig,
pub pattern: SparsePatternType,
pub exact_sparse: bool,
}Expand description
Configuration for sparse attention graph building
Fields§
§base_attention: AttentionConfigBase attention configuration
pattern: SparsePatternTypeSparse pattern type
exact_sparse: boolWhether to use exact sparse computation or approximation
Implementations§
Source§impl SparseAttentionGraphConfig
impl SparseAttentionGraphConfig
Sourcepub fn strided(base_attention: AttentionConfig, stride: usize) -> Result<Self>
pub fn strided(base_attention: AttentionConfig, stride: usize) -> Result<Self>
Create a new strided sparse attention configuration
Sourcepub fn local(
base_attention: AttentionConfig,
window_size: usize,
) -> Result<Self>
pub fn local( base_attention: AttentionConfig, window_size: usize, ) -> Result<Self>
Create a new local window sparse attention configuration
Sourcepub fn global_local(
base_attention: AttentionConfig,
window_size: usize,
global_positions: Vec<usize>,
) -> Result<Self>
pub fn global_local( base_attention: AttentionConfig, window_size: usize, global_positions: Vec<usize>, ) -> Result<Self>
Create a new global-local sparse attention configuration
Sourcepub fn block_sparse(
base_attention: AttentionConfig,
block_size: usize,
) -> Result<Self>
pub fn block_sparse( base_attention: AttentionConfig, block_size: usize, ) -> Result<Self>
Create a new block sparse attention configuration
Sourcepub fn with_exact_sparse(self, exact_sparse: bool) -> Self
pub fn with_exact_sparse(self, exact_sparse: bool) -> Self
Set whether to use exact sparse computation
Trait Implementations§
Source§impl Clone for SparseAttentionGraphConfig
impl Clone for SparseAttentionGraphConfig
Source§fn clone(&self) -> SparseAttentionGraphConfig
fn clone(&self) -> SparseAttentionGraphConfig
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 moreSource§impl Debug for SparseAttentionGraphConfig
impl Debug for SparseAttentionGraphConfig
Source§impl<'de> Deserialize<'de> for SparseAttentionGraphConfig
impl<'de> Deserialize<'de> for SparseAttentionGraphConfig
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for SparseAttentionGraphConfig
Auto Trait Implementations§
impl Freeze for SparseAttentionGraphConfig
impl RefUnwindSafe for SparseAttentionGraphConfig
impl Send for SparseAttentionGraphConfig
impl Sync for SparseAttentionGraphConfig
impl Unpin for SparseAttentionGraphConfig
impl UnsafeUnpin for SparseAttentionGraphConfig
impl UnwindSafe for SparseAttentionGraphConfig
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