mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2025-11-04 09:32:00 +00:00
ggml-cpu: reattempt fp32->fp16
Signed-off-by: Aaron Teo <aaron.teo1@ibm.com>
This commit is contained in:
@@ -3141,6 +3141,12 @@ void ggml_cpu_fp32_to_fp16(const float * x, ggml_fp16_t * y, int64_t n) {
|
|||||||
__m128i y_vec = _mm_cvtps_ph(x_vec, _MM_FROUND_TO_NEAREST_INT);
|
__m128i y_vec = _mm_cvtps_ph(x_vec, _MM_FROUND_TO_NEAREST_INT);
|
||||||
_mm_storel_epi64((__m128i *)(y + i), y_vec);
|
_mm_storel_epi64((__m128i *)(y + i), y_vec);
|
||||||
}
|
}
|
||||||
|
#elif defined(__NNPA__)
|
||||||
|
for (; i + 3 < n; i += 4) {
|
||||||
|
float32x4_t v_x = vec_xl(0, (const float *)(x + i));
|
||||||
|
uint16x8_t v_xd = vec_convert_to_fp16(v_xh, 0);
|
||||||
|
vec_xst(v_xd, 0, (ggml_fp16_t *)(y + i));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
for (; i < n; ++i) {
|
for (; i < n; ++i) {
|
||||||
y[i] = GGML_FP32_TO_FP16(x[i]);
|
y[i] = GGML_FP32_TO_FP16(x[i]);
|
||||||
|
|||||||
Reference in New Issue
Block a user