Debian Codegraph @

src/f32-vbinary/gen/f32-vprelu-wasmrelaxedsimd-u4.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vbinary/vop-wasmsimd.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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/vbinary.h"
16
17
18 void xnn_f32_vprelu_ukernel__wasmrelaxedsimd_u4(
19 size_t batch,
20 const float* input_a,
21 const float* input_b,
22 float* output,
23 const struct xnn_f32_default_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24 {
25 assert(batch != 0);
26 assert(batch % sizeof(float) == 0);
27 assert(input_a != NULL);
28 assert(input_b != NULL);
29 assert(output != NULL);
30
31 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
32 const v128_t va = wasm_v128_load(input_a);
33 input_a += 4;
34
35 const v128_t vb = wasm_v128_load(input_b);
36 input_b += 4;
37
38 v128_t vacc = wasm_f32x4_mul(va, vb);
39 const v128_t vmask = wasm_i32x4_shr(va, 31);
40
41 vacc = wasm_i32x4_relaxed_laneselect(vacc, va, vmask);
42
43 wasm_v128_store(output, vacc);
44 output += 4;
45 }
46 if XNN_UNLIKELY(batch != 0) {
47 const v128_t va = wasm_v128_load(input_a);
48 const v128_t vb = wasm_v128_load(input_b);
49
50 v128_t vacc = wasm_f32x4_mul(va, vb);
51 const v128_t vmask = wasm_i32x4_shr(va, 31);
52
53 vacc = wasm_i32x4_relaxed_laneselect(vacc, va, vmask);
54
55 if (batch & (2 * sizeof(float))) {
56 wasm_v128_store64_lane(output, vacc, 0);
57 vacc = wasm_v64x2_shuffle(vacc, vacc, 1, 1);
58 output += 2;
59 }
60 if (batch & (1 * sizeof(float))) {
61 wasm_v128_store32_lane(output, vacc, 0);
62 }
63 }
64 }