Debian Codegraph @

src/f32-velu/gen/f32-velu-scalar-rr2-p6-u5.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-velu/scalar-rr2-p6.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
18 void xnn_f32_velu_ukernel__scalar_rr2_p6_u5(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_elu_params params[restrict XNN_MIN_ELEMENTS(1)])
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const float vsat_cutoff = -0x1.154246p+4f;
30 const float vmagic_bias = 0x1.8000FEp23f;
31 const float vlog2e = 0x1.715476p+0f;
32 const float vminus_ln2_hi = -0x1.62E440p-1f;
33 const float vminus_ln2_lo = 0x1.0105C6p-21f;
34 const float vc6 = 0x1.6b7338p-10f;
35 const float vc5 = 0x1.12278Ep-7f;
36 const float vc4 = 0x1.555716p-5f;
37 const float vc3 = 0x1.5554B0p-3f;
38 const float vc2 = 0x1.FFFFFEp-2f;
39 const float vone = 1.0f;
40
41 const float vprescale = params->scalar.prescale;
42 const float valpha = params->scalar.alpha;
43 const float vbeta = params->scalar.beta;
44
45 for (; batch >= 5 * sizeof(float); batch -= 5 * sizeof(float)) {
46 float vx0 = input[0];
47 float vx1 = input[1];
48 float vx2 = input[2];
49 float vx3 = input[3];
50 float vx4 = input[4];
51 input += 5;
52
53 const float vz0 = vx0 * vprescale;
54 const float vz1 = vx1 * vprescale;
55 const float vz2 = vx2 * vprescale;
56 const float vz3 = vx3 * vprescale;
57 const float vz4 = vx4 * vprescale;
58
59 float vn0 = vz0 * vlog2e + vmagic_bias;
60 float vn1 = vz1 * vlog2e + vmagic_bias;
61 float vn2 = vz2 * vlog2e + vmagic_bias;
62 float vn3 = vz3 * vlog2e + vmagic_bias;
63 float vn4 = vz4 * vlog2e + vmagic_bias;
64
65 float vs0 = uint32_as_float(float_as_uint32(vn0) << 23);
66 vn0 -= vmagic_bias;
67 float vs1 = uint32_as_float(float_as_uint32(vn1) << 23);
68 vn1 -= vmagic_bias;
69 float vs2 = uint32_as_float(float_as_uint32(vn2) << 23);
70 vn2 -= vmagic_bias;
71 float vs3 = uint32_as_float(float_as_uint32(vn3) << 23);
72 vn3 -= vmagic_bias;
73 float vs4 = uint32_as_float(float_as_uint32(vn4) << 23);
74 vn4 -= vmagic_bias;
75
76 float vt0 = vn0 * vminus_ln2_hi + vz0;
77 float vt1 = vn1 * vminus_ln2_hi + vz1;
78 float vt2 = vn2 * vminus_ln2_hi + vz2;
79 float vt3 = vn3 * vminus_ln2_hi + vz3;
80 float vt4 = vn4 * vminus_ln2_hi + vz4;
81
82 vt0 = vn0 * vminus_ln2_lo + vt0;
83 vt1 = vn1 * vminus_ln2_lo + vt1;
84 vt2 = vn2 * vminus_ln2_lo + vt2;
85 vt3 = vn3 * vminus_ln2_lo + vt3;
86 vt4 = vn4 * vminus_ln2_lo + vt4;
87
88 if XNN_UNPREDICTABLE(vz0 <= vsat_cutoff) {
89 vs0 = 0.0f;
90 vt0 = 0.0f;
91 }
92 if XNN_UNPREDICTABLE(vz1 <= vsat_cutoff) {
93 vs1 = 0.0f;
94 vt1 = 0.0f;
95 }
96 if XNN_UNPREDICTABLE(vz2 <= vsat_cutoff) {
97 vs2 = 0.0f;
98 vt2 = 0.0f;
99 }
100 if XNN_UNPREDICTABLE(vz3 <= vsat_cutoff) {
101 vs3 = 0.0f;
102 vt3 = 0.0f;
103 }
104 if XNN_UNPREDICTABLE(vz4 <= vsat_cutoff) {
105 vs4 = 0.0f;
106 vt4 = 0.0f;
107 }
108
109 float vp0 = vc6 * vt0 + vc5;
110 float vp1 = vc6 * vt1 + vc5;
111 float vp2 = vc6 * vt2 + vc5;
112 float vp3 = vc6 * vt3 + vc5;
113 float vp4 = vc6 * vt4 + vc5;
114
115 vp0 = vp0 * vt0 + vc4;
116 vp1 = vp1 * vt1 + vc4;
117 vp2 = vp2 * vt2 + vc4;
118 vp3 = vp3 * vt3 + vc4;
119 vp4 = vp4 * vt4 + vc4;
120
121 vp0 = vp0 * vt0 + vc3;
122 vp1 = vp1 * vt1 + vc3;
123 vp2 = vp2 * vt2 + vc3;
124 vp3 = vp3 * vt3 + vc3;
125 vp4 = vp4 * vt4 + vc3;
126
127 vp0 = vp0 * vt0 + vc2;
128 vp1 = vp1 * vt1 + vc2;
129 vp2 = vp2 * vt2 + vc2;
130 vp3 = vp3 * vt3 + vc2;
131 vp4 = vp4 * vt4 + vc2;
132
133 vp0 *= vt0;
134 vp1 *= vt1;
135 vp2 *= vt2;
136 vp3 *= vt3;
137 vp4 *= vt4;
138
139 vt0 *= vs0;
140 vs0 -= vone;
141 vt1 *= vs1;
142 vs1 -= vone;
143 vt2 *= vs2;
144 vs2 -= vone;
145 vt3 *= vs3;
146 vs3 -= vone;
147 vt4 *= vs4;
148 vs4 -= vone;
149
150 vp0 = vp0 * vt0 + vt0;
151 vp1 = vp1 * vt1 + vt1;
152 vp2 = vp2 * vt2 + vt2;
153 vp3 = vp3 * vt3 + vt3;
154 vp4 = vp4 * vt4 + vt4;
155
156 const float ve0 = (vp0 + vs0) * valpha;
157 float vy0 = vx0 * vbeta;
158 const float ve1 = (vp1 + vs1) * valpha;
159 float vy1 = vx1 * vbeta;
160 const float ve2 = (vp2 + vs2) * valpha;
161 float vy2 = vx2 * vbeta;
162 const float ve3 = (vp3 + vs3) * valpha;
163 float vy3 = vx3 * vbeta;
164 const float ve4 = (vp4 + vs4) * valpha;
165 float vy4 = vx4 * vbeta;
166
167 if XNN_UNPREDICTABLE(vx0 < 0.0f) {
168 vy0 = ve0;
169 }
170 if XNN_UNPREDICTABLE(vx1 < 0.0f) {
171 vy1 = ve1;
172 }
173 if XNN_UNPREDICTABLE(vx2 < 0.0f) {
174 vy2 = ve2;
175 }
176 if XNN_UNPREDICTABLE(vx3 < 0.0f) {
177 vy3 = ve3;
178 }
179 if XNN_UNPREDICTABLE(vx4 < 0.0f) {
180 vy4 = ve4;
181 }
182
183 output[0] = vy0;
184 output[1] = vy1;
185 output[2] = vy2;
186 output[3] = vy3;
187 output[4] = vy4;
188 output += 5;
189 }
190 if XNN_UNLIKELY(batch != 0) {
191 do {
192 float vx = *input++;
193
194 const float vz = vx * vprescale;
195
196 float vn = vz * vlog2e + vmagic_bias;
197 float vs = uint32_as_float(float_as_uint32(vn) << 23);
198 vn -= vmagic_bias;
199
200 float vt = vn * vminus_ln2_hi + vz;
201 vt = vn * vminus_ln2_lo + vt;
202
203 if XNN_UNPREDICTABLE(vz <= vsat_cutoff) {
204 vs = 0.0f;
205 vt = 0.0f;
206 }
207
208 float vp = vc6 * vt + vc5;
209 vp = vp * vt + vc4;
210 vp = vp * vt + vc3;
211 vp = vp * vt + vc2;
212 vp *= vt;
213
214 vt *= vs;
215 vs -= vone;
216 vp = vp * vt + vt;
217 const float ve = (vp + vs) * valpha;
218
219 float vy = vx * vbeta;
220 if XNN_UNPREDICTABLE(vx < 0.0f) {
221 vy = ve;
222 }
223
224 *output++ = vy;
225
226 batch -= sizeof(float);
227 } while (batch != 0);
228 }
229 }