From: Diego Devesa Date: Wed, 2 Apr 2025 12:52:01 +0000 (+0200) Subject: llama : add option to override model tensor buffers (llama/11397) X-Git-Tag: upstream/1.7.5+105~75 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=a71c64512ad885e326cd4d9782fc8397115b3063;p=pkg%2Fggml%2Fsources%2Fwhisper.cpp llama : add option to override model tensor buffers (llama/11397) * llama : add option to override tensor buffers * ggml : fix possible underflow in ggml_nbytes --- diff --git a/ggml/src/ggml.c b/ggml/src/ggml.c index 161dd3fa..3e274d6a 100644 --- a/ggml/src/ggml.c +++ b/ggml/src/ggml.c @@ -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) {