| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/x32-packb/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 |
#include <assert.h> |
| 11 |
#include <stddef.h> |
| 12 |
|
| 13 |
#include "xnnpack/math.h" |
| 14 |
#include "xnnpack/packb.h" |
| 15 |
#include "xnnpack/unaligned.h" |
| 16 |
|
| 17 |
void xnn_x32_packb_gemm_ukernel_4c4s1r__scalar_int( |
| 18 |
size_t groups, |
| 19 |
size_t channels, |
| 20 |
const uint32_t* bias, |
| 21 |
uint32_t* packed_weights, |
| 22 |
size_t channel_tile_stride, |
| 23 |
size_t channel_subtile_stride, |
| 24 |
const struct xnn_x32_packb_params params[restrict XNN_MIN_ELEMENTS(1)]) |
| 25 |
{ |
| 26 |
assert(groups != 0); |
| 27 |
assert(channels != 0); |
| 28 |
assert(packed_weights != NULL); |
| 29 |
|
| 30 |
uint32_t* w = (uint32_t*) packed_weights; |
| 31 |
const uint32_t* b = (const uint32_t*) bias; |
| 32 |
do { |
| 33 |
// channel tile loop multiple of 4 |
| 34 |
size_t c = channels; |
| 35 |
for (; c >= 4; c -= 4) { |
| 36 |
const uint32_t b0 = b[0]; |
| 37 |
const uint32_t b1 = b[1]; |
| 38 |
const uint32_t b2 = b[2]; |
| 39 |
const uint32_t b3 = b[3]; |
| 40 |
unaligned_indexed_store_u32(w, 0, b0); |
| 41 |
unaligned_indexed_store_u32(w, 1, b1); |
| 42 |
unaligned_indexed_store_u32(w, 2, b2); |
| 43 |
unaligned_indexed_store_u32(w, 3, b3); |
| 44 |
b += 4; |
| 45 |
|
| 46 |
w = (uint32_t*) ((uintptr_t) w + channel_tile_stride); |
| 47 |
} |
| 48 |
|
| 49 |
|
| 50 |
if XNN_UNLIKELY(c != 0) { |
| 51 |
// channels remainder (1..3) |
| 52 |
uint32_t* prev_w = w; |
| 53 |
if (c & 2) { |
| 54 |
uint32_t b0 = b[0]; |
| 55 |
uint32_t b1 = b[1]; |
| 56 |
unaligned_indexed_store_u32(w, 0, b0); |
| 57 |
unaligned_indexed_store_u32(w, 1, b1); |
| 58 |
b += 2; |
| 59 |
w += 2; |
| 60 |
} |
| 61 |
if (c & 1) { |
| 62 |
uint32_t b0 = b[0]; |
| 63 |
unaligned_indexed_store_u32(w, 0, b0); |
| 64 |
b += 1; |
| 65 |
w += 1; |
| 66 |
} |
| 67 |
|
| 68 |
w = (uint32_t*) ((uintptr_t) prev_w + channel_subtile_stride); |
| 69 |
} |
| 70 |
} while (--groups != 0); |
| 71 |
} |