1 // Auto-generated file. Do not edit!
2 // Template: src/f32-dwconv2d-chw/5x5p2-neon.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/dwconv.h>
15 #include <xnnpack/math.h>
16
17
xnn_f32_dwconv2d_chw_ukernel_5x5p2__neonfma_2x4_acc2(size_t input_height,size_t input_width,const float * input,const float * weights,const float * zero,float * output,uint32_t padding_top,const union xnn_f32_chw_params params[restrict XNN_MIN_ELEMENTS (1)])18 void xnn_f32_dwconv2d_chw_ukernel_5x5p2__neonfma_2x4_acc2(
19 size_t input_height,
20 size_t input_width,
21 const float* input,
22 const float* weights,
23 const float* zero,
24 float* output,
25 uint32_t padding_top,
26 const union xnn_f32_chw_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
27 {
28 assert(input_height != 0);
29 assert(input_width != 0);
30 assert(input_width % sizeof(float) == 0);
31 assert(padding_top == 2);
32
33 const uint32x4_t vmask = vld1q_u32(params->neon.mask);
34 const float32x4_t vmax = vld1q_dup_f32(¶ms->neon.max);
35 const float32x4_t vmin = vld1q_dup_f32(¶ms->neon.min);
36
37 const float32x4_t vw0123 = vld1q_f32(weights);
38 const float32x4_t vw4567 = vld1q_f32(weights + 4);
39 const float32x4_t vw89AB = vld1q_f32(weights + 8);
40 const float32x4_t vwCDEF = vld1q_f32(weights + 12);
41 const float32x4_t vwGHIJ = vld1q_f32(weights + 16);
42 const float32x4_t vwKLMN = vld1q_f32(weights + 20);
43 const float32x2_t vwOP = vld1_f32(weights + 24);
44
45 const size_t input_decrement = round_up_po2(input_width, 4 * sizeof(float));
46
47 const float* i0 = zero;
48 const float* i1 = zero;
49 const float* i2 = input;
50 const float* i3 = (const float*) ((uintptr_t) i2 + input_width);
51 const float* i4 = (const float*) ((uintptr_t) i3 + input_width);
52 const float* i5 = (const float*) ((uintptr_t) i4 + input_width);
53
54 float* o0 = output;
55 float* o1 = (float*) ((uintptr_t) o0 + input_width);
56
57 size_t output_height = input_height;
58 do {
59 if XNN_UNPREDICTABLE(output_height < 2) {
60 i3 = zero;
61 o1 = o0;
62 }
63 if XNN_UNPREDICTABLE(output_height < 3) {
64 i4 = zero;
65 }
66 if XNN_UNPREDICTABLE(output_height < 4) {
67 i5 = zero;
68 }
69
70 float32x4_t vi0x0123 = vmovq_n_f32(0.0f);
71 float32x4_t vi1x0123 = vmovq_n_f32(0.0f);
72 float32x4_t vi2x0123 = vmovq_n_f32(0.0f);
73 float32x4_t vi3x0123 = vmovq_n_f32(0.0f);
74 float32x4_t vi4x0123 = vmovq_n_f32(0.0f);
75 float32x4_t vi5x0123 = vmovq_n_f32(0.0f);
76
77 float32x4_t vi0x4567 = vld1q_f32(i0); i0 += 4;
78 float32x4_t vi1x4567 = vld1q_f32(i1); i1 += 4;
79 float32x4_t vi2x4567 = vld1q_f32(i2); i2 += 4;
80 float32x4_t vi3x4567 = vld1q_f32(i3); i3 += 4;
81 float32x4_t vi4x4567 = vld1q_f32(i4); i4 += 4;
82 float32x4_t vi5x4567 = vld1q_f32(i5); i5 += 4;
83
84 size_t w = input_width;
85 for (; w > 8 * sizeof(float); w -= 4 * sizeof(float)) {
86 float32x4_t vo0p0 = vdupq_lane_f32(vget_low_f32(vw0123), 0);
87 float32x4_t vo1p0 = vdupq_lane_f32(vget_low_f32(vw0123), 0);
88
89 const float32x4_t vi0x89AB = vld1q_f32(i0); i0 += 4;
90 const float32x4_t vi1x89AB = vld1q_f32(i1); i1 += 4;
91 const float32x4_t vi2x89AB = vld1q_f32(i2); i2 += 4;
92 const float32x4_t vi3x89AB = vld1q_f32(i3); i3 += 4;
93 const float32x4_t vi4x89AB = vld1q_f32(i4); i4 += 4;
94 const float32x4_t vi5x89AB = vld1q_f32(i5); i5 += 4;
95
96 float32x4_t vo0p1 = vmulq_lane_f32(vi0x4567, vget_high_f32(vw0123), 1);
97 float32x4_t vo1p1 = vmulq_lane_f32(vi1x4567, vget_high_f32(vw0123), 1);
98
99 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x4567, vget_low_f32(vw89AB), 0);
100 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x4567, vget_low_f32(vw89AB), 0);
101
102 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x4567, vget_low_f32(vwCDEF), 1);
103 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x4567, vget_low_f32(vwCDEF), 1);
104
105 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x4567, vget_high_f32(vwGHIJ), 0);
106 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x4567, vget_high_f32(vwGHIJ), 0);
107
108 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x4567, vget_high_f32(vwKLMN), 1);
109 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x4567, vget_high_f32(vwKLMN), 1);
110
111 const float32x4_t vi0x3456 = vextq_f32(vi0x0123, vi0x4567, 3);
112 const float32x4_t vi1x3456 = vextq_f32(vi1x0123, vi1x4567, 3);
113 const float32x4_t vi2x3456 = vextq_f32(vi2x0123, vi2x4567, 3);
114 const float32x4_t vi3x3456 = vextq_f32(vi3x0123, vi3x4567, 3);
115 const float32x4_t vi4x3456 = vextq_f32(vi4x0123, vi4x4567, 3);
116 const float32x4_t vi5x3456 = vextq_f32(vi5x0123, vi5x4567, 3);
117
118 vo0p1 = vfmaq_lane_f32(vo0p1, vi0x3456, vget_high_f32(vw0123), 0);
119 vo1p1 = vfmaq_lane_f32(vo1p1, vi1x3456, vget_high_f32(vw0123), 0);
120
121 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x3456, vget_high_f32(vw4567), 1);
122 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x3456, vget_high_f32(vw4567), 1);
123
124 vo0p1 = vfmaq_lane_f32(vo0p1, vi2x3456, vget_low_f32(vwCDEF), 0);
125 vo1p1 = vfmaq_lane_f32(vo1p1, vi3x3456, vget_low_f32(vwCDEF), 0);
126
127 vo0p0 = vfmaq_lane_f32(vo0p0, vi3x3456, vget_low_f32(vwGHIJ), 1);
128 vo1p0 = vfmaq_lane_f32(vo1p0, vi4x3456, vget_low_f32(vwGHIJ), 1);
129
130 vo0p1 = vfmaq_lane_f32(vo0p1, vi4x3456, vget_high_f32(vwKLMN), 0);
131 vo1p1 = vfmaq_lane_f32(vo1p1, vi5x3456, vget_high_f32(vwKLMN), 0);
132
133 const float32x4_t vi0x2345 = vextq_f32(vi0x0123, vi0x4567, 2);
134 vi0x0123 = vi0x4567;
135 const float32x4_t vi1x2345 = vextq_f32(vi1x0123, vi1x4567, 2);
136 vi1x0123 = vi1x4567;
137 const float32x4_t vi2x2345 = vextq_f32(vi2x0123, vi2x4567, 2);
138 vi2x0123 = vi2x4567;
139 const float32x4_t vi3x2345 = vextq_f32(vi3x0123, vi3x4567, 2);
140 vi3x0123 = vi3x4567;
141 const float32x4_t vi4x2345 = vextq_f32(vi4x0123, vi4x4567, 2);
142 vi4x0123 = vi4x4567;
143 const float32x4_t vi5x2345 = vextq_f32(vi5x0123, vi5x4567, 2);
144 vi5x0123 = vi5x4567;
145
146 vo0p0 = vfmaq_lane_f32(vo0p0, vi0x2345, vget_low_f32(vw0123), 1);
147 vo1p0 = vfmaq_lane_f32(vo1p0, vi1x2345, vget_low_f32(vw0123), 1);
148
149 vo0p1 = vfmaq_lane_f32(vo0p1, vi1x2345, vget_high_f32(vw4567), 0);
150 vo1p1 = vfmaq_lane_f32(vo1p1, vi2x2345, vget_high_f32(vw4567), 0);
151
152 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x2345, vget_high_f32(vw89AB), 1);
153 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x2345, vget_high_f32(vw89AB), 1);
154
155 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x2345, vget_low_f32(vwGHIJ), 0);
156 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x2345, vget_low_f32(vwGHIJ), 0);
157
158 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x2345, vget_low_f32(vwKLMN), 1);
159 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x2345, vget_low_f32(vwKLMN), 1);
160
161 const float32x4_t vi0x5678 = vextq_f32(vi0x4567, vi0x89AB, 1);
162 const float32x4_t vi1x5678 = vextq_f32(vi1x4567, vi1x89AB, 1);
163 const float32x4_t vi2x5678 = vextq_f32(vi2x4567, vi2x89AB, 1);
164 const float32x4_t vi3x5678 = vextq_f32(vi3x4567, vi3x89AB, 1);
165 const float32x4_t vi4x5678 = vextq_f32(vi4x4567, vi4x89AB, 1);
166 const float32x4_t vi5x5678 = vextq_f32(vi5x4567, vi5x89AB, 1);
167
168 vo0p1 = vfmaq_lane_f32(vo0p1, vi0x5678, vget_low_f32(vw4567), 0);
169 vo1p1 = vfmaq_lane_f32(vo1p1, vi1x5678, vget_low_f32(vw4567), 0);
170
171 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x5678, vget_low_f32(vw89AB), 1);
172 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x5678, vget_low_f32(vw89AB), 1);
173
174 vo0p1 = vfmaq_lane_f32(vo0p1, vi2x5678, vget_high_f32(vwCDEF), 0);
175 vo1p1 = vfmaq_lane_f32(vo1p1, vi3x5678, vget_high_f32(vwCDEF), 0);
176
177 vo0p0 = vfmaq_lane_f32(vo0p0, vi3x5678, vget_high_f32(vwGHIJ), 1);
178 vo1p0 = vfmaq_lane_f32(vo1p0, vi4x5678, vget_high_f32(vwGHIJ), 1);
179
180 vo0p1 = vfmaq_lane_f32(vo0p1, vi4x5678, vwOP, 0);
181 vo1p1 = vfmaq_lane_f32(vo1p1, vi5x5678, vwOP, 0);
182
183 const float32x4_t vi0x6789 = vextq_f32(vi0x4567, vi0x89AB, 2);
184 vi0x4567 = vi0x89AB;
185 const float32x4_t vi1x6789 = vextq_f32(vi1x4567, vi1x89AB, 2);
186 vi1x4567 = vi1x89AB;
187 const float32x4_t vi2x6789 = vextq_f32(vi2x4567, vi2x89AB, 2);
188 vi2x4567 = vi2x89AB;
189 const float32x4_t vi3x6789 = vextq_f32(vi3x4567, vi3x89AB, 2);
190 vi3x4567 = vi3x89AB;
191 const float32x4_t vi4x6789 = vextq_f32(vi4x4567, vi4x89AB, 2);
192 vi4x4567 = vi4x89AB;
193 const float32x4_t vi5x6789 = vextq_f32(vi5x4567, vi5x89AB, 2);
194 vi5x4567 = vi5x89AB;
195
196 vo0p0 = vfmaq_lane_f32(vo0p0, vi0x6789, vget_low_f32(vw4567), 1);
197 vo1p0 = vfmaq_lane_f32(vo1p0, vi1x6789, vget_low_f32(vw4567), 1);
198
199 vo0p1 = vfmaq_lane_f32(vo0p1, vi1x6789, vget_high_f32(vw89AB), 0);
200 vo1p1 = vfmaq_lane_f32(vo1p1, vi2x6789, vget_high_f32(vw89AB), 0);
201
202 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x6789, vget_high_f32(vwCDEF), 1);
203 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x6789, vget_high_f32(vwCDEF), 1);
204
205 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x6789, vget_low_f32(vwKLMN), 0);
206 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x6789, vget_low_f32(vwKLMN), 0);
207
208 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x6789, vwOP, 1);
209 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x6789, vwOP, 1);
210
211 vo0p0 = vaddq_f32(vo0p0, vo0p1);
212 vo1p0 = vaddq_f32(vo1p0, vo1p1);
213
214 float32x4_t vo0 = vmaxq_f32(vo0p0, vmin);
215 float32x4_t vo1 = vmaxq_f32(vo1p0, vmin);
216
217 vo0 = vminq_f32(vo0, vmax);
218 vo1 = vminq_f32(vo1, vmax);
219
220 vst1q_f32(o1, vo1); o1 += 4;
221 vst1q_f32(o0, vo0); o0 += 4;
222 }
223 // Always process the last block of 5..8 pixels.
224 if XNN_LIKELY(w > 4 * sizeof(float)) {
225 float32x4_t vo0p0 = vdupq_lane_f32(vget_low_f32(vw0123), 0);
226 float32x4_t vo1p0 = vdupq_lane_f32(vget_low_f32(vw0123), 0);
227
228 float32x4_t vi0x89AB = vld1q_f32(i0); i0 += 4;
229 float32x4_t vi1x89AB = vld1q_f32(i1); i1 += 4;
230 float32x4_t vi2x89AB = vld1q_f32(i2); i2 += 4;
231 float32x4_t vi3x89AB = vld1q_f32(i3); i3 += 4;
232 float32x4_t vi4x89AB = vld1q_f32(i4); i4 += 4;
233 float32x4_t vi5x89AB = vld1q_f32(i5); i5 += 4;
234
235 vi0x89AB = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi0x89AB)));
236 vi1x89AB = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi1x89AB)));
237 vi2x89AB = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi2x89AB)));
238 vi3x89AB = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi3x89AB)));
239 vi4x89AB = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi4x89AB)));
240 vi5x89AB = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi5x89AB)));
241
242 float32x4_t vo0p1 = vmulq_lane_f32(vi0x4567, vget_high_f32(vw0123), 1);
243 float32x4_t vo1p1 = vmulq_lane_f32(vi1x4567, vget_high_f32(vw0123), 1);
244
245 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x4567, vget_low_f32(vw89AB), 0);
246 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x4567, vget_low_f32(vw89AB), 0);
247
248 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x4567, vget_low_f32(vwCDEF), 1);
249 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x4567, vget_low_f32(vwCDEF), 1);
250
251 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x4567, vget_high_f32(vwGHIJ), 0);
252 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x4567, vget_high_f32(vwGHIJ), 0);
253
254 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x4567, vget_high_f32(vwKLMN), 1);
255 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x4567, vget_high_f32(vwKLMN), 1);
256
257 const float32x4_t vi0x3456 = vextq_f32(vi0x0123, vi0x4567, 3);
258 const float32x4_t vi1x3456 = vextq_f32(vi1x0123, vi1x4567, 3);
259 const float32x4_t vi2x3456 = vextq_f32(vi2x0123, vi2x4567, 3);
260 const float32x4_t vi3x3456 = vextq_f32(vi3x0123, vi3x4567, 3);
261 const float32x4_t vi4x3456 = vextq_f32(vi4x0123, vi4x4567, 3);
262 const float32x4_t vi5x3456 = vextq_f32(vi5x0123, vi5x4567, 3);
263
264 vo0p1 = vfmaq_lane_f32(vo0p1, vi0x3456, vget_high_f32(vw0123), 0);
265 vo1p1 = vfmaq_lane_f32(vo1p1, vi1x3456, vget_high_f32(vw0123), 0);
266
267 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x3456, vget_high_f32(vw4567), 1);
268 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x3456, vget_high_f32(vw4567), 1);
269
270 vo0p1 = vfmaq_lane_f32(vo0p1, vi2x3456, vget_low_f32(vwCDEF), 0);
271 vo1p1 = vfmaq_lane_f32(vo1p1, vi3x3456, vget_low_f32(vwCDEF), 0);
272
273 vo0p0 = vfmaq_lane_f32(vo0p0, vi3x3456, vget_low_f32(vwGHIJ), 1);
274 vo1p0 = vfmaq_lane_f32(vo1p0, vi4x3456, vget_low_f32(vwGHIJ), 1);
275
276 vo0p1 = vfmaq_lane_f32(vo0p1, vi4x3456, vget_high_f32(vwKLMN), 0);
277 vo1p1 = vfmaq_lane_f32(vo1p1, vi5x3456, vget_high_f32(vwKLMN), 0);
278
279 const float32x4_t vi0x2345 = vextq_f32(vi0x0123, vi0x4567, 2);
280 vi0x0123 = vi0x4567;
281 const float32x4_t vi1x2345 = vextq_f32(vi1x0123, vi1x4567, 2);
282 vi1x0123 = vi1x4567;
283 const float32x4_t vi2x2345 = vextq_f32(vi2x0123, vi2x4567, 2);
284 vi2x0123 = vi2x4567;
285 const float32x4_t vi3x2345 = vextq_f32(vi3x0123, vi3x4567, 2);
286 vi3x0123 = vi3x4567;
287 const float32x4_t vi4x2345 = vextq_f32(vi4x0123, vi4x4567, 2);
288 vi4x0123 = vi4x4567;
289 const float32x4_t vi5x2345 = vextq_f32(vi5x0123, vi5x4567, 2);
290 vi5x0123 = vi5x4567;
291
292 vo0p0 = vfmaq_lane_f32(vo0p0, vi0x2345, vget_low_f32(vw0123), 1);
293 vo1p0 = vfmaq_lane_f32(vo1p0, vi1x2345, vget_low_f32(vw0123), 1);
294
295 vo0p1 = vfmaq_lane_f32(vo0p1, vi1x2345, vget_high_f32(vw4567), 0);
296 vo1p1 = vfmaq_lane_f32(vo1p1, vi2x2345, vget_high_f32(vw4567), 0);
297
298 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x2345, vget_high_f32(vw89AB), 1);
299 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x2345, vget_high_f32(vw89AB), 1);
300
301 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x2345, vget_low_f32(vwGHIJ), 0);
302 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x2345, vget_low_f32(vwGHIJ), 0);
303
304 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x2345, vget_low_f32(vwKLMN), 1);
305 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x2345, vget_low_f32(vwKLMN), 1);
306
307 const float32x4_t vi0x5678 = vextq_f32(vi0x4567, vi0x89AB, 1);
308 const float32x4_t vi1x5678 = vextq_f32(vi1x4567, vi1x89AB, 1);
309 const float32x4_t vi2x5678 = vextq_f32(vi2x4567, vi2x89AB, 1);
310 const float32x4_t vi3x5678 = vextq_f32(vi3x4567, vi3x89AB, 1);
311 const float32x4_t vi4x5678 = vextq_f32(vi4x4567, vi4x89AB, 1);
312 const float32x4_t vi5x5678 = vextq_f32(vi5x4567, vi5x89AB, 1);
313
314 vo0p1 = vfmaq_lane_f32(vo0p1, vi0x5678, vget_low_f32(vw4567), 0);
315 vo1p1 = vfmaq_lane_f32(vo1p1, vi1x5678, vget_low_f32(vw4567), 0);
316
317 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x5678, vget_low_f32(vw89AB), 1);
318 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x5678, vget_low_f32(vw89AB), 1);
319
320 vo0p1 = vfmaq_lane_f32(vo0p1, vi2x5678, vget_high_f32(vwCDEF), 0);
321 vo1p1 = vfmaq_lane_f32(vo1p1, vi3x5678, vget_high_f32(vwCDEF), 0);
322
323 vo0p0 = vfmaq_lane_f32(vo0p0, vi3x5678, vget_high_f32(vwGHIJ), 1);
324 vo1p0 = vfmaq_lane_f32(vo1p0, vi4x5678, vget_high_f32(vwGHIJ), 1);
325
326 vo0p1 = vfmaq_lane_f32(vo0p1, vi4x5678, vwOP, 0);
327 vo1p1 = vfmaq_lane_f32(vo1p1, vi5x5678, vwOP, 0);
328
329 const float32x4_t vi0x6789 = vextq_f32(vi0x4567, vi0x89AB, 2);
330 vi0x4567 = vi0x89AB;
331 const float32x4_t vi1x6789 = vextq_f32(vi1x4567, vi1x89AB, 2);
332 vi1x4567 = vi1x89AB;
333 const float32x4_t vi2x6789 = vextq_f32(vi2x4567, vi2x89AB, 2);
334 vi2x4567 = vi2x89AB;
335 const float32x4_t vi3x6789 = vextq_f32(vi3x4567, vi3x89AB, 2);
336 vi3x4567 = vi3x89AB;
337 const float32x4_t vi4x6789 = vextq_f32(vi4x4567, vi4x89AB, 2);
338 vi4x4567 = vi4x89AB;
339 const float32x4_t vi5x6789 = vextq_f32(vi5x4567, vi5x89AB, 2);
340 vi5x4567 = vi5x89AB;
341
342 vo0p0 = vfmaq_lane_f32(vo0p0, vi0x6789, vget_low_f32(vw4567), 1);
343 vo1p0 = vfmaq_lane_f32(vo1p0, vi1x6789, vget_low_f32(vw4567), 1);
344
345 vo0p1 = vfmaq_lane_f32(vo0p1, vi1x6789, vget_high_f32(vw89AB), 0);
346 vo1p1 = vfmaq_lane_f32(vo1p1, vi2x6789, vget_high_f32(vw89AB), 0);
347
348 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x6789, vget_high_f32(vwCDEF), 1);
349 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x6789, vget_high_f32(vwCDEF), 1);
350
351 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x6789, vget_low_f32(vwKLMN), 0);
352 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x6789, vget_low_f32(vwKLMN), 0);
353
354 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x6789, vwOP, 1);
355 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x6789, vwOP, 1);
356
357 vo0p0 = vaddq_f32(vo0p0, vo0p1);
358 vo1p0 = vaddq_f32(vo1p0, vo1p1);
359
360 float32x4_t vo0 = vmaxq_f32(vo0p0, vmin);
361 float32x4_t vo1 = vmaxq_f32(vo1p0, vmin);
362
363 vo0 = vminq_f32(vo0, vmax);
364 vo1 = vminq_f32(vo1, vmax);
365
366 vst1q_f32(o1, vo1); o1 += 4;
367 vst1q_f32(o0, vo0); o0 += 4;
368
369 w -= 4 * sizeof(float);
370 }
371 assert(w >= 1 * sizeof(float));
372 assert(w <= 4 * sizeof(float));
373 {
374 float32x4_t vo0p0 = vdupq_lane_f32(vget_low_f32(vw0123), 0);
375 float32x4_t vo1p0 = vdupq_lane_f32(vget_low_f32(vw0123), 0);
376
377 vi0x4567 = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi0x4567)));
378 vi1x4567 = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi1x4567)));
379 vi2x4567 = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi2x4567)));
380 vi3x4567 = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi3x4567)));
381 vi4x4567 = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi4x4567)));
382 vi5x4567 = vreinterpretq_f32_u32(vandq_u32(vmask, vreinterpretq_u32_f32(vi5x4567)));
383
384 float32x4_t vo0p1 = vmulq_lane_f32(vi0x4567, vget_high_f32(vw0123), 1);
385 float32x4_t vo1p1 = vmulq_lane_f32(vi1x4567, vget_high_f32(vw0123), 1);
386
387 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x4567, vget_low_f32(vw89AB), 0);
388 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x4567, vget_low_f32(vw89AB), 0);
389
390 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x4567, vget_low_f32(vwCDEF), 1);
391 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x4567, vget_low_f32(vwCDEF), 1);
392
393 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x4567, vget_high_f32(vwGHIJ), 0);
394 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x4567, vget_high_f32(vwGHIJ), 0);
395
396 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x4567, vget_high_f32(vwKLMN), 1);
397 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x4567, vget_high_f32(vwKLMN), 1);
398
399 const float32x4_t vi0x3456 = vextq_f32(vi0x0123, vi0x4567, 3);
400 const float32x4_t vi1x3456 = vextq_f32(vi1x0123, vi1x4567, 3);
401 const float32x4_t vi2x3456 = vextq_f32(vi2x0123, vi2x4567, 3);
402 const float32x4_t vi3x3456 = vextq_f32(vi3x0123, vi3x4567, 3);
403 const float32x4_t vi4x3456 = vextq_f32(vi4x0123, vi4x4567, 3);
404 const float32x4_t vi5x3456 = vextq_f32(vi5x0123, vi5x4567, 3);
405
406 vo0p1 = vfmaq_lane_f32(vo0p1, vi0x3456, vget_high_f32(vw0123), 0);
407 vo1p1 = vfmaq_lane_f32(vo1p1, vi1x3456, vget_high_f32(vw0123), 0);
408
409 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x3456, vget_high_f32(vw4567), 1);
410 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x3456, vget_high_f32(vw4567), 1);
411
412 vo0p1 = vfmaq_lane_f32(vo0p1, vi2x3456, vget_low_f32(vwCDEF), 0);
413 vo1p1 = vfmaq_lane_f32(vo1p1, vi3x3456, vget_low_f32(vwCDEF), 0);
414
415 vo0p0 = vfmaq_lane_f32(vo0p0, vi3x3456, vget_low_f32(vwGHIJ), 1);
416 vo1p0 = vfmaq_lane_f32(vo1p0, vi4x3456, vget_low_f32(vwGHIJ), 1);
417
418 vo0p1 = vfmaq_lane_f32(vo0p1, vi4x3456, vget_high_f32(vwKLMN), 0);
419 vo1p1 = vfmaq_lane_f32(vo1p1, vi5x3456, vget_high_f32(vwKLMN), 0);
420
421 const float32x4_t vi0x2345 = vextq_f32(vi0x0123, vi0x4567, 2);
422 const float32x4_t vi1x2345 = vextq_f32(vi1x0123, vi1x4567, 2);
423 const float32x4_t vi2x2345 = vextq_f32(vi2x0123, vi2x4567, 2);
424 const float32x4_t vi3x2345 = vextq_f32(vi3x0123, vi3x4567, 2);
425 const float32x4_t vi4x2345 = vextq_f32(vi4x0123, vi4x4567, 2);
426 const float32x4_t vi5x2345 = vextq_f32(vi5x0123, vi5x4567, 2);
427
428 vo0p0 = vfmaq_lane_f32(vo0p0, vi0x2345, vget_low_f32(vw0123), 1);
429 vo1p0 = vfmaq_lane_f32(vo1p0, vi1x2345, vget_low_f32(vw0123), 1);
430
431 vo0p1 = vfmaq_lane_f32(vo0p1, vi1x2345, vget_high_f32(vw4567), 0);
432 vo1p1 = vfmaq_lane_f32(vo1p1, vi2x2345, vget_high_f32(vw4567), 0);
433
434 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x2345, vget_high_f32(vw89AB), 1);
435 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x2345, vget_high_f32(vw89AB), 1);
436
437 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x2345, vget_low_f32(vwGHIJ), 0);
438 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x2345, vget_low_f32(vwGHIJ), 0);
439
440 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x2345, vget_low_f32(vwKLMN), 1);
441 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x2345, vget_low_f32(vwKLMN), 1);
442
443 const float32x4_t vzero = vmovq_n_f32(0.0f);
444 const float32x4_t vi0x5678 = vextq_f32(vi0x4567, vzero, 1);
445 const float32x4_t vi1x5678 = vextq_f32(vi1x4567, vzero, 1);
446 const float32x4_t vi2x5678 = vextq_f32(vi2x4567, vzero, 1);
447 const float32x4_t vi3x5678 = vextq_f32(vi3x4567, vzero, 1);
448 const float32x4_t vi4x5678 = vextq_f32(vi4x4567, vzero, 1);
449 const float32x4_t vi5x5678 = vextq_f32(vi5x4567, vzero, 1);
450
451 vo0p1 = vfmaq_lane_f32(vo0p1, vi0x5678, vget_low_f32(vw4567), 0);
452 vo1p1 = vfmaq_lane_f32(vo1p1, vi1x5678, vget_low_f32(vw4567), 0);
453
454 vo0p0 = vfmaq_lane_f32(vo0p0, vi1x5678, vget_low_f32(vw89AB), 1);
455 vo1p0 = vfmaq_lane_f32(vo1p0, vi2x5678, vget_low_f32(vw89AB), 1);
456
457 vo0p1 = vfmaq_lane_f32(vo0p1, vi2x5678, vget_high_f32(vwCDEF), 0);
458 vo1p1 = vfmaq_lane_f32(vo1p1, vi3x5678, vget_high_f32(vwCDEF), 0);
459
460 vo0p0 = vfmaq_lane_f32(vo0p0, vi3x5678, vget_high_f32(vwGHIJ), 1);
461 vo1p0 = vfmaq_lane_f32(vo1p0, vi4x5678, vget_high_f32(vwGHIJ), 1);
462
463 vo0p1 = vfmaq_lane_f32(vo0p1, vi4x5678, vwOP, 0);
464 vo1p1 = vfmaq_lane_f32(vo1p1, vi5x5678, vwOP, 0);
465
466 const float32x4_t vi0x6789 = vextq_f32(vi0x5678, vzero, 1);
467 const float32x4_t vi1x6789 = vextq_f32(vi1x5678, vzero, 1);
468 const float32x4_t vi2x6789 = vextq_f32(vi2x5678, vzero, 1);
469 const float32x4_t vi3x6789 = vextq_f32(vi3x5678, vzero, 1);
470 const float32x4_t vi4x6789 = vextq_f32(vi4x5678, vzero, 1);
471 const float32x4_t vi5x6789 = vextq_f32(vi5x5678, vzero, 1);
472
473 vo0p0 = vfmaq_lane_f32(vo0p0, vi0x6789, vget_low_f32(vw4567), 1);
474 vo1p0 = vfmaq_lane_f32(vo1p0, vi1x6789, vget_low_f32(vw4567), 1);
475
476 vo0p1 = vfmaq_lane_f32(vo0p1, vi1x6789, vget_high_f32(vw89AB), 0);
477 vo1p1 = vfmaq_lane_f32(vo1p1, vi2x6789, vget_high_f32(vw89AB), 0);
478
479 vo0p0 = vfmaq_lane_f32(vo0p0, vi2x6789, vget_high_f32(vwCDEF), 1);
480 vo1p0 = vfmaq_lane_f32(vo1p0, vi3x6789, vget_high_f32(vwCDEF), 1);
481
482 vo0p1 = vfmaq_lane_f32(vo0p1, vi3x6789, vget_low_f32(vwKLMN), 0);
483 vo1p1 = vfmaq_lane_f32(vo1p1, vi4x6789, vget_low_f32(vwKLMN), 0);
484
485 vo0p0 = vfmaq_lane_f32(vo0p0, vi4x6789, vwOP, 1);
486 vo1p0 = vfmaq_lane_f32(vo1p0, vi5x6789, vwOP, 1);
487
488 vo0p0 = vaddq_f32(vo0p0, vo0p1);
489 vo1p0 = vaddq_f32(vo1p0, vo1p1);
490
491 float32x4_t vo0 = vmaxq_f32(vo0p0, vmin);
492 float32x4_t vo1 = vmaxq_f32(vo1p0, vmin);
493
494 vo0 = vminq_f32(vo0, vmax);
495 vo1 = vminq_f32(vo1, vmax);
496
497 if XNN_LIKELY(w & (4 * sizeof(float))) {
498 vst1q_f32(o1, vo1); o1 += 4;
499 vst1q_f32(o0, vo0); o0 += 4;
500 } else {
501 float32x2_t vo0_lo = vget_low_f32(vo0);
502 float32x2_t vo1_lo = vget_low_f32(vo1);
503 if (w & (2 * sizeof(float))) {
504 vst1_f32(o1, vo1_lo); o1 += 2;
505 vst1_f32(o0, vo0_lo); o0 += 2;
506
507 vo0_lo = vget_high_f32(vo0);
508 vo1_lo = vget_high_f32(vo1);
509 }
510 if (w & (1 * sizeof(float))) {
511 vst1_lane_f32(o1, vo1_lo, 0); o1 += 1;
512 vst1_lane_f32(o0, vo0_lo, 0); o0 += 1;
513 }
514 }
515 }
516
517 i0 = (const float*) ((uintptr_t) i2 - input_decrement);
518 i1 = (const float*) ((uintptr_t) i3 - input_decrement);
519 i2 = (const float*) ((uintptr_t) i1 + input_width);
520 i3 = (const float*) ((uintptr_t) i2 + input_width);
521 i4 = (const float*) ((uintptr_t) i3 + input_width);
522 i5 = (const float*) ((uintptr_t) i4 + input_width);
523
524 o0 = o1;
525 o1 = (float*) ((uintptr_t) o0 + input_width);
526
527 output_height = doz(output_height, 2);
528 } while (output_height != 0);
529 }
530