mirror of
https://github.com/ggerganov/whisper.cpp.git
synced 2025-04-21 09:48:49 +02:00
ggml : use vDSP_sve and vDSP_maxv from Accelerate
This commit is contained in:
parent
f82a7dd019
commit
d51fc3ee0a
25
ggml.c
25
ggml.c
@ -1039,7 +1039,30 @@ inline static void ggml_vec_gelu_f32(const int n, float * y, const float * x) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline static void ggml_vec_sum_f32 (const int n, float * s, const float * x) { ggml_float sum = 0.0; for (int i = 0; i < n; ++i) sum += x[i]; *s += sum; }
|
inline static void ggml_vec_sum_f32(const int n, float * s, const float * x) {
|
||||||
|
#ifndef GGML_USE_ACCELERATE
|
||||||
|
ggml_float sum = 0.0;
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
sum += x[i];
|
||||||
|
*s += sum;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
vDSP_sve(x, 1, s, n);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
inline static void ggml_vec_max_f32(const int n, float * s, const float * x) {
|
||||||
|
#ifndef GGML_USE_ACCELERATE
|
||||||
|
ggml_float max = -INFINITY;
|
||||||
|
for (int i = 0; i < n; ++i) {
|
||||||
|
max = MAX(max, x[i]);
|
||||||
|
}
|
||||||
|
*s = max;
|
||||||
|
#else
|
||||||
|
vDSP_maxv(x, 1, s, n);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
inline static void ggml_vec_norm_inv_f32(const int n, float * s, const float * x) { ggml_vec_norm_f32(n, s, x); *s = 1./(*s); }
|
inline static void ggml_vec_norm_inv_f32(const int n, float * s, const float * x) { ggml_vec_norm_f32(n, s, x); *s = 1./(*s); }
|
||||||
|
|
||||||
//
|
//
|
||||||
|
Loading…
Reference in New Issue
Block a user