pub struct BlockLayout { /* private fields */ }Expand description
How a sequence is cut into cache blocks, and the sliding window (if any) those blocks must line up with.
Only constructible through BlockLayout::new, so a BlockLayout
value is itself the proof that the alignment rule holds – there is
no path that produces a mis-aligned one to be checked later and
forgotten.
Implementations§
Source§impl BlockLayout
impl BlockLayout
Sourcepub fn new(
block_size: usize,
sliding_window: Option<usize>,
) -> Result<Self, BlockLayoutError>
pub fn new( block_size: usize, sliding_window: Option<usize>, ) -> Result<Self, BlockLayoutError>
Validates and builds a layout. sliding_window is None for a
full-causal model and Some(w) for one whose sliding layers use
window w – including alternating models, where some layers
are full-attention: those layers are unconstrained, so the
model’s constraint is the window of the layers that have one.
Sourcepub fn full_attention(block_size: usize) -> Result<Self, BlockLayoutError>
pub fn full_attention(block_size: usize) -> Result<Self, BlockLayoutError>
A full-causal model’s layout. Cannot fail except on a zero block size.
pub fn block_size(&self) -> usize
pub fn sliding_window(&self) -> Option<usize>
Sourcepub fn blocks_per_window(&self) -> Option<usize>
pub fn blocks_per_window(&self) -> Option<usize>
How many whole blocks a sliding layer keeps resident. None for
a full-causal model, which keeps all of them.
Exact by construction: the layout would not exist if the window were not a whole number of blocks.
Trait Implementations§
Source§impl Clone for BlockLayout
impl Clone for BlockLayout
Source§fn clone(&self) -> BlockLayout
fn clone(&self) -> BlockLayout
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for BlockLayout
Source§impl Debug for BlockLayout
impl Debug for BlockLayout
impl Eq for BlockLayout
Source§impl PartialEq for BlockLayout
impl PartialEq for BlockLayout
impl StructuralPartialEq for BlockLayout
Auto Trait Implementations§
impl Freeze for BlockLayout
impl RefUnwindSafe for BlockLayout
impl Send for BlockLayout
impl Sync for BlockLayout
impl Unpin for BlockLayout
impl UnsafeUnpin for BlockLayout
impl UnwindSafe for BlockLayout
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
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> ⓘ
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> ⓘ
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