• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/f32-dwconv/up-scalar.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 <xnnpack/dwconv.h>
13 #include <xnnpack/math.h>
14 
15 
xnn_f32_dwconv_minmax_ukernel_up2x25__wasm(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)])16 void xnn_f32_dwconv_minmax_ukernel_up2x25__wasm(
17     size_t channels,
18     size_t output_width,
19     const float** input,
20     const float* weights,
21     float* output,
22     size_t input_stride,
23     size_t output_increment,
24     size_t input_offset,
25     const float* zero,
26     const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
27 {
28   assert(channels != 0);
29   assert(output_width != 0);
30 
31   const float vmin = params->scalar.min;
32   const float vmax = params->scalar.max;
33   do {
34     const float* i0 = input[0];
35     assert(i0 != NULL);
36     if XNN_UNPREDICTABLE(i0 != zero) {
37       i0 = (const float*) ((uintptr_t) i0 + input_offset);
38     }
39     const float* i1 = input[1];
40     assert(i1 != NULL);
41     if XNN_UNPREDICTABLE(i1 != zero) {
42       i1 = (const float*) ((uintptr_t) i1 + input_offset);
43     }
44     const float* i2 = input[2];
45     assert(i2 != NULL);
46     if XNN_UNPREDICTABLE(i2 != zero) {
47       i2 = (const float*) ((uintptr_t) i2 + input_offset);
48     }
49     const float* i3 = input[3];
50     assert(i3 != NULL);
51     if XNN_UNPREDICTABLE(i3 != zero) {
52       i3 = (const float*) ((uintptr_t) i3 + input_offset);
53     }
54     const float* i4 = input[4];
55     assert(i4 != NULL);
56     if XNN_UNPREDICTABLE(i4 != zero) {
57       i4 = (const float*) ((uintptr_t) i4 + input_offset);
58     }
59     const float* i5 = input[5];
60     assert(i5 != NULL);
61     if XNN_UNPREDICTABLE(i5 != zero) {
62       i5 = (const float*) ((uintptr_t) i5 + input_offset);
63     }
64     const float* i6 = input[6];
65     assert(i6 != NULL);
66     if XNN_UNPREDICTABLE(i6 != zero) {
67       i6 = (const float*) ((uintptr_t) i6 + input_offset);
68     }
69     const float* i7 = input[7];
70     assert(i7 != NULL);
71     if XNN_UNPREDICTABLE(i7 != zero) {
72       i7 = (const float*) ((uintptr_t) i7 + input_offset);
73     }
74     const float* i8 = input[8];
75     assert(i8 != NULL);
76     if XNN_UNPREDICTABLE(i8 != zero) {
77       i8 = (const float*) ((uintptr_t) i8 + input_offset);
78     }
79     const float* i9 = input[9];
80     assert(i9 != NULL);
81     if XNN_UNPREDICTABLE(i9 != zero) {
82       i9 = (const float*) ((uintptr_t) i9 + input_offset);
83     }
84     const float* i10 = input[10];
85     assert(i10 != NULL);
86     if XNN_UNPREDICTABLE(i10 != zero) {
87       i10 = (const float*) ((uintptr_t) i10 + input_offset);
88     }
89     const float* i11 = input[11];
90     assert(i11 != NULL);
91     if XNN_UNPREDICTABLE(i11 != zero) {
92       i11 = (const float*) ((uintptr_t) i11 + input_offset);
93     }
94     const float* i12 = input[12];
95     assert(i12 != NULL);
96     if XNN_UNPREDICTABLE(i12 != zero) {
97       i12 = (const float*) ((uintptr_t) i12 + input_offset);
98     }
99     const float* i13 = input[13];
100     assert(i13 != NULL);
101     if XNN_UNPREDICTABLE(i13 != zero) {
102       i13 = (const float*) ((uintptr_t) i13 + input_offset);
103     }
104     const float* i14 = input[14];
105     assert(i14 != NULL);
106     if XNN_UNPREDICTABLE(i14 != zero) {
107       i14 = (const float*) ((uintptr_t) i14 + input_offset);
108     }
109     const float* i15 = input[15];
110     assert(i15 != NULL);
111     if XNN_UNPREDICTABLE(i15 != zero) {
112       i15 = (const float*) ((uintptr_t) i15 + input_offset);
113     }
114     const float* i16 = input[16];
115     assert(i16 != NULL);
116     if XNN_UNPREDICTABLE(i16 != zero) {
117       i16 = (const float*) ((uintptr_t) i16 + input_offset);
118     }
119     const float* i17 = input[17];
120     assert(i17 != NULL);
121     if XNN_UNPREDICTABLE(i17 != zero) {
122       i17 = (const float*) ((uintptr_t) i17 + input_offset);
123     }
124     const float* i18 = input[18];
125     assert(i18 != NULL);
126     if XNN_UNPREDICTABLE(i18 != zero) {
127       i18 = (const float*) ((uintptr_t) i18 + input_offset);
128     }
129     const float* i19 = input[19];
130     assert(i19 != NULL);
131     if XNN_UNPREDICTABLE(i19 != zero) {
132       i19 = (const float*) ((uintptr_t) i19 + input_offset);
133     }
134     const float* i20 = input[20];
135     assert(i20 != NULL);
136     if XNN_UNPREDICTABLE(i20 != zero) {
137       i20 = (const float*) ((uintptr_t) i20 + input_offset);
138     }
139     const float* i21 = input[21];
140     assert(i21 != NULL);
141     if XNN_UNPREDICTABLE(i21 != zero) {
142       i21 = (const float*) ((uintptr_t) i21 + input_offset);
143     }
144     const float* i22 = input[22];
145     assert(i22 != NULL);
146     if XNN_UNPREDICTABLE(i22 != zero) {
147       i22 = (const float*) ((uintptr_t) i22 + input_offset);
148     }
149     const float* i23 = input[23];
150     assert(i23 != NULL);
151     if XNN_UNPREDICTABLE(i23 != zero) {
152       i23 = (const float*) ((uintptr_t) i23 + input_offset);
153     }
154     const float* i24 = input[24];
155     assert(i24 != NULL);
156     if XNN_UNPREDICTABLE(i24 != zero) {
157       i24 = (const float*) ((uintptr_t) i24 + input_offset);
158     }
159     input = (const float**) ((uintptr_t) input + input_stride);
160 
161     size_t c = channels;
162     const float* w = weights;
163     for (; c >= 2; c -= 2) {
164       float vacc0p0 = w[0];
165       float vacc1p0 = w[1];
166 
167 
168       const float vi0x0 = i0[0];
169       const float vi0x1 = i0[1];
170       i0 += 2;
171 
172       const float vk0x0 = w[2];
173       vacc0p0 = math_muladd_f32(vi0x0, vk0x0, vacc0p0);
174       const float vk0x1 = w[3];
175       vacc1p0 = math_muladd_f32(vi0x1, vk0x1, vacc1p0);
176 
177       const float vi1x0 = i1[0];
178       const float vi1x1 = i1[1];
179       i1 += 2;
180 
181       const float vk1x0 = w[4];
182       vacc0p0 = math_muladd_f32(vi1x0, vk1x0, vacc0p0);
183       const float vk1x1 = w[5];
184       vacc1p0 = math_muladd_f32(vi1x1, vk1x1, vacc1p0);
185 
186       const float vi2x0 = i2[0];
187       const float vi2x1 = i2[1];
188       i2 += 2;
189 
190       const float vk2x0 = w[6];
191       vacc0p0 = math_muladd_f32(vi2x0, vk2x0, vacc0p0);
192       const float vk2x1 = w[7];
193       vacc1p0 = math_muladd_f32(vi2x1, vk2x1, vacc1p0);
194 
195       const float vi3x0 = i3[0];
196       const float vi3x1 = i3[1];
197       i3 += 2;
198 
199       const float vk3x0 = w[8];
200       vacc0p0 = math_muladd_f32(vi3x0, vk3x0, vacc0p0);
201       const float vk3x1 = w[9];
202       vacc1p0 = math_muladd_f32(vi3x1, vk3x1, vacc1p0);
203 
204       const float vi4x0 = i4[0];
205       const float vi4x1 = i4[1];
206       i4 += 2;
207 
208       const float vk4x0 = w[10];
209       vacc0p0 = math_muladd_f32(vi4x0, vk4x0, vacc0p0);
210       const float vk4x1 = w[11];
211       vacc1p0 = math_muladd_f32(vi4x1, vk4x1, vacc1p0);
212 
213       const float vi5x0 = i5[0];
214       const float vi5x1 = i5[1];
215       i5 += 2;
216 
217       const float vk5x0 = w[12];
218       vacc0p0 = math_muladd_f32(vi5x0, vk5x0, vacc0p0);
219       const float vk5x1 = w[13];
220       vacc1p0 = math_muladd_f32(vi5x1, vk5x1, vacc1p0);
221 
222       const float vi6x0 = i6[0];
223       const float vi6x1 = i6[1];
224       i6 += 2;
225 
226       const float vk6x0 = w[14];
227       vacc0p0 = math_muladd_f32(vi6x0, vk6x0, vacc0p0);
228       const float vk6x1 = w[15];
229       vacc1p0 = math_muladd_f32(vi6x1, vk6x1, vacc1p0);
230 
231       const float vi7x0 = i7[0];
232       const float vi7x1 = i7[1];
233       i7 += 2;
234 
235       const float vk7x0 = w[16];
236       vacc0p0 = math_muladd_f32(vi7x0, vk7x0, vacc0p0);
237       const float vk7x1 = w[17];
238       vacc1p0 = math_muladd_f32(vi7x1, vk7x1, vacc1p0);
239 
240       const float vi8x0 = i8[0];
241       const float vi8x1 = i8[1];
242       i8 += 2;
243 
244       const float vk8x0 = w[18];
245       vacc0p0 = math_muladd_f32(vi8x0, vk8x0, vacc0p0);
246       const float vk8x1 = w[19];
247       vacc1p0 = math_muladd_f32(vi8x1, vk8x1, vacc1p0);
248 
249       const float vi9x0 = i9[0];
250       const float vi9x1 = i9[1];
251       i9 += 2;
252 
253       const float vk9x0 = w[20];
254       vacc0p0 = math_muladd_f32(vi9x0, vk9x0, vacc0p0);
255       const float vk9x1 = w[21];
256       vacc1p0 = math_muladd_f32(vi9x1, vk9x1, vacc1p0);
257 
258       const float vi10x0 = i10[0];
259       const float vi10x1 = i10[1];
260       i10 += 2;
261 
262       const float vk10x0 = w[22];
263       vacc0p0 = math_muladd_f32(vi10x0, vk10x0, vacc0p0);
264       const float vk10x1 = w[23];
265       vacc1p0 = math_muladd_f32(vi10x1, vk10x1, vacc1p0);
266 
267       const float vi11x0 = i11[0];
268       const float vi11x1 = i11[1];
269       i11 += 2;
270 
271       const float vk11x0 = w[24];
272       vacc0p0 = math_muladd_f32(vi11x0, vk11x0, vacc0p0);
273       const float vk11x1 = w[25];
274       vacc1p0 = math_muladd_f32(vi11x1, vk11x1, vacc1p0);
275 
276       const float vi12x0 = i12[0];
277       const float vi12x1 = i12[1];
278       i12 += 2;
279 
280       const float vk12x0 = w[26];
281       vacc0p0 = math_muladd_f32(vi12x0, vk12x0, vacc0p0);
282       const float vk12x1 = w[27];
283       vacc1p0 = math_muladd_f32(vi12x1, vk12x1, vacc1p0);
284 
285       const float vi13x0 = i13[0];
286       const float vi13x1 = i13[1];
287       i13 += 2;
288 
289       const float vk13x0 = w[28];
290       vacc0p0 = math_muladd_f32(vi13x0, vk13x0, vacc0p0);
291       const float vk13x1 = w[29];
292       vacc1p0 = math_muladd_f32(vi13x1, vk13x1, vacc1p0);
293 
294       const float vi14x0 = i14[0];
295       const float vi14x1 = i14[1];
296       i14 += 2;
297 
298       const float vk14x0 = w[30];
299       vacc0p0 = math_muladd_f32(vi14x0, vk14x0, vacc0p0);
300       const float vk14x1 = w[31];
301       vacc1p0 = math_muladd_f32(vi14x1, vk14x1, vacc1p0);
302 
303       const float vi15x0 = i15[0];
304       const float vi15x1 = i15[1];
305       i15 += 2;
306 
307       const float vk15x0 = w[32];
308       vacc0p0 = math_muladd_f32(vi15x0, vk15x0, vacc0p0);
309       const float vk15x1 = w[33];
310       vacc1p0 = math_muladd_f32(vi15x1, vk15x1, vacc1p0);
311 
312       const float vi16x0 = i16[0];
313       const float vi16x1 = i16[1];
314       i16 += 2;
315 
316       const float vk16x0 = w[34];
317       vacc0p0 = math_muladd_f32(vi16x0, vk16x0, vacc0p0);
318       const float vk16x1 = w[35];
319       vacc1p0 = math_muladd_f32(vi16x1, vk16x1, vacc1p0);
320 
321       const float vi17x0 = i17[0];
322       const float vi17x1 = i17[1];
323       i17 += 2;
324 
325       const float vk17x0 = w[36];
326       vacc0p0 = math_muladd_f32(vi17x0, vk17x0, vacc0p0);
327       const float vk17x1 = w[37];
328       vacc1p0 = math_muladd_f32(vi17x1, vk17x1, vacc1p0);
329 
330       const float vi18x0 = i18[0];
331       const float vi18x1 = i18[1];
332       i18 += 2;
333 
334       const float vk18x0 = w[38];
335       vacc0p0 = math_muladd_f32(vi18x0, vk18x0, vacc0p0);
336       const float vk18x1 = w[39];
337       vacc1p0 = math_muladd_f32(vi18x1, vk18x1, vacc1p0);
338 
339       const float vi19x0 = i19[0];
340       const float vi19x1 = i19[1];
341       i19 += 2;
342 
343       const float vk19x0 = w[40];
344       vacc0p0 = math_muladd_f32(vi19x0, vk19x0, vacc0p0);
345       const float vk19x1 = w[41];
346       vacc1p0 = math_muladd_f32(vi19x1, vk19x1, vacc1p0);
347 
348       const float vi20x0 = i20[0];
349       const float vi20x1 = i20[1];
350       i20 += 2;
351 
352       const float vk20x0 = w[42];
353       vacc0p0 = math_muladd_f32(vi20x0, vk20x0, vacc0p0);
354       const float vk20x1 = w[43];
355       vacc1p0 = math_muladd_f32(vi20x1, vk20x1, vacc1p0);
356 
357       const float vi21x0 = i21[0];
358       const float vi21x1 = i21[1];
359       i21 += 2;
360 
361       const float vk21x0 = w[44];
362       vacc0p0 = math_muladd_f32(vi21x0, vk21x0, vacc0p0);
363       const float vk21x1 = w[45];
364       vacc1p0 = math_muladd_f32(vi21x1, vk21x1, vacc1p0);
365 
366       const float vi22x0 = i22[0];
367       const float vi22x1 = i22[1];
368       i22 += 2;
369 
370       const float vk22x0 = w[46];
371       vacc0p0 = math_muladd_f32(vi22x0, vk22x0, vacc0p0);
372       const float vk22x1 = w[47];
373       vacc1p0 = math_muladd_f32(vi22x1, vk22x1, vacc1p0);
374 
375       const float vi23x0 = i23[0];
376       const float vi23x1 = i23[1];
377       i23 += 2;
378 
379       const float vk23x0 = w[48];
380       vacc0p0 = math_muladd_f32(vi23x0, vk23x0, vacc0p0);
381       const float vk23x1 = w[49];
382       vacc1p0 = math_muladd_f32(vi23x1, vk23x1, vacc1p0);
383 
384       const float vi24x0 = i24[0];
385       const float vi24x1 = i24[1];
386       i24 += 2;
387 
388       const float vk24x0 = w[50];
389       vacc0p0 = math_muladd_f32(vi24x0, vk24x0, vacc0p0);
390       const float vk24x1 = w[51];
391       vacc1p0 = math_muladd_f32(vi24x1, vk24x1, vacc1p0);
392 
393       w += 52;
394 
395 
396       float vacc0 = __builtin_wasm_max_f32(vacc0p0, vmin);
397       float vacc1 = __builtin_wasm_max_f32(vacc1p0, vmin);
398 
399       vacc0 = __builtin_wasm_min_f32(vacc0, vmax);
400       vacc1 = __builtin_wasm_min_f32(vacc1, vmax);
401 
402       output[0] = vacc0;
403       output[1] = vacc1;
404       output += 2;
405     }
406     for (; c >= 1; c -= 1) {
407       float vacc0p0 = *w++;
408 
409       const float vi0 = *i0++;
410       const float vk0 = w[1];
411       vacc0p0 = math_muladd_f32(vi0, vk0, vacc0p0);
412       const float vi1 = *i1++;
413       const float vk1 = w[3];
414       vacc0p0 = math_muladd_f32(vi1, vk1, vacc0p0);
415       const float vi2 = *i2++;
416       const float vk2 = w[5];
417       vacc0p0 = math_muladd_f32(vi2, vk2, vacc0p0);
418       const float vi3 = *i3++;
419       const float vk3 = w[7];
420       vacc0p0 = math_muladd_f32(vi3, vk3, vacc0p0);
421       const float vi4 = *i4++;
422       const float vk4 = w[9];
423       vacc0p0 = math_muladd_f32(vi4, vk4, vacc0p0);
424       const float vi5 = *i5++;
425       const float vk5 = w[11];
426       vacc0p0 = math_muladd_f32(vi5, vk5, vacc0p0);
427       const float vi6 = *i6++;
428       const float vk6 = w[13];
429       vacc0p0 = math_muladd_f32(vi6, vk6, vacc0p0);
430       const float vi7 = *i7++;
431       const float vk7 = w[15];
432       vacc0p0 = math_muladd_f32(vi7, vk7, vacc0p0);
433       const float vi8 = *i8++;
434       const float vk8 = w[17];
435       vacc0p0 = math_muladd_f32(vi8, vk8, vacc0p0);
436       const float vi9 = *i9++;
437       const float vk9 = w[19];
438       vacc0p0 = math_muladd_f32(vi9, vk9, vacc0p0);
439       const float vi10 = *i10++;
440       const float vk10 = w[21];
441       vacc0p0 = math_muladd_f32(vi10, vk10, vacc0p0);
442       const float vi11 = *i11++;
443       const float vk11 = w[23];
444       vacc0p0 = math_muladd_f32(vi11, vk11, vacc0p0);
445       const float vi12 = *i12++;
446       const float vk12 = w[25];
447       vacc0p0 = math_muladd_f32(vi12, vk12, vacc0p0);
448       const float vi13 = *i13++;
449       const float vk13 = w[27];
450       vacc0p0 = math_muladd_f32(vi13, vk13, vacc0p0);
451       const float vi14 = *i14++;
452       const float vk14 = w[29];
453       vacc0p0 = math_muladd_f32(vi14, vk14, vacc0p0);
454       const float vi15 = *i15++;
455       const float vk15 = w[31];
456       vacc0p0 = math_muladd_f32(vi15, vk15, vacc0p0);
457       const float vi16 = *i16++;
458       const float vk16 = w[33];
459       vacc0p0 = math_muladd_f32(vi16, vk16, vacc0p0);
460       const float vi17 = *i17++;
461       const float vk17 = w[35];
462       vacc0p0 = math_muladd_f32(vi17, vk17, vacc0p0);
463       const float vi18 = *i18++;
464       const float vk18 = w[37];
465       vacc0p0 = math_muladd_f32(vi18, vk18, vacc0p0);
466       const float vi19 = *i19++;
467       const float vk19 = w[39];
468       vacc0p0 = math_muladd_f32(vi19, vk19, vacc0p0);
469       const float vi20 = *i20++;
470       const float vk20 = w[41];
471       vacc0p0 = math_muladd_f32(vi20, vk20, vacc0p0);
472       const float vi21 = *i21++;
473       const float vk21 = w[43];
474       vacc0p0 = math_muladd_f32(vi21, vk21, vacc0p0);
475       const float vi22 = *i22++;
476       const float vk22 = w[45];
477       vacc0p0 = math_muladd_f32(vi22, vk22, vacc0p0);
478       const float vi23 = *i23++;
479       const float vk23 = w[47];
480       vacc0p0 = math_muladd_f32(vi23, vk23, vacc0p0);
481       const float vi24 = *i24++;
482       const float vk24 = w[49];
483       vacc0p0 = math_muladd_f32(vi24, vk24, vacc0p0);
484 
485 
486       float vacc0 = __builtin_wasm_max_f32(vacc0p0, vmin);
487       vacc0 = __builtin_wasm_min_f32(vacc0, vmax);
488       *output++ = vacc0;
489     }
490 
491     output = (float*) ((uintptr_t) output + output_increment);
492   } while (--output_width != 0);
493 }
494