Debian Codegraph @

src/f32-velu/gen/f32-velu-neon-rr2-p6-u16.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_u16(
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 >= 16 * sizeof(float); batch -= 16 * 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
64 const float32x4_t vz0123 = vmaxq_f32(vmulq_f32(vx0123, vprescale), vsat_cutoff);
65 const float32x4_t vz4567 = vmaxq_f32(vmulq_f32(vx4567, vprescale), vsat_cutoff);
66 const float32x4_t vz89AB = vmaxq_f32(vmulq_f32(vx89AB, vprescale), vsat_cutoff);
67 const float32x4_t vzCDEF = vmaxq_f32(vmulq_f32(vxCDEF, vprescale), vsat_cutoff);
68
69 float32x4_t vn0123 = vmlaq_f32(vmagic_bias, vz0123, vlog2e);
70 float32x4_t vn4567 = vmlaq_f32(vmagic_bias, vz4567, vlog2e);
71 float32x4_t vn89AB = vmlaq_f32(vmagic_bias, vz89AB, vlog2e);
72 float32x4_t vnCDEF = vmlaq_f32(vmagic_bias, vzCDEF, vlog2e);
73
74 float32x4_t vs0123 = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn0123), 23));
75 vn0123 = vsubq_f32(vn0123, vmagic_bias);
76 float32x4_t vs4567 = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn4567), 23));
77 vn4567 = vsubq_f32(vn4567, vmagic_bias);
78 float32x4_t vs89AB = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn89AB), 23));
79 vn89AB = vsubq_f32(vn89AB, vmagic_bias);
80 float32x4_t vsCDEF = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vnCDEF), 23));
81 vnCDEF = vsubq_f32(vnCDEF, vmagic_bias);
82
83 float32x4_t vt0123 = vmlaq_f32(vz0123, vn0123, vminus_ln2_hi);
84 float32x4_t vt4567 = vmlaq_f32(vz4567, vn4567, vminus_ln2_hi);
85 float32x4_t vt89AB = vmlaq_f32(vz89AB, vn89AB, vminus_ln2_hi);
86 float32x4_t vtCDEF = vmlaq_f32(vzCDEF, vnCDEF, vminus_ln2_hi);
87
88 vt0123 = vmlaq_f32(vt0123, vn0123, vminus_ln2_lo);
89 vt4567 = vmlaq_f32(vt4567, vn4567, vminus_ln2_lo);
90 vt89AB = vmlaq_f32(vt89AB, vn89AB, vminus_ln2_lo);
91 vtCDEF = vmlaq_f32(vtCDEF, vnCDEF, vminus_ln2_lo);
92
93 float32x4_t vp0123 = vmlaq_f32(vc5, vc6, vt0123);
94 float32x4_t vp4567 = vmlaq_f32(vc5, vc6, vt4567);
95 float32x4_t vp89AB = vmlaq_f32(vc5, vc6, vt89AB);
96 float32x4_t vpCDEF = vmlaq_f32(vc5, vc6, vtCDEF);
97
98 vp0123 = vmlaq_f32(vc4, vp0123, vt0123);
99 vp4567 = vmlaq_f32(vc4, vp4567, vt4567);
100 vp89AB = vmlaq_f32(vc4, vp89AB, vt89AB);
101 vpCDEF = vmlaq_f32(vc4, vpCDEF, vtCDEF);
102
103 vp0123 = vmlaq_f32(vc3, vp0123, vt0123);
104 vp4567 = vmlaq_f32(vc3, vp4567, vt4567);
105 vp89AB = vmlaq_f32(vc3, vp89AB, vt89AB);
106 vpCDEF = vmlaq_f32(vc3, vpCDEF, vtCDEF);
107
108 vp0123 = vmlaq_f32(vc2, vp0123, vt0123);
109 vp4567 = vmlaq_f32(vc2, vp4567, vt4567);
110 vp89AB = vmlaq_f32(vc2, vp89AB, vt89AB);
111 vpCDEF = vmlaq_f32(vc2, vpCDEF, vtCDEF);
112
113 vp0123 = vmulq_f32(vp0123, vt0123);
114 vp4567 = vmulq_f32(vp4567, vt4567);
115 vp89AB = vmulq_f32(vp89AB, vt89AB);
116 vpCDEF = vmulq_f32(vpCDEF, vtCDEF);
117
118 vt0123 = vmulq_f32(vt0123, vs0123);
119 vs0123 = vsubq_f32(vs0123, vone);
120 vt4567 = vmulq_f32(vt4567, vs4567);
121 vs4567 = vsubq_f32(vs4567, vone);
122 vt89AB = vmulq_f32(vt89AB, vs89AB);
123 vs89AB = vsubq_f32(vs89AB, vone);
124 vtCDEF = vmulq_f32(vtCDEF, vsCDEF);
125 vsCDEF = vsubq_f32(vsCDEF, vone);
126
127 vp0123 = vmlaq_f32(vt0123, vp0123, vt0123);
128 vp4567 = vmlaq_f32(vt4567, vp4567, vt4567);
129 vp89AB = vmlaq_f32(vt89AB, vp89AB, vt89AB);
130 vpCDEF = vmlaq_f32(vtCDEF, vpCDEF, vtCDEF);
131
132 const float32x4_t ve0123 = vmulq_f32(vaddq_f32(vp0123, vs0123), valpha);
133 const float32x4_t ve4567 = vmulq_f32(vaddq_f32(vp4567, vs4567), valpha);
134 const float32x4_t ve89AB = vmulq_f32(vaddq_f32(vp89AB, vs89AB), valpha);
135 const float32x4_t veCDEF = vmulq_f32(vaddq_f32(vpCDEF, vsCDEF), valpha);
136
137 const uint32x4_t vm0123 = vcltq_f32(vx0123, vmovq_n_f32(0.0f));
138 vx0123 = vmulq_f32(vx0123, vbeta);
139 const uint32x4_t vm4567 = vcltq_f32(vx4567, vmovq_n_f32(0.0f));
140 vx4567 = vmulq_f32(vx4567, vbeta);
141 const uint32x4_t vm89AB = vcltq_f32(vx89AB, vmovq_n_f32(0.0f));
142 vx89AB = vmulq_f32(vx89AB, vbeta);
143 const uint32x4_t vmCDEF = vcltq_f32(vxCDEF, vmovq_n_f32(0.0f));
144 vxCDEF = vmulq_f32(vxCDEF, vbeta);
145
146 const float32x4_t vy0123 = vbslq_f32(vm0123, ve0123, vx0123);
147 const float32x4_t vy4567 = vbslq_f32(vm4567, ve4567, vx4567);
148 const float32x4_t vy89AB = vbslq_f32(vm89AB, ve89AB, vx89AB);
149 const float32x4_t vyCDEF = vbslq_f32(vmCDEF, veCDEF, vxCDEF);
150
151 vst1q_f32(output, vy0123); output += 4;
152 vst1q_f32(output, vy4567); output += 4;
153 vst1q_f32(output, vy89AB); output += 4;
154 vst1q_f32(output, vyCDEF); output += 4;
155 }
156 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
157 float32x4_t vx = vld1q_f32(input); input += 4;
158
159 const float32x4_t vz = vmaxq_f32(vmulq_f32(vx, vprescale), vsat_cutoff);
160
161 float32x4_t vn = vmlaq_f32(vmagic_bias, vz, vlog2e);
162 float32x4_t vs = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn), 23));
163 vn = vsubq_f32(vn, vmagic_bias);
164
165 float32x4_t vt = vmlaq_f32(vz, vn, vminus_ln2_hi);
166 vt = vmlaq_f32(vt, vn, vminus_ln2_lo);
167
168 float32x4_t vp = vmlaq_f32(vc5, vc6, vt);
169 vp = vmlaq_f32(vc4, vp, vt);
170 vp = vmlaq_f32(vc3, vp, vt);
171 vp = vmlaq_f32(vc2, vp, vt);
172 vp = vmulq_f32(vp, vt);
173
174 vt = vmulq_f32(vt, vs);
175 vs = vsubq_f32(vs, vone);
176 vp = vmlaq_f32(vt, vp, vt);
177 const float32x4_t ve = vmulq_f32(vaddq_f32(vp, vs), valpha);
178
179 const uint32x4_t vm = vcltq_f32(vx, vmovq_n_f32(0.0f));
180 vx = vmulq_f32(vx, vbeta);
181 const float32x4_t vy = vbslq_f32(vm, ve, vx);
182
183 vst1q_f32(output, vy); output += 4;
184 }
185 if XNN_UNLIKELY(batch != 0) {
186 float32x4_t vx = vld1q_f32(input);
187
188 const float32x4_t vz = vmaxq_f32(vmulq_f32(vx, vprescale), vsat_cutoff);
189
190 float32x4_t vn = vmlaq_f32(vmagic_bias, vz, vlog2e);
191 float32x4_t vs = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn), 23));
192 vn = vsubq_f32(vn, vmagic_bias);
193
194 float32x4_t vt = vmlaq_f32(vz, vn, vminus_ln2_hi);
195 vt = vmlaq_f32(vt, vn, vminus_ln2_lo);
196
197 float32x4_t vp = vmlaq_f32(vc5, vc6, vt);
198 vp = vmlaq_f32(vc4, vp, vt);
199 vp = vmlaq_f32(vc3, vp, vt);
200 vp = vmlaq_f32(vc2, vp, vt);
201 vp = vmulq_f32(vp, vt);
202
203 vt = vmulq_f32(vt, vs);
204 vs = vsubq_f32(vs, vone);
205 vp = vmlaq_f32(vt, vp, vt);
206 const float32x4_t ve = vmulq_f32(vaddq_f32(vp, vs), valpha);
207
208 const uint32x4_t vm = vcltq_f32(vx, vmovq_n_f32(0.0f));
209 vx = vmulq_f32(vx, vbeta);
210 const float32x4_t vy = vbslq_f32(vm, ve, vx);
211
212 float32x2_t vy_lo = vget_low_f32(vy);
213 if (batch & (2 * sizeof(float))) {
214 vst1_f32(output, vy_lo); output += 2;
215 vy_lo = vget_high_f32(vy);
216 }
217 if (batch & (1 * sizeof(float))) {
218 vst1_lane_f32(output, vy_lo, 0);
219 }
220 }
221 }