Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential int8_t overflow in non-SIMD vec_dot #986

Merged
merged 1 commit into from
Apr 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions ggml.c
Original file line number Diff line number Diff line change
Expand Up @@ -2210,11 +2210,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;
}
Expand Down