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