]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
llama : allow getting n_batch from llama_context in c api (#4540)
authorMarcus Dunn <redacted>
Thu, 21 Dec 2023 19:57:48 +0000 (11:57 -0800)
committerGitHub <redacted>
Thu, 21 Dec 2023 19:57:48 +0000 (21:57 +0200)
* 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 <redacted>
llama.cpp
llama.h

index 90d860eb95de77a0515c71ae2d7bf75df4775061..63ebe581bfae6b6e9f23e205928a8815eef45308 100644 (file)
--- a/llama.cpp
+++ b/llama.cpp
@@ -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;
 }
diff --git a/llama.h b/llama.h
index 15ab4f80e233429d587369c6eee48700af6f86ea..0be4b1337b963e05a029d2ee4d01f98209dd4253 100644 (file)
--- a/llama.h
+++ b/llama.h
@@ -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);