1 // Auto-generated file. Do not edit!
2 // Template: src/f16-dwconv/up-neonfp16arith.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
16
xnn_f16_dwconv_minmax_ukernel_up8x25__neonfp16arith(size_t channels,size_t output_width,const void ** input,const void * weights,void * output_ptr,size_t input_stride,size_t output_increment,size_t input_offset,const void * zero,const struct xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f16_dwconv_minmax_ukernel_up8x25__neonfp16arith(
18 size_t channels,
19 size_t output_width,
20 const void** input,
21 const void* weights,
22 void* output_ptr,
23 size_t input_stride,
24 size_t output_increment,
25 size_t input_offset,
26 const void* zero,
27 const struct xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN
28 {
29 assert(channels != 0);
30 assert(output_width != 0);
31
32 __fp16* output = ( __fp16*) output_ptr;
33 const float16x8_t vmax = vld1q_dup_f16(¶ms->max);
34 const float16x8_t vmin = vld1q_dup_f16(¶ms->min);
35 do {
36 const __fp16* i0 = (const __fp16*) input[0];
37 assert(i0 != NULL);
38 if XNN_UNPREDICTABLE(i0 != (const __fp16*) zero) {
39 i0 = (const __fp16*) ((uintptr_t) i0 + input_offset);
40 }
41 const __fp16* i1 = (const __fp16*) input[1];
42 assert(i1 != NULL);
43 if XNN_UNPREDICTABLE(i1 != (const __fp16*) zero) {
44 i1 = (const __fp16*) ((uintptr_t) i1 + input_offset);
45 }
46 const __fp16* i2 = (const __fp16*) input[2];
47 assert(i2 != NULL);
48 if XNN_UNPREDICTABLE(i2 != (const __fp16*) zero) {
49 i2 = (const __fp16*) ((uintptr_t) i2 + input_offset);
50 }
51 const __fp16* i3 = (const __fp16*) input[3];
52 assert(i3 != NULL);
53 if XNN_UNPREDICTABLE(i3 != (const __fp16*) zero) {
54 i3 = (const __fp16*) ((uintptr_t) i3 + input_offset);
55 }
56 const __fp16* i4 = (const __fp16*) input[4];
57 assert(i4 != NULL);
58 if XNN_UNPREDICTABLE(i4 != (const __fp16*) zero) {
59 i4 = (const __fp16*) ((uintptr_t) i4 + input_offset);
60 }
61 const __fp16* i5 = (const __fp16*) input[5];
62 assert(i5 != NULL);
63 if XNN_UNPREDICTABLE(i5 != (const __fp16*) zero) {
64 i5 = (const __fp16*) ((uintptr_t) i5 + input_offset);
65 }
66 const __fp16* i6 = (const __fp16*) input[6];
67 assert(i6 != NULL);
68 if XNN_UNPREDICTABLE(i6 != (const __fp16*) zero) {
69 i6 = (const __fp16*) ((uintptr_t) i6 + input_offset);
70 }
71 const __fp16* i7 = (const __fp16*) input[7];
72 assert(i7 != NULL);
73 if XNN_UNPREDICTABLE(i7 != (const __fp16*) zero) {
74 i7 = (const __fp16*) ((uintptr_t) i7 + input_offset);
75 }
76 const __fp16* i8 = (const __fp16*) input[8];
77 assert(i8 != NULL);
78 if XNN_UNPREDICTABLE(i8 != (const __fp16*) zero) {
79 i8 = (const __fp16*) ((uintptr_t) i8 + input_offset);
80 }
81 const __fp16* i9 = (const __fp16*) input[9];
82 assert(i9 != NULL);
83 if XNN_UNPREDICTABLE(i9 != (const __fp16*) zero) {
84 i9 = (const __fp16*) ((uintptr_t) i9 + input_offset);
85 }
86 const __fp16* i10 = (const __fp16*) input[10];
87 assert(i10 != NULL);
88 if XNN_UNPREDICTABLE(i10 != (const __fp16*) zero) {
89 i10 = (const __fp16*) ((uintptr_t) i10 + input_offset);
90 }
91 const __fp16* i11 = (const __fp16*) input[11];
92 assert(i11 != NULL);
93 if XNN_UNPREDICTABLE(i11 != (const __fp16*) zero) {
94 i11 = (const __fp16*) ((uintptr_t) i11 + input_offset);
95 }
96 const __fp16* i12 = (const __fp16*) input[12];
97 assert(i12 != NULL);
98 if XNN_UNPREDICTABLE(i12 != (const __fp16*) zero) {
99 i12 = (const __fp16*) ((uintptr_t) i12 + input_offset);
100 }
101 const __fp16* i13 = (const __fp16*) input[13];
102 assert(i13 != NULL);
103 if XNN_UNPREDICTABLE(i13 != (const __fp16*) zero) {
104 i13 = (const __fp16*) ((uintptr_t) i13 + input_offset);
105 }
106 const __fp16* i14 = (const __fp16*) input[14];
107 assert(i14 != NULL);
108 if XNN_UNPREDICTABLE(i14 != (const __fp16*) zero) {
109 i14 = (const __fp16*) ((uintptr_t) i14 + input_offset);
110 }
111 const __fp16* i15 = (const __fp16*) input[15];
112 assert(i15 != NULL);
113 if XNN_UNPREDICTABLE(i15 != (const __fp16*) zero) {
114 i15 = (const __fp16*) ((uintptr_t) i15 + input_offset);
115 }
116 const __fp16* i16 = (const __fp16*) input[16];
117 assert(i16 != NULL);
118 if XNN_UNPREDICTABLE(i16 != (const __fp16*) zero) {
119 i16 = (const __fp16*) ((uintptr_t) i16 + input_offset);
120 }
121 const __fp16* i17 = (const __fp16*) input[17];
122 assert(i17 != NULL);
123 if XNN_UNPREDICTABLE(i17 != (const __fp16*) zero) {
124 i17 = (const __fp16*) ((uintptr_t) i17 + input_offset);
125 }
126 const __fp16* i18 = (const __fp16*) input[18];
127 assert(i18 != NULL);
128 if XNN_UNPREDICTABLE(i18 != (const __fp16*) zero) {
129 i18 = (const __fp16*) ((uintptr_t) i18 + input_offset);
130 }
131 const __fp16* i19 = (const __fp16*) input[19];
132 assert(i19 != NULL);
133 if XNN_UNPREDICTABLE(i19 != (const __fp16*) zero) {
134 i19 = (const __fp16*) ((uintptr_t) i19 + input_offset);
135 }
136 const __fp16* i20 = (const __fp16*) input[20];
137 assert(i20 != NULL);
138 if XNN_UNPREDICTABLE(i20 != (const __fp16*) zero) {
139 i20 = (const __fp16*) ((uintptr_t) i20 + input_offset);
140 }
141 const __fp16* i21 = (const __fp16*) input[21];
142 assert(i21 != NULL);
143 if XNN_UNPREDICTABLE(i21 != (const __fp16*) zero) {
144 i21 = (const __fp16*) ((uintptr_t) i21 + input_offset);
145 }
146 const __fp16* i22 = (const __fp16*) input[22];
147 assert(i22 != NULL);
148 if XNN_UNPREDICTABLE(i22 != (const __fp16*) zero) {
149 i22 = (const __fp16*) ((uintptr_t) i22 + input_offset);
150 }
151 const __fp16* i23 = (const __fp16*) input[23];
152 assert(i23 != NULL);
153 if XNN_UNPREDICTABLE(i23 != (const __fp16*) zero) {
154 i23 = (const __fp16*) ((uintptr_t) i23 + input_offset);
155 }
156 const __fp16* i24 = (const __fp16*) input[24];
157 assert(i24 != NULL);
158 if XNN_UNPREDICTABLE(i24 != (const __fp16*) zero) {
159 i24 = (const __fp16*) ((uintptr_t) i24 + input_offset);
160 }
161
162 input = (const void**) ((uintptr_t) input + input_stride);
163
164 size_t c = channels;
165 const __fp16* w = (const __fp16*) weights;
166 for (; c >= 8; c -= 8) {
167 float16x8_t vacc01234567p0 = vld1q_f16(w); w += 8;
168
169
170 const float16x8_t vi0x01234567 = vld1q_f16(i0); i0 += 8;
171 const float16x8_t vk0x01234567 = vld1q_f16(w); w += 8;
172 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi0x01234567, vk0x01234567);
173
174 const float16x8_t vi1x01234567 = vld1q_f16(i1); i1 += 8;
175 const float16x8_t vk1x01234567 = vld1q_f16(w); w += 8;
176 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi1x01234567, vk1x01234567);
177
178 const float16x8_t vi2x01234567 = vld1q_f16(i2); i2 += 8;
179 const float16x8_t vk2x01234567 = vld1q_f16(w); w += 8;
180 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi2x01234567, vk2x01234567);
181
182 const float16x8_t vi3x01234567 = vld1q_f16(i3); i3 += 8;
183 const float16x8_t vk3x01234567 = vld1q_f16(w); w += 8;
184 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi3x01234567, vk3x01234567);
185
186 const float16x8_t vi4x01234567 = vld1q_f16(i4); i4 += 8;
187 const float16x8_t vk4x01234567 = vld1q_f16(w); w += 8;
188 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi4x01234567, vk4x01234567);
189
190 const float16x8_t vi5x01234567 = vld1q_f16(i5); i5 += 8;
191 const float16x8_t vk5x01234567 = vld1q_f16(w); w += 8;
192 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi5x01234567, vk5x01234567);
193
194 const float16x8_t vi6x01234567 = vld1q_f16(i6); i6 += 8;
195 const float16x8_t vk6x01234567 = vld1q_f16(w); w += 8;
196 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi6x01234567, vk6x01234567);
197
198 const float16x8_t vi7x01234567 = vld1q_f16(i7); i7 += 8;
199 const float16x8_t vk7x01234567 = vld1q_f16(w); w += 8;
200 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi7x01234567, vk7x01234567);
201
202 const float16x8_t vi8x01234567 = vld1q_f16(i8); i8 += 8;
203 const float16x8_t vk8x01234567 = vld1q_f16(w); w += 8;
204 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi8x01234567, vk8x01234567);
205
206 const float16x8_t vi9x01234567 = vld1q_f16(i9); i9 += 8;
207 const float16x8_t vk9x01234567 = vld1q_f16(w); w += 8;
208 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi9x01234567, vk9x01234567);
209
210 const float16x8_t vi10x01234567 = vld1q_f16(i10); i10 += 8;
211 const float16x8_t vk10x01234567 = vld1q_f16(w); w += 8;
212 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi10x01234567, vk10x01234567);
213
214 const float16x8_t vi11x01234567 = vld1q_f16(i11); i11 += 8;
215 const float16x8_t vk11x01234567 = vld1q_f16(w); w += 8;
216 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi11x01234567, vk11x01234567);
217
218 const float16x8_t vi12x01234567 = vld1q_f16(i12); i12 += 8;
219 const float16x8_t vk12x01234567 = vld1q_f16(w); w += 8;
220 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi12x01234567, vk12x01234567);
221
222 const float16x8_t vi13x01234567 = vld1q_f16(i13); i13 += 8;
223 const float16x8_t vk13x01234567 = vld1q_f16(w); w += 8;
224 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi13x01234567, vk13x01234567);
225
226 const float16x8_t vi14x01234567 = vld1q_f16(i14); i14 += 8;
227 const float16x8_t vk14x01234567 = vld1q_f16(w); w += 8;
228 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi14x01234567, vk14x01234567);
229
230 const float16x8_t vi15x01234567 = vld1q_f16(i15); i15 += 8;
231 const float16x8_t vk15x01234567 = vld1q_f16(w); w += 8;
232 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi15x01234567, vk15x01234567);
233
234 const float16x8_t vi16x01234567 = vld1q_f16(i16); i16 += 8;
235 const float16x8_t vk16x01234567 = vld1q_f16(w); w += 8;
236 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi16x01234567, vk16x01234567);
237
238 const float16x8_t vi17x01234567 = vld1q_f16(i17); i17 += 8;
239 const float16x8_t vk17x01234567 = vld1q_f16(w); w += 8;
240 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi17x01234567, vk17x01234567);
241
242 const float16x8_t vi18x01234567 = vld1q_f16(i18); i18 += 8;
243 const float16x8_t vk18x01234567 = vld1q_f16(w); w += 8;
244 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi18x01234567, vk18x01234567);
245
246 const float16x8_t vi19x01234567 = vld1q_f16(i19); i19 += 8;
247 const float16x8_t vk19x01234567 = vld1q_f16(w); w += 8;
248 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi19x01234567, vk19x01234567);
249
250 const float16x8_t vi20x01234567 = vld1q_f16(i20); i20 += 8;
251 const float16x8_t vk20x01234567 = vld1q_f16(w); w += 8;
252 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi20x01234567, vk20x01234567);
253
254 const float16x8_t vi21x01234567 = vld1q_f16(i21); i21 += 8;
255 const float16x8_t vk21x01234567 = vld1q_f16(w); w += 8;
256 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi21x01234567, vk21x01234567);
257
258 const float16x8_t vi22x01234567 = vld1q_f16(i22); i22 += 8;
259 const float16x8_t vk22x01234567 = vld1q_f16(w); w += 8;
260 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi22x01234567, vk22x01234567);
261
262 const float16x8_t vi23x01234567 = vld1q_f16(i23); i23 += 8;
263 const float16x8_t vk23x01234567 = vld1q_f16(w); w += 8;
264 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi23x01234567, vk23x01234567);
265
266 const float16x8_t vi24x01234567 = vld1q_f16(i24); i24 += 8;
267 const float16x8_t vk24x01234567 = vld1q_f16(w); w += 8;
268 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi24x01234567, vk24x01234567);
269
270
271 float16x8_t vacc01234567 = vmaxq_f16(vacc01234567p0, vmin);
272 vacc01234567 = vminq_f16(vacc01234567, vmax);
273
274 vst1q_f16(output, vacc01234567); output += 8;
275 }
276 if XNN_UNLIKELY(c != 0) {
277 float16x8_t vacc01234567p0 = vld1q_f16(w); w += 8;
278
279
280 const float16x8_t vi0x01234567 = vld1q_f16(i0);
281 const float16x8_t vk0x01234567 = vld1q_f16(w); w += 8;
282 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi0x01234567, vk0x01234567);
283
284 const float16x8_t vi1x01234567 = vld1q_f16(i1);
285 const float16x8_t vk1x01234567 = vld1q_f16(w); w += 8;
286 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi1x01234567, vk1x01234567);
287
288 const float16x8_t vi2x01234567 = vld1q_f16(i2);
289 const float16x8_t vk2x01234567 = vld1q_f16(w); w += 8;
290 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi2x01234567, vk2x01234567);
291
292 const float16x8_t vi3x01234567 = vld1q_f16(i3);
293 const float16x8_t vk3x01234567 = vld1q_f16(w); w += 8;
294 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi3x01234567, vk3x01234567);
295
296 const float16x8_t vi4x01234567 = vld1q_f16(i4);
297 const float16x8_t vk4x01234567 = vld1q_f16(w); w += 8;
298 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi4x01234567, vk4x01234567);
299
300 const float16x8_t vi5x01234567 = vld1q_f16(i5);
301 const float16x8_t vk5x01234567 = vld1q_f16(w); w += 8;
302 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi5x01234567, vk5x01234567);
303
304 const float16x8_t vi6x01234567 = vld1q_f16(i6);
305 const float16x8_t vk6x01234567 = vld1q_f16(w); w += 8;
306 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi6x01234567, vk6x01234567);
307
308 const float16x8_t vi7x01234567 = vld1q_f16(i7);
309 const float16x8_t vk7x01234567 = vld1q_f16(w); w += 8;
310 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi7x01234567, vk7x01234567);
311
312 const float16x8_t vi8x01234567 = vld1q_f16(i8);
313 const float16x8_t vk8x01234567 = vld1q_f16(w); w += 8;
314 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi8x01234567, vk8x01234567);
315
316 const float16x8_t vi9x01234567 = vld1q_f16(i9);
317 const float16x8_t vk9x01234567 = vld1q_f16(w); w += 8;
318 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi9x01234567, vk9x01234567);
319
320 const float16x8_t vi10x01234567 = vld1q_f16(i10);
321 const float16x8_t vk10x01234567 = vld1q_f16(w); w += 8;
322 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi10x01234567, vk10x01234567);
323
324 const float16x8_t vi11x01234567 = vld1q_f16(i11);
325 const float16x8_t vk11x01234567 = vld1q_f16(w); w += 8;
326 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi11x01234567, vk11x01234567);
327
328 const float16x8_t vi12x01234567 = vld1q_f16(i12);
329 const float16x8_t vk12x01234567 = vld1q_f16(w); w += 8;
330 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi12x01234567, vk12x01234567);
331
332 const float16x8_t vi13x01234567 = vld1q_f16(i13);
333 const float16x8_t vk13x01234567 = vld1q_f16(w); w += 8;
334 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi13x01234567, vk13x01234567);
335
336 const float16x8_t vi14x01234567 = vld1q_f16(i14);
337 const float16x8_t vk14x01234567 = vld1q_f16(w); w += 8;
338 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi14x01234567, vk14x01234567);
339
340 const float16x8_t vi15x01234567 = vld1q_f16(i15);
341 const float16x8_t vk15x01234567 = vld1q_f16(w); w += 8;
342 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi15x01234567, vk15x01234567);
343
344 const float16x8_t vi16x01234567 = vld1q_f16(i16);
345 const float16x8_t vk16x01234567 = vld1q_f16(w); w += 8;
346 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi16x01234567, vk16x01234567);
347
348 const float16x8_t vi17x01234567 = vld1q_f16(i17);
349 const float16x8_t vk17x01234567 = vld1q_f16(w); w += 8;
350 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi17x01234567, vk17x01234567);
351
352 const float16x8_t vi18x01234567 = vld1q_f16(i18);
353 const float16x8_t vk18x01234567 = vld1q_f16(w); w += 8;
354 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi18x01234567, vk18x01234567);
355
356 const float16x8_t vi19x01234567 = vld1q_f16(i19);
357 const float16x8_t vk19x01234567 = vld1q_f16(w); w += 8;
358 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi19x01234567, vk19x01234567);
359
360 const float16x8_t vi20x01234567 = vld1q_f16(i20);
361 const float16x8_t vk20x01234567 = vld1q_f16(w); w += 8;
362 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi20x01234567, vk20x01234567);
363
364 const float16x8_t vi21x01234567 = vld1q_f16(i21);
365 const float16x8_t vk21x01234567 = vld1q_f16(w); w += 8;
366 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi21x01234567, vk21x01234567);
367
368 const float16x8_t vi22x01234567 = vld1q_f16(i22);
369 const float16x8_t vk22x01234567 = vld1q_f16(w); w += 8;
370 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi22x01234567, vk22x01234567);
371
372 const float16x8_t vi23x01234567 = vld1q_f16(i23);
373 const float16x8_t vk23x01234567 = vld1q_f16(w); w += 8;
374 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi23x01234567, vk23x01234567);
375
376 const float16x8_t vi24x01234567 = vld1q_f16(i24);
377 const float16x8_t vk24x01234567 = vld1q_f16(w); w += 8;
378 vacc01234567p0 = vfmaq_f16(vacc01234567p0, vi24x01234567, vk24x01234567);
379
380
381 float16x8_t vacc01234567 = vmaxq_f16(vacc01234567p0, vmin);
382 vacc01234567 = vminq_f16(vacc01234567, vmax);
383
384 float16x4_t vacc0123 = vget_low_f16(vacc01234567);
385 if (c & 4) {
386 vst1_f16(output, vacc0123); output += 4;
387 vacc0123 = vget_high_f16(vacc01234567);
388 }
389 if (c & 2) {
390 vst1_lane_u32(__builtin_assume_aligned(output, 1), vreinterpret_u32_f16(vacc0123), 0); output += 2;
391 vacc0123 = vext_f16(vacc0123, vacc0123, 2);
392 }
393 if (c & 1) {
394 vst1_lane_f16(output, vacc0123, 0); output += 1;
395 }
396 }
397
398 output = (__fp16*) ((uintptr_t) output + output_increment);
399 } while (--output_width != 0);
400 }
401