1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vunary/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 #include <math.h>
12 
13 #include <xnnpack/common.h>
14 #include <xnnpack/math.h>
15 #include <xnnpack/vunary.h>
16 
17 
xnn_f32_vabs_ukernel__scalar_x4(size_t n,const float * x,float * y,const union xnn_f32_abs_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_vabs_ukernel__scalar_x4(
19     size_t n,
20     const float* x,
21     float* y,
22     const union xnn_f32_abs_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24   assert(n != 0);
25   assert(n % sizeof(float) == 0);
26   assert(x != NULL);
27   assert(y != NULL);
28 
29   for (; n >= 4 * sizeof(float); n -= 4 * sizeof(float)) {
30     const float vx0 = x[0];
31     const float vx1 = x[1];
32     const float vx2 = x[2];
33     const float vx3 = x[3];
34     x += 4;
35 
36     const float vy0 = fabsf(vx0);
37     const float vy1 = fabsf(vx1);
38     const float vy2 = fabsf(vx2);
39     const float vy3 = fabsf(vx3);
40 
41     y[0] = vy0;
42     y[1] = vy1;
43     y[2] = vy2;
44     y[3] = vy3;
45     y += 4;
46   }
47   if XNN_UNLIKELY(n != 0) {
48     do {
49       const float vx = *x++;
50       const float vy = fabsf(vx);
51       *y++ = vy;
52       n -= sizeof(float);
53     } while (n != 0);
54   }
55 }
56