Fix QKK_64
This commit is contained in:
parent
4b06507172
commit
7e03872f1e
1 changed files with 57 additions and 35 deletions
|
@ -5,7 +5,6 @@
|
|||
#include <string.h>
|
||||
#include <assert.h>
|
||||
#include <float.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef __ARM_NEON
|
||||
|
||||
|
@ -2041,6 +2040,29 @@ void quantize_row_q4_K_reference(const float * restrict x, block_q4_K * restrict
|
|||
}
|
||||
}
|
||||
#else
|
||||
float weights[32];
|
||||
float mins[QK_K/32];
|
||||
float scales[QK_K/32];
|
||||
uint8_t Laux[32];
|
||||
float max_scale = 0; // as we are deducting the min, scales are always positive
|
||||
float max_min = 0;
|
||||
for (int j = 0; j < QK_K/32; ++j) {
|
||||
//scales[j] = make_qkx1_quants(32, 15, x + 32*j, L + 32*j, &mins[j], 9, 0.5f);
|
||||
float sum_x2 = 0;
|
||||
for (int l = 0; l < 32; ++l) sum_x2 += x[32*j + l] * x[32*j + l];
|
||||
float av_x = sqrtf(sum_x2/32);
|
||||
for (int l = 0; l < 32; ++l) weights[l] = av_x + fabsf(x[32*j + l]);
|
||||
scales[j] = make_qkx2_quants(32, 15, x + 32*j, weights, L + 32*j, &mins[j], Laux, -1.f, 0.1f, 20, false);
|
||||
float scale = scales[j];
|
||||
if (scale > max_scale) {
|
||||
max_scale = scale;
|
||||
}
|
||||
float min = mins[j];
|
||||
if (min > max_min) {
|
||||
max_min = min;
|
||||
}
|
||||
}
|
||||
|
||||
const float s_factor = 15.f;
|
||||
float inv_scale = max_scale > 0 ? s_factor/max_scale : 0.f;
|
||||
float inv_min = max_min > 0 ? s_factor/max_min : 0.f;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue