revert gguf fix

This commit is contained in:
Xuan Son Nguyen
2026-08-14 17:47:26 +02:00
parent 57270316a8
commit fd6e36310f
+5 -10
View File
@@ -689,17 +689,12 @@ static struct gguf_context * gguf_init_from_reader(const struct gguf_reader & gr
}
// check that the total number of elements is representable
bool ne_overflow = false;
int64_t ne_total = info.t.ne[0];
for (uint32_t j = 1; ok && j < GGML_MAX_DIMS; ++j) {
if (info.t.ne[j] != 0 && ne_total != 0 && INT64_MAX/info.t.ne[j] <= ne_total) {
ne_overflow = true;
break;
}
ne_total *= info.t.ne[j];
}
// (a zero-element tensor is trivially representable; the guard also avoids a division by zero below)
if (ok && ggml_nelements(&info.t) > 0 &&
((INT64_MAX/info.t.ne[1] <= info.t.ne[0]) ||
(INT64_MAX/info.t.ne[2] <= info.t.ne[0]*info.t.ne[1]) ||
(INT64_MAX/info.t.ne[3] <= info.t.ne[0]*info.t.ne[1]*info.t.ne[2]))) {
if (ok && ne_overflow) {
GGML_LOG_ERROR("%s: total number of elements in tensor '%s' with shape "
"(%" PRIi64 ", %" PRIi64 ", %" PRIi64 ", %" PRIi64 ") is >= %" PRIi64 "\n",
__func__, info.t.name, info.t.ne[0], info.t.ne[1], info.t.ne[2], info.t.ne[3], INT64_MAX);