• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vrelu/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/vunary.h>
13 #include <xnnpack/common.h>
14 #include <xnnpack/math.h>
15 
xnn_f32_vrelu_ukernel__scalar_x8(size_t n,const float * x_ptr,float * y_ptr,const union xnn_f32_relu_params params[restrict XNN_MIN_ELEMENTS (1)])16 void xnn_f32_vrelu_ukernel__scalar_x8(
17     size_t n,
18     const float* x_ptr,
19     float* y_ptr,
20     const union xnn_f32_relu_params params[restrict XNN_MIN_ELEMENTS(1)])
21 {
22   assert(n != 0);
23   assert(n % sizeof(float) == 0);
24   assert(x_ptr != NULL);
25   assert(y_ptr != NULL);
26 
27   const uint32_t* x = (const uint32_t*)x_ptr;
28   uint32_t* y = (uint32_t*)y_ptr;
29 
30   for (; n >= 8 * sizeof(uint32_t); n -= 8 * sizeof(uint32_t)) {
31     uint32_t vacc0 = x[0];
32     uint32_t vacc1 = x[1];
33     uint32_t vacc2 = x[2];
34     uint32_t vacc3 = x[3];
35     uint32_t vacc4 = x[4];
36     uint32_t vacc5 = x[5];
37     uint32_t vacc6 = x[6];
38     uint32_t vacc7 = x[7];
39     x += 8;
40 
41     vacc0 = ((vacc0 >> 31) - 1) & vacc0;
42     vacc1 = ((vacc1 >> 31) - 1) & vacc1;
43     vacc2 = ((vacc2 >> 31) - 1) & vacc2;
44     vacc3 = ((vacc3 >> 31) - 1) & vacc3;
45     vacc4 = ((vacc4 >> 31) - 1) & vacc4;
46     vacc5 = ((vacc5 >> 31) - 1) & vacc5;
47     vacc6 = ((vacc6 >> 31) - 1) & vacc6;
48     vacc7 = ((vacc7 >> 31) - 1) & vacc7;
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       uint32_t vacc = *x++;
63       vacc =  ((vacc >> 31) - 1) & vacc;
64       *y++ = vacc;
65       n -= sizeof(uint32_t);
66     } while (n != 0);
67   }
68 }
69