ggml-cpu : re-enable fast gelu_quick_f16 (#22339)
This commit is contained in:
+6
-13
@@ -1036,12 +1036,12 @@ inline static float ggml_gelu_quick_f32(float x) {
|
|||||||
return x*(1.0f/(1.0f+expf(GELU_QUICK_COEF*x)));
|
return x*(1.0f/(1.0f+expf(GELU_QUICK_COEF*x)));
|
||||||
}
|
}
|
||||||
|
|
||||||
//inline static void ggml_vec_gelu_quick_f16(const int n, ggml_fp16_t * y, const ggml_fp16_t * x) {
|
inline static void ggml_vec_gelu_quick_f16(const int n, ggml_fp16_t * y, const ggml_fp16_t * x) {
|
||||||
// const uint16_t * i16 = (const uint16_t *) x;
|
const uint16_t * i16 = (const uint16_t *) x;
|
||||||
// for (int i = 0; i < n; ++i) {
|
for (int i = 0; i < n; ++i) {
|
||||||
// y[i] = ggml_table_gelu_quick_f16[i16[i]];
|
y[i] = ggml_table_gelu_quick_f16[i16[i]];
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
#ifdef GGML_GELU_QUICK_FP16
|
#ifdef GGML_GELU_QUICK_FP16
|
||||||
inline static void ggml_vec_gelu_quick_f32(const int n, float * y, const float * x) {
|
inline static void ggml_vec_gelu_quick_f32(const int n, float * y, const float * x) {
|
||||||
@@ -1060,13 +1060,6 @@ inline static void ggml_vec_gelu_quick_f32(const int n, float * y, const float *
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline static void ggml_vec_gelu_quick_f16(const int n, ggml_fp16_t * y, const ggml_fp16_t * x) {
|
|
||||||
for (int i = 0; i < n; ++i) {
|
|
||||||
float v = GGML_CPU_FP16_TO_FP32(x[i]);
|
|
||||||
y[i] = GGML_CPU_FP32_TO_FP16(v*(1.0f/(1.0f+expf(GELU_QUICK_COEF*v))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sigmoid Linear Unit (SiLU) function
|
// Sigmoid Linear Unit (SiLU) function
|
||||||
inline static float ggml_silu_f32(float x) {
|
inline static float ggml_silu_f32(float x) {
|
||||||
return x/(1.0f + expf(-x));
|
return x/(1.0f + expf(-x));
|
||||||
|
|||||||
Reference in New Issue
Block a user