| 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_2c1s1r__scalar_float( |
| 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 |
float* w = (float*) packed_weights; |
| 31 |
const float* b = (const float*) bias; |
| 32 |
do { |
| 33 |
// channel tile loop multiple of 2 |
| 34 |
size_t c = channels; |
| 35 |
for (; c >= 2; c -= 2) { |
| 36 |
const float b0 = b[0]; |
| 37 |
const float b1 = b[1]; |
| 38 |
unaligned_indexed_store_f32(w, 0, b0); |
| 39 |
unaligned_indexed_store_f32(w, 1, b1); |
| 40 |
b += 2; |
| 41 |
|
| 42 |
w = (float*) ((uintptr_t) w + channel_tile_stride); |
| 43 |
} |
| 44 |
|
| 45 |
// channel subtile loop multiple of 1 |
| 46 |
if (c != 0) { |
| 47 |
const float b0 = b[0]; |
| 48 |
unaligned_indexed_store_f32(w, 0, b0); |
| 49 |
b += 1; |
| 50 |
|
| 51 |
w = (float*) ((uintptr_t) w + channel_subtile_stride); |
| 52 |
} |
| 53 |
|
| 54 |
} while (--groups != 0); |
| 55 |
} |