Debian Codegraph @

src/f32-rsum/gen/f32-rsum-wasmsimd-u4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-rsum/wasmsimd.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11
12 #include <wasm_simd128.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/reduce.h"
16
17
18 void xnn_f32_rsum_ukernel__wasmsimd_u4(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_scale_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 v128_t vacc0 = wasm_f32x4_const_splat(0.0f);
30 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
31 const v128_t vt = wasm_v128_load(input);
32 input += 4;
33
34 vacc0 = wasm_f32x4_add(vacc0, vt);
35 }
36 vacc0 = wasm_f32x4_add(vacc0, wasm_v64x2_shuffle(vacc0, vacc0, 1, 1));
37 if XNN_UNLIKELY(batch & (2 * sizeof(float))) {
38 const v128_t vt = wasm_v128_load64_zero(input);
39 input += 2;
40 vacc0 = wasm_f32x4_add(vacc0, vt);
41 }
42 vacc0 = wasm_f32x4_add(vacc0, wasm_v32x4_shuffle(vacc0, vacc0, 1, 1, 1, 1));
43 if XNN_UNLIKELY(batch & (1 * sizeof(float))) {
44 const v128_t vt = wasm_v128_load32_zero(input);
45 vacc0 = wasm_f32x4_add(vacc0, vt);
46 }
47 const v128_t vscale = wasm_v128_load32_zero(&params->scalar.scale);
48 vacc0 = wasm_f32x4_mul(vacc0, vscale);
49 *output += wasm_f32x4_extract_lane(vacc0, 0);
50 }