aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStephan Walter <stephan@walter.name>2023-04-15 18:28:56 +0000
committerGitHub <noreply@github.com>2023-04-15 18:28:56 +0000
commit2f7c8e014e3c0ceaf39688845c2ff6f919fb03b7 (patch)
tree7ce72121b1a727e1b5dac20463ee5d9977e88727
parent0ad964631f9b3970f1936008fcfb1eadef59c7ed (diff)
Fix potential int8 overflow in non-SIMD vec_dot (#986)
-rw-r--r--ggml.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/ggml.c b/ggml.c
index ccad76e..6997498 100644
--- a/ggml.c
+++ b/ggml.c
@@ -2373,11 +2373,11 @@ static void ggml_vec_dot_q4_0(const int n, float * restrict s, const void * rest
const uint8_t v0 = p0[j];
const uint8_t v1 = p1[j];
- const int8_t i0 = (int8_t) (v0 & 0xf) - 8;
- const int8_t i1 = (int8_t) (v0 >> 4) - 8;
+ const int i0 = (v0 & 0xf) - 8;
+ const int i1 = (v0 >> 4) - 8;
- const int8_t i2 = (int8_t) (v1 & 0xf) - 8;
- const int8_t i3 = (int8_t) (v1 >> 4) - 8;
+ const int i2 = (v1 & 0xf) - 8;
+ const int i3 = (v1 >> 4) - 8;
sumi += i0*i2 + i1*i3;
}