Debian Codegraph @

src/x64-transposec/gen/x64-transposec-2x2-multi-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_x64_transposec_ukernel__2x2_multi_switch_zip_neon(
19 const uint64_t* input,
20 uint64_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(uint64_t));
27 assert(block_height == 1 || input_stride >= block_width * sizeof(uint64_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(uint64_t);
32 const size_t tile_wbytes = tile_width * sizeof(uint64_t);
33 const size_t input_reset = tile_wbytes - round_down_po2(block_height, tile_height) * input_stride;
34 const size_t input_offset = tile_height * input_stride;
35 const size_t output_reset = tile_width * output_stride - round_down_po2(block_height, 2) * sizeof(uint64_t);
36
37 const uint64_t* i0 = input;
38 const uint64_t* i1 = (const uint64_t*) ((uintptr_t) i0 + input_stride);
39 uint64_t* o = (uint64_t*) output;
40
41 do {
42 const size_t rem = min(block_width - 1, 1);
43 const size_t oN_stride = rem * output_stride;
44 size_t bh = block_height;
45 for (; bh >= 2; bh -= 2) {
46 const uint64x2_t v1_0 = vld1q_u64(i0); i0 = (uint64_t*) ((uintptr_t) i0 + input_offset);
47 const uint64x2_t v1_1 = vld1q_u64(i1); i1 = (uint64_t*) ((uintptr_t) i1 + input_offset);
48
49 uint64x2x2_t v0_0;
50 #if XNN_ARCH_ARM64
51 v0_0.val[0] = vzip1q_u64(v1_0, v1_1);
52 v0_0.val[1] = vzip2q_u64(v1_0, v1_1);
53 #else
54 v0_0.val[0] = vcombine_u64(vget_low_u64(v1_0), vget_low_u64(v1_1));
55 v0_0.val[1] = vcombine_u64(vget_high_u64(v1_0), vget_high_u64(v1_1));
56 #endif
57
58
59 uint64_t *oN = (uint64_t*) ((uintptr_t) o + oN_stride);
60 switch (rem) {
61 case 1:
62 vst1q_u64(oN, v0_0.val[1]);
63 XNN_FALLTHROUGH
64 case 0:
65 vst1q_u64(o, v0_0.val[0]); o = (uint64_t*) ((uintptr_t) o + tile_hbytes);
66 break;
67 default:
68 XNN_UNREACHABLE;
69 }
70 }
71
72 if (bh != 0) {
73 const uint64x2_t v1_0 = vld1q_u64(i0);
74 const uint64x2_t v1_1 = vmovq_n_u64(0);
75
76 uint64x2x2_t v0_0;
77 #if XNN_ARCH_ARM64
78 v0_0.val[0] = vzip1q_u64(v1_0, v1_1);
79 v0_0.val[1] = vzip2q_u64(v1_0, v1_1);
80 #else
81 v0_0.val[0] = vcombine_u64(vget_low_u64(v1_0), vget_low_u64(v1_1));
82 v0_0.val[1] = vcombine_u64(vget_high_u64(v1_0), vget_high_u64(v1_1));
83 #endif
84
85
86 uint64x1_t v0_low = vget_low_u64(v0_0.val[0]);
87 uint64x1_t v1_low = vget_low_u64(v0_0.val[1]);
88
89 if (bh & 1) {
90 uint64_t* oN = (uint64_t*) ((uintptr_t) o + oN_stride);
91 switch (rem) {
92 case 1:
93 vst1_u64(oN, v1_low);
94 XNN_FALLTHROUGH
95 case 0:
96 vst1_u64(o, v0_low);
97 break;
98 default:
99 XNN_UNREACHABLE;
100 }
101 }
102
103 }
104
105 i0 = (const uint64_t*) ((uintptr_t) i0 + input_reset);
106 i1 = (const uint64_t*) ((uintptr_t) i0 + input_stride);
107 o = (uint64_t*) ((uintptr_t) o + output_reset);
108 block_width = doz(block_width, tile_width);
109 } while (block_width != 0);
110 }