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/0.0.1982~81 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=4735f784bd6c057205206d72cf9ad3320bea8ec3;p=pkg%2Fggml%2Fsources%2Fggml 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/src/ggml.c b/src/ggml.c index 161dd3fa..3e274d6a 100644 --- a/src/ggml.c +++ b/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) {