• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-dwconv/up-sse.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 <xmmintrin.h>
13 
14 #include <xnnpack/dwconv.h>
15 
16 
xnn_f32_dwconv_minmax_ukernel_up4x25__sse(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__sse(
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_OOB_READS
28 {
29   assert(channels != 0);
30   assert(output_width != 0);
31 
32   const __m128 vmax = _mm_load_ps(params->sse.max);
33   const __m128 vmin = _mm_load_ps(params->sse.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     input = (const float**) ((uintptr_t) input + input_stride);
161 
162     size_t c = channels;
163     const float* w = weights;
164     for (; c >= 4; c -= 4) {
165       __m128 vacc0123p0 = _mm_load_ps(w);
166 
167 
168       const __m128 vi0x0123 = _mm_loadu_ps(i0);
169       i0 += 4;
170 
171       const __m128 vk0x0123 = _mm_load_ps(w + 4);
172       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi0x0123, vk0x0123));
173 
174       const __m128 vi1x0123 = _mm_loadu_ps(i1);
175       i1 += 4;
176 
177       const __m128 vk1x0123 = _mm_load_ps(w + 8);
178       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi1x0123, vk1x0123));
179 
180       const __m128 vi2x0123 = _mm_loadu_ps(i2);
181       i2 += 4;
182 
183       const __m128 vk2x0123 = _mm_load_ps(w + 12);
184       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi2x0123, vk2x0123));
185 
186       const __m128 vi3x0123 = _mm_loadu_ps(i3);
187       i3 += 4;
188 
189       const __m128 vk3x0123 = _mm_load_ps(w + 16);
190       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi3x0123, vk3x0123));
191 
192       const __m128 vi4x0123 = _mm_loadu_ps(i4);
193       i4 += 4;
194 
195       const __m128 vk4x0123 = _mm_load_ps(w + 20);
196       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi4x0123, vk4x0123));
197 
198       const __m128 vi5x0123 = _mm_loadu_ps(i5);
199       i5 += 4;
200 
201       const __m128 vk5x0123 = _mm_load_ps(w + 24);
202       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi5x0123, vk5x0123));
203 
204       const __m128 vi6x0123 = _mm_loadu_ps(i6);
205       i6 += 4;
206 
207       const __m128 vk6x0123 = _mm_load_ps(w + 28);
208       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi6x0123, vk6x0123));
209 
210       const __m128 vi7x0123 = _mm_loadu_ps(i7);
211       i7 += 4;
212 
213       const __m128 vk7x0123 = _mm_load_ps(w + 32);
214       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi7x0123, vk7x0123));
215 
216       const __m128 vi8x0123 = _mm_loadu_ps(i8);
217       i8 += 4;
218 
219       const __m128 vk8x0123 = _mm_load_ps(w + 36);
220       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi8x0123, vk8x0123));
221 
222       const __m128 vi9x0123 = _mm_loadu_ps(i9);
223       i9 += 4;
224 
225       const __m128 vk9x0123 = _mm_load_ps(w + 40);
226       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi9x0123, vk9x0123));
227 
228       const __m128 vi10x0123 = _mm_loadu_ps(i10);
229       i10 += 4;
230 
231       const __m128 vk10x0123 = _mm_load_ps(w + 44);
232       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi10x0123, vk10x0123));
233 
234       const __m128 vi11x0123 = _mm_loadu_ps(i11);
235       i11 += 4;
236 
237       const __m128 vk11x0123 = _mm_load_ps(w + 48);
238       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi11x0123, vk11x0123));
239 
240       const __m128 vi12x0123 = _mm_loadu_ps(i12);
241       i12 += 4;
242 
243       const __m128 vk12x0123 = _mm_load_ps(w + 52);
244       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi12x0123, vk12x0123));
245 
246       const __m128 vi13x0123 = _mm_loadu_ps(i13);
247       i13 += 4;
248 
249       const __m128 vk13x0123 = _mm_load_ps(w + 56);
250       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi13x0123, vk13x0123));
251 
252       const __m128 vi14x0123 = _mm_loadu_ps(i14);
253       i14 += 4;
254 
255       const __m128 vk14x0123 = _mm_load_ps(w + 60);
256       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi14x0123, vk14x0123));
257 
258       const __m128 vi15x0123 = _mm_loadu_ps(i15);
259       i15 += 4;
260 
261       const __m128 vk15x0123 = _mm_load_ps(w + 64);
262       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi15x0123, vk15x0123));
263 
264       const __m128 vi16x0123 = _mm_loadu_ps(i16);
265       i16 += 4;
266 
267       const __m128 vk16x0123 = _mm_load_ps(w + 68);
268       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi16x0123, vk16x0123));
269 
270       const __m128 vi17x0123 = _mm_loadu_ps(i17);
271       i17 += 4;
272 
273       const __m128 vk17x0123 = _mm_load_ps(w + 72);
274       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi17x0123, vk17x0123));
275 
276       const __m128 vi18x0123 = _mm_loadu_ps(i18);
277       i18 += 4;
278 
279       const __m128 vk18x0123 = _mm_load_ps(w + 76);
280       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi18x0123, vk18x0123));
281 
282       const __m128 vi19x0123 = _mm_loadu_ps(i19);
283       i19 += 4;
284 
285       const __m128 vk19x0123 = _mm_load_ps(w + 80);
286       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi19x0123, vk19x0123));
287 
288       const __m128 vi20x0123 = _mm_loadu_ps(i20);
289       i20 += 4;
290 
291       const __m128 vk20x0123 = _mm_load_ps(w + 84);
292       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi20x0123, vk20x0123));
293 
294       const __m128 vi21x0123 = _mm_loadu_ps(i21);
295       i21 += 4;
296 
297       const __m128 vk21x0123 = _mm_load_ps(w + 88);
298       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi21x0123, vk21x0123));
299 
300       const __m128 vi22x0123 = _mm_loadu_ps(i22);
301       i22 += 4;
302 
303       const __m128 vk22x0123 = _mm_load_ps(w + 92);
304       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi22x0123, vk22x0123));
305 
306       const __m128 vi23x0123 = _mm_loadu_ps(i23);
307       i23 += 4;
308 
309       const __m128 vk23x0123 = _mm_load_ps(w + 96);
310       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi23x0123, vk23x0123));
311 
312       const __m128 vi24x0123 = _mm_loadu_ps(i24);
313       i24 += 4;
314 
315       const __m128 vk24x0123 = _mm_load_ps(w + 100);
316       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi24x0123, vk24x0123));
317 
318       w += 104;
319 
320 
321       __m128 vacc0123 = _mm_max_ps(vacc0123p0, vmin);
322       vacc0123 = _mm_min_ps(vacc0123, vmax);
323 
324       _mm_storeu_ps(output, vacc0123);
325       output += 4;
326     }
327     if XNN_UNLIKELY(c != 0) {
328       __m128 vacc0123p0 = _mm_load_ps(w);
329 
330       const __m128 vi0x0123 = _mm_loadu_ps(i0);
331       const __m128 vk0x0123 = _mm_load_ps(w + 4);
332       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi0x0123, vk0x0123));
333 
334       const __m128 vi1x0123 = _mm_loadu_ps(i1);
335       const __m128 vk1x0123 = _mm_load_ps(w + 8);
336       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi1x0123, vk1x0123));
337 
338       const __m128 vi2x0123 = _mm_loadu_ps(i2);
339       const __m128 vk2x0123 = _mm_load_ps(w + 12);
340       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi2x0123, vk2x0123));
341 
342       const __m128 vi3x0123 = _mm_loadu_ps(i3);
343       const __m128 vk3x0123 = _mm_load_ps(w + 16);
344       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi3x0123, vk3x0123));
345 
346       const __m128 vi4x0123 = _mm_loadu_ps(i4);
347       const __m128 vk4x0123 = _mm_load_ps(w + 20);
348       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi4x0123, vk4x0123));
349 
350       const __m128 vi5x0123 = _mm_loadu_ps(i5);
351       const __m128 vk5x0123 = _mm_load_ps(w + 24);
352       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi5x0123, vk5x0123));
353 
354       const __m128 vi6x0123 = _mm_loadu_ps(i6);
355       const __m128 vk6x0123 = _mm_load_ps(w + 28);
356       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi6x0123, vk6x0123));
357 
358       const __m128 vi7x0123 = _mm_loadu_ps(i7);
359       const __m128 vk7x0123 = _mm_load_ps(w + 32);
360       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi7x0123, vk7x0123));
361 
362       const __m128 vi8x0123 = _mm_loadu_ps(i8);
363       const __m128 vk8x0123 = _mm_load_ps(w + 36);
364       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi8x0123, vk8x0123));
365 
366       const __m128 vi9x0123 = _mm_loadu_ps(i9);
367       const __m128 vk9x0123 = _mm_load_ps(w + 40);
368       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi9x0123, vk9x0123));
369 
370       const __m128 vi10x0123 = _mm_loadu_ps(i10);
371       const __m128 vk10x0123 = _mm_load_ps(w + 44);
372       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi10x0123, vk10x0123));
373 
374       const __m128 vi11x0123 = _mm_loadu_ps(i11);
375       const __m128 vk11x0123 = _mm_load_ps(w + 48);
376       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi11x0123, vk11x0123));
377 
378       const __m128 vi12x0123 = _mm_loadu_ps(i12);
379       const __m128 vk12x0123 = _mm_load_ps(w + 52);
380       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi12x0123, vk12x0123));
381 
382       const __m128 vi13x0123 = _mm_loadu_ps(i13);
383       const __m128 vk13x0123 = _mm_load_ps(w + 56);
384       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi13x0123, vk13x0123));
385 
386       const __m128 vi14x0123 = _mm_loadu_ps(i14);
387       const __m128 vk14x0123 = _mm_load_ps(w + 60);
388       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi14x0123, vk14x0123));
389 
390       const __m128 vi15x0123 = _mm_loadu_ps(i15);
391       const __m128 vk15x0123 = _mm_load_ps(w + 64);
392       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi15x0123, vk15x0123));
393 
394       const __m128 vi16x0123 = _mm_loadu_ps(i16);
395       const __m128 vk16x0123 = _mm_load_ps(w + 68);
396       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi16x0123, vk16x0123));
397 
398       const __m128 vi17x0123 = _mm_loadu_ps(i17);
399       const __m128 vk17x0123 = _mm_load_ps(w + 72);
400       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi17x0123, vk17x0123));
401 
402       const __m128 vi18x0123 = _mm_loadu_ps(i18);
403       const __m128 vk18x0123 = _mm_load_ps(w + 76);
404       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi18x0123, vk18x0123));
405 
406       const __m128 vi19x0123 = _mm_loadu_ps(i19);
407       const __m128 vk19x0123 = _mm_load_ps(w + 80);
408       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi19x0123, vk19x0123));
409 
410       const __m128 vi20x0123 = _mm_loadu_ps(i20);
411       const __m128 vk20x0123 = _mm_load_ps(w + 84);
412       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi20x0123, vk20x0123));
413 
414       const __m128 vi21x0123 = _mm_loadu_ps(i21);
415       const __m128 vk21x0123 = _mm_load_ps(w + 88);
416       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi21x0123, vk21x0123));
417 
418       const __m128 vi22x0123 = _mm_loadu_ps(i22);
419       const __m128 vk22x0123 = _mm_load_ps(w + 92);
420       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi22x0123, vk22x0123));
421 
422       const __m128 vi23x0123 = _mm_loadu_ps(i23);
423       const __m128 vk23x0123 = _mm_load_ps(w + 96);
424       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi23x0123, vk23x0123));
425 
426       const __m128 vi24x0123 = _mm_loadu_ps(i24);
427       const __m128 vk24x0123 = _mm_load_ps(w + 100);
428       vacc0123p0 = _mm_add_ps(vacc0123p0, _mm_mul_ps(vi24x0123, vk24x0123));
429 
430 
431       __m128 vacc0123 = _mm_max_ps(vacc0123p0, vmin);
432       vacc0123 = _mm_min_ps(vacc0123, vmax);
433 
434       if (c & 2) {
435         _mm_storel_pi((__m64*) output, vacc0123);
436         vacc0123 = _mm_movehl_ps(vacc0123, vacc0123);
437         output += 2;
438       }
439       if (c & 1) {
440         _mm_store_ss(output, vacc0123);
441         output += 1;
442       }
443     }
444 
445     output = (float*) ((uintptr_t) output + output_increment);
446   } while (--output_width != 0);
447 }
448