1 // Auto-generated file. Do not edit!
2 // Template: src/f32-vbinary/vop-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_vsub_relu_ukernel__scalar_x8(size_t n,const float * a,const float * b,float * y,const union xnn_f32_relu_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_vsub_relu_ukernel__scalar_x8(
18 size_t n,
19 const float* a,
20 const float* b,
21 float* y,
22 const union xnn_f32_relu_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
31 for (; n >= 8 * sizeof(float); n -= 8 * sizeof(float)) {
32 const float va0 = a[0];
33 const float va1 = a[1];
34 const float va2 = a[2];
35 const float va3 = a[3];
36 const float va4 = a[4];
37 const float va5 = a[5];
38 const float va6 = a[6];
39 const float va7 = a[7];
40 a += 8;
41
42 const float vb0 = b[0];
43 const float vb1 = b[1];
44 const float vb2 = b[2];
45 const float vb3 = b[3];
46 const float vb4 = b[4];
47 const float vb5 = b[5];
48 const float vb6 = b[6];
49 const float vb7 = b[7];
50 b += 8;
51
52 float vy0 = va0 - vb0;
53 float vy1 = va1 - vb1;
54 float vy2 = va2 - vb2;
55 float vy3 = va3 - vb3;
56 float vy4 = va4 - vb4;
57 float vy5 = va5 - vb5;
58 float vy6 = va6 - vb6;
59 float vy7 = va7 - vb7;
60
61
62 vy0 = math_max_f32(vy0, 0.0f);
63 vy1 = math_max_f32(vy1, 0.0f);
64 vy2 = math_max_f32(vy2, 0.0f);
65 vy3 = math_max_f32(vy3, 0.0f);
66 vy4 = math_max_f32(vy4, 0.0f);
67 vy5 = math_max_f32(vy5, 0.0f);
68 vy6 = math_max_f32(vy6, 0.0f);
69 vy7 = math_max_f32(vy7, 0.0f);
70
71 y[0] = vy0;
72 y[1] = vy1;
73 y[2] = vy2;
74 y[3] = vy3;
75 y[4] = vy4;
76 y[5] = vy5;
77 y[6] = vy6;
78 y[7] = vy7;
79 y += 8;
80 }
81 if XNN_UNLIKELY(n != 0) {
82 do {
83 const float va = *a++;
84 const float vb = *b++;
85 float vy = va - vb;
86 vy = math_max_f32(vy, 0.0f);
87 *y++ = vy;
88 n -= sizeof(float);
89 } while (n != 0);
90 }
91 }
92