• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-dwconv/up-neon.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2019 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_f32_dwconv_minmax_ukernel_up4x25__neon(size_t channels,size_t output_width,const float ** input,const float * weights,float * output,size_t input_stride,size_t output_increment,size_t input_offset,const float * zero,const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_f32_dwconv_minmax_ukernel_up4x25__neon(
18     size_t channels,
19     size_t output_width,
20     const float** input,
21     const float* weights,
22     float* output,
23     size_t input_stride,
24     size_t output_increment,
25     size_t input_offset,
26     const float* zero,
27     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_DISABLE_TSAN
28 {
29   assert(channels != 0);
30   assert(output_width != 0);
31 
32   const float32x4_t vmax = vld1q_dup_f32(&params->scalar.max);
33   const float32x4_t vmin = vld1q_dup_f32(&params->scalar.min);
34   do {
35     const float* i0 = input[0];
36     assert(i0 != NULL);
37     if XNN_UNPREDICTABLE(i0 != zero) {
38       i0 = (const float*) ((uintptr_t) i0 + input_offset);
39     }
40     const float* i1 = input[1];
41     assert(i1 != NULL);
42     if XNN_UNPREDICTABLE(i1 != zero) {
43       i1 = (const float*) ((uintptr_t) i1 + input_offset);
44     }
45     const float* i2 = input[2];
46     assert(i2 != NULL);
47     if XNN_UNPREDICTABLE(i2 != zero) {
48       i2 = (const float*) ((uintptr_t) i2 + input_offset);
49     }
50     const float* i3 = input[3];
51     assert(i3 != NULL);
52     if XNN_UNPREDICTABLE(i3 != zero) {
53       i3 = (const float*) ((uintptr_t) i3 + input_offset);
54     }
55     const float* i4 = input[4];
56     assert(i4 != NULL);
57     if XNN_UNPREDICTABLE(i4 != zero) {
58       i4 = (const float*) ((uintptr_t) i4 + input_offset);
59     }
60     const float* i5 = input[5];
61     assert(i5 != NULL);
62     if XNN_UNPREDICTABLE(i5 != zero) {
63       i5 = (const float*) ((uintptr_t) i5 + input_offset);
64     }
65     const float* i6 = input[6];
66     assert(i6 != NULL);
67     if XNN_UNPREDICTABLE(i6 != zero) {
68       i6 = (const float*) ((uintptr_t) i6 + input_offset);
69     }
70     const float* i7 = input[7];
71     assert(i7 != NULL);
72     if XNN_UNPREDICTABLE(i7 != zero) {
73       i7 = (const float*) ((uintptr_t) i7 + input_offset);
74     }
75     const float* i8 = input[8];
76     assert(i8 != NULL);
77     if XNN_UNPREDICTABLE(i8 != zero) {
78       i8 = (const float*) ((uintptr_t) i8 + input_offset);
79     }
80     const float* i9 = input[9];
81     assert(i9 != NULL);
82     if XNN_UNPREDICTABLE(i9 != zero) {
83       i9 = (const float*) ((uintptr_t) i9 + input_offset);
84     }
85     const float* i10 = input[10];
86     assert(i10 != NULL);
87     if XNN_UNPREDICTABLE(i10 != zero) {
88       i10 = (const float*) ((uintptr_t) i10 + input_offset);
89     }
90     const float* i11 = input[11];
91     assert(i11 != NULL);
92     if XNN_UNPREDICTABLE(i11 != zero) {
93       i11 = (const float*) ((uintptr_t) i11 + input_offset);
94     }
95     const float* i12 = input[12];
96     assert(i12 != NULL);
97     if XNN_UNPREDICTABLE(i12 != zero) {
98       i12 = (const float*) ((uintptr_t) i12 + input_offset);
99     }
100     const float* i13 = input[13];
101     assert(i13 != NULL);
102     if XNN_UNPREDICTABLE(i13 != zero) {
103       i13 = (const float*) ((uintptr_t) i13 + input_offset);
104     }
105     const float* i14 = input[14];
106     assert(i14 != NULL);
107     if XNN_UNPREDICTABLE(i14 != zero) {
108       i14 = (const float*) ((uintptr_t) i14 + input_offset);
109     }
110     const float* i15 = input[15];
111     assert(i15 != NULL);
112     if XNN_UNPREDICTABLE(i15 != zero) {
113       i15 = (const float*) ((uintptr_t) i15 + input_offset);
114     }
115     const float* i16 = input[16];
116     assert(i16 != NULL);
117     if XNN_UNPREDICTABLE(i16 != zero) {
118       i16 = (const float*) ((uintptr_t) i16 + input_offset);
119     }
120     const float* i17 = input[17];
121     assert(i17 != NULL);
122     if XNN_UNPREDICTABLE(i17 != zero) {
123       i17 = (const float*) ((uintptr_t) i17 + input_offset);
124     }
125     const float* i18 = input[18];
126     assert(i18 != NULL);
127     if XNN_UNPREDICTABLE(i18 != zero) {
128       i18 = (const float*) ((uintptr_t) i18 + input_offset);
129     }
130     const float* i19 = input[19];
131     assert(i19 != NULL);
132     if XNN_UNPREDICTABLE(i19 != zero) {
133       i19 = (const float*) ((uintptr_t) i19 + input_offset);
134     }
135     const float* i20 = input[20];
136     assert(i20 != NULL);
137     if XNN_UNPREDICTABLE(i20 != zero) {
138       i20 = (const float*) ((uintptr_t) i20 + input_offset);
139     }
140     const float* i21 = input[21];
141     assert(i21 != NULL);
142     if XNN_UNPREDICTABLE(i21 != zero) {
143       i21 = (const float*) ((uintptr_t) i21 + input_offset);
144     }
145     const float* i22 = input[22];
146     assert(i22 != NULL);
147     if XNN_UNPREDICTABLE(i22 != zero) {
148       i22 = (const float*) ((uintptr_t) i22 + input_offset);
149     }
150     const float* i23 = input[23];
151     assert(i23 != NULL);
152     if XNN_UNPREDICTABLE(i23 != zero) {
153       i23 = (const float*) ((uintptr_t) i23 + input_offset);
154     }
155     const float* i24 = input[24];
156     assert(i24 != NULL);
157     if XNN_UNPREDICTABLE(i24 != zero) {
158       i24 = (const float*) ((uintptr_t) i24 + input_offset);
159     }
160 
161     input = (const float**) ((uintptr_t) input + input_stride);
162 
163     size_t c = channels;
164     const float* w = weights;
165     for (; c >= 4; c -= 4) {
166       float32x4_t vacc0123p0 = vld1q_f32(w); w += 4;
167 
168 
169       const float32x4_t vi0x0123 = vld1q_f32(i0); i0 += 4;
170       const float32x4_t vk0x0123 = vld1q_f32(w); w += 4;
171       vacc0123p0 = vmlaq_f32(vacc0123p0, vi0x0123, vk0x0123);
172 
173       const float32x4_t vi1x0123 = vld1q_f32(i1); i1 += 4;
174       const float32x4_t vk1x0123 = vld1q_f32(w); w += 4;
175       vacc0123p0 = vmlaq_f32(vacc0123p0, vi1x0123, vk1x0123);
176 
177       const float32x4_t vi2x0123 = vld1q_f32(i2); i2 += 4;
178       const float32x4_t vk2x0123 = vld1q_f32(w); w += 4;
179       vacc0123p0 = vmlaq_f32(vacc0123p0, vi2x0123, vk2x0123);
180 
181       const float32x4_t vi3x0123 = vld1q_f32(i3); i3 += 4;
182       const float32x4_t vk3x0123 = vld1q_f32(w); w += 4;
183       vacc0123p0 = vmlaq_f32(vacc0123p0, vi3x0123, vk3x0123);
184 
185       const float32x4_t vi4x0123 = vld1q_f32(i4); i4 += 4;
186       const float32x4_t vk4x0123 = vld1q_f32(w); w += 4;
187       vacc0123p0 = vmlaq_f32(vacc0123p0, vi4x0123, vk4x0123);
188 
189       const float32x4_t vi5x0123 = vld1q_f32(i5); i5 += 4;
190       const float32x4_t vk5x0123 = vld1q_f32(w); w += 4;
191       vacc0123p0 = vmlaq_f32(vacc0123p0, vi5x0123, vk5x0123);
192 
193       const float32x4_t vi6x0123 = vld1q_f32(i6); i6 += 4;
194       const float32x4_t vk6x0123 = vld1q_f32(w); w += 4;
195       vacc0123p0 = vmlaq_f32(vacc0123p0, vi6x0123, vk6x0123);
196 
197       const float32x4_t vi7x0123 = vld1q_f32(i7); i7 += 4;
198       const float32x4_t vk7x0123 = vld1q_f32(w); w += 4;
199       vacc0123p0 = vmlaq_f32(vacc0123p0, vi7x0123, vk7x0123);
200 
201       const float32x4_t vi8x0123 = vld1q_f32(i8); i8 += 4;
202       const float32x4_t vk8x0123 = vld1q_f32(w); w += 4;
203       vacc0123p0 = vmlaq_f32(vacc0123p0, vi8x0123, vk8x0123);
204 
205       const float32x4_t vi9x0123 = vld1q_f32(i9); i9 += 4;
206       const float32x4_t vk9x0123 = vld1q_f32(w); w += 4;
207       vacc0123p0 = vmlaq_f32(vacc0123p0, vi9x0123, vk9x0123);
208 
209       const float32x4_t vi10x0123 = vld1q_f32(i10); i10 += 4;
210       const float32x4_t vk10x0123 = vld1q_f32(w); w += 4;
211       vacc0123p0 = vmlaq_f32(vacc0123p0, vi10x0123, vk10x0123);
212 
213       const float32x4_t vi11x0123 = vld1q_f32(i11); i11 += 4;
214       const float32x4_t vk11x0123 = vld1q_f32(w); w += 4;
215       vacc0123p0 = vmlaq_f32(vacc0123p0, vi11x0123, vk11x0123);
216 
217       const float32x4_t vi12x0123 = vld1q_f32(i12); i12 += 4;
218       const float32x4_t vk12x0123 = vld1q_f32(w); w += 4;
219       vacc0123p0 = vmlaq_f32(vacc0123p0, vi12x0123, vk12x0123);
220 
221       const float32x4_t vi13x0123 = vld1q_f32(i13); i13 += 4;
222       const float32x4_t vk13x0123 = vld1q_f32(w); w += 4;
223       vacc0123p0 = vmlaq_f32(vacc0123p0, vi13x0123, vk13x0123);
224 
225       const float32x4_t vi14x0123 = vld1q_f32(i14); i14 += 4;
226       const float32x4_t vk14x0123 = vld1q_f32(w); w += 4;
227       vacc0123p0 = vmlaq_f32(vacc0123p0, vi14x0123, vk14x0123);
228 
229       const float32x4_t vi15x0123 = vld1q_f32(i15); i15 += 4;
230       const float32x4_t vk15x0123 = vld1q_f32(w); w += 4;
231       vacc0123p0 = vmlaq_f32(vacc0123p0, vi15x0123, vk15x0123);
232 
233       const float32x4_t vi16x0123 = vld1q_f32(i16); i16 += 4;
234       const float32x4_t vk16x0123 = vld1q_f32(w); w += 4;
235       vacc0123p0 = vmlaq_f32(vacc0123p0, vi16x0123, vk16x0123);
236 
237       const float32x4_t vi17x0123 = vld1q_f32(i17); i17 += 4;
238       const float32x4_t vk17x0123 = vld1q_f32(w); w += 4;
239       vacc0123p0 = vmlaq_f32(vacc0123p0, vi17x0123, vk17x0123);
240 
241       const float32x4_t vi18x0123 = vld1q_f32(i18); i18 += 4;
242       const float32x4_t vk18x0123 = vld1q_f32(w); w += 4;
243       vacc0123p0 = vmlaq_f32(vacc0123p0, vi18x0123, vk18x0123);
244 
245       const float32x4_t vi19x0123 = vld1q_f32(i19); i19 += 4;
246       const float32x4_t vk19x0123 = vld1q_f32(w); w += 4;
247       vacc0123p0 = vmlaq_f32(vacc0123p0, vi19x0123, vk19x0123);
248 
249       const float32x4_t vi20x0123 = vld1q_f32(i20); i20 += 4;
250       const float32x4_t vk20x0123 = vld1q_f32(w); w += 4;
251       vacc0123p0 = vmlaq_f32(vacc0123p0, vi20x0123, vk20x0123);
252 
253       const float32x4_t vi21x0123 = vld1q_f32(i21); i21 += 4;
254       const float32x4_t vk21x0123 = vld1q_f32(w); w += 4;
255       vacc0123p0 = vmlaq_f32(vacc0123p0, vi21x0123, vk21x0123);
256 
257       const float32x4_t vi22x0123 = vld1q_f32(i22); i22 += 4;
258       const float32x4_t vk22x0123 = vld1q_f32(w); w += 4;
259       vacc0123p0 = vmlaq_f32(vacc0123p0, vi22x0123, vk22x0123);
260 
261       const float32x4_t vi23x0123 = vld1q_f32(i23); i23 += 4;
262       const float32x4_t vk23x0123 = vld1q_f32(w); w += 4;
263       vacc0123p0 = vmlaq_f32(vacc0123p0, vi23x0123, vk23x0123);
264 
265       const float32x4_t vi24x0123 = vld1q_f32(i24); i24 += 4;
266       const float32x4_t vk24x0123 = vld1q_f32(w); w += 4;
267       vacc0123p0 = vmlaq_f32(vacc0123p0, vi24x0123, vk24x0123);
268 
269 
270       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
271       vacc0123 = vminq_f32(vacc0123, vmax);
272 
273       vst1q_f32(output, vacc0123); output += 4;
274     }
275     if XNN_UNLIKELY(c != 0) {
276       float32x4_t vacc0123p0 = vld1q_f32(w); w += 4;
277 
278 
279       const float32x4_t vi0x0123 = vld1q_f32(i0);
280       const float32x4_t vk0x0123 = vld1q_f32(w); w += 4;
281       vacc0123p0 = vmlaq_f32(vacc0123p0, vi0x0123, vk0x0123);
282 
283       const float32x4_t vi1x0123 = vld1q_f32(i1);
284       const float32x4_t vk1x0123 = vld1q_f32(w); w += 4;
285       vacc0123p0 = vmlaq_f32(vacc0123p0, vi1x0123, vk1x0123);
286 
287       const float32x4_t vi2x0123 = vld1q_f32(i2);
288       const float32x4_t vk2x0123 = vld1q_f32(w); w += 4;
289       vacc0123p0 = vmlaq_f32(vacc0123p0, vi2x0123, vk2x0123);
290 
291       const float32x4_t vi3x0123 = vld1q_f32(i3);
292       const float32x4_t vk3x0123 = vld1q_f32(w); w += 4;
293       vacc0123p0 = vmlaq_f32(vacc0123p0, vi3x0123, vk3x0123);
294 
295       const float32x4_t vi4x0123 = vld1q_f32(i4);
296       const float32x4_t vk4x0123 = vld1q_f32(w); w += 4;
297       vacc0123p0 = vmlaq_f32(vacc0123p0, vi4x0123, vk4x0123);
298 
299       const float32x4_t vi5x0123 = vld1q_f32(i5);
300       const float32x4_t vk5x0123 = vld1q_f32(w); w += 4;
301       vacc0123p0 = vmlaq_f32(vacc0123p0, vi5x0123, vk5x0123);
302 
303       const float32x4_t vi6x0123 = vld1q_f32(i6);
304       const float32x4_t vk6x0123 = vld1q_f32(w); w += 4;
305       vacc0123p0 = vmlaq_f32(vacc0123p0, vi6x0123, vk6x0123);
306 
307       const float32x4_t vi7x0123 = vld1q_f32(i7);
308       const float32x4_t vk7x0123 = vld1q_f32(w); w += 4;
309       vacc0123p0 = vmlaq_f32(vacc0123p0, vi7x0123, vk7x0123);
310 
311       const float32x4_t vi8x0123 = vld1q_f32(i8);
312       const float32x4_t vk8x0123 = vld1q_f32(w); w += 4;
313       vacc0123p0 = vmlaq_f32(vacc0123p0, vi8x0123, vk8x0123);
314 
315       const float32x4_t vi9x0123 = vld1q_f32(i9);
316       const float32x4_t vk9x0123 = vld1q_f32(w); w += 4;
317       vacc0123p0 = vmlaq_f32(vacc0123p0, vi9x0123, vk9x0123);
318 
319       const float32x4_t vi10x0123 = vld1q_f32(i10);
320       const float32x4_t vk10x0123 = vld1q_f32(w); w += 4;
321       vacc0123p0 = vmlaq_f32(vacc0123p0, vi10x0123, vk10x0123);
322 
323       const float32x4_t vi11x0123 = vld1q_f32(i11);
324       const float32x4_t vk11x0123 = vld1q_f32(w); w += 4;
325       vacc0123p0 = vmlaq_f32(vacc0123p0, vi11x0123, vk11x0123);
326 
327       const float32x4_t vi12x0123 = vld1q_f32(i12);
328       const float32x4_t vk12x0123 = vld1q_f32(w); w += 4;
329       vacc0123p0 = vmlaq_f32(vacc0123p0, vi12x0123, vk12x0123);
330 
331       const float32x4_t vi13x0123 = vld1q_f32(i13);
332       const float32x4_t vk13x0123 = vld1q_f32(w); w += 4;
333       vacc0123p0 = vmlaq_f32(vacc0123p0, vi13x0123, vk13x0123);
334 
335       const float32x4_t vi14x0123 = vld1q_f32(i14);
336       const float32x4_t vk14x0123 = vld1q_f32(w); w += 4;
337       vacc0123p0 = vmlaq_f32(vacc0123p0, vi14x0123, vk14x0123);
338 
339       const float32x4_t vi15x0123 = vld1q_f32(i15);
340       const float32x4_t vk15x0123 = vld1q_f32(w); w += 4;
341       vacc0123p0 = vmlaq_f32(vacc0123p0, vi15x0123, vk15x0123);
342 
343       const float32x4_t vi16x0123 = vld1q_f32(i16);
344       const float32x4_t vk16x0123 = vld1q_f32(w); w += 4;
345       vacc0123p0 = vmlaq_f32(vacc0123p0, vi16x0123, vk16x0123);
346 
347       const float32x4_t vi17x0123 = vld1q_f32(i17);
348       const float32x4_t vk17x0123 = vld1q_f32(w); w += 4;
349       vacc0123p0 = vmlaq_f32(vacc0123p0, vi17x0123, vk17x0123);
350 
351       const float32x4_t vi18x0123 = vld1q_f32(i18);
352       const float32x4_t vk18x0123 = vld1q_f32(w); w += 4;
353       vacc0123p0 = vmlaq_f32(vacc0123p0, vi18x0123, vk18x0123);
354 
355       const float32x4_t vi19x0123 = vld1q_f32(i19);
356       const float32x4_t vk19x0123 = vld1q_f32(w); w += 4;
357       vacc0123p0 = vmlaq_f32(vacc0123p0, vi19x0123, vk19x0123);
358 
359       const float32x4_t vi20x0123 = vld1q_f32(i20);
360       const float32x4_t vk20x0123 = vld1q_f32(w); w += 4;
361       vacc0123p0 = vmlaq_f32(vacc0123p0, vi20x0123, vk20x0123);
362 
363       const float32x4_t vi21x0123 = vld1q_f32(i21);
364       const float32x4_t vk21x0123 = vld1q_f32(w); w += 4;
365       vacc0123p0 = vmlaq_f32(vacc0123p0, vi21x0123, vk21x0123);
366 
367       const float32x4_t vi22x0123 = vld1q_f32(i22);
368       const float32x4_t vk22x0123 = vld1q_f32(w); w += 4;
369       vacc0123p0 = vmlaq_f32(vacc0123p0, vi22x0123, vk22x0123);
370 
371       const float32x4_t vi23x0123 = vld1q_f32(i23);
372       const float32x4_t vk23x0123 = vld1q_f32(w); w += 4;
373       vacc0123p0 = vmlaq_f32(vacc0123p0, vi23x0123, vk23x0123);
374 
375       const float32x4_t vi24x0123 = vld1q_f32(i24);
376       const float32x4_t vk24x0123 = vld1q_f32(w); w += 4;
377       vacc0123p0 = vmlaq_f32(vacc0123p0, vi24x0123, vk24x0123);
378 
379 
380       float32x4_t vacc0123 = vmaxq_f32(vacc0123p0, vmin);
381       vacc0123 = vminq_f32(vacc0123, vmax);
382 
383       float32x2_t vacc01 = vget_low_f32(vacc0123);
384       if (c & 2) {
385         vst1_f32(output, vacc01); output += 2;
386         vacc01 = vget_high_f32(vacc0123);
387       }
388       if (c & 1) {
389         vst1_lane_f32(output, vacc01, 0); output += 1;
390       }
391     }
392 
393     output = (float*) ((uintptr_t) output + output_increment);
394   } while (--output_width != 0);
395 }
396