]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
llama : add option to override model tensor buffers (llama/11397)
authorDiego Devesa <redacted>
Wed, 2 Apr 2025 12:52:01 +0000 (14:52 +0200)
committerGeorgi Gerganov <redacted>
Thu, 24 Apr 2025 17:39:16 +0000 (20:39 +0300)
* llama : add option to override tensor buffers

* ggml : fix possible underflow in ggml_nbytes

ggml/src/ggml.c

index 161dd3fa94547c9a7b2b83372e65920b5019d65d..3e274d6ae39614b106270de27a4b158c95db072a 100644 (file)
@@ -1159,6 +1159,12 @@ int64_t ggml_nrows(const struct ggml_tensor * tensor) {
 }
 
 size_t ggml_nbytes(const struct ggml_tensor * tensor) {
+    for (int i = 0; i < GGML_MAX_DIMS; ++i) {
+        if (tensor->ne[i] <= 0) {
+            return 0;
+        }
+    }
+
     size_t nbytes;
     const size_t blck_size = ggml_blck_size(tensor->type);
     if (blck_size == 1) {