24.04
generic.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2021-2023 Arm Limited.
3
*
4
* SPDX-License-Identifier: MIT
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in all
14
* copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
* SOFTWARE.
23
*/
24
25
#include <cstdint>
26
#include <cstddef>
27
28
#if defined(ARM_COMPUTE_ENABLE_SVE)
29
30
namespace
arm_conv
{
31
namespace
pooling
{
32
33
34
void
sve_u8_nhwc_max_generic_depthfirst_impl(
35
const
uint64_t,
36
const
uint64_t n_valid_cells,
37
uint64_t n_channels,
38
const
uint8_t *
const
*
const
inptrs,
39
uint8_t *outptr
40
)
41
{
42
__asm__ __volatile__(
43
"mov x9, #0x0\n"
44
"cntb x28\n"
45
"cntb x27, ALL, MUL #2\n"
46
"cntb x26, ALL, MUL #3\n"
47
"whilelt p4.b, x9, %x[n_channels]\n"
48
"whilelt p3.b, x28, %x[n_channels]\n"
49
"whilelt p2.b, x27, %x[n_channels]\n"
50
"whilelt p1.b, x26, %x[n_channels]\n"
51
"ptrue p0.b\n"
52
"b.none 7f\n"
53
"1:"
// 4-vectors of channels
54
"lsr x25, %x[n_valid_cells], #0x2\n"
55
"mov z8.b, #0x0\n"
56
"mov z7.b, #0x0\n"
57
"mov x24, %x[inptrs]\n"
58
"mov z6.b, #0x0\n"
59
"mov z5.b, #0x0\n"
60
"cbz x25, 4f\n"
61
"ldp x23, x22, [x24, #0x0]\n"
62
"ldp x21, x20, [x24, #0x10]\n"
63
"subs x25, x25, #0x1\n"
64
"add x24, x24, #0x20\n"
65
"ld1b { z4.b }, p4/Z, [x23, x9]\n"
66
"ld1b { z3.b }, p4/Z, [x22, x9]\n"
67
"ld1b { z2.b }, p4/Z, [x21, x9]\n"
68
"ld1b { z1.b }, p4/Z, [x20, x9]\n"
69
"ld1b { z0.b }, p3/Z, [x23, x28]\n"
70
"ld1b { z31.b }, p3/Z, [x22, x28]\n"
71
"ld1b { z22.b }, p3/Z, [x21, x28]\n"
72
"ld1b { z30.b }, p3/Z, [x20, x28]\n"
73
"ld1b { z29.b }, p2/Z, [x23, x27]\n"
74
"ld1b { z28.b }, p2/Z, [x22, x27]\n"
75
"ld1b { z21.b }, p2/Z, [x21, x27]\n"
76
"ld1b { z27.b }, p2/Z, [x20, x27]\n"
77
"ld1b { z26.b }, p1/Z, [x23, x26]\n"
78
"ld1b { z25.b }, p1/Z, [x22, x26]\n"
79
"ld1b { z20.b }, p1/Z, [x21, x26]\n"
80
"ld1b { z24.b }, p1/Z, [x20, x26]\n"
81
"beq 3f\n"
82
"2:"
// 4-vectors of channels: 4 inputs loop
83
"movprfx z19, z4\n umax z19.b, p0/M, z19.b, z3.b\n"
84
"movprfx z23, z2\n umax z23.b, p0/M, z23.b, z1.b\n"
85
"ldp x23, x22, [x24, #0x0]\n"
86
"ldp x21, x20, [x24, #0x10]\n"
87
"movprfx z18, z0\n umax z18.b, p0/M, z18.b, z31.b\n"
88
"umax z22.b, p0/M, z22.b, z30.b\n"
89
"ld1b { z4.b }, p4/Z, [x23, x9]\n"
90
"ld1b { z3.b }, p4/Z, [x22, x9]\n"
91
"movprfx z17, z29\n umax z17.b, p0/M, z17.b, z28.b\n"
92
"umax z21.b, p0/M, z21.b, z27.b\n"
93
"ld1b { z2.b }, p4/Z, [x21, x9]\n"
94
"ld1b { z1.b }, p4/Z, [x20, x9]\n"
95
"movprfx z16, z26\n umax z16.b, p0/M, z16.b, z25.b\n"
96
"umax z20.b, p0/M, z20.b, z24.b\n"
97
"ld1b { z0.b }, p3/Z, [x23, x28]\n"
98
"ld1b { z31.b }, p3/Z, [x22, x28]\n"
99
"umax z19.b, p0/M, z19.b, z23.b\n"
100
"umax z18.b, p0/M, z18.b, z22.b\n"
101
"ld1b { z22.b }, p3/Z, [x21, x28]\n"
102
"ld1b { z30.b }, p3/Z, [x20, x28]\n"
103
"umax z17.b, p0/M, z17.b, z21.b\n"
104
"umax z16.b, p0/M, z16.b, z20.b\n"
105
"ld1b { z29.b }, p2/Z, [x23, x27]\n"
106
"ld1b { z28.b }, p2/Z, [x22, x27]\n"
107
"subs x25, x25, #0x1\n"
108
"umax z8.b, p0/M, z8.b, z19.b\n"
109
"ld1b { z21.b }, p2/Z, [x21, x27]\n"
110
"ld1b { z27.b }, p2/Z, [x20, x27]\n"
111
"umax z7.b, p0/M, z7.b, z18.b\n"
112
"umax z6.b, p0/M, z6.b, z17.b\n"
113
"ld1b { z26.b }, p1/Z, [x23, x26]\n"
114
"ld1b { z25.b }, p1/Z, [x22, x26]\n"
115
"umax z5.b, p0/M, z5.b, z16.b\n"
116
"add x24, x24, #0x20\n"
117
"ld1b { z20.b }, p1/Z, [x21, x26]\n"
118
"ld1b { z24.b }, p1/Z, [x20, x26]\n"
119
"bgt 2b\n"
120
"3:"
// 4-vectors of channels: 4 inputs tail
121
"movprfx z19, z4\n umax z19.b, p0/M, z19.b, z3.b\n"
122
"movprfx z23, z2\n umax z23.b, p0/M, z23.b, z1.b\n"
123
"movprfx z18, z0\n umax z18.b, p0/M, z18.b, z31.b\n"
124
"umax z22.b, p0/M, z22.b, z30.b\n"
125
"movprfx z17, z29\n umax z17.b, p0/M, z17.b, z28.b\n"
126
"umax z21.b, p0/M, z21.b, z27.b\n"
127
"movprfx z16, z26\n umax z16.b, p0/M, z16.b, z25.b\n"
128
"umax z20.b, p0/M, z20.b, z24.b\n"
129
"umax z19.b, p0/M, z19.b, z23.b\n"
130
"umax z18.b, p0/M, z18.b, z22.b\n"
131
"umax z17.b, p0/M, z17.b, z21.b\n"
132
"umax z16.b, p0/M, z16.b, z20.b\n"
133
"umax z8.b, p0/M, z8.b, z19.b\n"
134
"umax z7.b, p0/M, z7.b, z18.b\n"
135
"umax z6.b, p0/M, z6.b, z17.b\n"
136
"umax z5.b, p0/M, z5.b, z16.b\n"
137
"4:"
// 4-vectors of channels: After loop
138
"ands x21, %x[n_valid_cells], #0x3\n"
139
"beq 6f\n"
140
"5:"
// 4-vectors of channels: Single input loop
141
"ldr x20, [x24], #0x8\n"
142
"ld1b { z16.b }, p4/Z, [x20, x9]\n"
143
"subs x21, x21, #0x1\n"
144
"umax z8.b, p0/M, z8.b, z16.b\n"
145
"ld1b { z17.b }, p3/Z, [x20, x28]\n"
146
"ld1b { z16.b }, p2/Z, [x20, x27]\n"
147
"umax z7.b, p0/M, z7.b, z17.b\n"
148
"umax z6.b, p0/M, z6.b, z16.b\n"
149
"ld1b { z16.b }, p1/Z, [x20, x26]\n"
150
"umax z5.b, p0/M, z5.b, z16.b\n"
151
"bgt 5b\n"
152
"6:"
// 4-vectors of channels: Single input loop: End
153
"st1b { z8.b }, p4, [%x[outptr], x9]\n"
154
"incb x9, ALL, MUL #4\n"
155
"st1b { z7.b }, p3, [%x[outptr], x28]\n"
156
"incb x28, ALL, MUL #4\n"
157
"st1b { z6.b }, p2, [%x[outptr], x27]\n"
158
"incb x27, ALL, MUL #4\n"
159
"st1b { z5.b }, p1, [%x[outptr], x26]\n"
160
"incb x26, ALL, MUL #4\n"
161
"whilelt p1.b, x26, %x[n_channels]\n"
162
"b.any 1b\n"
163
"7:"
// Single vector of channels
164
"whilelt p4.b, x9, %x[n_channels]\n"
165
"b.none 14f\n"
166
"8:"
// Single vector of channels: Loop
167
"lsr x25, %x[n_valid_cells], #0x2\n"
168
"mov z8.b, #0x0\n"
169
"mov x24, %x[inptrs]\n"
170
"cbz x25, 11f\n"
171
"ldp x23, x22, [x24, #0x0]\n"
172
"ldp x21, x20, [x24, #0x10]\n"
173
"subs x25, x25, #0x1\n"
174
"add x24, x24, #0x20\n"
175
"ld1b { z4.b }, p4/Z, [x23, x9]\n"
176
"ld1b { z3.b }, p4/Z, [x22, x9]\n"
177
"ld1b { z2.b }, p4/Z, [x21, x9]\n"
178
"ld1b { z1.b }, p4/Z, [x20, x9]\n"
179
"beq 10f\n"
180
"9:"
// Single vector of channels: Loop: 4 inputs loop
181
"movprfx z16, z4\n umax z16.b, p0/M, z16.b, z3.b\n"
182
"movprfx z17, z2\n umax z17.b, p0/M, z17.b, z1.b\n"
183
"ldp x23, x22, [x24, #0x0]\n"
184
"ldp x21, x20, [x24, #0x10]\n"
185
"umax z16.b, p0/M, z16.b, z17.b\n"
186
"subs x25, x25, #0x1\n"
187
"ld1b { z4.b }, p4/Z, [x23, x9]\n"
188
"ld1b { z3.b }, p4/Z, [x22, x9]\n"
189
"umax z8.b, p0/M, z8.b, z16.b\n"
190
"add x24, x24, #0x20\n"
191
"ld1b { z2.b }, p4/Z, [x21, x9]\n"
192
"ld1b { z1.b }, p4/Z, [x20, x9]\n"
193
"bgt 9b\n"
194
"10:"
// Single vector of channels: Loop: 4 inputs tail
195
"movprfx z16, z4\n umax z16.b, p0/M, z16.b, z3.b\n"
196
"movprfx z17, z2\n umax z17.b, p0/M, z17.b, z1.b\n"
197
"umax z16.b, p0/M, z16.b, z17.b\n"
198
"umax z8.b, p0/M, z8.b, z16.b\n"
199
"11:"
// Single vector of channels: Loop: After loop
200
"ands x21, %x[n_valid_cells], #0x3\n"
201
"beq 13f\n"
202
"12:"
// Single vector of channels: Loop: Single input loop
203
"ldr x20, [x24], #0x8\n"
204
"ld1b { z16.b }, p4/Z, [x20, x9]\n"
205
"subs x21, x21, #0x1\n"
206
"umax z8.b, p0/M, z8.b, z16.b\n"
207
"bgt 12b\n"
208
"13:"
// Single vector of channels: Loop: Single input loop: End
209
"st1b { z8.b }, p4, [%x[outptr], x9]\n"
210
"incb x9\n"
211
"whilelt p4.b, x9, %x[n_channels]\n"
212
"b.any 8b\n"
213
"14:"
// End
214
:
215
: [inptrs]
"r"
(inptrs), [n_channels]
"r"
(n_channels), [n_valid_cells]
"r"
(n_valid_cells), [outptr]
"r"
(outptr)
216
:
"cc"
,
"memory"
,
"p0"
,
"p1"
,
"p2"
,
"p3"
,
"p4"
,
"x9"
,
"x20"
,
"x21"
,
"x22"
,
"x23"
,
"x24"
,
"x25"
,
"x26"
,
"x27"
,
"x28"
,
"z0"
,
"z1"
,
"z2"
,
"z3"
,
"z4"
,
"z5"
,
"z6"
,
"z7"
,
"z8"
,
"z16"
,
"z17"
,
"z18"
,
"z19"
,
"z20"
,
"z21"
,
"z22"
,
"z23"
,
"z24"
,
"z25"
,
"z26"
,
"z27"
,
"z28"
,
"z29"
,
"z30"
,
"z31"
217
);
218
}
219
220
}
// namespace pooling
221
}
// namespace arm_conv
222
223
#endif // defined(ARM_COMPUTE_ENABLE_SVE)
arm_conv::pooling::pooling
template UniquePoolingCommon< float, float > pooling(const PoolingArgs &, const Nothing &)
arm_conv
Definition:
addressing.cpp:30
src
core
NEON
kernels
arm_conv
pooling
kernels
sve_u8_nhwc_max_generic_depthfirst
generic.cpp
Generated on Mon Apr 29 2024 10:53:54 for Compute Library by
1.8.17