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
xnn_x16_transposec_ukernel__4x1_scalar_int(const uint16_t * input,uint16_t * output,size_t input_stride,size_t output_stride,size_t block_width,size_t block_height)17 void xnn_x16_transposec_ukernel__4x1_scalar_int(
18 const uint16_t *input,
19 uint16_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(output_stride >= block_height * sizeof(int16_t));
26 assert(input_stride >= block_width * sizeof(int16_t));
27
28 const size_t tile_height = 4;
29 const size_t tile_width = 1;
30 const size_t tile_wbytes = tile_width * sizeof(int16_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(int16_t);
33 const size_t input_offset = tile_height * input_stride;
34
35 const int16_t* i0 = (const int16_t*) input;
36 const int16_t* i1 = (const int16_t*) ((uintptr_t) i0 + input_stride);
37 const int16_t* i2 = (const int16_t*) ((uintptr_t) i1 + input_stride);
38 const int16_t* i3 = (const int16_t*) ((uintptr_t) i2 + input_stride);
39
40 int16_t* o0 = (int16_t*) output;
41
42 do {
43 size_t bh = block_height;
44 for (; bh >= 4; bh -= 4) {
45 *o0++ = i0[0];
46 *o0++ = i1[0];
47 *o0++ = i2[0];
48 *o0++ = i3[0];
49 i0 = (const int16_t*) ((uintptr_t) i0 + input_offset);
50 i1 = (const int16_t*) ((uintptr_t) i1 + input_offset);
51 i2 = (const int16_t*) ((uintptr_t) i2 + input_offset);
52 i3 = (const int16_t*) ((uintptr_t) i3 + input_offset);
53 }
54 const int16_t* i = i0;
55 if (bh & 2) {
56 o0[0] = i0[0];
57 o0[1] = i1[0];
58 o0 += 2;
59 i = i2;
60 }
61 if (bh & 1) {
62 o0[0] = i[0];
63 }
64
65 i0 = (const int16_t*) ((uintptr_t) i0 + input_reset);
66 i1 = (const int16_t*) ((uintptr_t) i0 + input_stride);
67 i2 = (const int16_t*) ((uintptr_t) i1 + input_stride);
68 i3 = (const int16_t*) ((uintptr_t) i2 + input_stride);
69 o0 = (int16_t*) ((uintptr_t) o0 + output_reset);
70 block_width = doz(block_width, tile_width);
71 } while (block_width != 0);
72 }
73