| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/x32-transposec/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 |
|
| 11 |
#include <assert.h> |
| 12 |
|
| 13 |
#include "xnnpack/common.h" |
| 14 |
#include "xnnpack/math.h" |
| 15 |
#include "xnnpack/transpose.h" |
| 16 |
|
| 17 |
void xnn_x8_transposec_ukernel__2x4_scalar_int( |
| 18 |
const uint8_t *input, |
| 19 |
uint8_t * output, |
| 20 |
size_t input_stride, |
| 21 |
size_t output_stride, |
| 22 |
size_t block_width, |
| 23 |
size_t block_height) XNN_OOB_READS |
| 24 |
{ |
| 25 |
assert(block_width == 1 || output_stride >= block_height * sizeof(int8_t)); |
| 26 |
assert(block_height == 1 || input_stride >= block_width * sizeof(int8_t)); |
| 27 |
|
| 28 |
const size_t tile_height = 2; |
| 29 |
const size_t tile_width = 4; |
| 30 |
const size_t tile_wbytes = tile_width * sizeof(int8_t); |
| 31 |
const size_t input_reset = tile_wbytes - round_down_po2(block_height, tile_height) * input_stride; |
| 32 |
const size_t output_reset = tile_width * output_stride - round_down_po2(block_height, 2) * sizeof(int8_t); |
| 33 |
const size_t input_offset = tile_height * input_stride; |
| 34 |
|
| 35 |
const int8_t* i0 = (const int8_t*) input; |
| 36 |
const int8_t* i1 = (const int8_t*) ((uintptr_t) i0 + input_stride); |
| 37 |
|
| 38 |
int8_t* o0 = (int8_t*) output; |
| 39 |
int8_t* o1 = (int8_t*) ((uintptr_t) o0 + output_stride); |
| 40 |
int8_t* o2 = (int8_t*) ((uintptr_t) o1 + output_stride); |
| 41 |
int8_t* o3 = (int8_t*) ((uintptr_t) o2 + output_stride); |
| 42 |
|
| 43 |
do { |
| 44 |
if XNN_UNPREDICTABLE(block_width < 2) { |
| 45 |
o1 = o0; |
| 46 |
} |
| 47 |
if XNN_UNPREDICTABLE(block_width <= 2) { |
| 48 |
o2 = o0; |
| 49 |
} |
| 50 |
if XNN_UNPREDICTABLE(block_width < 4) { |
| 51 |
o3 = o0; |
| 52 |
} |
| 53 |
size_t bh = block_height; |
| 54 |
for (; bh >= 2; bh -= 2) { |
| 55 |
*o3++ = i0[3]; |
| 56 |
*o3++ = i1[3]; |
| 57 |
*o2++ = i0[2]; |
| 58 |
*o2++ = i1[2]; |
| 59 |
*o1++ = i0[1]; |
| 60 |
*o1++ = i1[1]; |
| 61 |
*o0++ = i0[0]; |
| 62 |
*o0++ = i1[0]; |
| 63 |
i0 = (const int8_t*) ((uintptr_t) i0 + input_offset); |
| 64 |
i1 = (const int8_t*) ((uintptr_t) i1 + input_offset); |
| 65 |
} |
| 66 |
if (bh & 1) { |
| 67 |
o3[0] = i0[3]; |
| 68 |
o2[0] = i0[2]; |
| 69 |
o1[0] = i0[1]; |
| 70 |
o0[0] = i0[0]; |
| 71 |
} |
| 72 |
|
| 73 |
i0 = (const int8_t*) ((uintptr_t) i0 + input_reset); |
| 74 |
i1 = (const int8_t*) ((uintptr_t) i0 + input_stride); |
| 75 |
o0 = (int8_t*) ((uintptr_t) o0 + output_reset); |
| 76 |
o1 = (int8_t*) ((uintptr_t) o1 + output_reset); |
| 77 |
o2 = (int8_t*) ((uintptr_t) o2 + output_reset); |
| 78 |
o3 = (int8_t*) ((uintptr_t) o3 + output_reset); |
| 79 |
block_width = doz(block_width, tile_width); |
| 80 |
} while (block_width != 0); |
| 81 |
} |