From: Johannes Gäßler Date: Wed, 4 Mar 2026 11:04:31 +0000 (+0100) Subject: ggml: fix ggml_is_contiguous_n for ne == 1 (llama/20092) X-Git-Tag: v0.9.8~83 X-Git-Url: https://git.djapps.eu/?a=commitdiff_plain;h=9c7c3c3a63d3f79641195d5a69410cbf9ba221ac;p=pkg%2Fggml%2Fsources%2Fggml ggml: fix ggml_is_contiguous_n for ne == 1 (llama/20092) --- diff --git a/src/ggml.c b/src/ggml.c index e9529fbb..d644cca8 100644 --- a/src/ggml.c +++ b/src/ggml.c @@ -1410,16 +1410,14 @@ static bool ggml_is_contiguous_n(const struct ggml_tensor * tensor, int n) { } next_nb *= tensor->ne[0]/ggml_blck_size(tensor->type); for (int i = 1; i < GGML_MAX_DIMS; i++) { - if (tensor->ne[i] != 1) { - if (i > n) { - if (tensor->nb[i] != next_nb) { - return false; - } - next_nb *= tensor->ne[i]; - } else { - // this dimension does not need to be contiguous - next_nb = tensor->ne[i]*tensor->nb[i]; + if (i > n) { + if (tensor->ne[i] != 1 && tensor->nb[i] != next_nb) { + return false; } + next_nb *= tensor->ne[i]; + } else { + // this dimension does not need to be contiguous + next_nb = tensor->ne[i]*tensor->nb[i]; } } return true;