]> git.djapps.eu Git - pkg/ggml/sources/ggml/commitdiff
ggml : add vector scaling using Accelerate (#380)
authortaher <redacted>
Sun, 23 Jul 2023 14:54:27 +0000 (07:54 -0700)
committerGitHub <redacted>
Sun, 23 Jul 2023 14:54:27 +0000 (17:54 +0300)
* Added vector scaling using Accelerate

* added missing elif

src/ggml.c

index 14658ae4fcbf2701452a37191464a65ac9c75dff..b1be7d8d543fb7c65db99b89476987d417699145 100644 (file)
@@ -3440,7 +3440,9 @@ inline static void ggml_vec_mad_f32(const int n, float * restrict y, const float
 
 //inline static void ggml_vec_scale_f32(const int n, float * y, const float   v) { for (int i = 0; i < n; ++i) y[i] *= v;          }
 inline static void ggml_vec_scale_f32(const int n, float * y, const float   v) {
-#if defined(GGML_SIMD)
+#if defined(GGML_USE_ACCELERATE)
+    vDSP_vsmul(y, 1, &v, y, 1, n);
+#elif defined(GGML_SIMD)
     const int np = (n & ~(GGML_F32_STEP - 1));
 
     GGML_F32_VEC vx = GGML_F32_VEC_SET1(v);