aboutsummaryrefslogtreecommitdiff
path: root/src/core/NEON/kernels/arm_conv/depthwise/kernels/sve_fp32_nhwc_3x3_s1_output2x2_mla_depthfirst/generic_indirect.cpp
blob: 77a6c683b0042d08ca78f5b3f93b36ea1127a18f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
/*
 * Copyright (c) 2021 Arm Limited.
 *
 * SPDX-License-Identifier: MIT
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to
 * deal in the Software without restriction, including without limitation the
 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 * sell copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#include <cstddef>
#include <cstdint>

#if __aarch64__ && defined(ARM_COMPUTE_ENABLE_SVE)

namespace arm_conv {
namespace depthwise {

void sve_fp32_nhwc_3x3_s1_output2x2_mla_depthfirst_indirect_impl(
  const float *const *const input_ptrs,
  float *const *const outptrs,
  const void *params,
  unsigned int n_channels,
  const float activation_min,
  const float activation_max
)
{
  struct Args
  {
    float *const *outptrs;
    const void *params;
    const float min, max;
    const float *inptrs[16];

    Args(
      const float *const *const input_ptrs,
      float *const *const outptrs,
      const void *const params,
      const float min,
      const float max
    ) : outptrs(outptrs), params(params), min(min), max(max)
    {
      inptrs[0] = input_ptrs[5];
      inptrs[1] = input_ptrs[0];
      inptrs[2] = input_ptrs[3];
      inptrs[3] = input_ptrs[6];
      inptrs[4] = input_ptrs[9];
      inptrs[5] = input_ptrs[12];
      inptrs[6] = input_ptrs[15];
      inptrs[7] = input_ptrs[1];
      inptrs[8] = input_ptrs[2];
      inptrs[9] = input_ptrs[10];
      inptrs[10] = input_ptrs[4];
      inptrs[11] = input_ptrs[7];
      inptrs[12] = input_ptrs[8];
      inptrs[13] = input_ptrs[11];
      inptrs[14] = input_ptrs[13];
      inptrs[15] = input_ptrs[14];

    }
  };

  Args params_struct(input_ptrs, outptrs, params,
                     activation_min, activation_max);

  __asm__ __volatile__(
    "ldr x19, [%x[params_struct], %[offsetof_args_outptrs]]\n"
    "ptrue p3.b\n"
    "ldr x15, [%x[params_struct], %[offsetof_args_params]]\n"
    "add x14, %x[params_struct], %[offsetof_Args_inptrs]\n"
    "ld1rw { z18.s }, p3/Z, [%x[params_struct], %[offsetof_args_min]]\n"
    "mov x13, #0x0\n"
    "ld1rw { z17.s }, p3/Z, [%x[params_struct], %[offsetof_args_max]]\n"
    "cntw x12\n"
    "ldp x11, x10, [x19, #0x0]\n"
    "sub x9, XZR, x12\n"
    "ldp x28, x27, [x19, #0x10]\n"
    "whilelt p2.s, XZR, %x[n_channels]\n"
    "ld1w { z16.s }, p3/Z, [x15]\n"
    "cmp x12, %x[n_channels]\n"
    "ld1w { z0.s }, p3/Z, [x15, #1, MUL VL]\n"
    "ld1w { z1.s }, p3/Z, [x15, #2, MUL VL]\n"
    "ld1w { z2.s }, p3/Z, [x15, #3, MUL VL]\n"
    "ld1w { z3.s }, p3/Z, [x15, #4, MUL VL]\n"
    "ld1w { z4.s }, p3/Z, [x15, #5, MUL VL]\n"
    "ld1w { z5.s }, p3/Z, [x15, #6, MUL VL]\n"
    "ld1w { z6.s }, p3/Z, [x15, #7, MUL VL]\n"
    "addvl x15, x15, #16\n"
    "ldp x26, x25, [x14, #0x0]\n"
    "ld1w { z7.s }, p3/Z, [x15, #-8, MUL VL]\n"
    "ld1w { z8.s }, p3/Z, [x15, #-7, MUL VL]\n"
    "addvl x15, x15, #-6\n"
    "ld1w { z9.s }, p2/Z, [x26, x13, LSL #2]\n"
    "ld1w { z10.s }, p2/Z, [x25, x13, LSL #2]\n"
    "ldp x24, x23, [x14, #0x10]\n"
    "ldr x22, [x14, #0x20]\n"
    "ld1w { z11.s }, p2/Z, [x24, x13, LSL #2]\n"
    "ld1w { z12.s }, p2/Z, [x23, x13, LSL #2]\n"
    "ld1w { z13.s }, p2/Z, [x22, x13, LSL #2]\n"
    "bge 2f\n"
    "1:"  // Channel loop
    "movprfx z31, z16\n fmla z31.s, p3/M, z4.s, z9.s\n"
    "ldr x21, [x14, #0x28]\n"
    "whilelt p1.s, x12, %x[n_channels]\n"
    "movprfx z30, z16\n fmla z30.s, p3/M, z3.s, z9.s\n"
    "ldr x20, [x14, #0x30]\n"
    "incw x9\n"
    "movprfx z29, z16\n fmla z29.s, p3/M, z1.s, z9.s\n"
    "ldr x19, [x14, #0x38]\n"
    "mov p0.b, p2.b\n"
    "movprfx z28, z16\n fmla z28.s, p3/M, z0.s, z9.s\n"
    "ld1w { z9.s }, p2/Z, [x21, x13, LSL #2]\n"
    "ldr x26, [x14, #0x40]\n"
    "fmla z31.s, p3/M, z0.s, z10.s\n"
    "ldr x25, [x14, #0x48]\n"
    "fmla z30.s, p3/M, z2.s, z11.s\n"
    "ld1w { z11.s }, p2/Z, [x20, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z2.s, z12.s\n"
    "ldr x24, [x14, #0x50]\n"
    "fmla z28.s, p3/M, z1.s, z12.s\n"
    "ld1w { z10.s }, p2/Z, [x25, x13, LSL #2]\n"
    "fmla z31.s, p3/M, z5.s, z12.s\n"
    "ldr x23, [x14, #0x58]\n"
    "fmla z30.s, p3/M, z4.s, z12.s\n"
    "ld1w { z12.s }, p2/Z, [x19, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z6.s, z9.s\n"
    "ld1w { z9.s }, p2/Z, [x26, x13, LSL #2]\n"
    "fmla z28.s, p3/M, z3.s, z13.s\n"
    "ldr x22, [x14, #0x60]\n"
    "fmla z31.s, p3/M, z7.s, z13.s\n"
    "ldr x21, [x14, #0x68]\n"
    "fmla z30.s, p3/M, z6.s, z13.s\n"
    "ldr x20, [x14, #0x70]\n"
    "fmla z29.s, p3/M, z4.s, z13.s\n"
    "ldr x19, [x14, #0x78]\n"
    "fmla z28.s, p3/M, z8.s, z11.s\n"
    "ld1w { z11.s }, p2/Z, [x24, x13, LSL #2]\n"
    "fmla z31.s, p3/M, z1.s, z12.s\n"
    "ldp x26, x25, [x14, #0x0]\n"
    "fmla z30.s, p3/M, z0.s, z12.s\n"
    "ld1w { z12.s }, p2/Z, [x23, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z5.s, z10.s\n"
    "ldp x24, x23, [x14, #0x10]\n"
    "fmla z28.s, p3/M, z4.s, z10.s\n"
    "ld1w { z16.s }, p3/Z, [x15]\n"
    "fmla z31.s, p3/M, z2.s, z9.s\n"
    "ld1w { z4.s }, p3/Z, [x15, #5, MUL VL]\n"
    "fmla z30.s, p3/M, z1.s, z9.s\n"
    "ld1w { z9.s }, p2/Z, [x22, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z0.s, z11.s\n"
    "ldr x22, [x14, #0x20]\n"
    "fmla z28.s, p3/M, z2.s, z12.s\n"
    "ld1w { z0.s }, p3/Z, [x15, #1, MUL VL]\n"
    "fmla z31.s, p3/M, z8.s, z10.s\n"
    "ld1w { z1.s }, p3/Z, [x15, #2, MUL VL]\n"
    "fmla z30.s, p3/M, z7.s, z10.s\n"
    "ld1w { z10.s }, p2/Z, [x21, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z3.s, z9.s\n"
    "ld1w { z13.s }, p1/Z, [x22, x12, LSL #2]\n"
    "fmla z31.s, p3/M, z3.s, z11.s\n"
    "ld1w { z11.s }, p2/Z, [x20, x13, LSL #2]\n"
    "fmla z28.s, p3/M, z5.s, z10.s\n"
    "ld1w { z2.s }, p3/Z, [x15, #3, MUL VL]\n"
    "fmla z30.s, p3/M, z5.s, z12.s\n"
    "ld1w { z12.s }, p2/Z, [x19, x13, LSL #2]\n"
    "incw x13\n"
    "fmla z29.s, p3/M, z7.s, z11.s\n"
    "ld1w { z3.s }, p3/Z, [x15, #4, MUL VL]\n"
    "whilelt p2.s, x13, %x[n_channels]\n"
    "fmla z31.s, p3/M, z6.s, z9.s\n"
    "ld1w { z9.s }, p1/Z, [x26, x12, LSL #2]\n"
    "fmla z28.s, p3/M, z6.s, z11.s\n"
    "ld1w { z11.s }, p1/Z, [x24, x12, LSL #2]\n"
    "fmla z30.s, p3/M, z8.s, z10.s\n"
    "ld1w { z10.s }, p1/Z, [x25, x12, LSL #2]\n"
    "ld1w { z5.s }, p3/Z, [x15, #6, MUL VL]\n"
    "fmla z29.s, p3/M, z8.s, z12.s\n"
    "ld1w { z6.s }, p3/Z, [x15, #7, MUL VL]\n"
    "fmla z28.s, p3/M, z7.s, z12.s\n"
    "addvl x15, x15, #16\n"
    "fmax z31.s, p3/M, z31.s, z18.s\n"
    "ld1w { z12.s }, p1/Z, [x23, x12, LSL #2]\n"
    "incw x12\n"
    "fmax z30.s, p3/M, z30.s, z18.s\n"
    "ld1w { z7.s }, p3/Z, [x15, #-8, MUL VL]\n"
    "cmp x12, %x[n_channels]\n"
    "fmax z29.s, p3/M, z29.s, z18.s\n"
    "ld1w { z8.s }, p3/Z, [x15, #-7, MUL VL]\n"
    "addvl x15, x15, #-6\n"
    "fmax z28.s, p3/M, z28.s, z18.s\n"
    "fmin z31.s, p3/M, z31.s, z17.s\n"
    "st1w { z31.s }, p0, [x11, x9, LSL #2]\n"
    "fmin z30.s, p3/M, z30.s, z17.s\n"
    "fmin z29.s, p3/M, z29.s, z17.s\n"
    "st1w { z30.s }, p0, [x10, x9, LSL #2]\n"
    "fmin z28.s, p3/M, z28.s, z17.s\n"
    "st1w { z29.s }, p0, [x28, x9, LSL #2]\n"
    "st1w { z28.s }, p0, [x27, x9, LSL #2]\n"
    "blt 1b\n"
    "2:"  // Channel tail
    "movprfx z31, z16\n fmla z31.s, p3/M, z4.s, z9.s\n"
    "ldr x21, [x14, #0x28]\n"
    "incw x9\n"
    "movprfx z30, z16\n fmla z30.s, p3/M, z3.s, z9.s\n"
    "ldr x20, [x14, #0x30]\n"
    "mov p0.b, p2.b\n"
    "movprfx z29, z16\n fmla z29.s, p3/M, z1.s, z9.s\n"
    "ldr x19, [x14, #0x38]\n"
    "movprfx z28, z16\n fmla z28.s, p3/M, z0.s, z9.s\n"
    "ld1w { z9.s }, p2/Z, [x21, x13, LSL #2]\n"
    "ldr x26, [x14, #0x40]\n"
    "fmla z31.s, p3/M, z0.s, z10.s\n"
    "ldr x25, [x14, #0x48]\n"
    "fmla z30.s, p3/M, z2.s, z11.s\n"
    "ld1w { z11.s }, p2/Z, [x20, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z2.s, z12.s\n"
    "fmla z28.s, p3/M, z1.s, z12.s\n"
    "ld1w { z10.s }, p2/Z, [x25, x13, LSL #2]\n"
    "ldr x24, [x14, #0x50]\n"
    "fmla z31.s, p3/M, z5.s, z12.s\n"
    "ldr x23, [x14, #0x58]\n"
    "fmla z30.s, p3/M, z4.s, z12.s\n"
    "ld1w { z12.s }, p2/Z, [x19, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z6.s, z9.s\n"
    "fmla z28.s, p3/M, z3.s, z13.s\n"
    "ld1w { z9.s }, p2/Z, [x26, x13, LSL #2]\n"
    "ldr x22, [x14, #0x60]\n"
    "fmla z31.s, p3/M, z7.s, z13.s\n"
    "ldr x21, [x14, #0x68]\n"
    "fmla z30.s, p3/M, z6.s, z13.s\n"
    "ldr x20, [x14, #0x70]\n"
    "fmla z29.s, p3/M, z4.s, z13.s\n"
    "fmla z28.s, p3/M, z8.s, z11.s\n"
    "ld1w { z11.s }, p2/Z, [x24, x13, LSL #2]\n"
    "ldr x19, [x14, #0x78]\n"
    "fmla z31.s, p3/M, z1.s, z12.s\n"
    "fmla z30.s, p3/M, z0.s, z12.s\n"
    "ld1w { z12.s }, p2/Z, [x23, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z5.s, z10.s\n"
    "fmla z28.s, p3/M, z4.s, z10.s\n"
    "fmla z31.s, p3/M, z2.s, z9.s\n"
    "fmla z30.s, p3/M, z1.s, z9.s\n"
    "ld1w { z9.s }, p2/Z, [x22, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z0.s, z11.s\n"
    "fmla z28.s, p3/M, z2.s, z12.s\n"
    "fmla z31.s, p3/M, z8.s, z10.s\n"
    "fmla z30.s, p3/M, z7.s, z10.s\n"
    "ld1w { z10.s }, p2/Z, [x21, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z3.s, z9.s\n"
    "fmla z31.s, p3/M, z3.s, z11.s\n"
    "ld1w { z11.s }, p2/Z, [x20, x13, LSL #2]\n"
    "fmla z28.s, p3/M, z5.s, z10.s\n"
    "fmla z30.s, p3/M, z5.s, z12.s\n"
    "ld1w { z12.s }, p2/Z, [x19, x13, LSL #2]\n"
    "fmla z29.s, p3/M, z7.s, z11.s\n"
    "fmla z31.s, p3/M, z6.s, z9.s\n"
    "fmla z28.s, p3/M, z6.s, z11.s\n"
    "fmla z30.s, p3/M, z8.s, z10.s\n"
    "fmla z29.s, p3/M, z8.s, z12.s\n"
    "fmla z28.s, p3/M, z7.s, z12.s\n"
    "fmax z31.s, p3/M, z31.s, z18.s\n"
    "fmax z30.s, p3/M, z30.s, z18.s\n"
    "fmax z29.s, p3/M, z29.s, z18.s\n"
    "fmin z31.s, p3/M, z31.s, z17.s\n"
    "st1w { z31.s }, p0, [x11, x9, LSL #2]\n"
    "fmin z30.s, p3/M, z30.s, z17.s\n"
    "fmin z29.s, p3/M, z29.s, z17.s\n"
    "st1w { z30.s }, p0, [x10, x9, LSL #2]\n"
    "fmax z28.s, p3/M, z28.s, z18.s\n"
    "st1w { z29.s }, p0, [x28, x9, LSL #2]\n"
    "fmin z28.s, p3/M, z28.s, z17.s\n"
    "st1w { z28.s }, p0, [x27, x9, LSL #2]\n"
    :
    : [n_channels] "r" ((unsigned long) n_channels), [offsetof_Args_inptrs] "I" (offsetof(Args, inptrs)), [offsetof_args_max] "I" (offsetof(Args, max)), [offsetof_args_min] "I" (offsetof(Args, min)), [offsetof_args_outptrs] "I" (offsetof(Args, outptrs)), [offsetof_args_params] "I" (offsetof(Args, params)), [params_struct] "r" (&params_struct)
    : "cc", "memory", "p0", "p1", "p2", "p3", "x9", "x10", "x11", "x12", "x13", "x14", "x15", "x19", "x20", "x21", "x22", "x23", "x24", "x25", "x26", "x27", "x28", "z0", "z1", "z2", "z3", "z4", "z5", "z6", "z7", "z8", "z9", "z10", "z11", "z12", "z13", "z16", "z17", "z18", "z28", "z29", "z30", "z31"
  );
}

}  // namespace depthwise
}  // namespace arm_conv

#endif  // __aarch64__ && defined(ARM_COMPUTE_ENABLE_SVE)