Skip to content

Commit e12e9fe

Browse files
committed
ggml-cpu: reattempt fp32->fp16
Signed-off-by: Aaron Teo <[email protected]>
1 parent 54811fc commit e12e9fe

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

ggml/src/ggml-cpu/ggml-cpu.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3142,10 +3142,12 @@ void ggml_cpu_fp32_to_fp16(const float * x, ggml_fp16_t * y, int64_t n) {
31423142
_mm_storel_epi64((__m128i *)(y + i), y_vec);
31433143
}
31443144
#elif defined(__NNPA__)
3145-
for (; i + 3 < n; i += 4) {
3146-
float32x4_t v_x = vec_xl(0, (const float *)(x + i));
3147-
uint16x8_t v_xd = vec_convert_to_fp16(v_x, 0);
3148-
vec_xst(v_xd, 0, (ggml_fp16_t *)(y + i));
3145+
for (; i + 7 < n; i += 8) {
3146+
float32x4_t v_xh = vec_xl(0, (const float *)(x + i + 0));
3147+
float32x4_t v_xl = vec_xl(0, (const float *)(x + i + 4));
3148+
__vector short int v_xd = vec_round_from_fp32(v_xh, v_xl, 0);
3149+
__vector short int v_xfp16 = vec_convert_to_fp16(v_xd, 0);
3150+
vec_xst(v_xfp16, 0, (ggml_fp16_t *)(y + i));
31493151
}
31503152
#endif
31513153
for (; i < n; ++i) {

0 commit comments

Comments
 (0)