Skip to content

Commit a226c84

Browse files
authored
Merge pull request #45 from utilityai/n_batch
added n_batch
2 parents e08d111 + 541e451 commit a226c84

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

llama-cpp-2/src/context.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::model::LlamaModel;
88
use crate::timing::LlamaTimings;
99
use crate::token::data::LlamaTokenData;
1010
use crate::token::LlamaToken;
11-
use crate::{DecodeError};
11+
use crate::DecodeError;
1212
use std::ptr::NonNull;
1313
use std::slice;
1414

@@ -45,6 +45,12 @@ impl<'model> LlamaContext<'model> {
4545
}
4646
}
4747

48+
/// Gets the max number of tokens in a batch.
49+
#[must_use]
50+
pub fn n_batch(&self) -> u32 {
51+
unsafe { llama_cpp_sys_2::llama_n_batch(self.context.as_ptr()) }
52+
}
53+
4854
/// Gets the size of the context.
4955
#[must_use]
5056
pub fn n_ctx(&self) -> u32 {

0 commit comments

Comments
 (0)