mirror of
https://git.adityakumar.xyz/llama.cpp.git
synced 2024-11-12 16:29:44 +00:00
Fix potential int8 overflow in non-SIMD vec_dot (#986)
This commit is contained in:
parent
0ad964631f
commit
2f7c8e014e
1 changed files with 4 additions and 4 deletions
8
ggml.c
8
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 v0 = p0[j];
|
||||||
const uint8_t v1 = p1[j];
|
const uint8_t v1 = p1[j];
|
||||||
|
|
||||||
const int8_t i0 = (int8_t) (v0 & 0xf) - 8;
|
const int i0 = (v0 & 0xf) - 8;
|
||||||
const int8_t i1 = (int8_t) (v0 >> 4) - 8;
|
const int i1 = (v0 >> 4) - 8;
|
||||||
|
|
||||||
const int8_t i2 = (int8_t) (v1 & 0xf) - 8;
|
const int i2 = (v1 & 0xf) - 8;
|
||||||
const int8_t i3 = (int8_t) (v1 >> 4) - 8;
|
const int i3 = (v1 >> 4) - 8;
|
||||||
|
|
||||||
sumi += i0*i2 + i1*i3;
|
sumi += i0*i2 + i1*i3;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue