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_acc5(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_acc5(
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 float vo0p3 = vi3x0 * vk30;
115 float vo0p4 = vi4x0 * vk40;
116
117 vi0x0 = vi0x1;
118 vi1x0 = vi1x1;
119 vi2x0 = vi2x1;
120 vi3x0 = vi3x1;
121 vi4x0 = vi4x1;
122
123 vo0p0 += vi0x1 * vk01;
124 vo0p1 += vi1x1 * vk11;
125 vo0p2 += vi2x1 * vk21;
126 vo0p3 += vi3x1 * vk31;
127 vo0p4 += vi4x1 * vk41;
128
129 vi0x1 = vi0x2;
130 vi1x1 = vi1x2;
131 vi2x1 = vi2x2;
132 vi3x1 = vi3x2;
133 vi4x1 = vi4x2;
134
135 vo0p0 += vi0x2 * vk02;
136 vo0p1 += vi1x2 * vk12;
137 vo0p2 += vi2x2 * vk22;
138 vo0p3 += vi3x2 * vk32;
139 vo0p4 += 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 vo0p3 += vi3x3 * vk33;
151 vo0p4 += vi4x3 * vk43;
152
153 vi0x3 = vi0x4;
154 vi1x3 = vi1x4;
155 vi2x3 = vi2x4;
156 vi3x3 = vi3x4;
157 vi4x3 = vi4x4;
158
159 vo0p0 += vi0x4 * vk04;
160 vo0p1 += vi1x4 * vk14;
161 vo0p2 += vi2x4 * vk24;
162 vo0p3 += vi3x4 * vk34;
163 vo0p4 += vi4x4 * vk44;
164
165 vo0p0 += vo0p1;
166 vo0p2 += vo0p3;
167 vo0p0 += vo0p2;
168 vo0p0 += vo0p4;
169
170 float vo0 = math_max_f32(vo0p0, vmin);
171
172 vo0 = math_min_f32(vo0, vmax);
173
174 *o0++ = vo0;
175 }
176 assert(w == 2 * sizeof(float));
177 {
178 float vo0p0 = vbias + vi0x0 * vk00;
179 float vo0p1 = vi1x0 * vk10;
180 float vo0p2 = vi2x0 * vk20;
181 float vo0p3 = vi3x0 * vk30;
182 float vo0p4 = vi4x0 * vk40;
183
184 vi0x0 = vi0x1;
185 vi1x0 = vi1x1;
186 vi2x0 = vi2x1;
187 vi3x0 = vi3x1;
188 vi4x0 = vi4x1;
189
190 vo0p0 += vi0x1 * vk01;
191 vo0p1 += vi1x1 * vk11;
192 vo0p2 += vi2x1 * vk21;
193 vo0p3 += vi3x1 * vk31;
194 vo0p4 += vi4x1 * vk41;
195
196 vi0x1 = vi0x2;
197 vi1x1 = vi1x2;
198 vi2x1 = vi2x2;
199 vi3x1 = vi3x2;
200 vi4x1 = vi4x2;
201
202 vo0p0 += vi0x2 * vk02;
203 vo0p1 += vi1x2 * vk12;
204 vo0p2 += vi2x2 * vk22;
205 vo0p3 += vi3x2 * vk32;
206 vo0p4 += vi4x2 * vk42;
207
208 vi0x2 = vi0x3;
209 vi1x2 = vi1x3;
210 vi2x2 = vi2x3;
211 vi3x2 = vi3x3;
212 vi4x2 = vi4x3;
213
214 vo0p0 += vi0x3 * vk03;
215 vo0p1 += vi1x3 * vk13;
216 vo0p2 += vi2x3 * vk23;
217 vo0p3 += vi3x3 * vk33;
218 vo0p4 += vi4x3 * vk43;
219
220 vo0p0 += vo0p1;
221 vo0p2 += vo0p3;
222 vo0p0 += vo0p2;
223 vo0p0 += vo0p4;
224
225 float vo0 = math_max_f32(vo0p0, vmin);
226
227 vo0 = math_min_f32(vo0, vmax);
228
229 *o0++ = vo0;
230 }
231 w -= 1 * sizeof(float);
232 }
233 assert(w == 1 * sizeof(float));
234 {
235 float vo0p0 = vbias + vi0x0 * vk00;
236 float vo0p1 = vi1x0 * vk10;
237 float vo0p2 = vi2x0 * vk20;
238 float vo0p3 = vi3x0 * vk30;
239 float vo0p4 = vi4x0 * vk40;
240
241 vo0p0 += vi0x1 * vk01;
242 vo0p1 += vi1x1 * vk11;
243 vo0p2 += vi2x1 * vk21;
244 vo0p3 += vi3x1 * vk31;
245 vo0p4 += vi4x1 * vk41;
246
247 vo0p0 += vi0x2 * vk02;
248 vo0p1 += vi1x2 * vk12;
249 vo0p2 += vi2x2 * vk22;
250 vo0p3 += vi3x2 * vk32;
251 vo0p4 += vi4x2 * vk42;
252
253 vo0p0 += vo0p1;
254 vo0p2 += vo0p3;
255 vo0p0 += vo0p2;
256 vo0p0 += vo0p4;
257
258 float vo0 = math_max_f32(vo0p0, vmin);
259
260 vo0 = math_min_f32(vo0, vmax);
261
262 *o0++ = vo0;
263 }
264
265 i0 = (const float*) ((uintptr_t) i1 - input_width);
266 i1 = (const float*) ((uintptr_t) i2 - input_width);
267
268
269 } while (--output_height != 0);
270 }
271