Debian Codegraph @

src/x8-packw/gen/x8-packw-x32-gemm-goi-scalar-u4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/x8-packw/scalar.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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
11 #include <assert.h>
12 #include <stddef.h>
13 #include <stdint.h>
14
15 #include "xnnpack/math.h"
16 #include "xnnpack/packw.h"
17 #include "xnnpack/unaligned.h"
18
19 void xnn_x8_packw_gemm_goi_ukernel_x32__scalar_u4(
20 size_t g,
21 size_t nc,
22 size_t kc,
23 size_t nr,
24 size_t kr,
25 size_t sr,
26 const int8_t* weights,
27 const uint32_t* bias,
28 const void* scale,
29 int8_t* packed_weights,
30 size_t extra_bytes,
31 const void* params)
32 {
33 assert(g != 0);
34 assert(nc != 0);
35 assert(kc != 0);
36 assert(nr == 32); // This kernel is for NR=32
37 assert(kr == 1);
38 assert(sr == 1);
39 assert(weights != NULL);
40 assert(packed_weights != NULL);
41
42 int8_t* out = (int8_t*) packed_weights;
43 const uint32_t* b = (const uint32_t*) bias;
44
45 do {
46 // NC main loop multiple of 32
47 const int8_t* w0 = (const int8_t*) weights;
48 size_t n = nc;
49 for (;n >= 32; n -= 32) {
50 if XNN_LIKELY(b != NULL) {
51 unaligned_store_s32(out + 0 * sizeof(int32_t), b[0]);
52 unaligned_store_s32(out + 1 * sizeof(int32_t), b[1]);
53 unaligned_store_s32(out + 2 * sizeof(int32_t), b[2]);
54 unaligned_store_s32(out + 3 * sizeof(int32_t), b[3]);
55 unaligned_store_s32(out + 4 * sizeof(int32_t), b[4]);
56 unaligned_store_s32(out + 5 * sizeof(int32_t), b[5]);
57 unaligned_store_s32(out + 6 * sizeof(int32_t), b[6]);
58 unaligned_store_s32(out + 7 * sizeof(int32_t), b[7]);
59 unaligned_store_s32(out + 8 * sizeof(int32_t), b[8]);
60 unaligned_store_s32(out + 9 * sizeof(int32_t), b[9]);
61 unaligned_store_s32(out + 10 * sizeof(int32_t), b[10]);
62 unaligned_store_s32(out + 11 * sizeof(int32_t), b[11]);
63 unaligned_store_s32(out + 12 * sizeof(int32_t), b[12]);
64 unaligned_store_s32(out + 13 * sizeof(int32_t), b[13]);
65 unaligned_store_s32(out + 14 * sizeof(int32_t), b[14]);
66 unaligned_store_s32(out + 15 * sizeof(int32_t), b[15]);
67 unaligned_store_s32(out + 16 * sizeof(int32_t), b[16]);
68 unaligned_store_s32(out + 17 * sizeof(int32_t), b[17]);
69 unaligned_store_s32(out + 18 * sizeof(int32_t), b[18]);
70 unaligned_store_s32(out + 19 * sizeof(int32_t), b[19]);
71 unaligned_store_s32(out + 20 * sizeof(int32_t), b[20]);
72 unaligned_store_s32(out + 21 * sizeof(int32_t), b[21]);
73 unaligned_store_s32(out + 22 * sizeof(int32_t), b[22]);
74 unaligned_store_s32(out + 23 * sizeof(int32_t), b[23]);
75 unaligned_store_s32(out + 24 * sizeof(int32_t), b[24]);
76 unaligned_store_s32(out + 25 * sizeof(int32_t), b[25]);
77 unaligned_store_s32(out + 26 * sizeof(int32_t), b[26]);
78 unaligned_store_s32(out + 27 * sizeof(int32_t), b[27]);
79 unaligned_store_s32(out + 28 * sizeof(int32_t), b[28]);
80 unaligned_store_s32(out + 29 * sizeof(int32_t), b[29]);
81 unaligned_store_s32(out + 30 * sizeof(int32_t), b[30]);
82 unaligned_store_s32(out + 31 * sizeof(int32_t), b[31]);
83 b += 32;
84 } else {
85 unaligned_store_s32(out + 0 * sizeof(int32_t), 0);
86 unaligned_store_s32(out + 1 * sizeof(int32_t), 0);
87 unaligned_store_s32(out + 2 * sizeof(int32_t), 0);
88 unaligned_store_s32(out + 3 * sizeof(int32_t), 0);
89 unaligned_store_s32(out + 4 * sizeof(int32_t), 0);
90 unaligned_store_s32(out + 5 * sizeof(int32_t), 0);
91 unaligned_store_s32(out + 6 * sizeof(int32_t), 0);
92 unaligned_store_s32(out + 7 * sizeof(int32_t), 0);
93 unaligned_store_s32(out + 8 * sizeof(int32_t), 0);
94 unaligned_store_s32(out + 9 * sizeof(int32_t), 0);
95 unaligned_store_s32(out + 10 * sizeof(int32_t), 0);
96 unaligned_store_s32(out + 11 * sizeof(int32_t), 0);
97 unaligned_store_s32(out + 12 * sizeof(int32_t), 0);
98 unaligned_store_s32(out + 13 * sizeof(int32_t), 0);
99 unaligned_store_s32(out + 14 * sizeof(int32_t), 0);
100 unaligned_store_s32(out + 15 * sizeof(int32_t), 0);
101 unaligned_store_s32(out + 16 * sizeof(int32_t), 0);
102 unaligned_store_s32(out + 17 * sizeof(int32_t), 0);
103 unaligned_store_s32(out + 18 * sizeof(int32_t), 0);
104 unaligned_store_s32(out + 19 * sizeof(int32_t), 0);
105 unaligned_store_s32(out + 20 * sizeof(int32_t), 0);
106 unaligned_store_s32(out + 21 * sizeof(int32_t), 0);
107 unaligned_store_s32(out + 22 * sizeof(int32_t), 0);
108 unaligned_store_s32(out + 23 * sizeof(int32_t), 0);
109 unaligned_store_s32(out + 24 * sizeof(int32_t), 0);
110 unaligned_store_s32(out + 25 * sizeof(int32_t), 0);
111 unaligned_store_s32(out + 26 * sizeof(int32_t), 0);
112 unaligned_store_s32(out + 27 * sizeof(int32_t), 0);
113 unaligned_store_s32(out + 28 * sizeof(int32_t), 0);
114 unaligned_store_s32(out + 29 * sizeof(int32_t), 0);
115 unaligned_store_s32(out + 30 * sizeof(int32_t), 0);
116 unaligned_store_s32(out + 31 * sizeof(int32_t), 0);
117 }
118 out += 32 * sizeof(uint32_t);
119
120 const int8_t* w1 = w0 + kc;
121 const int8_t* w2 = w1 + kc;
122 const int8_t* w3 = w2 + kc;
123 const int8_t* w4 = w3 + kc;
124 const int8_t* w5 = w4 + kc;
125 const int8_t* w6 = w5 + kc;
126 const int8_t* w7 = w6 + kc;
127 const int8_t* w8 = w7 + kc;
128 const int8_t* w9 = w8 + kc;
129 const int8_t* w10 = w9 + kc;
130 const int8_t* w11 = w10 + kc;
131 const int8_t* w12 = w11 + kc;
132 const int8_t* w13 = w12 + kc;
133 const int8_t* w14 = w13 + kc;
134 const int8_t* w15 = w14 + kc;
135 const int8_t* w16 = w15 + kc;
136 const int8_t* w17 = w16 + kc;
137 const int8_t* w18 = w17 + kc;
138 const int8_t* w19 = w18 + kc;
139 const int8_t* w20 = w19 + kc;
140 const int8_t* w21 = w20 + kc;
141 const int8_t* w22 = w21 + kc;
142 const int8_t* w23 = w22 + kc;
143 const int8_t* w24 = w23 + kc;
144 const int8_t* w25 = w24 + kc;
145 const int8_t* w26 = w25 + kc;
146 const int8_t* w27 = w26 + kc;
147 const int8_t* w28 = w27 + kc;
148 const int8_t* w29 = w28 + kc;
149 const int8_t* w30 = w29 + kc;
150 const int8_t* w31 = w30 + kc;
151
152 // KC main loop multiple of 32x4
153 size_t k = kc;
154 for (; k >= 4; k -= 4) {
155 const int8_t v00 = w0[0];
156 const int8_t v01 = w0[1];
157 const int8_t v02 = w0[2];
158 const int8_t v03 = w0[3];
159 w0 += 4;
160 const int8_t v10 = w1[0];
161 const int8_t v11 = w1[1];
162 const int8_t v12 = w1[2];
163 const int8_t v13 = w1[3];
164 w1 += 4;
165 const int8_t v20 = w2[0];
166 const int8_t v21 = w2[1];
167 const int8_t v22 = w2[2];
168 const int8_t v23 = w2[3];
169 w2 += 4;
170 const int8_t v30 = w3[0];
171 const int8_t v31 = w3[1];
172 const int8_t v32 = w3[2];
173 const int8_t v33 = w3[3];
174 w3 += 4;
175 const int8_t v40 = w4[0];
176 const int8_t v41 = w4[1];
177 const int8_t v42 = w4[2];
178 const int8_t v43 = w4[3];
179 w4 += 4;
180 const int8_t v50 = w5[0];
181 const int8_t v51 = w5[1];
182 const int8_t v52 = w5[2];
183 const int8_t v53 = w5[3];
184 w5 += 4;
185 const int8_t v60 = w6[0];
186 const int8_t v61 = w6[1];
187 const int8_t v62 = w6[2];
188 const int8_t v63 = w6[3];
189 w6 += 4;
190 const int8_t v70 = w7[0];
191 const int8_t v71 = w7[1];
192 const int8_t v72 = w7[2];
193 const int8_t v73 = w7[3];
194 w7 += 4;
195 const int8_t v80 = w8[0];
196 const int8_t v81 = w8[1];
197 const int8_t v82 = w8[2];
198 const int8_t v83 = w8[3];
199 w8 += 4;
200 const int8_t v90 = w9[0];
201 const int8_t v91 = w9[1];
202 const int8_t v92 = w9[2];
203 const int8_t v93 = w9[3];
204 w9 += 4;
205 const int8_t v100 = w10[0];
206 const int8_t v101 = w10[1];
207 const int8_t v102 = w10[2];
208 const int8_t v103 = w10[3];
209 w10 += 4;
210 const int8_t v110 = w11[0];
211 const int8_t v111 = w11[1];
212 const int8_t v112 = w11[2];
213 const int8_t v113 = w11[3];
214 w11 += 4;
215 const int8_t v120 = w12[0];
216 const int8_t v121 = w12[1];
217 const int8_t v122 = w12[2];
218 const int8_t v123 = w12[3];
219 w12 += 4;
220 const int8_t v130 = w13[0];
221 const int8_t v131 = w13[1];
222 const int8_t v132 = w13[2];
223 const int8_t v133 = w13[3];
224 w13 += 4;
225 const int8_t v140 = w14[0];
226 const int8_t v141 = w14[1];
227 const int8_t v142 = w14[2];
228 const int8_t v143 = w14[3];
229 w14 += 4;
230 const int8_t v150 = w15[0];
231 const int8_t v151 = w15[1];
232 const int8_t v152 = w15[2];
233 const int8_t v153 = w15[3];
234 w15 += 4;
235 const int8_t v160 = w16[0];
236 const int8_t v161 = w16[1];
237 const int8_t v162 = w16[2];
238 const int8_t v163 = w16[3];
239 w16 += 4;
240 const int8_t v170 = w17[0];
241 const int8_t v171 = w17[1];
242 const int8_t v172 = w17[2];
243 const int8_t v173 = w17[3];
244 w17 += 4;
245 const int8_t v180 = w18[0];
246 const int8_t v181 = w18[1];
247 const int8_t v182 = w18[2];
248 const int8_t v183 = w18[3];
249 w18 += 4;
250 const int8_t v190 = w19[0];
251 const int8_t v191 = w19[1];
252 const int8_t v192 = w19[2];
253 const int8_t v193 = w19[3];
254 w19 += 4;
255 const int8_t v200 = w20[0];
256 const int8_t v201 = w20[1];
257 const int8_t v202 = w20[2];
258 const int8_t v203 = w20[3];
259 w20 += 4;
260 const int8_t v210 = w21[0];
261 const int8_t v211 = w21[1];
262 const int8_t v212 = w21[2];
263 const int8_t v213 = w21[3];
264 w21 += 4;
265 const int8_t v220 = w22[0];
266 const int8_t v221 = w22[1];
267 const int8_t v222 = w22[2];
268 const int8_t v223 = w22[3];
269 w22 += 4;
270 const int8_t v230 = w23[0];
271 const int8_t v231 = w23[1];
272 const int8_t v232 = w23[2];
273 const int8_t v233 = w23[3];
274 w23 += 4;
275 const int8_t v240 = w24[0];
276 const int8_t v241 = w24[1];
277 const int8_t v242 = w24[2];
278 const int8_t v243 = w24[3];
279 w24 += 4;
280 const int8_t v250 = w25[0];
281 const int8_t v251 = w25[1];
282 const int8_t v252 = w25[2];
283 const int8_t v253 = w25[3];
284 w25 += 4;
285 const int8_t v260 = w26[0];
286 const int8_t v261 = w26[1];
287 const int8_t v262 = w26[2];
288 const int8_t v263 = w26[3];
289 w26 += 4;
290 const int8_t v270 = w27[0];
291 const int8_t v271 = w27[1];
292 const int8_t v272 = w27[2];
293 const int8_t v273 = w27[3];
294 w27 += 4;
295 const int8_t v280 = w28[0];
296 const int8_t v281 = w28[1];
297 const int8_t v282 = w28[2];
298 const int8_t v283 = w28[3];
299 w28 += 4;
300 const int8_t v290 = w29[0];
301 const int8_t v291 = w29[1];
302 const int8_t v292 = w29[2];
303 const int8_t v293 = w29[3];
304 w29 += 4;
305 const int8_t v300 = w30[0];
306 const int8_t v301 = w30[1];
307 const int8_t v302 = w30[2];
308 const int8_t v303 = w30[3];
309 w30 += 4;
310 const int8_t v310 = w31[0];
311 const int8_t v311 = w31[1];
312 const int8_t v312 = w31[2];
313 const int8_t v313 = w31[3];
314 w31 += 4;
315 out[0] = v00;
316 out[1] = v10;
317 out[2] = v20;
318 out[3] = v30;
319 out[4] = v40;
320 out[5] = v50;
321 out[6] = v60;
322 out[7] = v70;
323 out[8] = v80;
324 out[9] = v90;
325 out[10] = v100;
326 out[11] = v110;
327 out[12] = v120;
328 out[13] = v130;
329 out[14] = v140;
330 out[15] = v150;
331 out[16] = v160;
332 out[17] = v170;
333 out[18] = v180;
334 out[19] = v190;
335 out[20] = v200;
336 out[21] = v210;
337 out[22] = v220;
338 out[23] = v230;
339 out[24] = v240;
340 out[25] = v250;
341 out[26] = v260;
342 out[27] = v270;
343 out[28] = v280;
344 out[29] = v290;
345 out[30] = v300;
346 out[31] = v310;
347 out[32] = v01;
348 out[33] = v11;
349 out[34] = v21;
350 out[35] = v31;
351 out[36] = v41;
352 out[37] = v51;
353 out[38] = v61;
354 out[39] = v71;
355 out[40] = v81;
356 out[41] = v91;
357 out[42] = v101;
358 out[43] = v111;
359 out[44] = v121;
360 out[45] = v131;
361 out[46] = v141;
362 out[47] = v151;
363 out[48] = v161;
364 out[49] = v171;
365 out[50] = v181;
366 out[51] = v191;
367 out[52] = v201;
368 out[53] = v211;
369 out[54] = v221;
370 out[55] = v231;
371 out[56] = v241;
372 out[57] = v251;
373 out[58] = v261;
374 out[59] = v271;
375 out[60] = v281;
376 out[61] = v291;
377 out[62] = v301;
378 out[63] = v311;
379 out[64] = v02;
380 out[65] = v12;
381 out[66] = v22;
382 out[67] = v32;
383 out[68] = v42;
384 out[69] = v52;
385 out[70] = v62;
386 out[71] = v72;
387 out[72] = v82;
388 out[73] = v92;
389 out[74] = v102;
390 out[75] = v112;
391 out[76] = v122;
392 out[77] = v132;
393 out[78] = v142;
394 out[79] = v152;
395 out[80] = v162;
396 out[81] = v172;
397 out[82] = v182;
398 out[83] = v192;
399 out[84] = v202;
400 out[85] = v212;
401 out[86] = v222;
402 out[87] = v232;
403 out[88] = v242;
404 out[89] = v252;
405 out[90] = v262;
406 out[91] = v272;
407 out[92] = v282;
408 out[93] = v292;
409 out[94] = v302;
410 out[95] = v312;
411 out[96] = v03;
412 out[97] = v13;
413 out[98] = v23;
414 out[99] = v33;
415 out[100] = v43;
416 out[101] = v53;
417 out[102] = v63;
418 out[103] = v73;
419 out[104] = v83;
420 out[105] = v93;
421 out[106] = v103;
422 out[107] = v113;
423 out[108] = v123;
424 out[109] = v133;
425 out[110] = v143;
426 out[111] = v153;
427 out[112] = v163;
428 out[113] = v173;
429 out[114] = v183;
430 out[115] = v193;
431 out[116] = v203;
432 out[117] = v213;
433 out[118] = v223;
434 out[119] = v233;
435 out[120] = v243;
436 out[121] = v253;
437 out[122] = v263;
438 out[123] = v273;
439 out[124] = v283;
440 out[125] = v293;
441 out[126] = v303;
442 out[127] = v313;
443 out += 128;
444 }
445
446 // KC remainder
447 for (; k != 0; --k) {
448 const int8_t v0 = *w0++;
449 out[0] = v0;
450 const int8_t v1 = *w1++;
451 out[1] = v1;
452 const int8_t v2 = *w2++;
453 out[2] = v2;
454 const int8_t v3 = *w3++;
455 out[3] = v3;
456 const int8_t v4 = *w4++;
457 out[4] = v4;
458 const int8_t v5 = *w5++;
459 out[5] = v5;
460 const int8_t v6 = *w6++;
461 out[6] = v6;
462 const int8_t v7 = *w7++;
463 out[7] = v7;
464 const int8_t v8 = *w8++;
465 out[8] = v8;
466 const int8_t v9 = *w9++;
467 out[9] = v9;
468 const int8_t v10 = *w10++;
469 out[10] = v10;
470 const int8_t v11 = *w11++;
471 out[11] = v11;
472 const int8_t v12 = *w12++;
473 out[12] = v12;
474 const int8_t v13 = *w13++;
475 out[13] = v13;
476 const int8_t v14 = *w14++;
477 out[14] = v14;
478 const int8_t v15 = *w15++;
479 out[15] = v15;
480 const int8_t v16 = *w16++;
481 out[16] = v16;
482 const int8_t v17 = *w17++;
483 out[17] = v17;
484 const int8_t v18 = *w18++;
485 out[18] = v18;
486 const int8_t v19 = *w19++;
487 out[19] = v19;
488 const int8_t v20 = *w20++;
489 out[20] = v20;
490 const int8_t v21 = *w21++;
491 out[21] = v21;
492 const int8_t v22 = *w22++;
493 out[22] = v22;
494 const int8_t v23 = *w23++;
495 out[23] = v23;
496 const int8_t v24 = *w24++;
497 out[24] = v24;
498 const int8_t v25 = *w25++;
499 out[25] = v25;
500 const int8_t v26 = *w26++;
501 out[26] = v26;
502 const int8_t v27 = *w27++;
503 out[27] = v27;
504 const int8_t v28 = *w28++;
505 out[28] = v28;
506 const int8_t v29 = *w29++;
507 out[29] = v29;
508 const int8_t v30 = *w30++;
509 out[30] = v30;
510 const int8_t v31 = *w31++;
511 out[31] = v31;
512 out += 32;
513 }
514 out = (int8_t*) ((uintptr_t) out + extra_bytes);
515 w0 = w31;
516 }
517
518 // NC remainder (1..31)
519 if XNN_UNLIKELY(n != 0) {
520 if XNN_LIKELY(b != NULL) {
521 size_t nb = n;
522 do {
523 unaligned_store_s32(out, *b++);
524 out += sizeof(uint32_t);
525 } while (--nb != 0);
526 } else {
527 size_t nb = n;
528 do {
529 unaligned_store_s32(out, 0);
530 out += sizeof(uint32_t);
531 } while (--nb != 0);
532 }
533 out += (32 - n) * sizeof(uint32_t);
534
535 // NR remainder has less than 32 rows so last row is not loaded
536 const int8_t* w1 = w0 + kc;
537 if XNN_UNPREDICTABLE(n < 2) {
538 w1 = w0;
539 }
540 const int8_t* w2 = w1 + kc;
541 if XNN_UNPREDICTABLE(n <= 2) {
542 w2 = w1;
543 }
544 const int8_t* w3 = w2 + kc;
545 if XNN_UNPREDICTABLE(n < 4) {
546 w3 = w2;
547 }
548 const int8_t* w4 = w3 + kc;
549 if XNN_UNPREDICTABLE(n <= 4) {
550 w4 = w3;
551 }
552 const int8_t* w5 = w4 + kc;
553 if XNN_UNPREDICTABLE(n < 6) {
554 w5 = w4;
555 }
556 const int8_t* w6 = w5 + kc;
557 if XNN_UNPREDICTABLE(n <= 6) {
558 w6 = w5;
559 }
560 const int8_t* w7 = w6 + kc;
561 if XNN_UNPREDICTABLE(n < 8) {
562 w7 = w6;
563 }
564 const int8_t* w8 = w7 + kc;
565 if XNN_UNPREDICTABLE(n <= 8) {
566 w8 = w7;
567 }
568 const int8_t* w9 = w8 + kc;
569 if XNN_UNPREDICTABLE(n < 10) {
570 w9 = w8;
571 }
572 const int8_t* w10 = w9 + kc;
573 if XNN_UNPREDICTABLE(n <= 10) {
574 w10 = w9;
575 }
576 const int8_t* w11 = w10 + kc;
577 if XNN_UNPREDICTABLE(n < 12) {
578 w11 = w10;
579 }
580 const int8_t* w12 = w11 + kc;
581 if XNN_UNPREDICTABLE(n <= 12) {
582 w12 = w11;
583 }
584 const int8_t* w13 = w12 + kc;
585 if XNN_UNPREDICTABLE(n < 14) {
586 w13 = w12;
587 }
588 const int8_t* w14 = w13 + kc;
589 if XNN_UNPREDICTABLE(n <= 14) {
590 w14 = w13;
591 }
592 const int8_t* w15 = w14 + kc;
593 if XNN_UNPREDICTABLE(n < 16) {
594 w15 = w14;
595 }
596 const int8_t* w16 = w15 + kc;
597 if XNN_UNPREDICTABLE(n <= 16) {
598 w16 = w15;
599 }
600 const int8_t* w17 = w16 + kc;
601 if XNN_UNPREDICTABLE(n < 18) {
602 w17 = w16;
603 }
604 const int8_t* w18 = w17 + kc;
605 if XNN_UNPREDICTABLE(n <= 18) {
606 w18 = w17;
607 }
608 const int8_t* w19 = w18 + kc;
609 if XNN_UNPREDICTABLE(n < 20) {
610 w19 = w18;
611 }
612 const int8_t* w20 = w19 + kc;
613 if XNN_UNPREDICTABLE(n <= 20) {
614 w20 = w19;
615 }
616 const int8_t* w21 = w20 + kc;
617 if XNN_UNPREDICTABLE(n < 22) {
618 w21 = w20;
619 }
620 const int8_t* w22 = w21 + kc;
621 if XNN_UNPREDICTABLE(n <= 22) {
622 w22 = w21;
623 }
624 const int8_t* w23 = w22 + kc;
625 if XNN_UNPREDICTABLE(n < 24) {
626 w23 = w22;
627 }
628 const int8_t* w24 = w23 + kc;
629 if XNN_UNPREDICTABLE(n <= 24) {
630 w24 = w23;
631 }
632 const int8_t* w25 = w24 + kc;
633 if XNN_UNPREDICTABLE(n < 26) {
634 w25 = w24;
635 }
636 const int8_t* w26 = w25 + kc;
637 if XNN_UNPREDICTABLE(n <= 26) {
638 w26 = w25;
639 }
640 const int8_t* w27 = w26 + kc;
641 if XNN_UNPREDICTABLE(n < 28) {
642 w27 = w26;
643 }
644 const int8_t* w28 = w27 + kc;
645 if XNN_UNPREDICTABLE(n <= 28) {
646 w28 = w27;
647 }
648 const int8_t* w29 = w28 + kc;
649 if XNN_UNPREDICTABLE(n < 30) {
650 w29 = w28;
651 }
652 const int8_t* w30 = w29 + kc;
653 if XNN_UNPREDICTABLE(n <= 30) {
654 w30 = w29;
655 }
656
657 // KC main loop multiple of 32x4
658 size_t k = kc;
659 for (; k >= 4; k -= 4) {
660 const int8_t v00 = w0[0];
661 const int8_t v01 = w0[1];
662 const int8_t v02 = w0[2];
663 const int8_t v03 = w0[3];
664 w0 += 4;
665 const int8_t v10 = w1[0];
666 const int8_t v11 = w1[1];
667 const int8_t v12 = w1[2];
668 const int8_t v13 = w1[3];
669 w1 += 4;
670 const int8_t v20 = w2[0];
671 const int8_t v21 = w2[1];
672 const int8_t v22 = w2[2];
673 const int8_t v23 = w2[3];
674 w2 += 4;
675 const int8_t v30 = w3[0];
676 const int8_t v31 = w3[1];
677 const int8_t v32 = w3[2];
678 const int8_t v33 = w3[3];
679 w3 += 4;
680 const int8_t v40 = w4[0];
681 const int8_t v41 = w4[1];
682 const int8_t v42 = w4[2];
683 const int8_t v43 = w4[3];
684 w4 += 4;
685 const int8_t v50 = w5[0];
686 const int8_t v51 = w5[1];
687 const int8_t v52 = w5[2];
688 const int8_t v53 = w5[3];
689 w5 += 4;
690 const int8_t v60 = w6[0];
691 const int8_t v61 = w6[1];
692 const int8_t v62 = w6[2];
693 const int8_t v63 = w6[3];
694 w6 += 4;
695 const int8_t v70 = w7[0];
696 const int8_t v71 = w7[1];
697 const int8_t v72 = w7[2];
698 const int8_t v73 = w7[3];
699 w7 += 4;
700 const int8_t v80 = w8[0];
701 const int8_t v81 = w8[1];
702 const int8_t v82 = w8[2];
703 const int8_t v83 = w8[3];
704 w8 += 4;
705 const int8_t v90 = w9[0];
706 const int8_t v91 = w9[1];
707 const int8_t v92 = w9[2];
708 const int8_t v93 = w9[3];
709 w9 += 4;
710 const int8_t v100 = w10[0];
711 const int8_t v101 = w10[1];
712 const int8_t v102 = w10[2];
713 const int8_t v103 = w10[3];
714 w10 += 4;
715 const int8_t v110 = w11[0];
716 const int8_t v111 = w11[1];
717 const int8_t v112 = w11[2];
718 const int8_t v113 = w11[3];
719 w11 += 4;
720 const int8_t v120 = w12[0];
721 const int8_t v121 = w12[1];
722 const int8_t v122 = w12[2];
723 const int8_t v123 = w12[3];
724 w12 += 4;
725 const int8_t v130 = w13[0];
726 const int8_t v131 = w13[1];
727 const int8_t v132 = w13[2];
728 const int8_t v133 = w13[3];
729 w13 += 4;
730 const int8_t v140 = w14[0];
731 const int8_t v141 = w14[1];
732 const int8_t v142 = w14[2];
733 const int8_t v143 = w14[3];
734 w14 += 4;
735 const int8_t v150 = w15[0];
736 const int8_t v151 = w15[1];
737 const int8_t v152 = w15[2];
738 const int8_t v153 = w15[3];
739 w15 += 4;
740 const int8_t v160 = w16[0];
741 const int8_t v161 = w16[1];
742 const int8_t v162 = w16[2];
743 const int8_t v163 = w16[3];
744 w16 += 4;
745 const int8_t v170 = w17[0];
746 const int8_t v171 = w17[1];
747 const int8_t v172 = w17[2];
748 const int8_t v173 = w17[3];
749 w17 += 4;
750 const int8_t v180 = w18[0];
751 const int8_t v181 = w18[1];
752 const int8_t v182 = w18[2];
753 const int8_t v183 = w18[3];
754 w18 += 4;
755 const int8_t v190 = w19[0];
756 const int8_t v191 = w19[1];
757 const int8_t v192 = w19[2];
758 const int8_t v193 = w19[3];
759 w19 += 4;
760 const int8_t v200 = w20[0];
761 const int8_t v201 = w20[1];
762 const int8_t v202 = w20[2];
763 const int8_t v203 = w20[3];
764 w20 += 4;
765 const int8_t v210 = w21[0];
766 const int8_t v211 = w21[1];
767 const int8_t v212 = w21[2];
768 const int8_t v213 = w21[3];
769 w21 += 4;
770 const int8_t v220 = w22[0];
771 const int8_t v221 = w22[1];
772 const int8_t v222 = w22[2];
773 const int8_t v223 = w22[3];
774 w22 += 4;
775 const int8_t v230 = w23[0];
776 const int8_t v231 = w23[1];
777 const int8_t v232 = w23[2];
778 const int8_t v233 = w23[3];
779 w23 += 4;
780 const int8_t v240 = w24[0];
781 const int8_t v241 = w24[1];
782 const int8_t v242 = w24[2];
783 const int8_t v243 = w24[3];
784 w24 += 4;
785 const int8_t v250 = w25[0];
786 const int8_t v251 = w25[1];
787 const int8_t v252 = w25[2];
788 const int8_t v253 = w25[3];
789 w25 += 4;
790 const int8_t v260 = w26[0];
791 const int8_t v261 = w26[1];
792 const int8_t v262 = w26[2];
793 const int8_t v263 = w26[3];
794 w26 += 4;
795 const int8_t v270 = w27[0];
796 const int8_t v271 = w27[1];
797 const int8_t v272 = w27[2];
798 const int8_t v273 = w27[3];
799 w27 += 4;
800 const int8_t v280 = w28[0];
801 const int8_t v281 = w28[1];
802 const int8_t v282 = w28[2];
803 const int8_t v283 = w28[3];
804 w28 += 4;
805 const int8_t v290 = w29[0];
806 const int8_t v291 = w29[1];
807 const int8_t v292 = w29[2];
808 const int8_t v293 = w29[3];
809 w29 += 4;
810 const int8_t v300 = w30[0];
811 const int8_t v301 = w30[1];
812 const int8_t v302 = w30[2];
813 const int8_t v303 = w30[3];
814 w30 += 4;
815 out[0] = v00;
816 out[1] = v10;
817 out[2] = v20;
818 out[3] = v30;
819 out[4] = v40;
820 out[5] = v50;
821 out[6] = v60;
822 out[7] = v70;
823 out[8] = v80;
824 out[9] = v90;
825 out[10] = v100;
826 out[11] = v110;
827 out[12] = v120;
828 out[13] = v130;
829 out[14] = v140;
830 out[15] = v150;
831 out[16] = v160;
832 out[17] = v170;
833 out[18] = v180;
834 out[19] = v190;
835 out[20] = v200;
836 out[21] = v210;
837 out[22] = v220;
838 out[23] = v230;
839 out[24] = v240;
840 out[25] = v250;
841 out[26] = v260;
842 out[27] = v270;
843 out[28] = v280;
844 out[29] = v290;
845 out[30] = v300;
846 out[32] = v01;
847 out[33] = v11;
848 out[34] = v21;
849 out[35] = v31;
850 out[36] = v41;
851 out[37] = v51;
852 out[38] = v61;
853 out[39] = v71;
854 out[40] = v81;
855 out[41] = v91;
856 out[42] = v101;
857 out[43] = v111;
858 out[44] = v121;
859 out[45] = v131;
860 out[46] = v141;
861 out[47] = v151;
862 out[48] = v161;
863 out[49] = v171;
864 out[50] = v181;
865 out[51] = v191;
866 out[52] = v201;
867 out[53] = v211;
868 out[54] = v221;
869 out[55] = v231;
870 out[56] = v241;
871 out[57] = v251;
872 out[58] = v261;
873 out[59] = v271;
874 out[60] = v281;
875 out[61] = v291;
876 out[62] = v301;
877 out[64] = v02;
878 out[65] = v12;
879 out[66] = v22;
880 out[67] = v32;
881 out[68] = v42;
882 out[69] = v52;
883 out[70] = v62;
884 out[71] = v72;
885 out[72] = v82;
886 out[73] = v92;
887 out[74] = v102;
888 out[75] = v112;
889 out[76] = v122;
890 out[77] = v132;
891 out[78] = v142;
892 out[79] = v152;
893 out[80] = v162;
894 out[81] = v172;
895 out[82] = v182;
896 out[83] = v192;
897 out[84] = v202;
898 out[85] = v212;
899 out[86] = v222;
900 out[87] = v232;
901 out[88] = v242;
902 out[89] = v252;
903 out[90] = v262;
904 out[91] = v272;
905 out[92] = v282;
906 out[93] = v292;
907 out[94] = v302;
908 out[96] = v03;
909 out[97] = v13;
910 out[98] = v23;
911 out[99] = v33;
912 out[100] = v43;
913 out[101] = v53;
914 out[102] = v63;
915 out[103] = v73;
916 out[104] = v83;
917 out[105] = v93;
918 out[106] = v103;
919 out[107] = v113;
920 out[108] = v123;
921 out[109] = v133;
922 out[110] = v143;
923 out[111] = v153;
924 out[112] = v163;
925 out[113] = v173;
926 out[114] = v183;
927 out[115] = v193;
928 out[116] = v203;
929 out[117] = v213;
930 out[118] = v223;
931 out[119] = v233;
932 out[120] = v243;
933 out[121] = v253;
934 out[122] = v263;
935 out[123] = v273;
936 out[124] = v283;
937 out[125] = v293;
938 out[126] = v303;
939 out += 128;
940 }
941
942 // KC remainder of 1..3
943 for (; k != 0; --k) {
944 const int8_t v0 = *w0++;
945 out[0] = v0;
946 const int8_t v1 = *w1++;
947 out[1] = v1;
948 const int8_t v2 = *w2++;
949 out[2] = v2;
950 const int8_t v3 = *w3++;
951 out[3] = v3;
952 const int8_t v4 = *w4++;
953 out[4] = v4;
954 const int8_t v5 = *w5++;
955 out[5] = v5;
956 const int8_t v6 = *w6++;
957 out[6] = v6;
958 const int8_t v7 = *w7++;
959 out[7] = v7;
960 const int8_t v8 = *w8++;
961 out[8] = v8;
962 const int8_t v9 = *w9++;
963 out[9] = v9;
964 const int8_t v10 = *w10++;
965 out[10] = v10;
966 const int8_t v11 = *w11++;
967 out[11] = v11;
968 const int8_t v12 = *w12++;
969 out[12] = v12;
970 const int8_t v13 = *w13++;
971 out[13] = v13;
972 const int8_t v14 = *w14++;
973 out[14] = v14;
974 const int8_t v15 = *w15++;
975 out[15] = v15;
976 const int8_t v16 = *w16++;
977 out[16] = v16;
978 const int8_t v17 = *w17++;
979 out[17] = v17;
980 const int8_t v18 = *w18++;
981 out[18] = v18;
982 const int8_t v19 = *w19++;
983 out[19] = v19;
984 const int8_t v20 = *w20++;
985 out[20] = v20;
986 const int8_t v21 = *w21++;
987 out[21] = v21;
988 const int8_t v22 = *w22++;
989 out[22] = v22;
990 const int8_t v23 = *w23++;
991 out[23] = v23;
992 const int8_t v24 = *w24++;
993 out[24] = v24;
994 const int8_t v25 = *w25++;
995 out[25] = v25;
996 const int8_t v26 = *w26++;
997 out[26] = v26;
998 const int8_t v27 = *w27++;
999 out[27] = v27;
1000 const int8_t v28 = *w28++;
1001 out[28] = v28;
1002 const int8_t v29 = *w29++;
1003 out[29] = v29;
1004 const int8_t v30 = *w30++;
1005 out[30] = v30;
1006 out += 32;
1007 }
1008 out = (int8_t*) ((uintptr_t) out + extra_bytes);
1009 }
1010 weights += nc * kc;
1011 } while (--g != 0);
1012 }