Skip to content

allowed getting n_batch from llama_context in c api #4540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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