Debian Codegraph @

src/f32-velu/gen/f32-velu-neonfma-rr1-p6-u12.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__neonfma_rr1_p6_u12(
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 = vmovq_n_f32(-0x1.62E430p-1f);
50 XNN_FORCE_REALIZATION(vminus_ln2);
51
52 const float32x4_t vprescale = vld1q_dup_f32(&params->scalar.prescale);
53 const float32x4_t valpha = vld1q_dup_f32(&params->scalar.alpha);
54 const float32x4_t vbeta = vld1q_dup_f32(&params->scalar.beta);
55
56 for (; batch >= 12 * sizeof(float); batch -= 12 * sizeof(float)) {
57 float32x4_t vx0123 = vld1q_f32(input); input += 4;
58 float32x4_t vx4567 = vld1q_f32(input); input += 4;
59 float32x4_t vx89AB = vld1q_f32(input); input += 4;
60
61 const float32x4_t vz0123 = vmaxq_f32(vmulq_f32(vx0123, vprescale), vsat_cutoff);
62 const float32x4_t vz4567 = vmaxq_f32(vmulq_f32(vx4567, vprescale), vsat_cutoff);
63 const float32x4_t vz89AB = vmaxq_f32(vmulq_f32(vx89AB, vprescale), vsat_cutoff);
64
65 float32x4_t vn0123 = vfmaq_f32(vmagic_bias, vz0123, vlog2e);
66 float32x4_t vn4567 = vfmaq_f32(vmagic_bias, vz4567, vlog2e);
67 float32x4_t vn89AB = vfmaq_f32(vmagic_bias, vz89AB, vlog2e);
68
69 float32x4_t vs0123 = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn0123), 23));
70 vn0123 = vsubq_f32(vn0123, vmagic_bias);
71 float32x4_t vs4567 = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn4567), 23));
72 vn4567 = vsubq_f32(vn4567, vmagic_bias);
73 float32x4_t vs89AB = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn89AB), 23));
74 vn89AB = vsubq_f32(vn89AB, vmagic_bias);
75
76 float32x4_t vt0123 = vfmaq_f32(vz0123, vn0123, vminus_ln2);
77 float32x4_t vt4567 = vfmaq_f32(vz4567, vn4567, vminus_ln2);
78 float32x4_t vt89AB = vfmaq_f32(vz89AB, vn89AB, vminus_ln2);
79
80 float32x4_t vp0123 = vfmaq_f32(vc5, vc6, vt0123);
81 float32x4_t vp4567 = vfmaq_f32(vc5, vc6, vt4567);
82 float32x4_t vp89AB = vfmaq_f32(vc5, vc6, vt89AB);
83
84 vp0123 = vfmaq_f32(vc4, vp0123, vt0123);
85 vp4567 = vfmaq_f32(vc4, vp4567, vt4567);
86 vp89AB = vfmaq_f32(vc4, vp89AB, vt89AB);
87
88 vp0123 = vfmaq_f32(vc3, vp0123, vt0123);
89 vp4567 = vfmaq_f32(vc3, vp4567, vt4567);
90 vp89AB = vfmaq_f32(vc3, vp89AB, vt89AB);
91
92 vp0123 = vfmaq_f32(vc2, vp0123, vt0123);
93 vp4567 = vfmaq_f32(vc2, vp4567, vt4567);
94 vp89AB = vfmaq_f32(vc2, vp89AB, vt89AB);
95
96 vp0123 = vmulq_f32(vp0123, vt0123);
97 vp4567 = vmulq_f32(vp4567, vt4567);
98 vp89AB = vmulq_f32(vp89AB, vt89AB);
99
100 vt0123 = vmulq_f32(vt0123, vs0123);
101 vs0123 = vsubq_f32(vs0123, vone);
102 vt4567 = vmulq_f32(vt4567, vs4567);
103 vs4567 = vsubq_f32(vs4567, vone);
104 vt89AB = vmulq_f32(vt89AB, vs89AB);
105 vs89AB = vsubq_f32(vs89AB, vone);
106
107 vp0123 = vfmaq_f32(vt0123, vp0123, vt0123);
108 vp4567 = vfmaq_f32(vt4567, vp4567, vt4567);
109 vp89AB = vfmaq_f32(vt89AB, vp89AB, vt89AB);
110
111 const float32x4_t ve0123 = vmulq_f32(vaddq_f32(vp0123, vs0123), valpha);
112 const float32x4_t ve4567 = vmulq_f32(vaddq_f32(vp4567, vs4567), valpha);
113 const float32x4_t ve89AB = vmulq_f32(vaddq_f32(vp89AB, vs89AB), valpha);
114
115 const uint32x4_t vm0123 = vcltq_f32(vx0123, vmovq_n_f32(0.0f));
116 vx0123 = vmulq_f32(vx0123, vbeta);
117 const uint32x4_t vm4567 = vcltq_f32(vx4567, vmovq_n_f32(0.0f));
118 vx4567 = vmulq_f32(vx4567, vbeta);
119 const uint32x4_t vm89AB = vcltq_f32(vx89AB, vmovq_n_f32(0.0f));
120 vx89AB = vmulq_f32(vx89AB, vbeta);
121
122 const float32x4_t vy0123 = vbslq_f32(vm0123, ve0123, vx0123);
123 const float32x4_t vy4567 = vbslq_f32(vm4567, ve4567, vx4567);
124 const float32x4_t vy89AB = vbslq_f32(vm89AB, ve89AB, vx89AB);
125
126 vst1q_f32(output, vy0123); output += 4;
127 vst1q_f32(output, vy4567); output += 4;
128 vst1q_f32(output, vy89AB); output += 4;
129 }
130 for (; batch >= 4 * sizeof(float); batch -= 4 * sizeof(float)) {
131 float32x4_t vx = vld1q_f32(input); input += 4;
132
133 const float32x4_t vz = vmaxq_f32(vmulq_f32(vx, vprescale), vsat_cutoff);
134
135 float32x4_t vn = vfmaq_f32(vmagic_bias, vz, vlog2e);
136 float32x4_t vs = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn), 23));
137 vn = vsubq_f32(vn, vmagic_bias);
138
139 float32x4_t vt = vfmaq_f32(vz, vn, vminus_ln2);
140
141 float32x4_t vp = vfmaq_f32(vc5, vc6, vt);
142 vp = vfmaq_f32(vc4, vp, vt);
143 vp = vfmaq_f32(vc3, vp, vt);
144 vp = vfmaq_f32(vc2, vp, vt);
145 vp = vmulq_f32(vp, vt);
146
147 vt = vmulq_f32(vt, vs);
148 vs = vsubq_f32(vs, vone);
149 vp = vfmaq_f32(vt, vp, vt);
150 const float32x4_t ve = vmulq_f32(vaddq_f32(vp, vs), valpha);
151
152 const uint32x4_t vm = vcltq_f32(vx, vmovq_n_f32(0.0f));
153 vx = vmulq_f32(vx, vbeta);
154 const float32x4_t vy = vbslq_f32(vm, ve, vx);
155
156 vst1q_f32(output, vy); output += 4;
157 }
158 if XNN_UNLIKELY(batch != 0) {
159 float32x4_t vx = vld1q_f32(input);
160
161 const float32x4_t vz = vmaxq_f32(vmulq_f32(vx, vprescale), vsat_cutoff);
162
163 float32x4_t vn = vfmaq_f32(vmagic_bias, vz, vlog2e);
164 float32x4_t vs = vreinterpretq_f32_s32(vshlq_n_s32(vreinterpretq_s32_f32(vn), 23));
165 vn = vsubq_f32(vn, vmagic_bias);
166
167 float32x4_t vt = vfmaq_f32(vz, vn, vminus_ln2);
168
169 float32x4_t vp = vfmaq_f32(vc5, vc6, vt);
170 vp = vfmaq_f32(vc4, vp, vt);
171 vp = vfmaq_f32(vc3, vp, vt);
172 vp = vfmaq_f32(vc2, vp, vt);
173 vp = vmulq_f32(vp, vt);
174
175 vt = vmulq_f32(vt, vs);
176 vs = vsubq_f32(vs, vone);
177 vp = vfmaq_f32(vt, vp, vt);
178 const float32x4_t ve = vmulq_f32(vaddq_f32(vp, vs), valpha);
179
180 const uint32x4_t vm = vcltq_f32(vx, vmovq_n_f32(0.0f));
181 vx = vmulq_f32(vx, vbeta);
182 const float32x4_t vy = vbslq_f32(vm, ve, vx);
183
184 float32x2_t vy_lo = vget_low_f32(vy);
185 if (batch & (2 * sizeof(float))) {
186 vst1_f32(output, vy_lo); output += 2;
187 vy_lo = vget_high_f32(vy);
188 }
189 if (batch & (1 * sizeof(float))) {
190 vst1_lane_f32(output, vy_lo, 0);
191 }
192 }
193 }