Debian Codegraph @

src/f32-velu/gen/f32-velu-neon-rr2-p6-u24.c

raw symbols SCIP
1 // Auto-generated file. Do not edit!
2 // Template: src/f32-velu/neon-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
12 #include <arm_neon.h>
13
14 #include "xnnpack/vunary.h"
15 #include "xnnpack/common.h"
16
17
18 void xnn_f32_velu_ukernel__neon_rr2_p6_u24(
19 size_t batch,
20 const float* input,
21 float* output,
22 const struct xnn_f32_elu_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
23 {
24 assert(batch != 0);
25 assert(batch % sizeof(float) == 0);
26 assert(input != NULL);
27 assert(output != NULL);
28
29 const float32x4_t vsat_cutoff = vmovq_n_f32(-0x1.154246p+4f);
30 const float32x4_t vmagic_bias = vmovq_n_f32(0x1.8000FEp23f);
31 const float32x4_t vlog2e = vmovq_n_f32(0x1.715476p+0f);
32 const float32x4_t vc6 = vmovq_n_f32(0x1.6b7338p-10f);
33 const float32x4_t vc5 = vmovq_n_f32(0x1.12278Ep-7f);
34 const float32x4_t vc4 = vmovq_n_f32(0x1.555716p-5f);
35 const float32x4_t vc3 = vmovq_n_f32(0x1.5554B0p-3f);
36 const float32x4_t vc2 = vmovq_n_f32(0x1.FFFFFEp-2f);
37 const float32x4_t vone = vmovq_n_f32(1.0f);
38
39 XNN_FORCE_REALIZATION(vsat_cutoff);
40 XNN_FORCE_REALIZATION(vmagic_bias);
41 XNN_FORCE_REALIZATION(vlog2e);
42 XNN_FORCE_REALIZATION(vc6);
43 XNN_FORCE_REALIZATION(vc5);
44 XNN_FORCE_REALIZATION(vc4);
45 XNN_FORCE_REALIZATION(vc3);
46 XNN_FORCE_REALIZATION(vc2);
47 XNN_FORCE_REALIZATION(vone);
48
49 const float32x4_t vminus_ln2_hi = vmovq_n_f32(-0x1.62E440p-1f);
50 const float32x4_t vminus_ln2_lo = vmovq_n_f32(0x1.0105C6p-21f);
51 XNN_FORCE_REALIZATION(vminus_ln2_hi);
52 XNN_FORCE_REALIZATION(vminus_ln2_lo);
53
54 const float32x4_t vprescale = vld1q_dup_f32(&params->scalar.prescale);
55 const float32x4_t valpha = vld1q_dup_f32(&params->scalar.alpha);
56 const float32x4_t vbeta = vld1q_dup_f32(&params->scalar.beta);
57
58 for (; batch >= 24 * sizeof(float); batch -= 24 * sizeof(float)) {
59 float32x4_t vx0123 = vld1q_f32(input); input += 4;
60 float32x4_t vx4567 = vld1q_f32(input); input += 4;
61 float32x4_t vx89AB = vld1q_f32(input); input += 4;
62 float32x4_t vxCDEF = vld1q_f32(input); input += 4;
63 float32x4_t vxGHIJ = vld1q_f32(input); input += 4;
64 float32x4_t vxKLMN = vld1q_f32(input); input += 4;
65
66 const float32x4_t vz0123 = vmaxq_f32(vmulq_f32(vx0123, vprescale), vsat_cutoff);
67 const float32x4_t vz4567 = vmaxq_f32(vmulq_f32(vx4567, vprescale), vsat_cutoff);
68 const float32x4_t vz89AB = vmaxq_f32(vmulq_f32(vx89AB, vprescale), vsat_cutoff);
69 const float32x4_t vzCDEF = vmaxq_f32(vmulq_f32(vxCDEF, vprescale), vsat_cutoff);
70 const float32x4_t vzGHIJ = vmaxq_f32(vmulq_f32(vxGHIJ, vprescale), vsat_cutoff);
71 const float32x4_t vzKLMN = vmaxq_f32(vmulq_f32(vxKLMN, vprescale), vsat_cutoff);
72
73 float32x4_t vn0123 = vmlaq_f32(vmagic_bias, vz0123, vlog2e);
74 float32x4_t vn4567 = vmlaq_f32(vmagic_bias, vz4567, vlog2e);
75 float32x4_t vn89AB = vmlaq_f32(vmagic_bias, vz89AB, vlog2e);
76 float32x4_t vnCDEF = vmlaq_f32(vmagic_bias, vzCDEF, vlog2e);
77 float32x4_t vnGHIJ = vmlaq_f32(vmagic_bias, vzGHIJ, vlog2e);
78 float32x4_t vnKLMN = vmlaq_f32(vmagic_bias, vzKLMN, vlog2e);
79
80 float32x4_t vs0123 = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn0123), 23));
81 vn0123 = vsubq_f32(vn0123, vmagic_bias);
82 float32x4_t vs4567 = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn4567), 23));
83 vn4567 = vsubq_f32(vn4567, vmagic_bias);
84 float32x4_t vs89AB = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn89AB), 23));
85 vn89AB = vsubq_f32(vn89AB, vmagic_bias);
86 float32x4_t vsCDEF = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vnCDEF), 23));
87 vnCDEF = vsubq_f32(vnCDEF, vmagic_bias);
88 float32x4_t vsGHIJ = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vnGHIJ), 23));
89 vnGHIJ = vsubq_f32(vnGHIJ, vmagic_bias);
90 float32x4_t vsKLMN = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vnKLMN), 23));
91 vnKLMN = vsubq_f32(vnKLMN, vmagic_bias);
92
93 float32x4_t vt0123 = vmlaq_f32(vz0123, vn0123, vminus_ln2_hi);
94 float32x4_t vt4567 = vmlaq_f32(vz4567, vn4567, vminus_ln2_hi);
95 float32x4_t vt89AB = vmlaq_f32(vz89AB, vn89AB, vminus_ln2_hi);
96 float32x4_t vtCDEF = vmlaq_f32(vzCDEF, vnCDEF, vminus_ln2_hi);
97 float32x4_t vtGHIJ = vmlaq_f32(vzGHIJ, vnGHIJ, vminus_ln2_hi);
98 float32x4_t vtKLMN = vmlaq_f32(vzKLMN, vnKLMN, vminus_ln2_hi);
99
100 vt0123 = vmlaq_f32(vt0123, vn0123, vminus_ln2_lo);
101 vt4567 = vmlaq_f32(vt4567, vn4567, vminus_ln2_lo);
102 vt89AB = vmlaq_f32(vt89AB, vn89AB, vminus_ln2_lo);
103 vtCDEF = vmlaq_f32(vtCDEF, vnCDEF, vminus_ln2_lo);
104 vtGHIJ = vmlaq_f32(vtGHIJ, vnGHIJ, vminus_ln2_lo);
105 vtKLMN = vmlaq_f32(vtKLMN, vnKLMN, vminus_ln2_lo);
106
107 float32x4_t vp0123 = vmlaq_f32(vc5, vc6, vt0123);
108 float32x4_t vp4567 = vmlaq_f32(vc5, vc6, vt4567);
109 float32x4_t vp89AB = vmlaq_f32(vc5, vc6, vt89AB);
110 float32x4_t vpCDEF = vmlaq_f32(vc5, vc6, vtCDEF);
111 float32x4_t vpGHIJ = vmlaq_f32(vc5, vc6, vtGHIJ);
112 float32x4_t vpKLMN = vmlaq_f32(vc5, vc6, vtKLMN);
113
114 vp0123 = vmlaq_f32(vc4, vp0123, vt0123);
115 vp4567 = vmlaq_f32(vc4, vp4567, vt4567);
116 vp89AB = vmlaq_f32(vc4, vp89AB, vt89AB);
117 vpCDEF = vmlaq_f32(vc4, vpCDEF, vtCDEF);
118 vpGHIJ = vmlaq_f32(vc4, vpGHIJ, vtGHIJ);
119 vpKLMN = vmlaq_f32(vc4, vpKLMN, vtKLMN);
120
121 vp0123 = vmlaq_f32(vc3, vp0123, vt0123);
122 vp4567 = vmlaq_f32(vc3, vp4567, vt4567);
123 vp89AB = vmlaq_f32(vc3, vp89AB, vt89AB);
124 vpCDEF = vmlaq_f32(vc3, vpCDEF, vtCDEF);
125 vpGHIJ = vmlaq_f32(vc3, vpGHIJ, vtGHIJ);
126 vpKLMN = vmlaq_f32(vc3, vpKLMN, vtKLMN);
127
128 vp0123 = vmlaq_f32(vc2, vp0123, vt0123);
129 vp4567 = vmlaq_f32(vc2, vp4567, vt4567);
130 vp89AB = vmlaq_f32(vc2, vp89AB, vt89AB);
131 vpCDEF = vmlaq_f32(vc2, vpCDEF, vtCDEF);
132 vpGHIJ = vmlaq_f32(vc2, vpGHIJ, vtGHIJ);
133 vpKLMN = vmlaq_f32(vc2, vpKLMN, vtKLMN);
134
135 vp0123 = vmulq_f32(vp0123, vt0123);
136 vp4567 = vmulq_f32(vp4567, vt4567);
137 vp89AB = vmulq_f32(vp89AB, vt89AB);
138 vpCDEF = vmulq_f32(vpCDEF, vtCDEF);
139 vpGHIJ = vmulq_f32(vpGHIJ, vtGHIJ);
140 vpKLMN = vmulq_f32(vpKLMN, vtKLMN);
141
142 vt0123 = vmulq_f32(vt0123, vs0123);
143 vs0123 = vsubq_f32(vs0123, vone);
144 vt4567 = vmulq_f32(vt4567, vs4567);
145 vs4567 = vsubq_f32(vs4567, vone);
146 vt89AB = vmulq_f32(vt89AB, vs89AB);
147 vs89AB = vsubq_f32(vs89AB, vone);
148 vtCDEF = vmulq_f32(vtCDEF, vsCDEF);
149 vsCDEF = vsubq_f32(vsCDEF, vone);
150 vtGHIJ = vmulq_f32(vtGHIJ, vsGHIJ);
151 vsGHIJ = vsubq_f32(vsGHIJ, vone);
152 vtKLMN = vmulq_f32(vtKLMN, vsKLMN);
153 vsKLMN = vsubq_f32(vsKLMN, vone);
154
155 vp0123 = vmlaq_f32(vt0123, vp0123, vt0123);
156 vp4567 = vmlaq_f32(vt4567, vp4567, vt4567);
157 vp89AB = vmlaq_f32(vt89AB, vp89AB, vt89AB);
158 vpCDEF = vmlaq_f32(vtCDEF, vpCDEF, vtCDEF);
159 vpGHIJ = vmlaq_f32(vtGHIJ, vpGHIJ, vtGHIJ);
160 vpKLMN = vmlaq_f32(vtKLMN, vpKLMN, vtKLMN);
161
162 const float32x4_t ve0123 = vmulq_f32(vaddq_f32(vp0123, vs0123), valpha);
163 const float32x4_t ve4567 = vmulq_f32(vaddq_f32(vp4567, vs4567), valpha);
164 const float32x4_t ve89AB = vmulq_f32(vaddq_f32(vp89AB, vs89AB), valpha);
165 const float32x4_t veCDEF = vmulq_f32(vaddq_f32(vpCDEF, vsCDEF), valpha);
166 const float32x4_t veGHIJ = vmulq_f32(vaddq_f32(vpGHIJ, vsGHIJ), valpha);
167 const float32x4_t veKLMN = vmulq_f32(vaddq_f32(vpKLMN, vsKLMN), valpha);
168
169 const uint32x4_t vm0123 = vcltq_f32(vx0123, vmovq_n_f32(0.0f));
170 vx0123 = vmulq_f32(vx0123, vbeta);
171 const uint32x4_t vm4567 = vcltq_f32(vx4567, vmovq_n_f32(0.0f));
172 vx4567 = vmulq_f32(vx4567, vbeta);
173 const uint32x4_t vm89AB = vcltq_f32(vx89AB, vmovq_n_f32(0.0f));
174 vx89AB = vmulq_f32(vx89AB, vbeta);
175 const uint32x4_t vmCDEF = vcltq_f32(vxCDEF, vmovq_n_f32(0.0f));
176 vxCDEF = vmulq_f32(vxCDEF, vbeta);
177 const uint32x4_t vmGHIJ = vcltq_f32(vxGHIJ, vmovq_n_f32(0.0f));
178 vxGHIJ = vmulq_f32(vxGHIJ, vbeta);
179 const uint32x4_t vmKLMN = vcltq_f32(vxKLMN, vmovq_n_f32(0.0f));
180 vxKLMN = vmulq_f32(vxKLMN, vbeta);
181
182 const float32x4_t vy0123 = vbslq_f32(vm0123, ve0123, vx0123);
183 const float32x4_t vy4567 = vbslq_f32(vm4567, ve4567, vx4567);
184 const float32x4_t vy89AB = vbslq_f32(vm89AB, ve89AB, vx89AB);
185 const float32x4_t vyCDEF = vbslq_f32(vmCDEF, veCDEF, vxCDEF);
186 const float32x4_t vyGHIJ = vbslq_f32(vmGHIJ, veGHIJ, vxGHIJ);
187 const float32x4_t vyKLMN = vbslq_f32(vmKLMN, veKLMN, vxKLMN);
188
189 vst1q_f32(output, vy0123); output += 4;
190 vst1q_f32(output, vy4567); output += 4;
191 vst1q_f32(output, vy89AB); output += 4;
192 vst1q_f32(output, vyCDEF); output += 4;
193 vst1q_f32(output, vyGHIJ); output += 4;
194 vst1q_f32(output, vyKLMN); output += 4;
195 }
196 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
197 float32x4_t vx = vld1q_f32(input); input += 4;
198
199 const float32x4_t vz = vmaxq_f32(vmulq_f32(vx, vprescale), vsat_cutoff);
200
201 float32x4_t vn = vmlaq_f32(vmagic_bias, vz, vlog2e);
202 float32x4_t vs = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn), 23));
203 vn = vsubq_f32(vn, vmagic_bias);
204
205 float32x4_t vt = vmlaq_f32(vz, vn, vminus_ln2_hi);
206 vt = vmlaq_f32(vt, vn, vminus_ln2_lo);
207
208 float32x4_t vp = vmlaq_f32(vc5, vc6, vt);
209 vp = vmlaq_f32(vc4, vp, vt);
210 vp = vmlaq_f32(vc3, vp, vt);
211 vp = vmlaq_f32(vc2, vp, vt);
212 vp = vmulq_f32(vp, vt);
213
214 vt = vmulq_f32(vt, vs);
215 vs = vsubq_f32(vs, vone);
216 vp = vmlaq_f32(vt, vp, vt);
217 const float32x4_t ve = vmulq_f32(vaddq_f32(vp, vs), valpha);
218
219 const uint32x4_t vm = vcltq_f32(vx, vmovq_n_f32(0.0f));
220 vx = vmulq_f32(vx, vbeta);
221 const float32x4_t vy = vbslq_f32(vm, ve, vx);
222
223 vst1q_f32(output, vy); output += 4;
224 }
225 if XNN_UNLIKELY(batch != 0) {
226 float32x4_t vx = vld1q_f32(input);
227
228 const float32x4_t vz = vmaxq_f32(vmulq_f32(vx, vprescale), vsat_cutoff);
229
230 float32x4_t vn = vmlaq_f32(vmagic_bias, vz, vlog2e);
231 float32x4_t vs = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn), 23));
232 vn = vsubq_f32(vn, vmagic_bias);
233
234 float32x4_t vt = vmlaq_f32(vz, vn, vminus_ln2_hi);
235 vt = vmlaq_f32(vt, vn, vminus_ln2_lo);
236
237 float32x4_t vp = vmlaq_f32(vc5, vc6, vt);
238 vp = vmlaq_f32(vc4, vp, vt);
239 vp = vmlaq_f32(vc3, vp, vt);
240 vp = vmlaq_f32(vc2, vp, vt);
241 vp = vmulq_f32(vp, vt);
242
243 vt = vmulq_f32(vt, vs);
244 vs = vsubq_f32(vs, vone);
245 vp = vmlaq_f32(vt, vp, vt);
246 const float32x4_t ve = vmulq_f32(vaddq_f32(vp, vs), valpha);
247
248 const uint32x4_t vm = vcltq_f32(vx, vmovq_n_f32(0.0f));
249 vx = vmulq_f32(vx, vbeta);
250 const float32x4_t vy = vbslq_f32(vm, ve, vx);
251
252 float32x2_t vy_lo = vget_low_f32(vy);
253 if (batch & (2 * sizeof(float))) {
254 vst1_f32(output, vy_lo); output += 2;
255 vy_lo = vget_high_f32(vy);
256 }
257 if (batch & (1 * sizeof(float))) {
258 vst1_lane_f32(output, vy_lo, 0);
259 }
260 }
261 }