pub struct LayerKVCache { /* private fields */ }Expand description
Per-layer KV cache storing Key and Value tensors with pre-allocated buffers
Implementations§
Source§impl LayerKVCache
impl LayerKVCache
Sourcepub fn with_capacity(max_seq_len: usize) -> Self
pub fn with_capacity(max_seq_len: usize) -> Self
Create a layer cache with specified maximum sequence length
Sourcepub fn deallocate(&mut self)
pub fn deallocate(&mut self)
Fully deallocate buffers
Sourcepub fn max_seq_len(&self) -> usize
pub fn max_seq_len(&self) -> usize
Get maximum sequence length (buffer capacity)
Sourcepub fn get_kv(&self) -> Option<(Tensor, Tensor)>
pub fn get_kv(&self) -> Option<(Tensor, Tensor)>
Get view of the filled portion of K,V buffers
Returns (K, V) tensors narrowed to current sequence length
Sourcepub fn k(&self) -> Option<Tensor>
👎Deprecated: Use get_kv() instead for better performance
pub fn k(&self) -> Option<Tensor>
Use get_kv() instead for better performance
Get cached K tensor (legacy interface)
Sourcepub fn v(&self) -> Option<Tensor>
👎Deprecated: Use get_kv() instead for better performance
pub fn v(&self) -> Option<Tensor>
Use get_kv() instead for better performance
Get cached V tensor (legacy interface)
Trait Implementations§
Source§impl Clone for LayerKVCache
impl Clone for LayerKVCache
Source§fn clone(&self) -> LayerKVCache
fn clone(&self) -> LayerKVCache
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for LayerKVCache
impl Debug for LayerKVCache
Auto Trait Implementations§
impl !RefUnwindSafe for LayerKVCache
impl !UnwindSafe for LayerKVCache
impl Freeze for LayerKVCache
impl Send for LayerKVCache
impl Sync for LayerKVCache
impl Unpin for LayerKVCache
impl UnsafeUnpin for LayerKVCache
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,
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