Debian Codegraph @

src/f32-rsum/gen/f32-rsum-wasmsimd-u16-acc2.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_u16_acc2(
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 v128_t vacc1 = wasm_f32x4_const_splat(0.0f);
31 for (; batch >= 16 * sizeof(float); batch -= 16 * sizeof(float)) {
32 const v128_t vt0 = wasm_v128_load(input);
33 const v128_t vt1 = wasm_v128_load(input + 4);
34 const v128_t vt2 = wasm_v128_load(input + 8);
35 const v128_t vt3 = wasm_v128_load(input + 12);
36 input += 16;
37
38 vacc0 = wasm_f32x4_add(vacc0, vt0);
39 vacc1 = wasm_f32x4_add(vacc1, vt1);
40 vacc0 = wasm_f32x4_add(vacc0, vt2);
41 vacc1 = wasm_f32x4_add(vacc1, vt3);
42 }
43 vacc0 = wasm_f32x4_add(vacc0, vacc1);
44 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
45 const v128_t vt = wasm_v128_load(input);
46 input += 4;
47
48 vacc0 = wasm_f32x4_add(vacc0, vt);
49 }
50 vacc0 = wasm_f32x4_add(vacc0, wasm_v64x2_shuffle(vacc0, vacc0, 1, 1));
51 if XNN_UNLIKELY(batch & (2 * sizeof(float))) {
52 const v128_t vt = wasm_v128_load64_zero(input);
53 input += 2;
54 vacc0 = wasm_f32x4_add(vacc0, vt);
55 }
56 vacc0 = wasm_f32x4_add(vacc0, wasm_v32x4_shuffle(vacc0, vacc0, 1, 1, 1, 1));
57 if XNN_UNLIKELY(batch & (1 * sizeof(float))) {
58 const v128_t vt = wasm_v128_load32_zero(input);
59 vacc0 = wasm_f32x4_add(vacc0, vt);
60 }
61 const v128_t vscale = wasm_v128_load32_zero(&params->scalar.scale);
62 vacc0 = wasm_f32x4_mul(vacc0, vscale);
63 *output += wasm_f32x4_extract_lane(vacc0, 0);
64 }