pub struct KVCacheView<'a> { /* private fields */ }
Expand description
An updateable view of the KV cache. (use only for debugging purposes)
Implementations§
Source§impl KVCacheView<'_>
impl KVCacheView<'_>
Sourcepub fn update(&mut self)
pub fn update(&mut self)
Update the KV cache view structure with the current state of the KV cache. (use only for debugging purposes)
Sourcepub fn n_cells(&self) -> i32
pub fn n_cells(&self) -> i32
Number of KV cache cells. This will be the same as the context size.
Sourcepub fn token_count(&self) -> i32
pub fn token_count(&self) -> i32
Number of tokens in the cache. For example, if there are two populated cells, the first with 1 sequence id in it and the second with 2 sequence ids then you’ll have 3 tokens.
Sourcepub fn used_cells(&self) -> i32
pub fn used_cells(&self) -> i32
Number of populated cache cells.
Sourcepub fn max_contiguous(&self) -> i32
pub fn max_contiguous(&self) -> i32
Maximum contiguous empty slots in the cache.
Sourcepub fn max_contiguous_idx(&self) -> i32
pub fn max_contiguous_idx(&self) -> i32
Index to the start of the max_contiguous
slot range. Can be negative
when cache is full.
Sourcepub fn cells(&self) -> impl Iterator<Item = KVCacheViewCell>
pub fn cells(&self) -> impl Iterator<Item = KVCacheViewCell>
Sourcepub fn cells_sequences(&self) -> impl Iterator<Item = &[llama_seq_id]>
pub fn cells_sequences(&self) -> impl Iterator<Item = &[llama_seq_id]>
The sequences for each cell. There will be n_max_seq
items per cell.
§Panics
- if
n_cells * n_max_seq
does not fit into usize. - if
n_max_seq
does not fit into usize.
Trait Implementations§
Source§impl<'a> Debug for KVCacheView<'a>
impl<'a> Debug for KVCacheView<'a>
Auto Trait Implementations§
impl<'a> Freeze for KVCacheView<'a>
impl<'a> RefUnwindSafe for KVCacheView<'a>
impl<'a> !Send for KVCacheView<'a>
impl<'a> !Sync for KVCacheView<'a>
impl<'a> Unpin for KVCacheView<'a>
impl<'a> UnwindSafe for KVCacheView<'a>
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