• 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_ukernel_up2x4__wasm(size_t channels,size_t output_width,const float ** input,const float * weights,float * output,size_t input_stride,size_t output_increment,const union xnn_f32_output_params params[restrict static1])16 void xnn_f32_dwconv_ukernel_up2x4__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     const union xnn_f32_output_params params[restrict static 1])
25 {
26   assert(channels != 0);
27   assert(output_width != 0);
28 
29   const float vmin = params->scalar.min;
30   const float vmax = params->scalar.max;
31   do {
32     const float* i0 = input[0];
33     assert(i0 != NULL);
34     const float* i1 = input[1];
35     assert(i1 != NULL);
36     const float* i2 = input[2];
37     assert(i2 != NULL);
38     const float* i3 = input[3];
39     assert(i3 != NULL);
40     input = (const float**) ((uintptr_t) input + input_stride);
41 
42     size_t c = channels;
43     const float* w = weights;
44     for (; c >= 2; c -= 2) {
45       float vacc0p0 = w[0];
46       float vacc1p0 = w[1];
47 
48 
49       const float vi0x0 = i0[0];
50       const float vi0x1 = i0[1];
51       i0 += 2;
52 
53       const float vk0x0 = w[2];
54       vacc0p0 += vi0x0 * vk0x0;
55       const float vk0x1 = w[3];
56       vacc1p0 += vi0x1 * vk0x1;
57 
58       const float vi1x0 = i1[0];
59       const float vi1x1 = i1[1];
60       i1 += 2;
61 
62       const float vk1x0 = w[4];
63       vacc0p0 += vi1x0 * vk1x0;
64       const float vk1x1 = w[5];
65       vacc1p0 += vi1x1 * vk1x1;
66 
67       const float vi2x0 = i2[0];
68       const float vi2x1 = i2[1];
69       i2 += 2;
70 
71       const float vk2x0 = w[6];
72       vacc0p0 += vi2x0 * vk2x0;
73       const float vk2x1 = w[7];
74       vacc1p0 += vi2x1 * vk2x1;
75 
76       const float vi3x0 = i3[0];
77       const float vi3x1 = i3[1];
78       i3 += 2;
79 
80       const float vk3x0 = w[8];
81       vacc0p0 += vi3x0 * vk3x0;
82       const float vk3x1 = w[9];
83       vacc1p0 += vi3x1 * vk3x1;
84 
85       w += 10;
86 
87 
88       float vacc0 = __builtin_wasm_max_f32(vacc0p0, vmin);
89       float vacc1 = __builtin_wasm_max_f32(vacc1p0, vmin);
90 
91       vacc0 = __builtin_wasm_min_f32(vacc0, vmax);
92       vacc1 = __builtin_wasm_min_f32(vacc1, vmax);
93 
94       output[0] = vacc0;
95       output[1] = vacc1;
96       output += 2;
97     }
98     for (; c >= 1; c -= 1) {
99       float vacc0p0 = *w++;
100 
101       const float vi0 = *i0++;
102       const float vk0 = w[1];
103       vacc0p0 += vi0 * vk0;
104       const float vi1 = *i1++;
105       const float vk1 = w[3];
106       vacc0p0 += vi1 * vk1;
107       const float vi2 = *i2++;
108       const float vk2 = w[5];
109       vacc0p0 += vi2 * vk2;
110       const float vi3 = *i3++;
111       const float vk3 = w[7];
112       vacc0p0 += vi3 * vk3;
113 
114 
115       float vacc0 = __builtin_wasm_max_f32(vacc0p0, vmin);
116       vacc0 = __builtin_wasm_min_f32(vacc0, vmax);
117       *output++ = vacc0;
118     }
119 
120     output = (float*) ((uintptr_t) output + output_increment);
121   } while (--output_width != 0);
122 }
123