This commit is contained in:
Eddie-Wang1120 2024-06-10 00:00:52 +08:00
parent 97d22be58c
commit 344467f2b8
2 changed files with 6 additions and 2 deletions

View File

@ -1417,7 +1417,7 @@ class BitnetModel(Model):
def weight_quant(self, weight): def weight_quant(self, weight):
dtype = weight.dtype dtype = weight.dtype
weight = weight.float() weight = weight.float()
s = 1 / weight.abs().mean().clamp(min=1e-5) s = 1 / weight.abs().mean().clamp(min=1e-5)
result = (weight * s).round().clamp(-1, 1) / s result = (weight * s).round().clamp(-1, 1) / s
return result.type(dtype) return result.type(dtype)

View File

@ -3802,6 +3802,10 @@ void ggml_vec_dot_i2_i8_s(int n, float * restrict s, size_t bs, const void * res
UNUSED(by); UNUSED(by);
UNUSED(nrc); UNUSED(nrc);
#if defined(__AVX2__)
// TODO
#else
int sumi = 0; int sumi = 0;
for (int i = 0; i < n / 4; i++) { for (int i = 0; i < n / 4; i++) {
@ -3812,7 +3816,7 @@ void ggml_vec_dot_i2_i8_s(int n, float * restrict s, size_t bs, const void * res
sumi += (int)y[i*4+3] * weight[3]; sumi += (int)y[i*4+3] * weight[3];
} }
*s = (float)sumi; *s = (float)sumi;
#endif
} }
void ggml_vec_dot_q4_0_q8_0(int n, float * restrict s, size_t bs, const void * restrict vx, size_t bx, const void * restrict vy, size_t by, int nrc) { void ggml_vec_dot_q4_0_q8_0(int n, float * restrict s, size_t bs, const void * restrict vx, size_t bx, const void * restrict vy, size_t by, int nrc) {