1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vrelu/wasm.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 <xnnpack/vunary.h>
13 #include <xnnpack/common.h>
14 #include <xnnpack/math.h>
15
16
xnn_f32_vrelu_ukernel__wasm_x8(size_t n,const float * x,float * y,const union xnn_f32_relu_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_vrelu_ukernel__wasm_x8(
18 size_t n,
19 const float* x,
20 float* y,
21 const union xnn_f32_relu_params params[restrict XNN_MIN_ELEMENTS(1)])
22 {
23 assert(n != 0);
24 assert(n % sizeof(float) == 0);
25 assert(x != NULL);
26 assert(y != NULL);
27
28 const float vzero = 0.0f;
29
30 for (; n >= 8 * sizeof(float); n -= 8 * sizeof(float)) {
31 float vacc0 = x[0];
32 float vacc1 = x[1];
33 float vacc2 = x[2];
34 float vacc3 = x[3];
35 float vacc4 = x[4];
36 float vacc5 = x[5];
37 float vacc6 = x[6];
38 float vacc7 = x[7];
39 x += 8;
40
41 vacc0 = __builtin_wasm_max_f32(vacc0, vzero);
42 vacc1 = __builtin_wasm_max_f32(vacc1, vzero);
43 vacc2 = __builtin_wasm_max_f32(vacc2, vzero);
44 vacc3 = __builtin_wasm_max_f32(vacc3, vzero);
45 vacc4 = __builtin_wasm_max_f32(vacc4, vzero);
46 vacc5 = __builtin_wasm_max_f32(vacc5, vzero);
47 vacc6 = __builtin_wasm_max_f32(vacc6, vzero);
48 vacc7 = __builtin_wasm_max_f32(vacc7, vzero);
49
50 y[0] = vacc0;
51 y[1] = vacc1;
52 y[2] = vacc2;
53 y[3] = vacc3;
54 y[4] = vacc4;
55 y[5] = vacc5;
56 y[6] = vacc6;
57 y[7] = vacc7;
58 y += 8;
59 }
60 if XNN_UNLIKELY(n != 0) {
61 do {
62 float vacc = *x++;
63 vacc = __builtin_wasm_max_f32(vacc, vzero);
64 *y++ = vacc;
65 n -= sizeof(float);
66 } while (n != 0);
67 }
68 }
69