ggml : fix f16 mad

This commit is contained in:
Georgi Gerganov 2024-01-28 18:10:16 +02:00
parent 3a428a1097
commit 8612864108
No known key found for this signature in database
GPG Key ID: 449E073F9DC10735

4
ggml.c
View File

@ -1344,12 +1344,12 @@ inline static void ggml_vec_mad_f16(const int n, ggml_fp16_t * restrict y, const
// leftovers // leftovers
for (int i = np; i < n; ++i) { for (int i = np; i < n; ++i) {
y[i] += GGML_FP32_TO_FP16(GGML_FP16_TO_FP32(x[i])*v); y[i] = GGML_FP32_TO_FP16(GGML_FP16_TO_FP32(y[i]) + GGML_FP16_TO_FP32(x[i])*v);
} }
#else #else
// scalar // scalar
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
y[i] += GGML_FP32_TO_FP16(GGML_FP16_TO_FP32(x[i])*v); y[i] = GGML_FP32_TO_FP16(GGML_FP16_TO_FP32(y[i]) + GGML_FP16_TO_FP32(x[i])*v);
} }
#endif #endif
} }