• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vlrelu/scalar.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__scalar_x4(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__scalar_x4(
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 
27   for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) {
28     const float vx0 = x[0];
29     const float vx1 = x[1];
30     const float vx2 = x[2];
31     const float vx3 = x[3];
32     x += 4;
33 
34     float vacc0 = vx0 * vslope;
35     float vacc1 = vx1 * vslope;
36     float vacc2 = vx2 * vslope;
37     float vacc3 = vx3 * vslope;
38 
39     vacc0 = XNN_UNPREDICTABLE(vx0 < 0.0f) ? vacc0 : vx0;
40     vacc1 = XNN_UNPREDICTABLE(vx1 < 0.0f) ? vacc1 : vx1;
41     vacc2 = XNN_UNPREDICTABLE(vx2 < 0.0f) ? vacc2 : vx2;
42     vacc3 = XNN_UNPREDICTABLE(vx3 < 0.0f) ? vacc3 : vx3;
43 
44     y[0] = vacc0;
45     y[1] = vacc1;
46     y[2] = vacc2;
47     y[3] = vacc3;
48     y += 4;
49   }
50   if XNN_UNLIKELY(n != 0) {
51     do {
52       const float vx = *x++;
53       float vacc = vx * vslope;
54       vacc = XNN_UNPREDICTABLE(vx < 0.0f) ? vacc : vx;
55       *y++ = vacc;
56       n -= sizeof(float);
57     } while (n != 0);
58   }
59 }
60