1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-dwconv/unipass-scalar.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 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 #include <math.h>
12
13 #include <xnnpack/dwconv.h>
14 #include <xnnpack/math.h>
15
16
xnn_qc8_dwconv_minmax_fp32_ukernel_up1x25__scalar_lrintf(size_t channels,size_t output_width,const int8_t ** input,const void * weights,int8_t * output,size_t input_stride,size_t output_increment,size_t input_offset,const int8_t * zero,const union xnn_qs8_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qc8_dwconv_minmax_fp32_ukernel_up1x25__scalar_lrintf(
18 size_t channels,
19 size_t output_width,
20 const int8_t** input,
21 const void* weights,
22 int8_t* output,
23 size_t input_stride,
24 size_t output_increment,
25 size_t input_offset,
26 const int8_t* zero,
27 const union xnn_qs8_minmax_params params[restrict XNN_MIN_ELEMENTS(1)])
28 {
29 assert(channels != 0);
30 assert(output_width != 0);
31
32 const float voutput_min_less_zero_point = params->scalar_lrintf.output_min_less_zero_point;
33 const float voutput_max_less_zero_point = params->scalar_lrintf.output_max_less_zero_point;
34 const int32_t voutput_zero_point = params->scalar_lrintf.output_zero_point;
35 do {
36 const int8_t* i0 = input[0];
37 assert(i0 != NULL);
38 if XNN_UNPREDICTABLE(i0 != zero) {
39 i0 = (const int8_t*) ((uintptr_t) i0 + input_offset);
40 }
41 const int8_t* i1 = input[1];
42 assert(i1 != NULL);
43 if XNN_UNPREDICTABLE(i1 != zero) {
44 i1 = (const int8_t*) ((uintptr_t) i1 + input_offset);
45 }
46 const int8_t* i2 = input[2];
47 assert(i2 != NULL);
48 if XNN_UNPREDICTABLE(i2 != zero) {
49 i2 = (const int8_t*) ((uintptr_t) i2 + input_offset);
50 }
51 const int8_t* i3 = input[3];
52 assert(i3 != NULL);
53 if XNN_UNPREDICTABLE(i3 != zero) {
54 i3 = (const int8_t*) ((uintptr_t) i3 + input_offset);
55 }
56 const int8_t* i4 = input[4];
57 assert(i4 != NULL);
58 if XNN_UNPREDICTABLE(i4 != zero) {
59 i4 = (const int8_t*) ((uintptr_t) i4 + input_offset);
60 }
61 const int8_t* i5 = input[5];
62 assert(i5 != NULL);
63 if XNN_UNPREDICTABLE(i5 != zero) {
64 i5 = (const int8_t*) ((uintptr_t) i5 + input_offset);
65 }
66 const int8_t* i6 = input[6];
67 assert(i6 != NULL);
68 if XNN_UNPREDICTABLE(i6 != zero) {
69 i6 = (const int8_t*) ((uintptr_t) i6 + input_offset);
70 }
71 const int8_t* i7 = input[7];
72 assert(i7 != NULL);
73 if XNN_UNPREDICTABLE(i7 != zero) {
74 i7 = (const int8_t*) ((uintptr_t) i7 + input_offset);
75 }
76 const int8_t* i8 = input[8];
77 assert(i8 != NULL);
78 if XNN_UNPREDICTABLE(i8 != zero) {
79 i8 = (const int8_t*) ((uintptr_t) i8 + input_offset);
80 }
81 const int8_t* i9 = input[9];
82 assert(i9 != NULL);
83 if XNN_UNPREDICTABLE(i9 != zero) {
84 i9 = (const int8_t*) ((uintptr_t) i9 + input_offset);
85 }
86 const int8_t* i10 = input[10];
87 assert(i10 != NULL);
88 if XNN_UNPREDICTABLE(i10 != zero) {
89 i10 = (const int8_t*) ((uintptr_t) i10 + input_offset);
90 }
91 const int8_t* i11 = input[11];
92 assert(i11 != NULL);
93 if XNN_UNPREDICTABLE(i11 != zero) {
94 i11 = (const int8_t*) ((uintptr_t) i11 + input_offset);
95 }
96 const int8_t* i12 = input[12];
97 assert(i12 != NULL);
98 if XNN_UNPREDICTABLE(i12 != zero) {
99 i12 = (const int8_t*) ((uintptr_t) i12 + input_offset);
100 }
101 const int8_t* i13 = input[13];
102 assert(i13 != NULL);
103 if XNN_UNPREDICTABLE(i13 != zero) {
104 i13 = (const int8_t*) ((uintptr_t) i13 + input_offset);
105 }
106 const int8_t* i14 = input[14];
107 assert(i14 != NULL);
108 if XNN_UNPREDICTABLE(i14 != zero) {
109 i14 = (const int8_t*) ((uintptr_t) i14 + input_offset);
110 }
111 const int8_t* i15 = input[15];
112 assert(i15 != NULL);
113 if XNN_UNPREDICTABLE(i15 != zero) {
114 i15 = (const int8_t*) ((uintptr_t) i15 + input_offset);
115 }
116 const int8_t* i16 = input[16];
117 assert(i16 != NULL);
118 if XNN_UNPREDICTABLE(i16 != zero) {
119 i16 = (const int8_t*) ((uintptr_t) i16 + input_offset);
120 }
121 const int8_t* i17 = input[17];
122 assert(i17 != NULL);
123 if XNN_UNPREDICTABLE(i17 != zero) {
124 i17 = (const int8_t*) ((uintptr_t) i17 + input_offset);
125 }
126 const int8_t* i18 = input[18];
127 assert(i18 != NULL);
128 if XNN_UNPREDICTABLE(i18 != zero) {
129 i18 = (const int8_t*) ((uintptr_t) i18 + input_offset);
130 }
131 const int8_t* i19 = input[19];
132 assert(i19 != NULL);
133 if XNN_UNPREDICTABLE(i19 != zero) {
134 i19 = (const int8_t*) ((uintptr_t) i19 + input_offset);
135 }
136 const int8_t* i20 = input[20];
137 assert(i20 != NULL);
138 if XNN_UNPREDICTABLE(i20 != zero) {
139 i20 = (const int8_t*) ((uintptr_t) i20 + input_offset);
140 }
141 const int8_t* i21 = input[21];
142 assert(i21 != NULL);
143 if XNN_UNPREDICTABLE(i21 != zero) {
144 i21 = (const int8_t*) ((uintptr_t) i21 + input_offset);
145 }
146 const int8_t* i22 = input[22];
147 assert(i22 != NULL);
148 if XNN_UNPREDICTABLE(i22 != zero) {
149 i22 = (const int8_t*) ((uintptr_t) i22 + input_offset);
150 }
151 const int8_t* i23 = input[23];
152 assert(i23 != NULL);
153 if XNN_UNPREDICTABLE(i23 != zero) {
154 i23 = (const int8_t*) ((uintptr_t) i23 + input_offset);
155 }
156 const int8_t* i24 = input[24];
157 assert(i24 != NULL);
158 if XNN_UNPREDICTABLE(i24 != zero) {
159 i24 = (const int8_t*) ((uintptr_t) i24 + input_offset);
160 }
161 input = (const int8_t**) ((uintptr_t) input + input_stride);
162
163 size_t c = channels;
164 const void* w = weights;
165 do {
166 int32_t vacc = *((const int32_t*) w);
167
168 const int32_t vi0 = (int32_t) *i0++;
169 const int32_t vk0 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[0];
170 vacc += vi0 * vk0;
171 const int32_t vi1 = (int32_t) *i1++;
172 const int32_t vk1 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[1];
173 vacc += vi1 * vk1;
174 const int32_t vi2 = (int32_t) *i2++;
175 const int32_t vk2 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[2];
176 vacc += vi2 * vk2;
177 const int32_t vi3 = (int32_t) *i3++;
178 const int32_t vk3 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[3];
179 vacc += vi3 * vk3;
180 const int32_t vi4 = (int32_t) *i4++;
181 const int32_t vk4 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[4];
182 vacc += vi4 * vk4;
183 const int32_t vi5 = (int32_t) *i5++;
184 const int32_t vk5 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[5];
185 vacc += vi5 * vk5;
186 const int32_t vi6 = (int32_t) *i6++;
187 const int32_t vk6 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[6];
188 vacc += vi6 * vk6;
189 const int32_t vi7 = (int32_t) *i7++;
190 const int32_t vk7 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[7];
191 vacc += vi7 * vk7;
192 const int32_t vi8 = (int32_t) *i8++;
193 const int32_t vk8 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[8];
194 vacc += vi8 * vk8;
195 const int32_t vi9 = (int32_t) *i9++;
196 const int32_t vk9 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[9];
197 vacc += vi9 * vk9;
198 const int32_t vi10 = (int32_t) *i10++;
199 const int32_t vk10 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[10];
200 vacc += vi10 * vk10;
201 const int32_t vi11 = (int32_t) *i11++;
202 const int32_t vk11 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[11];
203 vacc += vi11 * vk11;
204 const int32_t vi12 = (int32_t) *i12++;
205 const int32_t vk12 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[12];
206 vacc += vi12 * vk12;
207 const int32_t vi13 = (int32_t) *i13++;
208 const int32_t vk13 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[13];
209 vacc += vi13 * vk13;
210 const int32_t vi14 = (int32_t) *i14++;
211 const int32_t vk14 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[14];
212 vacc += vi14 * vk14;
213 const int32_t vi15 = (int32_t) *i15++;
214 const int32_t vk15 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[15];
215 vacc += vi15 * vk15;
216 const int32_t vi16 = (int32_t) *i16++;
217 const int32_t vk16 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[16];
218 vacc += vi16 * vk16;
219 const int32_t vi17 = (int32_t) *i17++;
220 const int32_t vk17 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[17];
221 vacc += vi17 * vk17;
222 const int32_t vi18 = (int32_t) *i18++;
223 const int32_t vk18 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[18];
224 vacc += vi18 * vk18;
225 const int32_t vi19 = (int32_t) *i19++;
226 const int32_t vk19 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[19];
227 vacc += vi19 * vk19;
228 const int32_t vi20 = (int32_t) *i20++;
229 const int32_t vk20 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[20];
230 vacc += vi20 * vk20;
231 const int32_t vi21 = (int32_t) *i21++;
232 const int32_t vk21 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[21];
233 vacc += vi21 * vk21;
234 const int32_t vi22 = (int32_t) *i22++;
235 const int32_t vk22 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[22];
236 vacc += vi22 * vk22;
237 const int32_t vi23 = (int32_t) *i23++;
238 const int32_t vk23 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[23];
239 vacc += vi23 * vk23;
240 const int32_t vi24 = (int32_t) *i24++;
241 const int32_t vk24 = ((const int8_t*) ((uintptr_t) w + sizeof(int32_t)))[24];
242 vacc += vi24 * vk24;
243
244 w = (const void*) ((uintptr_t) w + sizeof(int32_t) + 25 * sizeof(int8_t));
245
246 typedef XNN_UNALIGNED float unaligned_float;
247 const float vscale = *((const unaligned_float*) w);
248 w = (const void*) ((const float*) w + 1);
249 float vfpacc = (float) vacc * vscale;
250
251 vfpacc = math_max_f32(vfpacc, voutput_min_less_zero_point);
252 vfpacc = math_min_f32(vfpacc, voutput_max_less_zero_point);
253 const int32_t vrndacc = (int32_t) lrintf(vfpacc);
254 int32_t vout = vrndacc + voutput_zero_point;
255
256 *output++ = (int8_t) vout;
257 } while (--c != 0);
258
259 output = (int8_t*) ((uintptr_t) output + output_increment);
260 } while (--output_width != 0);
261 }
262