• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-vbinary/vopc-scalar.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2019 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/math.h>
14 #include <xnnpack/vbinary.h>
15 
16 
xnn_f32_vsubc_minmax_ukernel__scalar_x8(size_t n,const float * a,const float * b,float * y,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_vsubc_minmax_ukernel__scalar_x8(
18     size_t n,
19     const float* a,
20     const float* b,
21     float* y,
22     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24   assert(n != 0);
25   assert(n % sizeof(float) == 0);
26   assert(a != NULL);
27   assert(b != NULL);
28   assert(y != NULL);
29 
30   const float vy_min = params->scalar.min;
31   const float vy_max = params->scalar.max;
32 
33   const float vb = *b;
34   for (; n >= 8 * sizeof(float); n -= 8 * sizeof(float)) {
35     const float va0 = a[0];
36     const float va1 = a[1];
37     const float va2 = a[2];
38     const float va3 = a[3];
39     const float va4 = a[4];
40     const float va5 = a[5];
41     const float va6 = a[6];
42     const float va7 = a[7];
43     a += 8;
44 
45     float vy0 = va0 - vb;
46     float vy1 = va1 - vb;
47     float vy2 = va2 - vb;
48     float vy3 = va3 - vb;
49     float vy4 = va4 - vb;
50     float vy5 = va5 - vb;
51     float vy6 = va6 - vb;
52     float vy7 = va7 - vb;
53 
54 
55     vy0 = math_max_f32(vy0, vy_min);
56     vy1 = math_max_f32(vy1, vy_min);
57     vy2 = math_max_f32(vy2, vy_min);
58     vy3 = math_max_f32(vy3, vy_min);
59     vy4 = math_max_f32(vy4, vy_min);
60     vy5 = math_max_f32(vy5, vy_min);
61     vy6 = math_max_f32(vy6, vy_min);
62     vy7 = math_max_f32(vy7, vy_min);
63 
64     vy0 = math_min_f32(vy0, vy_max);
65     vy1 = math_min_f32(vy1, vy_max);
66     vy2 = math_min_f32(vy2, vy_max);
67     vy3 = math_min_f32(vy3, vy_max);
68     vy4 = math_min_f32(vy4, vy_max);
69     vy5 = math_min_f32(vy5, vy_max);
70     vy6 = math_min_f32(vy6, vy_max);
71     vy7 = math_min_f32(vy7, vy_max);
72 
73     y[0] = vy0;
74     y[1] = vy1;
75     y[2] = vy2;
76     y[3] = vy3;
77     y[4] = vy4;
78     y[5] = vy5;
79     y[6] = vy6;
80     y[7] = vy7;
81     y += 8;
82   }
83   if XNN_UNLIKELY(n != 0) {
84     do {
85       const float va = *a++;
86       float vy = va - vb;
87       vy = math_max_f32(vy, vy_min);
88       vy = math_min_f32(vy, vy_max);
89       *y++ = vy;
90       n -= sizeof(float);
91     } while (n != 0);
92   }
93 }
94