Update ggml-quants.c

Co-authored-by: Jared Van Bortel <cebtenzzre@gmail.com>
This commit is contained in:
Michael Potter 2023-11-12 16:52:45 -08:00 committed by GitHub
parent bf1c8d761a
commit 7a5e92e748
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1273,8 +1273,12 @@ static float make_qkx2_quants(int n, int nmax, const float * restrict x, const f
float max = x[0]; float max = x[0];
float sum_w = weights[0]; float sum_w = weights[0];
float sum_x = sum_w * x[0]; float sum_x = sum_w * x[0];
// Mark i as volatile to prevent the -O3 optimizer from unrolling this loop and breaking MacOS Sonoma quantization +#if defined(__APPLE__) && defined(__clang_major__) && __clang_major__ >= 15
for (volatile int i = 1; i < n; ++i) { + // use 'volatile' to prevent unroll and work around a bug in Apple clang 15.x.x
+ for (volatile int i = 1; i < n; ++i) {
+#else
for (int i = 1; i < n; ++i) {
+#endif
if (x[i] < min) min = x[i]; if (x[i] < min) min = x[i];
if (x[i] > max) max = x[i]; if (x[i] > max) max = x[i];
float w = weights[i]; float w = weights[i];