Struct llama_cpp_2::llama_batch::LlamaBatch
source · pub struct LlamaBatch { /* private fields */ }
Expand description
A safe wrapper around llama_batch
.
Implementations§
source§impl LlamaBatch
impl LlamaBatch
sourcepub fn clear(&mut self)
pub fn clear(&mut self)
Clear the batch. This does not free the memory associated with the batch, but it does reset the number of tokens to 0.
sourcepub fn add(
&mut self,
LlamaToken: LlamaToken,
pos: llama_pos,
seq_ids: &[i32],
logits: bool
)
pub fn add( &mut self, LlamaToken: LlamaToken, pos: llama_pos, seq_ids: &[i32], logits: bool )
add a token to the batch for sequences [seq_ids
] at position [pos]. If [logits] is true, the
token will be initilized and can be read from after the next decode.
Panics
- [
self.llama_batch.n_tokens
] does not fit into a usize - [
seq_ids.len()
] does not fit into allama_seq_id
sourcepub fn new(n_tokens: usize, n_seq_max: i32) -> Self
pub fn new(n_tokens: usize, n_seq_max: i32) -> Self
Create a new LlamaBatch
that cab contain up to n_tokens
tokens.
Arguments
n_tokens
: the maximum number of tokens that can be added to the batchn_seq_max
: the maximum number of sequences that can be added to the batch (generally 1 unless you know what you are doing)
Panics
Panics if n_tokens
is greater than i32::MAX
.
Trait Implementations§
source§impl Debug for LlamaBatch
impl Debug for LlamaBatch
Auto Trait Implementations§
impl RefUnwindSafe for LlamaBatch
impl !Send for LlamaBatch
impl !Sync for LlamaBatch
impl Unpin for LlamaBatch
impl UnwindSafe for LlamaBatch
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