diff --git a/ggml/src/ggml-cpu/ggml-cpu.c b/ggml/src/ggml-cpu/ggml-cpu.c index 2e1dd28f34..9309667300 100644 --- a/ggml/src/ggml-cpu/ggml-cpu.c +++ b/ggml/src/ggml-cpu/ggml-cpu.c @@ -3146,8 +3146,15 @@ void ggml_cpu_fp32_to_fp16(const float * x, ggml_fp16_t * y, int64_t n) { float32x4_t v_xh = vec_xl(0, (const float *)(x + i + 0)); float32x4_t v_xl = vec_xl(0, (const float *)(x + i + 4)); uint16x8_t v_xd = vec_round_from_fp32(v_xh, v_xl, 0); - uint16x8_t v_xfp16 = vec_convert_to_fp16(v_xd, 0); - vec_xst(v_xfp16, 0, (ggml_fp16_t *)(y + i)); + uint16x8_t v_y = vec_convert_to_fp16(v_xd, 0); + vec_xst(v_y, 0, (ggml_fp16_t *)(y + i)); + } + for (; i + 3 < n; i += 4) { + float32x4_t v_x = vec_xl(0, (const float *)(x + i)); + float32x4_t v_zero = vec_splats(0.0f); + uint16x8_t v_xd = vec_round_from_fp32(v_x, v_zero, 0); + uint16x8_t v_y = vec_convert_to_fp16(v_xd, 0); + vec_xst(v_y, 0, (ggml_fp16_t *)(y + i)); } #endif for (; i < n; ++i) {