• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vlrelu/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/common.h>
13 #include <xnnpack/vunary.h>
14 
15 
xnn_f32_vlrelu_ukernel__wasm_x1(size_t n,const float * x,float * y,const union xnn_f32_lrelu_params params[restrict XNN_MIN_ELEMENTS (1)])16 void xnn_f32_vlrelu_ukernel__wasm_x1(
17     size_t n,
18     const float* x,
19     float* y,
20     const union xnn_f32_lrelu_params params[restrict XNN_MIN_ELEMENTS(1)])
21 {
22   assert(n != 0);
23   assert(n % sizeof(float) == 0);
24 
25   const float vslope = params->scalar.slope;
26   const float vzero = 0.0f;
27 
28   do {
29     const float vx = *x++;
30     const float vnegx = __builtin_wasm_min_f32(vx, vzero);
31     float vacc = vnegx * vslope;
32     const float vposx = __builtin_wasm_max_f32(vx, vzero);
33     vacc += vposx;
34     *y++ = vacc;
35     n -= sizeof(float);
36   } while (n != 0);
37 }
38