From ed866f550b7f752f4c6fb49b06bb18226d803ef8 Mon Sep 17 00:00:00 2001 From: Georgi Gerganov Date: Thu, 14 Dec 2023 13:49:20 +0200 Subject: [PATCH] ggml : fix row size compute to avoid overflows --- ggml.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ggml.c b/ggml.c index c7845c9c2..ed77054bf 100644 --- a/ggml.c +++ b/ggml.c @@ -2012,7 +2012,8 @@ size_t ggml_type_size(enum ggml_type type) { } size_t ggml_row_size(enum ggml_type type, int64_t ne) { - return (ggml_type_size(type)*ne)/ggml_blck_size(type); + assert(ne % ggml_blck_size(type) == 0); + return ggml_type_size(type)*ne/ggml_blck_size(type); } double ggml_type_sizef(enum ggml_type type) {