pub struct ToroidalMask {
pub seq_len: usize,
pub radius: f32,
pub alpha: f32,
pub grid_size: usize,
pub mask_type: MaskType,
}Expand description
Toroidal attention mask generator.
Creates masks according to Eq. 17 from the paper:
M_Tonnetz(i, j) = 1 if d_Tonnetz(i, j) ≤ r
exp(-α · d_Tonnetz(i,j)) otherwiseFields§
§seq_len: usizeSequence length
radius: f32Locality radius (hard cutoff)
alpha: f32Decay rate for soft falloff
grid_size: usizeGrid size for Tonnetz mapping
mask_type: MaskTypeMask type variant
Implementations§
Source§impl ToroidalMask
impl ToroidalMask
Sourcepub fn new(seq_len: usize, radius: f32, alpha: f32) -> Self
pub fn new(seq_len: usize, radius: f32, alpha: f32) -> Self
Create a new toroidal mask configuration (hybrid by default).
Sourcepub fn with_grid(
seq_len: usize,
radius: f32,
alpha: f32,
grid_size: usize,
) -> Self
pub fn with_grid( seq_len: usize, radius: f32, alpha: f32, grid_size: usize, ) -> Self
Create with custom grid size.
Sourcepub fn hard_cutoff(seq_len: usize, radius: f32, grid_size: usize) -> Self
pub fn hard_cutoff(seq_len: usize, radius: f32, grid_size: usize) -> Self
Create hard cutoff mask: M(i,j) = 1 if d <= r, else 0
Sourcepub fn soft_exponential(seq_len: usize, alpha: f32, grid_size: usize) -> Self
pub fn soft_exponential(seq_len: usize, alpha: f32, grid_size: usize) -> Self
Create soft exponential mask: M(i,j) = exp(-α * d)
Trait Implementations§
Source§impl Clone for ToroidalMask
impl Clone for ToroidalMask
Source§fn clone(&self) -> ToroidalMask
fn clone(&self) -> ToroidalMask
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 ToroidalMask
impl RefUnwindSafe for ToroidalMask
impl Send for ToroidalMask
impl Sync for ToroidalMask
impl Unpin for ToroidalMask
impl UnsafeUnpin for ToroidalMask
impl UnwindSafe for ToroidalMask
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