pub enum AttentionMask {
None,
Causal,
Padding(Vec<usize>),
SlidingWindow(usize),
Custom(Arc<UnifiedTensor>),
}Expand description
Attention mask for custom attention patterns
Variants§
None
No mask (full attention)
Causal
Causal mask (lower triangular)
Padding(Vec<usize>)
Padding mask to ignore padded tokens
SlidingWindow(usize)
Sliding window mask
Custom(Arc<UnifiedTensor>)
Custom mask tensor
Implementations§
Source§impl AttentionMask
impl AttentionMask
Sourcepub fn from_lengths(lengths: Vec<usize>) -> Self
pub fn from_lengths(lengths: Vec<usize>) -> Self
Create a padding mask from sequence lengths
Sourcepub fn sliding_window(window_size: usize) -> Self
pub fn sliding_window(window_size: usize) -> Self
Create a sliding window mask
Trait Implementations§
Source§impl Clone for AttentionMask
impl Clone for AttentionMask
Auto Trait Implementations§
impl !RefUnwindSafe for AttentionMask
impl !UnwindSafe for AttentionMask
impl Freeze for AttentionMask
impl Send for AttentionMask
impl Sync for AttentionMask
impl Unpin for AttentionMask
impl UnsafeUnpin for AttentionMask
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