pub struct KVCache { /* private fields */ }Expand description
Full model KV cache containing all layers
Implementations§
Source§impl KVCache
impl KVCache
Sourcepub fn with_capacity(num_layers: usize, max_seq_len: usize) -> Self
pub fn with_capacity(num_layers: usize, max_seq_len: usize) -> Self
Create a new KV cache with specified max sequence length
Sourcepub fn num_layers(&self) -> usize
pub fn num_layers(&self) -> usize
Get the number of layers
Sourcepub fn layer_mut(&mut self, layer_idx: usize) -> &mut LayerKVCache
pub fn layer_mut(&mut self, layer_idx: usize) -> &mut LayerKVCache
Get mutable reference to a specific layer’s cache
Sourcepub fn layer(&self, layer_idx: usize) -> &LayerKVCache
pub fn layer(&self, layer_idx: usize) -> &LayerKVCache
Get reference to a specific layer’s cache
Sourcepub fn set_seq_len(&mut self, seq_len: usize)
pub fn set_seq_len(&mut self, seq_len: usize)
Update the cached sequence length
Sourcepub fn max_seq_len(&self) -> usize
pub fn max_seq_len(&self) -> usize
Get maximum sequence length
Sourcepub fn deallocate(&mut self)
pub fn deallocate(&mut self)
Fully deallocate all buffers
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for KVCache
impl !UnwindSafe for KVCache
impl Freeze for KVCache
impl Send for KVCache
impl Sync for KVCache
impl Unpin for KVCache
impl UnsafeUnpin for KVCache
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
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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