Skip to content

Commit

Permalink
llama : allow getting n_batch from llama_context in c api (ggerganov#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
MarcusDunn and ggerganov committed Dec 21, 2023
1 parent 56fa508 commit 31f2775
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion llama.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9532,10 +9532,14 @@ const llama_model * llama_get_model(const struct llama_context * ctx) {
return &ctx->model;
}

int llama_n_ctx(const struct llama_context * ctx) {
uint32_t llama_n_ctx(const struct llama_context * ctx) {
return ctx->cparams.n_ctx;
}

uint32_t llama_n_batch(const struct llama_context * ctx) {
return ctx->cparams.n_batch;
}

enum llama_vocab_type llama_vocab_type(const struct llama_model * model) {
return model->vocab.type;
}
Expand Down
4 changes: 3 additions & 1 deletion llama.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,9 @@ extern "C" {

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

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

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

Expand Down

0 comments on commit 31f2775

Please sign in to comment.