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_fp32_nhwc_avg_generic_depthfirst_impl(
35
const
uint64_t window_cells,
36
const
uint64_t n_valid_cells,
37
uint64_t n_channels,
38
const
float
*
const
*
const
inptrs,
39
float
*outptr
40
)
41
{
42
const
auto
rescale_value =
static_cast<
float
>
(1.0f /
static_cast<
float
>
(window_cells));
43
44
__asm__ __volatile__(
45
"mov x9, #0x0\n"
46
"cntw x28\n"
47
"cntw x27, ALL, MUL #2\n"
48
"cntw x26, ALL, MUL #3\n"
49
"ptrue p0.b\n"
50
"whilelt p3.s, x9, %x[n_channels]\n"
51
"ld1rw { z7.s }, p0/Z, [%x[rescale_ptr]]\n"
52
"whilelt p2.s, x28, %x[n_channels]\n"
53
"whilelt p1.s, x27, %x[n_channels]\n"
54
"whilelt p0.s, x26, %x[n_channels]\n"
55
"b.none 7f\n"
56
"1:"
// 4-vectors of channels
57
"lsr x25, %x[n_valid_cells], #0x2\n"
58
"mov z6.b, #0x0\n"
59
"mov z5.b, #0x0\n"
60
"mov x24, %x[inptrs]\n"
61
"mov z4.b, #0x0\n"
62
"mov z3.b, #0x0\n"
63
"cbz x25, 4f\n"
64
"ldp x23, x22, [x24, #0x0]\n"
65
"ldp x21, x20, [x24, #0x10]\n"
66
"subs x25, x25, #0x1\n"
67
"add x24, x24, #0x20\n"
68
"ld1w { z2.s }, p3/Z, [x23, x9, LSL #2]\n"
69
"ld1w { z1.s }, p3/Z, [x22, x9, LSL #2]\n"
70
"ld1w { z0.s }, p3/Z, [x21, x9, LSL #2]\n"
71
"ld1w { z31.s }, p3/Z, [x20, x9, LSL #2]\n"
72
"ld1w { z30.s }, p2/Z, [x23, x28, LSL #2]\n"
73
"ld1w { z22.s }, p2/Z, [x22, x28, LSL #2]\n"
74
"ld1w { z29.s }, p2/Z, [x21, x28, LSL #2]\n"
75
"ld1w { z28.s }, p2/Z, [x20, x28, LSL #2]\n"
76
"ld1w { z27.s }, p1/Z, [x23, x27, LSL #2]\n"
77
"ld1w { z21.s }, p1/Z, [x22, x27, LSL #2]\n"
78
"ld1w { z26.s }, p1/Z, [x21, x27, LSL #2]\n"
79
"ld1w { z17.s }, p1/Z, [x20, x27, LSL #2]\n"
80
"ld1w { z25.s }, p0/Z, [x23, x26, LSL #2]\n"
81
"ld1w { z20.s }, p0/Z, [x22, x26, LSL #2]\n"
82
"ld1w { z24.s }, p0/Z, [x21, x26, LSL #2]\n"
83
"ld1w { z16.s }, p0/Z, [x20, x26, LSL #2]\n"
84
"beq 3f\n"
85
"2:"
// 4-vectors of channels: 4 inputs loop
86
"fadd z23.s, z2.s, z1.s\n"
87
"fadd z19.s, z0.s, z31.s\n"
88
"ldp x23, x22, [x24, #0x0]\n"
89
"ldp x21, x20, [x24, #0x10]\n"
90
"fadd z22.s, z30.s, z22.s\n"
91
"fadd z18.s, z29.s, z28.s\n"
92
"subs x25, x25, #0x1\n"
93
"add x24, x24, #0x20\n"
94
"fadd z21.s, z27.s, z21.s\n"
95
"fadd z17.s, z26.s, z17.s\n"
96
"ld1w { z2.s }, p3/Z, [x23, x9, LSL #2]\n"
97
"ld1w { z1.s }, p3/Z, [x22, x9, LSL #2]\n"
98
"fadd z20.s, z25.s, z20.s\n"
99
"fadd z16.s, z24.s, z16.s\n"
100
"ld1w { z0.s }, p3/Z, [x21, x9, LSL #2]\n"
101
"ld1w { z31.s }, p3/Z, [x20, x9, LSL #2]\n"
102
"fadd z19.s, z23.s, z19.s\n"
103
"fadd z18.s, z22.s, z18.s\n"
104
"ld1w { z30.s }, p2/Z, [x23, x28, LSL #2]\n"
105
"ld1w { z22.s }, p2/Z, [x22, x28, LSL #2]\n"
106
"fadd z17.s, z21.s, z17.s\n"
107
"fadd z16.s, z20.s, z16.s\n"
108
"ld1w { z29.s }, p2/Z, [x21, x28, LSL #2]\n"
109
"ld1w { z28.s }, p2/Z, [x20, x28, LSL #2]\n"
110
"fadd z6.s, z6.s, z19.s\n"
111
"fadd z5.s, z5.s, z18.s\n"
112
"ld1w { z27.s }, p1/Z, [x23, x27, LSL #2]\n"
113
"ld1w { z21.s }, p1/Z, [x22, x27, LSL #2]\n"
114
"fadd z4.s, z4.s, z17.s\n"
115
"fadd z3.s, z3.s, z16.s\n"
116
"ld1w { z26.s }, p1/Z, [x21, x27, LSL #2]\n"
117
"ld1w { z17.s }, p1/Z, [x20, x27, LSL #2]\n"
118
"ld1w { z25.s }, p0/Z, [x23, x26, LSL #2]\n"
119
"ld1w { z20.s }, p0/Z, [x22, x26, LSL #2]\n"
120
"ld1w { z24.s }, p0/Z, [x21, x26, LSL #2]\n"
121
"ld1w { z16.s }, p0/Z, [x20, x26, LSL #2]\n"
122
"bgt 2b\n"
123
"3:"
// 4-vectors of channels: 4 inputs tail
124
"fadd z23.s, z2.s, z1.s\n"
125
"fadd z19.s, z0.s, z31.s\n"
126
"fadd z22.s, z30.s, z22.s\n"
127
"fadd z18.s, z29.s, z28.s\n"
128
"fadd z21.s, z27.s, z21.s\n"
129
"fadd z17.s, z26.s, z17.s\n"
130
"fadd z20.s, z25.s, z20.s\n"
131
"fadd z16.s, z24.s, z16.s\n"
132
"fadd z19.s, z23.s, z19.s\n"
133
"fadd z18.s, z22.s, z18.s\n"
134
"fadd z17.s, z21.s, z17.s\n"
135
"fadd z16.s, z20.s, z16.s\n"
136
"fadd z6.s, z6.s, z19.s\n"
137
"fadd z5.s, z5.s, z18.s\n"
138
"fadd z4.s, z4.s, z17.s\n"
139
"fadd z3.s, z3.s, z16.s\n"
140
"4:"
// 4-vectors of channels: After loop
141
"ands x21, %x[n_valid_cells], #0x3\n"
142
"beq 6f\n"
143
"5:"
// 4-vectors of channels: Single input loop
144
"ldr x20, [x24], #0x8\n"
145
"ld1w { z16.s }, p3/Z, [x20, x9, LSL #2]\n"
146
"subs x21, x21, #0x1\n"
147
"fadd z6.s, z6.s, z16.s\n"
148
"ld1w { z17.s }, p2/Z, [x20, x28, LSL #2]\n"
149
"ld1w { z16.s }, p1/Z, [x20, x27, LSL #2]\n"
150
"fadd z5.s, z5.s, z17.s\n"
151
"fadd z4.s, z4.s, z16.s\n"
152
"ld1w { z16.s }, p0/Z, [x20, x26, LSL #2]\n"
153
"fadd z3.s, z3.s, z16.s\n"
154
"bgt 5b\n"
155
"6:"
// 4-vectors of channels: Single input loop: End
156
"fmul z6.s, z6.s, z7.s\n"
157
"fmul z5.s, z5.s, z7.s\n"
158
"st1w { z6.s }, p3, [%x[outptr], x9, LSL #2]\n"
159
"fmul z4.s, z4.s, z7.s\n"
160
"fmul z3.s, z3.s, z7.s\n"
161
"st1w { z5.s }, p2, [%x[outptr], x28, LSL #2]\n"
162
"st1w { z4.s }, p1, [%x[outptr], x27, LSL #2]\n"
163
"incw x9, ALL, MUL #4\n"
164
"incw x28, ALL, MUL #4\n"
165
"st1w { z3.s }, p0, [%x[outptr], x26, LSL #2]\n"
166
"incw x26, ALL, MUL #4\n"
167
"whilelt p0.s, x26, %x[n_channels]\n"
168
"incw x27, ALL, MUL #4\n"
169
"b.any 1b\n"
170
"7:"
// Single vector of channels
171
"whilelt p3.s, x9, %x[n_channels]\n"
172
"b.none 14f\n"
173
"8:"
// Single vector of channels: Loop
174
"lsr x25, %x[n_valid_cells], #0x2\n"
175
"mov z6.b, #0x0\n"
176
"mov x24, %x[inptrs]\n"
177
"cbz x25, 11f\n"
178
"ldp x23, x22, [x24, #0x0]\n"
179
"ldp x21, x20, [x24, #0x10]\n"
180
"subs x25, x25, #0x1\n"
181
"add x24, x24, #0x20\n"
182
"ld1w { z2.s }, p3/Z, [x23, x9, LSL #2]\n"
183
"ld1w { z1.s }, p3/Z, [x22, x9, LSL #2]\n"
184
"ld1w { z0.s }, p3/Z, [x21, x9, LSL #2]\n"
185
"ld1w { z31.s }, p3/Z, [x20, x9, LSL #2]\n"
186
"beq 10f\n"
187
"9:"
// Single vector of channels: Loop: 4 inputs loop
188
"fadd z17.s, z2.s, z1.s\n"
189
"fadd z16.s, z0.s, z31.s\n"
190
"ldp x23, x22, [x24, #0x0]\n"
191
"ldp x21, x20, [x24, #0x10]\n"
192
"fadd z16.s, z17.s, z16.s\n"
193
"subs x25, x25, #0x1\n"
194
"fadd z6.s, z6.s, z16.s\n"
195
"add x24, x24, #0x20\n"
196
"ld1w { z2.s }, p3/Z, [x23, x9, LSL #2]\n"
197
"ld1w { z1.s }, p3/Z, [x22, x9, LSL #2]\n"
198
"ld1w { z0.s }, p3/Z, [x21, x9, LSL #2]\n"
199
"ld1w { z31.s }, p3/Z, [x20, x9, LSL #2]\n"
200
"bgt 9b\n"
201
"10:"
// Single vector of channels: Loop: 4 inputs tail
202
"fadd z17.s, z2.s, z1.s\n"
203
"fadd z16.s, z0.s, z31.s\n"
204
"fadd z16.s, z17.s, z16.s\n"
205
"fadd z6.s, z6.s, z16.s\n"
206
"11:"
// Single vector of channels: Loop: After loop
207
"ands x21, %x[n_valid_cells], #0x3\n"
208
"beq 13f\n"
209
"12:"
// Single vector of channels: Loop: Single input loop
210
"ldr x20, [x24], #0x8\n"
211
"ld1w { z16.s }, p3/Z, [x20, x9, LSL #2]\n"
212
"subs x21, x21, #0x1\n"
213
"fadd z6.s, z6.s, z16.s\n"
214
"bgt 12b\n"
215
"13:"
// Single vector of channels: Loop: Single input loop: End
216
"fmul z6.s, z6.s, z7.s\n"
217
"st1w { z6.s }, p3, [%x[outptr], x9, LSL #2]\n"
218
"incw x9\n"
219
"whilelt p3.s, x9, %x[n_channels]\n"
220
"b.any 8b\n"
221
"14:"
// End
222
:
223
: [inptrs]
"r"
(inptrs), [n_channels]
"r"
(n_channels), [n_valid_cells]
"r"
(n_valid_cells), [outptr]
"r"
(outptr), [rescale_ptr]
"r"
(&rescale_value)
224
:
"cc"
,
"memory"
,
"p0"
,
"p1"
,
"p2"
,
"p3"
,
"x9"
,
"x20"
,
"x21"
,
"x22"
,
"x23"
,
"x24"
,
"x25"
,
"x26"
,
"x27"
,
"x28"
,
"z0"
,
"z1"
,
"z2"
,
"z3"
,
"z4"
,
"z5"
,
"z6"
,
"z7"
,
"z16"
,
"z17"
,
"z18"
,
"z19"
,
"z20"
,
"z21"
,
"z22"
,
"z23"
,
"z24"
,
"z25"
,
"z26"
,
"z27"
,
"z28"
,
"z29"
,
"z30"
,
"z31"
225
);
226
}
227
228
}
// namespace pooling
229
}
// namespace arm_conv
230
231
#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_fp32_nhwc_avg_generic_depthfirst
generic.cpp
Generated on Mon Apr 29 2024 10:53:54 for Compute Library by
1.8.17