MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / ggml_vec_mad_f32

Function ggml_vec_mad_f32

ggml.c:1279–1308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1277}
1278
1279inline static void ggml_vec_mad_f32(const int n, float * restrict y, const float * restrict x, const float v) {
1280#if defined(GGML_SIMD)
1281 const int np = (n & ~(GGML_F32_STEP - 1));
1282
1283 GGML_F32_VEC vx = GGML_F32_VEC_SET1(v);
1284
1285 GGML_F32_VEC ax[GGML_F32_ARR];
1286 GGML_F32_VEC ay[GGML_F32_ARR];
1287
1288 for (int i = 0; i < np; i += GGML_F32_STEP) {
1289 for (int j = 0; j < GGML_F32_ARR; j++) {
1290 ax[j] = GGML_F32_VEC_LOAD(x + i + j*GGML_F32_EPR);
1291 ay[j] = GGML_F32_VEC_LOAD(y + i + j*GGML_F32_EPR);
1292 ay[j] = GGML_F32_VEC_FMA(ay[j], ax[j], vx);
1293
1294 GGML_F32_VEC_STORE(y + i + j*GGML_F32_EPR, ay[j]);
1295 }
1296 }
1297
1298 // leftovers
1299 for (int i = np; i < n; ++i) {
1300 y[i] += x[i]*v;
1301 }
1302#else
1303 // scalar
1304 for (int i = 0; i < n; ++i) {
1305 y[i] += x[i]*v;
1306 }
1307#endif
1308}
1309
1310// xs and vs are byte strides of x and v
1311inline static void ggml_vec_mad_f32_unroll(const int n, const int xs, const int vs, float * restrict y, const float * restrict xv, const float * restrict vv) {

Calls

no outgoing calls

Tested by

no test coverage detected