Debian Codegraph @

src/x32-transposec/gen/x32-transposec-2x2-reuse-switch-zip-neon.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/x32-transposec/neon-zip.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 #include <arm_neon.h>
11
12 #include <assert.h>
13
14 #include "xnnpack/common.h"
15 #include "xnnpack/math.h"
16 #include "xnnpack/transpose.h"
17
18 void xnn_x32_transposec_ukernel__2x2_reuse_switch_zip_neon(
19 const uint32_t* input,
20 uint32_t* output,
21 size_t input_stride,
22 size_t output_stride,
23 size_t block_width,
24 size_t block_height) XNN_OOB_READS
25 {
26 assert(block_width == 1 || output_stride >= block_height * sizeof(uint32_t));
27 assert(block_height == 1 || input_stride >= block_width * sizeof(uint32_t));
28
29 const size_t tile_height = 2;
30 const size_t tile_width = 2;
31 const size_t tile_hbytes = tile_height * sizeof(uint32_t);
32 const size_t tile_wbytes = tile_width * sizeof(uint32_t);
33 const size_t input_reset = tile_wbytes - round_down_po2(block_height, tile_height) * input_stride;
34 const size_t output_reset = tile_width * output_stride - round_down_po2(block_height, 2) * sizeof(uint32_t);
35
36 const uint32_t* i0 = input;
37 uint32_t* o = (uint32_t*) output;
38
39 do {
40 const size_t rem = min(block_width - 1, 1);
41 const size_t oN_stride = rem * output_stride;
42 size_t bh = block_height;
43 for (; bh >= 2; bh -= 2) {
44 const uint32x2_t v1_0 = vld1_u32(i0); i0 = (uint32_t*) ((uintptr_t) i0 + input_stride);
45 const uint32x2_t v1_1 = vld1_u32(i0); i0 = (uint32_t*) ((uintptr_t) i0 + input_stride);
46
47 const uint32x2x2_t v0_0 = vzip_u32(v1_0, v1_1);
48
49
50 uint32_t *oN = (uint32_t*) ((uintptr_t) o + oN_stride);
51 switch (rem) {
52 case 1:
53 vst1_u32(oN, v0_0.val[1]);
54 XNN_FALLTHROUGH
55 case 0:
56 vst1_u32(o, v0_0.val[0]); o = (uint32_t*) ((uintptr_t) o + tile_hbytes);
57 break;
58 default:
59 XNN_UNREACHABLE;
60 }
61 }
62
63 if (bh != 0) {
64 const uint32x2_t v1_0 = vld1_u32(i0);
65 const uint32x2_t v1_1 = vmov_n_u32(0);
66
67 const uint32x2x2_t v0_0 = vzip_u32(v1_0, v1_1);
68
69
70 uint32x2_t v0_low = v0_0.val[0];
71 uint32x2_t v1_low = v0_0.val[1];
72
73 if (bh & 1) {
74 uint32_t* oN = (uint32_t*) ((uintptr_t) o + oN_stride);
75 switch (rem) {
76 case 1:
77 vst1_lane_u32(oN, v1_low, 0);
78 XNN_FALLTHROUGH
79 case 0:
80 vst1_lane_u32(o, v0_low, 0);
81 break;
82 default:
83 XNN_UNREACHABLE;
84 }
85 }
86 }
87
88 i0 = (const uint32_t*) ((uintptr_t) i0 + input_reset);
89 o = (uint32_t*) ((uintptr_t) o + output_reset);
90 block_width = doz(block_width, tile_width);
91 } while (block_width != 0);
92 }