pub enum BidiSchedule {
StridedCyclic,
StridedStretched,
SymmetricCyclic,
SymmetricStretched,
Custom(Vec<usize>),
}Expand description
How a bidirectional layer stack maps virtual layer indices to real layer indices, interleaving the straight (→, even indices) and reverse (←, odd indices) directions.
Variants§
StridedCyclic
Use even virtual positions for straight-direction (→), and odd virtual positions for reverse-direction (←), wrapping around for each schedule.
§Example
- virtual len = 10, real len = 4:
→ ← → ← → ← → ← → ←
[(0⇒0, 1⇒1), (2⇒2, 3⇒3)], [(4⇒0, 5⇒1), (6⇒2, 7⇒3)], [(8⇒0, 9⇒1), (...)]
StridedStretched
Use even virtual positions for straight-direction (→), and odd virtual positions for reverse-direction (←), stretching for each schedule.
§Example
- virtual len = 10, real len = 4:
→ ← → ← → ← → ← → ←
[(0⇒0, 1⇒1), (2⇒0, 3⇒1), (4⇒0, 5⇒1)], [(6⇒2, 7⇒3), (8⇒2, 9⇒3), (...)]
SymmetricCyclic
Fills virtual positions by wrapping around the real schedule in a looping fashion, replicating between the straight (→) and reverse (←) directions.
§Example
- virtual len = 10, real len = 4:
→ ← → ← → ← → ← → ←
[(0⇒0, 1⇒0), (2⇒1, 3⇒1), (4⇒2, 5⇒2), (6⇒3, 7⇒3)], [(8⇒0, 9⇒0), (...)]
SymmetricStretched
Fills virtual positions by stretching the real schedule, replicating between the straight (→) and reverse (←) directions.
§Example
- virtual len = 10, real len = 4:
→ ← → ← → ← → ← → ←
[(0⇒0, 1⇒0), (2⇒0, 3⇒0)],[(4⇒1, 5⇒1), (...)], [(6⇒2, 7⇒2)], [(8⇒3, 9⇒3)]
Custom(Vec<usize>)
Fills virtual positions by referring to the index vector.
§Example
- virtual len = 10, real len = 4, custom =
[0, 1, 2, 2, 1, 0, 0, 0, 3, 2]:
→ ← → ← → ← → ← → ←
[(0⇒0, 1⇒1)], [(2⇒2, 3⇒2)], [(4⇒1, 5⇒0)], [(6⇒0, 7⇒0)], [(8⇒3, 9⇒2)], [(...)]
Implementations§
Source§impl BidiSchedule
impl BidiSchedule
Sourcepub fn real_idx(
&self,
virtual_idx: usize,
virtual_len: usize,
real_len: usize,
) -> usize
pub fn real_idx( &self, virtual_idx: usize, virtual_len: usize, real_len: usize, ) -> usize
Map virtual_idx (in 0..virtual_len) to a real layer index in
0..real_len. Even/odd virtual_idx selects the straight/reverse
direction; the outer index virtual_idx / 2 is what the schedule cycles
or stretches over.
Trait Implementations§
Source§impl Clone for BidiSchedule
impl Clone for BidiSchedule
Source§fn clone(&self) -> BidiSchedule
fn clone(&self) -> BidiSchedule
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more