Skip to content

Commit 31f2775

Browse files
llama : allow getting n_batch from llama_context in c api (#4540)
* allowed getting n_batch from llama_context in c api * changed to use `uint32_t` instead of `int` * changed to use `uint32_t` instead of `int` in `llama_n_ctx` * Update llama.h --------- Co-authored-by: Georgi Gerganov <ggerganov@gmail.com>
1 parent 56fa508 commit 31f2775

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

llama.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9532,10 +9532,14 @@ const llama_model * llama_get_model(const struct llama_context * ctx) {
95329532
return &ctx->model;
95339533
}
95349534

9535-
int llama_n_ctx(const struct llama_context * ctx) {
9535+
uint32_t llama_n_ctx(const struct llama_context * ctx) {
95369536
return ctx->cparams.n_ctx;
95379537
}
95389538

9539+
uint32_t llama_n_batch(const struct llama_context * ctx) {
9540+
return ctx->cparams.n_batch;
9541+
}
9542+
95399543
enum llama_vocab_type llama_vocab_type(const struct llama_model * model) {
95409544
return model->vocab.type;
95419545
}

llama.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,9 @@ extern "C" {
314314

315315
LLAMA_API const struct llama_model * llama_get_model(const struct llama_context * ctx);
316316

317-
LLAMA_API int llama_n_ctx (const struct llama_context * ctx);
317+
// TODO: become more consistent with returned int types across the API
318+
LLAMA_API uint32_t llama_n_ctx (const struct llama_context * ctx);
319+
LLAMA_API uint32_t llama_n_batch (const struct llama_context * ctx);
318320

319321
LLAMA_API enum llama_vocab_type llama_vocab_type(const struct llama_model * model);
320322

0 commit comments

Comments
 (0)