| 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_u2( |
| 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 32x2 |
| 153 |
size_t k = kc; |
| 154 |
for (; k >= 2; k -= 2) { |
| 155 |
const int8_t v00 = w0[0]; |
| 156 |
const int8_t v01 = w0[1]; |
| 157 |
w0 += 2; |
| 158 |
const int8_t v10 = w1[0]; |
| 159 |
const int8_t v11 = w1[1]; |
| 160 |
w1 += 2; |
| 161 |
const int8_t v20 = w2[0]; |
| 162 |
const int8_t v21 = w2[1]; |
| 163 |
w2 += 2; |
| 164 |
const int8_t v30 = w3[0]; |
| 165 |
const int8_t v31 = w3[1]; |
| 166 |
w3 += 2; |
| 167 |
const int8_t v40 = w4[0]; |
| 168 |
const int8_t v41 = w4[1]; |
| 169 |
w4 += 2; |
| 170 |
const int8_t v50 = w5[0]; |
| 171 |
const int8_t v51 = w5[1]; |
| 172 |
w5 += 2; |
| 173 |
const int8_t v60 = w6[0]; |
| 174 |
const int8_t v61 = w6[1]; |
| 175 |
w6 += 2; |
| 176 |
const int8_t v70 = w7[0]; |
| 177 |
const int8_t v71 = w7[1]; |
| 178 |
w7 += 2; |
| 179 |
const int8_t v80 = w8[0]; |
| 180 |
const int8_t v81 = w8[1]; |
| 181 |
w8 += 2; |
| 182 |
const int8_t v90 = w9[0]; |
| 183 |
const int8_t v91 = w9[1]; |
| 184 |
w9 += 2; |
| 185 |
const int8_t v100 = w10[0]; |
| 186 |
const int8_t v101 = w10[1]; |
| 187 |
w10 += 2; |
| 188 |
const int8_t v110 = w11[0]; |
| 189 |
const int8_t v111 = w11[1]; |
| 190 |
w11 += 2; |
| 191 |
const int8_t v120 = w12[0]; |
| 192 |
const int8_t v121 = w12[1]; |
| 193 |
w12 += 2; |
| 194 |
const int8_t v130 = w13[0]; |
| 195 |
const int8_t v131 = w13[1]; |
| 196 |
w13 += 2; |
| 197 |
const int8_t v140 = w14[0]; |
| 198 |
const int8_t v141 = w14[1]; |
| 199 |
w14 += 2; |
| 200 |
const int8_t v150 = w15[0]; |
| 201 |
const int8_t v151 = w15[1]; |
| 202 |
w15 += 2; |
| 203 |
const int8_t v160 = w16[0]; |
| 204 |
const int8_t v161 = w16[1]; |
| 205 |
w16 += 2; |
| 206 |
const int8_t v170 = w17[0]; |
| 207 |
const int8_t v171 = w17[1]; |
| 208 |
w17 += 2; |
| 209 |
const int8_t v180 = w18[0]; |
| 210 |
const int8_t v181 = w18[1]; |
| 211 |
w18 += 2; |
| 212 |
const int8_t v190 = w19[0]; |
| 213 |
const int8_t v191 = w19[1]; |
| 214 |
w19 += 2; |
| 215 |
const int8_t v200 = w20[0]; |
| 216 |
const int8_t v201 = w20[1]; |
| 217 |
w20 += 2; |
| 218 |
const int8_t v210 = w21[0]; |
| 219 |
const int8_t v211 = w21[1]; |
| 220 |
w21 += 2; |
| 221 |
const int8_t v220 = w22[0]; |
| 222 |
const int8_t v221 = w22[1]; |
| 223 |
w22 += 2; |
| 224 |
const int8_t v230 = w23[0]; |
| 225 |
const int8_t v231 = w23[1]; |
| 226 |
w23 += 2; |
| 227 |
const int8_t v240 = w24[0]; |
| 228 |
const int8_t v241 = w24[1]; |
| 229 |
w24 += 2; |
| 230 |
const int8_t v250 = w25[0]; |
| 231 |
const int8_t v251 = w25[1]; |
| 232 |
w25 += 2; |
| 233 |
const int8_t v260 = w26[0]; |
| 234 |
const int8_t v261 = w26[1]; |
| 235 |
w26 += 2; |
| 236 |
const int8_t v270 = w27[0]; |
| 237 |
const int8_t v271 = w27[1]; |
| 238 |
w27 += 2; |
| 239 |
const int8_t v280 = w28[0]; |
| 240 |
const int8_t v281 = w28[1]; |
| 241 |
w28 += 2; |
| 242 |
const int8_t v290 = w29[0]; |
| 243 |
const int8_t v291 = w29[1]; |
| 244 |
w29 += 2; |
| 245 |
const int8_t v300 = w30[0]; |
| 246 |
const int8_t v301 = w30[1]; |
| 247 |
w30 += 2; |
| 248 |
const int8_t v310 = w31[0]; |
| 249 |
const int8_t v311 = w31[1]; |
| 250 |
w31 += 2; |
| 251 |
out[0] = v00; |
| 252 |
out[1] = v10; |
| 253 |
out[2] = v20; |
| 254 |
out[3] = v30; |
| 255 |
out[4] = v40; |
| 256 |
out[5] = v50; |
| 257 |
out[6] = v60; |
| 258 |
out[7] = v70; |
| 259 |
out[8] = v80; |
| 260 |
out[9] = v90; |
| 261 |
out[10] = v100; |
| 262 |
out[11] = v110; |
| 263 |
out[12] = v120; |
| 264 |
out[13] = v130; |
| 265 |
out[14] = v140; |
| 266 |
out[15] = v150; |
| 267 |
out[16] = v160; |
| 268 |
out[17] = v170; |
| 269 |
out[18] = v180; |
| 270 |
out[19] = v190; |
| 271 |
out[20] = v200; |
| 272 |
out[21] = v210; |
| 273 |
out[22] = v220; |
| 274 |
out[23] = v230; |
| 275 |
out[24] = v240; |
| 276 |
out[25] = v250; |
| 277 |
out[26] = v260; |
| 278 |
out[27] = v270; |
| 279 |
out[28] = v280; |
| 280 |
out[29] = v290; |
| 281 |
out[30] = v300; |
| 282 |
out[31] = v310; |
| 283 |
out[32] = v01; |
| 284 |
out[33] = v11; |
| 285 |
out[34] = v21; |
| 286 |
out[35] = v31; |
| 287 |
out[36] = v41; |
| 288 |
out[37] = v51; |
| 289 |
out[38] = v61; |
| 290 |
out[39] = v71; |
| 291 |
out[40] = v81; |
| 292 |
out[41] = v91; |
| 293 |
out[42] = v101; |
| 294 |
out[43] = v111; |
| 295 |
out[44] = v121; |
| 296 |
out[45] = v131; |
| 297 |
out[46] = v141; |
| 298 |
out[47] = v151; |
| 299 |
out[48] = v161; |
| 300 |
out[49] = v171; |
| 301 |
out[50] = v181; |
| 302 |
out[51] = v191; |
| 303 |
out[52] = v201; |
| 304 |
out[53] = v211; |
| 305 |
out[54] = v221; |
| 306 |
out[55] = v231; |
| 307 |
out[56] = v241; |
| 308 |
out[57] = v251; |
| 309 |
out[58] = v261; |
| 310 |
out[59] = v271; |
| 311 |
out[60] = v281; |
| 312 |
out[61] = v291; |
| 313 |
out[62] = v301; |
| 314 |
out[63] = v311; |
| 315 |
out += 64; |
| 316 |
} |
| 317 |
|
| 318 |
// KC remainder |
| 319 |
for (; k != 0; --k) { |
| 320 |
const int8_t v0 = *w0++; |
| 321 |
out[0] = v0; |
| 322 |
const int8_t v1 = *w1++; |
| 323 |
out[1] = v1; |
| 324 |
const int8_t v2 = *w2++; |
| 325 |
out[2] = v2; |
| 326 |
const int8_t v3 = *w3++; |
| 327 |
out[3] = v3; |
| 328 |
const int8_t v4 = *w4++; |
| 329 |
out[4] = v4; |
| 330 |
const int8_t v5 = *w5++; |
| 331 |
out[5] = v5; |
| 332 |
const int8_t v6 = *w6++; |
| 333 |
out[6] = v6; |
| 334 |
const int8_t v7 = *w7++; |
| 335 |
out[7] = v7; |
| 336 |
const int8_t v8 = *w8++; |
| 337 |
out[8] = v8; |
| 338 |
const int8_t v9 = *w9++; |
| 339 |
out[9] = v9; |
| 340 |
const int8_t v10 = *w10++; |
| 341 |
out[10] = v10; |
| 342 |
const int8_t v11 = *w11++; |
| 343 |
out[11] = v11; |
| 344 |
const int8_t v12 = *w12++; |
| 345 |
out[12] = v12; |
| 346 |
const int8_t v13 = *w13++; |
| 347 |
out[13] = v13; |
| 348 |
const int8_t v14 = *w14++; |
| 349 |
out[14] = v14; |
| 350 |
const int8_t v15 = *w15++; |
| 351 |
out[15] = v15; |
| 352 |
const int8_t v16 = *w16++; |
| 353 |
out[16] = v16; |
| 354 |
const int8_t v17 = *w17++; |
| 355 |
out[17] = v17; |
| 356 |
const int8_t v18 = *w18++; |
| 357 |
out[18] = v18; |
| 358 |
const int8_t v19 = *w19++; |
| 359 |
out[19] = v19; |
| 360 |
const int8_t v20 = *w20++; |
| 361 |
out[20] = v20; |
| 362 |
const int8_t v21 = *w21++; |
| 363 |
out[21] = v21; |
| 364 |
const int8_t v22 = *w22++; |
| 365 |
out[22] = v22; |
| 366 |
const int8_t v23 = *w23++; |
| 367 |
out[23] = v23; |
| 368 |
const int8_t v24 = *w24++; |
| 369 |
out[24] = v24; |
| 370 |
const int8_t v25 = *w25++; |
| 371 |
out[25] = v25; |
| 372 |
const int8_t v26 = *w26++; |
| 373 |
out[26] = v26; |
| 374 |
const int8_t v27 = *w27++; |
| 375 |
out[27] = v27; |
| 376 |
const int8_t v28 = *w28++; |
| 377 |
out[28] = v28; |
| 378 |
const int8_t v29 = *w29++; |
| 379 |
out[29] = v29; |
| 380 |
const int8_t v30 = *w30++; |
| 381 |
out[30] = v30; |
| 382 |
const int8_t v31 = *w31++; |
| 383 |
out[31] = v31; |
| 384 |
out += 32; |
| 385 |
} |
| 386 |
out = (int8_t*) ((uintptr_t) out + extra_bytes); |
| 387 |
w0 = w31; |
| 388 |
} |
| 389 |
|
| 390 |
// NC remainder (1..31) |
| 391 |
if XNN_UNLIKELY(n != 0) { |
| 392 |
if XNN_LIKELY(b != NULL) { |
| 393 |
size_t nb = n; |
| 394 |
do { |
| 395 |
unaligned_store_s32(out, *b++); |
| 396 |
out += sizeof(uint32_t); |
| 397 |
} while (--nb != 0); |
| 398 |
} else { |
| 399 |
size_t nb = n; |
| 400 |
do { |
| 401 |
unaligned_store_s32(out, 0); |
| 402 |
out += sizeof(uint32_t); |
| 403 |
} while (--nb != 0); |
| 404 |
} |
| 405 |
out += (32 - n) * sizeof(uint32_t); |
| 406 |
|
| 407 |
// NR remainder has less than 32 rows so last row is not loaded |
| 408 |
const int8_t* w1 = w0 + kc; |
| 409 |
if XNN_UNPREDICTABLE(n < 2) { |
| 410 |
w1 = w0; |
| 411 |
} |
| 412 |
const int8_t* w2 = w1 + kc; |
| 413 |
if XNN_UNPREDICTABLE(n <= 2) { |
| 414 |
w2 = w1; |
| 415 |
} |
| 416 |
const int8_t* w3 = w2 + kc; |
| 417 |
if XNN_UNPREDICTABLE(n < 4) { |
| 418 |
w3 = w2; |
| 419 |
} |
| 420 |
const int8_t* w4 = w3 + kc; |
| 421 |
if XNN_UNPREDICTABLE(n <= 4) { |
| 422 |
w4 = w3; |
| 423 |
} |
| 424 |
const int8_t* w5 = w4 + kc; |
| 425 |
if XNN_UNPREDICTABLE(n < 6) { |
| 426 |
w5 = w4; |
| 427 |
} |
| 428 |
const int8_t* w6 = w5 + kc; |
| 429 |
if XNN_UNPREDICTABLE(n <= 6) { |
| 430 |
w6 = w5; |
| 431 |
} |
| 432 |
const int8_t* w7 = w6 + kc; |
| 433 |
if XNN_UNPREDICTABLE(n < 8) { |
| 434 |
w7 = w6; |
| 435 |
} |
| 436 |
const int8_t* w8 = w7 + kc; |
| 437 |
if XNN_UNPREDICTABLE(n <= 8) { |
| 438 |
w8 = w7; |
| 439 |
} |
| 440 |
const int8_t* w9 = w8 + kc; |
| 441 |
if XNN_UNPREDICTABLE(n < 10) { |
| 442 |
w9 = w8; |
| 443 |
} |
| 444 |
const int8_t* w10 = w9 + kc; |
| 445 |
if XNN_UNPREDICTABLE(n <= 10) { |
| 446 |
w10 = w9; |
| 447 |
} |
| 448 |
const int8_t* w11 = w10 + kc; |
| 449 |
if XNN_UNPREDICTABLE(n < 12) { |
| 450 |
w11 = w10; |
| 451 |
} |
| 452 |
const int8_t* w12 = w11 + kc; |
| 453 |
if XNN_UNPREDICTABLE(n <= 12) { |
| 454 |
w12 = w11; |
| 455 |
} |
| 456 |
const int8_t* w13 = w12 + kc; |
| 457 |
if XNN_UNPREDICTABLE(n < 14) { |
| 458 |
w13 = w12; |
| 459 |
} |
| 460 |
const int8_t* w14 = w13 + kc; |
| 461 |
if XNN_UNPREDICTABLE(n <= 14) { |
| 462 |
w14 = w13; |
| 463 |
} |
| 464 |
const int8_t* w15 = w14 + kc; |
| 465 |
if XNN_UNPREDICTABLE(n < 16) { |
| 466 |
w15 = w14; |
| 467 |
} |
| 468 |
const int8_t* w16 = w15 + kc; |
| 469 |
if XNN_UNPREDICTABLE(n <= 16) { |
| 470 |
w16 = w15; |
| 471 |
} |
| 472 |
const int8_t* w17 = w16 + kc; |
| 473 |
if XNN_UNPREDICTABLE(n < 18) { |
| 474 |
w17 = w16; |
| 475 |
} |
| 476 |
const int8_t* w18 = w17 + kc; |
| 477 |
if XNN_UNPREDICTABLE(n <= 18) { |
| 478 |
w18 = w17; |
| 479 |
} |
| 480 |
const int8_t* w19 = w18 + kc; |
| 481 |
if XNN_UNPREDICTABLE(n < 20) { |
| 482 |
w19 = w18; |
| 483 |
} |
| 484 |
const int8_t* w20 = w19 + kc; |
| 485 |
if XNN_UNPREDICTABLE(n <= 20) { |
| 486 |
w20 = w19; |
| 487 |
} |
| 488 |
const int8_t* w21 = w20 + kc; |
| 489 |
if XNN_UNPREDICTABLE(n < 22) { |
| 490 |
w21 = w20; |
| 491 |
} |
| 492 |
const int8_t* w22 = w21 + kc; |
| 493 |
if XNN_UNPREDICTABLE(n <= 22) { |
| 494 |
w22 = w21; |
| 495 |
} |
| 496 |
const int8_t* w23 = w22 + kc; |
| 497 |
if XNN_UNPREDICTABLE(n < 24) { |
| 498 |
w23 = w22; |
| 499 |
} |
| 500 |
const int8_t* w24 = w23 + kc; |
| 501 |
if XNN_UNPREDICTABLE(n <= 24) { |
| 502 |
w24 = w23; |
| 503 |
} |
| 504 |
const int8_t* w25 = w24 + kc; |
| 505 |
if XNN_UNPREDICTABLE(n < 26) { |
| 506 |
w25 = w24; |
| 507 |
} |
| 508 |
const int8_t* w26 = w25 + kc; |
| 509 |
if XNN_UNPREDICTABLE(n <= 26) { |
| 510 |
w26 = w25; |
| 511 |
} |
| 512 |
const int8_t* w27 = w26 + kc; |
| 513 |
if XNN_UNPREDICTABLE(n < 28) { |
| 514 |
w27 = w26; |
| 515 |
} |
| 516 |
const int8_t* w28 = w27 + kc; |
| 517 |
if XNN_UNPREDICTABLE(n <= 28) { |
| 518 |
w28 = w27; |
| 519 |
} |
| 520 |
const int8_t* w29 = w28 + kc; |
| 521 |
if XNN_UNPREDICTABLE(n < 30) { |
| 522 |
w29 = w28; |
| 523 |
} |
| 524 |
const int8_t* w30 = w29 + kc; |
| 525 |
if XNN_UNPREDICTABLE(n <= 30) { |
| 526 |
w30 = w29; |
| 527 |
} |
| 528 |
|
| 529 |
// KC main loop multiple of 32x2 |
| 530 |
size_t k = kc; |
| 531 |
for (; k >= 2; k -= 2) { |
| 532 |
const int8_t v00 = w0[0]; |
| 533 |
const int8_t v01 = w0[1]; |
| 534 |
w0 += 2; |
| 535 |
const int8_t v10 = w1[0]; |
| 536 |
const int8_t v11 = w1[1]; |
| 537 |
w1 += 2; |
| 538 |
const int8_t v20 = w2[0]; |
| 539 |
const int8_t v21 = w2[1]; |
| 540 |
w2 += 2; |
| 541 |
const int8_t v30 = w3[0]; |
| 542 |
const int8_t v31 = w3[1]; |
| 543 |
w3 += 2; |
| 544 |
const int8_t v40 = w4[0]; |
| 545 |
const int8_t v41 = w4[1]; |
| 546 |
w4 += 2; |
| 547 |
const int8_t v50 = w5[0]; |
| 548 |
const int8_t v51 = w5[1]; |
| 549 |
w5 += 2; |
| 550 |
const int8_t v60 = w6[0]; |
| 551 |
const int8_t v61 = w6[1]; |
| 552 |
w6 += 2; |
| 553 |
const int8_t v70 = w7[0]; |
| 554 |
const int8_t v71 = w7[1]; |
| 555 |
w7 += 2; |
| 556 |
const int8_t v80 = w8[0]; |
| 557 |
const int8_t v81 = w8[1]; |
| 558 |
w8 += 2; |
| 559 |
const int8_t v90 = w9[0]; |
| 560 |
const int8_t v91 = w9[1]; |
| 561 |
w9 += 2; |
| 562 |
const int8_t v100 = w10[0]; |
| 563 |
const int8_t v101 = w10[1]; |
| 564 |
w10 += 2; |
| 565 |
const int8_t v110 = w11[0]; |
| 566 |
const int8_t v111 = w11[1]; |
| 567 |
w11 += 2; |
| 568 |
const int8_t v120 = w12[0]; |
| 569 |
const int8_t v121 = w12[1]; |
| 570 |
w12 += 2; |
| 571 |
const int8_t v130 = w13[0]; |
| 572 |
const int8_t v131 = w13[1]; |
| 573 |
w13 += 2; |
| 574 |
const int8_t v140 = w14[0]; |
| 575 |
const int8_t v141 = w14[1]; |
| 576 |
w14 += 2; |
| 577 |
const int8_t v150 = w15[0]; |
| 578 |
const int8_t v151 = w15[1]; |
| 579 |
w15 += 2; |
| 580 |
const int8_t v160 = w16[0]; |
| 581 |
const int8_t v161 = w16[1]; |
| 582 |
w16 += 2; |
| 583 |
const int8_t v170 = w17[0]; |
| 584 |
const int8_t v171 = w17[1]; |
| 585 |
w17 += 2; |
| 586 |
const int8_t v180 = w18[0]; |
| 587 |
const int8_t v181 = w18[1]; |
| 588 |
w18 += 2; |
| 589 |
const int8_t v190 = w19[0]; |
| 590 |
const int8_t v191 = w19[1]; |
| 591 |
w19 += 2; |
| 592 |
const int8_t v200 = w20[0]; |
| 593 |
const int8_t v201 = w20[1]; |
| 594 |
w20 += 2; |
| 595 |
const int8_t v210 = w21[0]; |
| 596 |
const int8_t v211 = w21[1]; |
| 597 |
w21 += 2; |
| 598 |
const int8_t v220 = w22[0]; |
| 599 |
const int8_t v221 = w22[1]; |
| 600 |
w22 += 2; |
| 601 |
const int8_t v230 = w23[0]; |
| 602 |
const int8_t v231 = w23[1]; |
| 603 |
w23 += 2; |
| 604 |
const int8_t v240 = w24[0]; |
| 605 |
const int8_t v241 = w24[1]; |
| 606 |
w24 += 2; |
| 607 |
const int8_t v250 = w25[0]; |
| 608 |
const int8_t v251 = w25[1]; |
| 609 |
w25 += 2; |
| 610 |
const int8_t v260 = w26[0]; |
| 611 |
const int8_t v261 = w26[1]; |
| 612 |
w26 += 2; |
| 613 |
const int8_t v270 = w27[0]; |
| 614 |
const int8_t v271 = w27[1]; |
| 615 |
w27 += 2; |
| 616 |
const int8_t v280 = w28[0]; |
| 617 |
const int8_t v281 = w28[1]; |
| 618 |
w28 += 2; |
| 619 |
const int8_t v290 = w29[0]; |
| 620 |
const int8_t v291 = w29[1]; |
| 621 |
w29 += 2; |
| 622 |
const int8_t v300 = w30[0]; |
| 623 |
const int8_t v301 = w30[1]; |
| 624 |
w30 += 2; |
| 625 |
out[0] = v00; |
| 626 |
out[1] = v10; |
| 627 |
out[2] = v20; |
| 628 |
out[3] = v30; |
| 629 |
out[4] = v40; |
| 630 |
out[5] = v50; |
| 631 |
out[6] = v60; |
| 632 |
out[7] = v70; |
| 633 |
out[8] = v80; |
| 634 |
out[9] = v90; |
| 635 |
out[10] = v100; |
| 636 |
out[11] = v110; |
| 637 |
out[12] = v120; |
| 638 |
out[13] = v130; |
| 639 |
out[14] = v140; |
| 640 |
out[15] = v150; |
| 641 |
out[16] = v160; |
| 642 |
out[17] = v170; |
| 643 |
out[18] = v180; |
| 644 |
out[19] = v190; |
| 645 |
out[20] = v200; |
| 646 |
out[21] = v210; |
| 647 |
out[22] = v220; |
| 648 |
out[23] = v230; |
| 649 |
out[24] = v240; |
| 650 |
out[25] = v250; |
| 651 |
out[26] = v260; |
| 652 |
out[27] = v270; |
| 653 |
out[28] = v280; |
| 654 |
out[29] = v290; |
| 655 |
out[30] = v300; |
| 656 |
out[32] = v01; |
| 657 |
out[33] = v11; |
| 658 |
out[34] = v21; |
| 659 |
out[35] = v31; |
| 660 |
out[36] = v41; |
| 661 |
out[37] = v51; |
| 662 |
out[38] = v61; |
| 663 |
out[39] = v71; |
| 664 |
out[40] = v81; |
| 665 |
out[41] = v91; |
| 666 |
out[42] = v101; |
| 667 |
out[43] = v111; |
| 668 |
out[44] = v121; |
| 669 |
out[45] = v131; |
| 670 |
out[46] = v141; |
| 671 |
out[47] = v151; |
| 672 |
out[48] = v161; |
| 673 |
out[49] = v171; |
| 674 |
out[50] = v181; |
| 675 |
out[51] = v191; |
| 676 |
out[52] = v201; |
| 677 |
out[53] = v211; |
| 678 |
out[54] = v221; |
| 679 |
out[55] = v231; |
| 680 |
out[56] = v241; |
| 681 |
out[57] = v251; |
| 682 |
out[58] = v261; |
| 683 |
out[59] = v271; |
| 684 |
out[60] = v281; |
| 685 |
out[61] = v291; |
| 686 |
out[62] = v301; |
| 687 |
out += 64; |
| 688 |
} |
| 689 |
|
| 690 |
// KC remainder of 1..1 |
| 691 |
for (; k != 0; --k) { |
| 692 |
const int8_t v0 = *w0++; |
| 693 |
out[0] = v0; |
| 694 |
const int8_t v1 = *w1++; |
| 695 |
out[1] = v1; |
| 696 |
const int8_t v2 = *w2++; |
| 697 |
out[2] = v2; |
| 698 |
const int8_t v3 = *w3++; |
| 699 |
out[3] = v3; |
| 700 |
const int8_t v4 = *w4++; |
| 701 |
out[4] = v4; |
| 702 |
const int8_t v5 = *w5++; |
| 703 |
out[5] = v5; |
| 704 |
const int8_t v6 = *w6++; |
| 705 |
out[6] = v6; |
| 706 |
const int8_t v7 = *w7++; |
| 707 |
out[7] = v7; |
| 708 |
const int8_t v8 = *w8++; |
| 709 |
out[8] = v8; |
| 710 |
const int8_t v9 = *w9++; |
| 711 |
out[9] = v9; |
| 712 |
const int8_t v10 = *w10++; |
| 713 |
out[10] = v10; |
| 714 |
const int8_t v11 = *w11++; |
| 715 |
out[11] = v11; |
| 716 |
const int8_t v12 = *w12++; |
| 717 |
out[12] = v12; |
| 718 |
const int8_t v13 = *w13++; |
| 719 |
out[13] = v13; |
| 720 |
const int8_t v14 = *w14++; |
| 721 |
out[14] = v14; |
| 722 |
const int8_t v15 = *w15++; |
| 723 |
out[15] = v15; |
| 724 |
const int8_t v16 = *w16++; |
| 725 |
out[16] = v16; |
| 726 |
const int8_t v17 = *w17++; |
| 727 |
out[17] = v17; |
| 728 |
const int8_t v18 = *w18++; |
| 729 |
out[18] = v18; |
| 730 |
const int8_t v19 = *w19++; |
| 731 |
out[19] = v19; |
| 732 |
const int8_t v20 = *w20++; |
| 733 |
out[20] = v20; |
| 734 |
const int8_t v21 = *w21++; |
| 735 |
out[21] = v21; |
| 736 |
const int8_t v22 = *w22++; |
| 737 |
out[22] = v22; |
| 738 |
const int8_t v23 = *w23++; |
| 739 |
out[23] = v23; |
| 740 |
const int8_t v24 = *w24++; |
| 741 |
out[24] = v24; |
| 742 |
const int8_t v25 = *w25++; |
| 743 |
out[25] = v25; |
| 744 |
const int8_t v26 = *w26++; |
| 745 |
out[26] = v26; |
| 746 |
const int8_t v27 = *w27++; |
| 747 |
out[27] = v27; |
| 748 |
const int8_t v28 = *w28++; |
| 749 |
out[28] = v28; |
| 750 |
const int8_t v29 = *w29++; |
| 751 |
out[29] = v29; |
| 752 |
const int8_t v30 = *w30++; |
| 753 |
out[30] = v30; |
| 754 |
out += 32; |
| 755 |
} |
| 756 |
out = (int8_t*) ((uintptr_t) out + extra_bytes); |
| 757 |
} |
| 758 |
weights += nc * kc; |
| 759 |
} while (--g != 0); |
| 760 |
} |