Skip to content

Commit 2f7c8e0

Browse files
authored
Fix potential int8 overflow in non-SIMD vec_dot (#986)
1 parent 0ad9646 commit 2f7c8e0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

ggml.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2373,11 +2373,11 @@ static void ggml_vec_dot_q4_0(const int n, float * restrict s, const void * rest
23732373
const uint8_t v0 = p0[j];
23742374
const uint8_t v1 = p1[j];
23752375

2376-
const int8_t i0 = (int8_t) (v0 & 0xf) - 8;
2377-
const int8_t i1 = (int8_t) (v0 >> 4) - 8;
2376+
const int i0 = (v0 & 0xf) - 8;
2377+
const int i1 = (v0 >> 4) - 8;
23782378

2379-
const int8_t i2 = (int8_t) (v1 & 0xf) - 8;
2380-
const int8_t i3 = (int8_t) (v1 >> 4) - 8;
2379+
const int i2 = (v1 & 0xf) - 8;
2380+
const int i3 = (v1 >> 4) - 8;
23812381

23822382
sumi += i0*i2 + i1*i3;
23832383
}

0 commit comments

Comments
 (0)