1 // Auto-generated file. Do not edit!
2 // Template: src/f32-dwconv2d-chw/5x5p2-scalar.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 <xnnpack/dwconv.h>
13 #include <xnnpack/math.h>
14
15
xnn_f32_dwconv2d_chw_ukernel_5x5p2__scalar_1x1_acc3(size_t input_height,size_t input_width,const float * input,const float * weights,const float * zero,float * output,uint32_t padding_top,const union xnn_f32_chw_params params[restrict XNN_MIN_ELEMENTS (1)])16 void xnn_f32_dwconv2d_chw_ukernel_5x5p2__scalar_1x1_acc3(
17 size_t input_height,
18 size_t input_width,
19 const float* input,
20 const float* weights,
21 const float* zero,
22 float* output,
23 uint32_t padding_top,
24 const union xnn_f32_chw_params params[restrict XNN_MIN_ELEMENTS(1)])
25 {
26 assert(input_height != 0);
27 assert(input_width != 0);
28 assert(input_width % sizeof(float) == 0);
29 assert(padding_top == 2);
30
31 const float vmin = params->scalar.min;
32 const float vmax = params->scalar.max;
33
34 const float vbias = weights[0];
35 const float vk00 = weights[1];
36 const float vk01 = weights[2];
37 const float vk02 = weights[3];
38 const float vk03 = weights[4];
39 const float vk04 = weights[5];
40 const float vk10 = weights[6];
41 const float vk11 = weights[7];
42 const float vk12 = weights[8];
43 const float vk13 = weights[9];
44 const float vk14 = weights[10];
45 const float vk20 = weights[11];
46 const float vk21 = weights[12];
47 const float vk22 = weights[13];
48 const float vk23 = weights[14];
49 const float vk24 = weights[15];
50 const float vk30 = weights[16];
51 const float vk31 = weights[17];
52 const float vk32 = weights[18];
53 const float vk33 = weights[19];
54 const float vk34 = weights[20];
55 const float vk40 = weights[21];
56 const float vk41 = weights[22];
57 const float vk42 = weights[23];
58 const float vk43 = weights[24];
59 const float vk44 = weights[25];
60
61 const float* i0 = zero;
62 const float* i1 = zero;
63 const float* i2 = input;
64 const float* i3 = (const float*) ((uintptr_t) i2 + input_width);
65 const float* i4 = (const float*) ((uintptr_t) i3 + input_width);
66
67 float* o0 = output;
68
69 size_t output_height = input_height;
70 do {
71 if XNN_UNPREDICTABLE(output_height < 2) {
72 i3 = zero;
73 }
74 if XNN_UNPREDICTABLE(output_height < 3) {
75 i4 = zero;
76 }
77
78 float vi0x0 = 0.0f;
79 float vi1x0 = 0.0f;
80 float vi2x0 = 0.0f;
81 float vi3x0 = 0.0f;
82 float vi4x0 = 0.0f;
83
84 float vi0x1 = 0.0f;
85 float vi1x1 = 0.0f;
86 float vi2x1 = 0.0f;
87 float vi3x1 = 0.0f;
88 float vi4x1 = 0.0f;
89
90 float vi0x2 = *i0++;
91 float vi1x2 = *i1++;
92 float vi2x2 = *i2++;
93 float vi3x2 = *i3++;
94 float vi4x2 = *i4++;
95
96 size_t w = input_width;
97 if (w > 1 * sizeof(float)) {
98 float vi0x3 = *i0++;
99 float vi1x3 = *i1++;
100 float vi2x3 = *i2++;
101 float vi3x3 = *i3++;
102 float vi4x3 = *i4++;
103
104 for (; w > 2 * sizeof(float); w -= 1 * sizeof(float)) {
105 const float vi0x4 = *i0++;
106 const float vi1x4 = *i1++;
107 const float vi2x4 = *i2++;
108 const float vi3x4 = *i3++;
109 const float vi4x4 = *i4++;
110
111 float vo0p0 = vbias + vi0x0 * vk00;
112 float vo0p1 = vi1x0 * vk10;
113 float vo0p2 = vi2x0 * vk20;
114 vo0p0 += vi3x0 * vk30;
115 vo0p1 += vi4x0 * vk40;
116
117 vi0x0 = vi0x1;
118 vi1x0 = vi1x1;
119 vi2x0 = vi2x1;
120 vi3x0 = vi3x1;
121 vi4x0 = vi4x1;
122
123 vo0p2 += vi0x1 * vk01;
124 vo0p0 += vi1x1 * vk11;
125 vo0p1 += vi2x1 * vk21;
126 vo0p2 += vi3x1 * vk31;
127 vo0p0 += vi4x1 * vk41;
128
129 vi0x1 = vi0x2;
130 vi1x1 = vi1x2;
131 vi2x1 = vi2x2;
132 vi3x1 = vi3x2;
133 vi4x1 = vi4x2;
134
135 vo0p1 += vi0x2 * vk02;
136 vo0p2 += vi1x2 * vk12;
137 vo0p0 += vi2x2 * vk22;
138 vo0p1 += vi3x2 * vk32;
139 vo0p2 += vi4x2 * vk42;
140
141 vi0x2 = vi0x3;
142 vi1x2 = vi1x3;
143 vi2x2 = vi2x3;
144 vi3x2 = vi3x3;
145 vi4x2 = vi4x3;
146
147 vo0p0 += vi0x3 * vk03;
148 vo0p1 += vi1x3 * vk13;
149 vo0p2 += vi2x3 * vk23;
150 vo0p0 += vi3x3 * vk33;
151 vo0p1 += vi4x3 * vk43;
152
153 vi0x3 = vi0x4;
154 vi1x3 = vi1x4;
155 vi2x3 = vi2x4;
156 vi3x3 = vi3x4;
157 vi4x3 = vi4x4;
158
159 vo0p2 += vi0x4 * vk04;
160 vo0p0 += vi1x4 * vk14;
161 vo0p1 += vi2x4 * vk24;
162 vo0p2 += vi3x4 * vk34;
163 vo0p0 += vi4x4 * vk44;
164
165 vo0p0 += vo0p1;
166 vo0p0 += vo0p2;
167
168 float vo0 = math_max_f32(vo0p0, vmin);
169
170 vo0 = math_min_f32(vo0, vmax);
171
172 *o0++ = vo0;
173 }
174 assert(w == 2 * sizeof(float));
175 {
176 float vo0p0 = vbias + vi0x0 * vk00;
177 float vo0p1 = vi1x0 * vk10;
178 float vo0p2 = vi2x0 * vk20;
179 vo0p0 += vi3x0 * vk30;
180 vo0p1 += vi4x0 * vk40;
181
182 vi0x0 = vi0x1;
183 vi1x0 = vi1x1;
184 vi2x0 = vi2x1;
185 vi3x0 = vi3x1;
186 vi4x0 = vi4x1;
187
188 vo0p2 += vi0x1 * vk01;
189 vo0p0 += vi1x1 * vk11;
190 vo0p1 += vi2x1 * vk21;
191 vo0p2 += vi3x1 * vk31;
192 vo0p0 += vi4x1 * vk41;
193
194 vi0x1 = vi0x2;
195 vi1x1 = vi1x2;
196 vi2x1 = vi2x2;
197 vi3x1 = vi3x2;
198 vi4x1 = vi4x2;
199
200 vo0p1 += vi0x2 * vk02;
201 vo0p2 += vi1x2 * vk12;
202 vo0p0 += vi2x2 * vk22;
203 vo0p1 += vi3x2 * vk32;
204 vo0p2 += vi4x2 * vk42;
205
206 vi0x2 = vi0x3;
207 vi1x2 = vi1x3;
208 vi2x2 = vi2x3;
209 vi3x2 = vi3x3;
210 vi4x2 = vi4x3;
211
212 vo0p0 += vi0x3 * vk03;
213 vo0p1 += vi1x3 * vk13;
214 vo0p2 += vi2x3 * vk23;
215 vo0p0 += vi3x3 * vk33;
216 vo0p1 += vi4x3 * vk43;
217
218 vo0p0 += vo0p1;
219 vo0p0 += vo0p2;
220
221 float vo0 = math_max_f32(vo0p0, vmin);
222
223 vo0 = math_min_f32(vo0, vmax);
224
225 *o0++ = vo0;
226 }
227 w -= 1 * sizeof(float);
228 }
229 assert(w == 1 * sizeof(float));
230 {
231 float vo0p0 = vbias + vi0x0 * vk00;
232 float vo0p1 = vi1x0 * vk10;
233 float vo0p2 = vi2x0 * vk20;
234 vo0p0 += vi3x0 * vk30;
235 vo0p1 += vi4x0 * vk40;
236
237 vo0p2 += vi0x1 * vk01;
238 vo0p0 += vi1x1 * vk11;
239 vo0p1 += vi2x1 * vk21;
240 vo0p2 += vi3x1 * vk31;
241 vo0p0 += vi4x1 * vk41;
242
243 vo0p1 += vi0x2 * vk02;
244 vo0p2 += vi1x2 * vk12;
245 vo0p0 += vi2x2 * vk22;
246 vo0p1 += vi3x2 * vk32;
247 vo0p2 += vi4x2 * vk42;
248
249 vo0p0 += vo0p1;
250 vo0p0 += vo0p2;
251
252 float vo0 = math_max_f32(vo0p0, vmin);
253
254 vo0 = math_min_f32(vo0, vmax);
255
256 *o0++ = vo0;
257 }
258
259 i0 = (const float*) ((uintptr_t) i1 - input_width);
260 i1 = (const float*) ((uintptr_t) i2 - input_width);
261
262
263 } while (--output_height != 0);
264 }
265