Skip to content

Commit 8d4a798

Browse files
committed
ggml-cpu: add fp16->fp32 nnpa first
Signed-off-by: Aaron Teo <[email protected]>
1 parent 4a9f60c commit 8d4a798

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

ggml/src/ggml-cpu/ggml-cpu-impl.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,17 @@ struct ggml_compute_params {
6262
#if defined(__s390x__) && defined(__VEC__)
6363
#ifndef __VXE__
6464
#define __VXE__
65-
#endif
65+
#endif // __VXE__
6666
#ifndef __VXE2__
6767
#define __VXE2__
68-
#endif
69-
#endif
68+
#endif // __VXE2__
69+
#endif // __s390x__ && __VEC__
70+
71+
#if defined(__s390x__) && defined(GGML_NNPA)
72+
#ifndef __NNPA__
73+
#define __NNPA__
74+
#endif // __NNPA__
75+
#endif // __s390x__ && GGML_NNPA
7076

7177
#if defined(__ARM_FEATURE_SVE)
7278
#include <sys/prctl.h>

ggml/src/ggml-cpu/simd-mappings.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,12 @@ static inline void __lsx_f16x4_store(ggml_fp16_t * x, __m128 y) {
962962
#define GGML_F16_STEP GGML_F32_STEP
963963
#define GGML_F16_EPR GGML_F32_EPR
964964

965-
static inline __vector float __lzs_f16cx4_load(const ggml_fp16_t * x) {
965+
static inline float32x4_t __lzs_f16cx4_load(const ggml_fp16_t * x) {
966+
#ifdef __NNPA__
967+
uint16x8_t tmp = vec_xl(0, (const ggml_fp16_t *)x);
968+
uint16x8_t nnpa = vec_convert_from_fp16(tmp, 0);
969+
return vec_extend_to_fp32_hi(nnpa, 0);
970+
#else
966971
float tmp[4];
967972

968973
for (int i = 0; i < 4; i++) {
@@ -972,6 +977,7 @@ static inline __vector float __lzs_f16cx4_load(const ggml_fp16_t * x) {
972977
// note: keep type-cast here to prevent compiler bugs
973978
// see: https://github.com/ggml-org/llama.cpp/issues/12846
974979
return vec_xl(0, (const float *)(tmp));
980+
#endif
975981
}
976982

977983
static inline void __lzs_f16cx4_store(ggml_fp16_t * x, __vector float y) {

0 commit comments

Comments
 (0)