aboutsummaryrefslogtreecommitdiff
path: root/arm_compute/core/NEON/kernels/winograd/transforms/kernel_2x2_3x3/a64_float.hpp
blob: 3dd62d1ac1bf67c946d0b8e61f61a878a0d8e725 (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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
/*
 * Copyright (c) 2017 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.
 */
#pragma once

#ifdef __aarch64__
namespace winograd {
template <>
template <>
inline void winograd2x2_3x3_gemm_kernel_transform_impl<float>::transform_kernel<0>(
    const float* const kernel,
    const int n_input_channels,
    const int n_output_channels,
    float* const matrix_base,
    const int mstride,
    const int matrix_row_stride
) {
  // Use one input pointer for each row of the kernel, use two additional
  // offsets to extract columns.
  const int kernel_col_stride = n_input_channels * n_output_channels;
  const int kernel_row_stride = 3 * kernel_col_stride;
  const float *inptr0 = kernel;
  const float *inptr1 = kernel + kernel_row_stride;
  const float *inptr2 = kernel + kernel_row_stride*2;

  // Use four output pointers, for output matrices 0, 4, 8 and 12. Use three
  // offsets to extract further matrices.
  float  *outptr0 = matrix_base;
  float  *outptr4 = matrix_base + mstride * 4;
  float  *outptr8 = matrix_base + mstride * 8;
  float *outptr12 = matrix_base + mstride * 12;

  // For every input channel
  for (int in_c = 0; in_c < n_input_channels; in_c++) {
    int n_remaining_channels = n_output_channels;

    asm volatile (
        // Registers into which to read the kernel
        "w_11 .req v0\n"  "qw_11 .req q0\n"
        "w_12 .req v1\n"  "qw_12 .req q1\n"
        "w_13 .req v2\n"  "qw_13 .req q2\n"
        "w_21 .req v3\n"  "qw_21 .req q3\n"
        "w_22 .req v4\n"  "qw_22 .req q4\n"
        "w_23 .req v5\n"  "qw_23 .req q5\n"
        "w_31 .req v6\n"  "qw_31 .req q6\n"
        "w_32 .req v7\n"  "qw_32 .req q7\n"
        "w_33 .req v8\n"  "qw_33 .req q8\n"

        // Transformed matrix Ww
        "Ww11 .req w_11\n"  "Ww12 .req w_12\n"  "Ww13 .req w_13\n"
        "Ww21 .req  v9\n"   "Ww22 .req v10\n"   "Ww23 .req v11\n"
        "Ww31 .req v12\n"   "Ww32 .req v13\n"   "Ww33 .req v14\n"
        "Ww41 .req w_31\n"  "Ww42 .req w_32\n"  "Ww43 .req w_33\n"

        // Output matrix U = WwWT
        "U11 .req Ww11\n"   "U12 .req v15\n"  "U13 .req v16\n"  "U14 .req Ww13\n"
        "U21 .req Ww21\n"   "U22 .req v17\n"  "U23 .req v18\n"  "U24 .req Ww23\n"
        "U31 .req Ww31\n"   "U32 .req v19\n"  "U33 .req v20\n"  "U34 .req Ww33\n"
        "U41 .req Ww41\n"   "U42 .req v21\n"  "U43 .req v22\n"  "U44 .req Ww43\n"

        // Storage view of output matrices
        "qU11 .req   q0\n"   "qU12 .req q15\n"  "qU13 .req q16\n"  "qU14 .req   q2\n"
        "qU21 .req   q9\n"   "qU22 .req q17\n"  "qU23 .req q18\n"  "qU24 .req  q11\n"
        "qU31 .req  q12\n"   "qU32 .req q19\n"  "qU33 .req q20\n"  "qU34 .req  q14\n"
        "qU41 .req   q6\n"   "qU42 .req q21\n"  "qU43 .req q22\n"  "qU44 .req   q8\n"

        "half .req v23\n"  // {0.5, ..., 0.5}
        "dup half.4s, %w[one_half]\n"
        "scratch .req v24\n"

        "1:"
          // Load tile of the kernel
          "ldr qw_11, [%x[inptr0]]\n"
          "str qU11, [%x[outptr0]]\n"
          "ldr qw_12, [%x[inptr0], %x[colstride1]]\n"
          "ldr qw_13, [%x[inptr0], %x[colstride2]]\n"
          "str qU14, [%x[outptr0], %x[mstride3]]\n"
          "add %x[inptr0], %x[inptr0], #0x10\n"

          "ldr qw_21, [%x[inptr1]]\n"
          "ldr qw_22, [%x[inptr1], %x[colstride1]]\n"
          "ldr qw_23, [%x[inptr1], %x[colstride2]]\n"
          "add %x[inptr1], %x[inptr1], #0x10\n"

          "ldr qw_31, [%x[inptr2]]\n"
          "str qU41, [%x[outptr12]]\n"
          "ldr qw_32, [%x[inptr2], %x[colstride1]]\n"
          "ldr qw_33, [%x[inptr2], %x[colstride2]]\n"
          "str qU44, [%x[outptr12], %x[mstride3]]\n"
          "add %x[inptr2], %x[inptr2], #0x10\n"

          // Compute 2nd and 3rd rows of Ww
          "fadd scratch.4s, w_11.4s, w_31.4s\n"
          "fmul Ww21.4s, scratch.4s, half.4s\n"
          "fmla Ww21.4s, w_21.4s, half.4s\n"
          "str qU21, [%x[outptr4]]\n"
          "fmul Ww31.4s, scratch.4s, half.4s\n"
          "fmls Ww31.4s, w_21.4s, half.4s\n"
          "str qU31, [%x[outptr8]]\n"

          "fadd scratch.4s, w_12.4s, w_32.4s\n"
          "fmul Ww22.4s, scratch.4s, half.4s\n"
          "fmla Ww22.4s, w_22.4s, half.4s\n"
          "fmul Ww32.4s, scratch.4s, half.4s\n"
          "fmls Ww32.4s, w_22.4s, half.4s\n"

          "fadd scratch.4s, w_13.4s, w_33.4s\n"
          "fmul Ww23.4s, scratch.4s, half.4s\n"
          "fmla Ww23.4s, w_23.4s, half.4s\n"
          "str qU24, [%x[outptr4], %x[mstride3]]\n"
          "fmul Ww33.4s, scratch.4s, half.4s\n"
          "fmls Ww33.4s, w_23.4s, half.4s\n"
          "str qU34, [%x[outptr8], %x[mstride3]]\n"

          // Compute and store U, only need to compute the 2nd and 3rd columns
          // of U and update output pointers
          "fadd scratch.4s, Ww11.4s, Ww13.4s\n"
          "fmul U12.4s, scratch.4s, half.4s\n"
          "fmla U12.4s, Ww12.4s, half.4s\n"
          "str qU12, [%x[outptr0], %x[mstride1]]\n"
          "fmul U13.4s, scratch.4s, half.4s\n"
          "fmls U13.4s, Ww12.4s, half.4s\n"
          "str qU13, [%x[outptr0], %x[mstride2]]\n"
          "add  %x[outptr0],  %x[outptr0], #0x10\n"

          "fadd scratch.4s, Ww21.4s, Ww23.4s\n"
          "fmul U22.4s, scratch.4s, half.4s\n"
          "fmla U22.4s, Ww22.4s, half.4s\n"
          "str qU22, [%x[outptr4], %x[mstride1]]\n"
          "fmul U23.4s, scratch.4s, half.4s\n"
          "fmls U23.4s, Ww22.4s, half.4s\n"
          "str qU23, [%x[outptr4], %x[mstride2]]\n"
          "add  %x[outptr4],  %x[outptr4], #0x10\n"

          "fadd scratch.4s, Ww31.4s, Ww33.4s\n"
          "fmul U32.4s, scratch.4s, half.4s\n"
          "fmla U32.4s, Ww32.4s, half.4s\n"
          "str qU32, [%x[outptr8], %x[mstride1]]\n"
          "fmul U33.4s, scratch.4s, half.4s\n"
          "fmls U33.4s, Ww32.4s, half.4s\n"
          "str qU33, [%x[outptr8], %x[mstride2]]\n"
          "add  %x[outptr8],  %x[outptr8], #0x10\n"

          "fadd scratch.4s, Ww41.4s, Ww43.4s\n"
          "fmul U42.4s, scratch.4s, half.4s\n"
          "fmla U42.4s, Ww42.4s, half.4s\n"
          "str qU42, [%x[outptr12], %x[mstride1]]\n"
          "fmul U43.4s, scratch.4s, half.4s\n"
          "fmls U43.4s, Ww42.4s, half.4s\n"
          "str qU43, [%x[outptr12], %x[mstride2]]\n"
          "add %x[outptr12], %x[outptr12], #0x10\n"

          "subs %x[n_remaining_channels], %x[n_remaining_channels], #4\n"
          "bne 1b\n"

        // Clear aliases
        ".unreq half\n"
        ".unreq scratch\n"
        ".unreq w_11\n"  ".unreq qw_11\n"
        ".unreq w_12\n"  ".unreq qw_12\n"
        ".unreq w_13\n"  ".unreq qw_13\n"
        ".unreq w_21\n"  ".unreq qw_21\n"
        ".unreq w_22\n"  ".unreq qw_22\n"
        ".unreq w_23\n"  ".unreq qw_23\n"
        ".unreq w_31\n"  ".unreq qw_31\n"
        ".unreq w_32\n"  ".unreq qw_32\n"
        ".unreq w_33\n"  ".unreq qw_33\n"
        ".unreq Ww11\n"  ".unreq Ww12\n"  ".unreq Ww13\n"
        ".unreq Ww21\n"  ".unreq Ww22\n"  ".unreq Ww23\n"
        ".unreq Ww31\n"  ".unreq Ww32\n"  ".unreq Ww33\n"
        ".unreq Ww41\n"  ".unreq Ww42\n"  ".unreq Ww43\n"
        ".unreq U11\n"   ".unreq U12\n"   ".unreq U13\n"   ".unreq U14\n"
        ".unreq U21\n"   ".unreq U22\n"   ".unreq U23\n"   ".unreq U24\n"
        ".unreq U31\n"   ".unreq U32\n"   ".unreq U33\n"   ".unreq U34\n"
        ".unreq U41\n"   ".unreq U42\n"   ".unreq U43\n"   ".unreq U44\n"
        ".unreq qU11\n"  ".unreq qU12\n"  ".unreq qU13\n"  ".unreq qU14\n"
        ".unreq qU21\n"  ".unreq qU22\n"  ".unreq qU23\n"  ".unreq qU24\n"
        ".unreq qU31\n"  ".unreq qU32\n"  ".unreq qU33\n"  ".unreq qU34\n"
        ".unreq qU41\n"  ".unreq qU42\n"  ".unreq qU43\n"  ".unreq qU44\n"

      : [inptr0] "+r" (inptr0),
        [inptr1] "+r" (inptr1),
        [inptr2] "+r" (inptr2),
        [outptr0] "+r" (outptr0),
        [outptr4] "+r" (outptr4),
        [outptr8] "+r" (outptr8),
        [outptr12] "+r" (outptr12),
        [n_remaining_channels] "+r" (n_remaining_channels)
      : [mstride1] "r" (sizeof(float) * mstride),
        [mstride2] "r" (sizeof(float) * mstride * 2),
        [mstride3] "r" (sizeof(float) * mstride * 3),
        [colstride1] "r" (sizeof(float) * kernel_col_stride),
        [colstride2] "r" (sizeof(float) * kernel_col_stride * 2),
        [one_half] "r" (0.5f)
      : "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
        "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19",
        "v20", "v21", "v22", "v23", "v24"
    );

    // Progression to complete stride
    outptr0 += matrix_row_stride - n_output_channels;
    outptr4 += matrix_row_stride - n_output_channels;
    outptr8 += matrix_row_stride - n_output_channels;
    outptr12 += matrix_row_stride - n_output_channels;
  }
}

template <>
template <>
inline void winograd2x2_3x3_gemm_kernel_transform_impl<float>::transform_kernel<2>(
    const float* const kernel,
    const int n_input_channels,
    const int n_output_channels,
    float* const matrix_base,
    const int mstride,
    const int matrix_row_stride
) {
  // Use one input pointer for each row of the kernel, use two additional
  // offsets to extract columns.
  const int kernel_col_stride = n_input_channels * n_output_channels;
  const int kernel_row_stride = 3 * kernel_col_stride;
  const float *inptr0 = kernel;
  const float *inptr1 = kernel + kernel_row_stride;
  const float *inptr2 = kernel + kernel_row_stride*2;

  // Use four output pointers, for output matrices 0, 4, 8 and 12. Use three
  // offsets to extract further matrices.
  float  *outptr0 = matrix_base;
  float  *outptr4 = matrix_base + mstride * 4;
  float  *outptr8 = matrix_base + mstride * 8;
  float *outptr12 = matrix_base + mstride * 12;

  // For every input channel
  for (int in_c = 0; in_c < n_input_channels; in_c++) {
    int n_remaining_channels = n_output_channels;

    asm volatile (
        // Registers into which to read the kernel
        "w_11 .req v0\n"  "qw_11 .req q0\n"  "dw_11 .req d0\n"
        "w_12 .req v1\n"  "qw_12 .req q1\n"  "dw_12 .req d1\n"
        "w_13 .req v2\n"  "qw_13 .req q2\n"  "dw_13 .req d2\n"
        "w_21 .req v3\n"  "qw_21 .req q3\n"  "dw_21 .req d3\n"
        "w_22 .req v4\n"  "qw_22 .req q4\n"  "dw_22 .req d4\n"
        "w_23 .req v5\n"  "qw_23 .req q5\n"  "dw_23 .req d5\n"
        "w_31 .req v6\n"  "qw_31 .req q6\n"  "dw_31 .req d6\n"
        "w_32 .req v7\n"  "qw_32 .req q7\n"  "dw_32 .req d7\n"
        "w_33 .req v8\n"  "qw_33 .req q8\n"  "dw_33 .req d8\n"

        // Transformed matrix Ww
        "Ww11 .req w_11\n"  "Ww12 .req w_12\n"  "Ww13 .req w_13\n"
        "Ww21 .req  v9\n"   "Ww22 .req v10\n"   "Ww23 .req v11\n"
        "Ww31 .req v12\n"   "Ww32 .req v13\n"   "Ww33 .req v14\n"
        "Ww41 .req w_31\n"  "Ww42 .req w_32\n"  "Ww43 .req w_33\n"

        // Output matrix U = WwWT
        "U11 .req Ww11\n"   "U12 .req v15\n"  "U13 .req v16\n"  "U14 .req Ww13\n"
        "U21 .req Ww21\n"   "U22 .req v17\n"  "U23 .req v18\n"  "U24 .req Ww23\n"
        "U31 .req Ww31\n"   "U32 .req v19\n"  "U33 .req v20\n"  "U34 .req Ww33\n"
        "U41 .req Ww41\n"   "U42 .req v21\n"  "U43 .req v22\n"  "U44 .req Ww43\n"

        // Storage view of output matrices
        "qU11 .req   q0\n"   "qU12 .req q15\n"  "qU13 .req q16\n"  "qU14 .req   q2\n"
        "qU21 .req   q9\n"   "qU22 .req q17\n"  "qU23 .req q18\n"  "qU24 .req  q11\n"
        "qU31 .req  q12\n"   "qU32 .req q19\n"  "qU33 .req q20\n"  "qU34 .req  q14\n"
        "qU41 .req   q6\n"   "qU42 .req q21\n"  "qU43 .req q22\n"  "qU44 .req   q8\n"

        "dU11 .req   d0\n"   "dU12 .req d15\n"  "dU13 .req d16\n"  "dU14 .req   d2\n"
        "dU21 .req   d9\n"   "dU22 .req d17\n"  "dU23 .req d18\n"  "dU24 .req  d11\n"
        "dU31 .req  d12\n"   "dU32 .req d19\n"  "dU33 .req d20\n"  "dU34 .req  d14\n"
        "dU41 .req   d6\n"   "dU42 .req d21\n"  "dU43 .req d22\n"  "dU44 .req   d8\n"

        "half .req v23\n"  // {0.5, ..., 0.5}
        "dup half.4s, %w[one_half]\n"
        "scratch .req v24\n"
        
        // Subtract the tail from the number of remaining channels and jump to
        // the tail if necessary.
        "subs %x[n_remaining_channels], %x[n_remaining_channels], #2\n"
        "beq 2f\n"

        "1:"
          // Load tile of the kernel
          "ldr qw_11, [%x[inptr0]]\n"
          "str qU11, [%x[outptr0]]\n"
          "ldr qw_12, [%x[inptr0], %x[colstride1]]\n"
          "ldr qw_13, [%x[inptr0], %x[colstride2]]\n"
          "str qU14, [%x[outptr0], %x[mstride3]]\n"
          "add %x[inptr0], %x[inptr0], #0x10\n"

          "ldr qw_21, [%x[inptr1]]\n"
          "ldr qw_22, [%x[inptr1], %x[colstride1]]\n"
          "ldr qw_23, [%x[inptr1], %x[colstride2]]\n"
          "add %x[inptr1], %x[inptr1], #0x10\n"

          "ldr qw_31, [%x[inptr2]]\n"
          "str qU41, [%x[outptr12]]\n"
          "ldr qw_32, [%x[inptr2], %x[colstride1]]\n"
          "ldr qw_33, [%x[inptr2], %x[colstride2]]\n"
          "str qU44, [%x[outptr12], %x[mstride3]]\n"
          "add %x[inptr2], %x[inptr2], #0x10\n"

          // Compute 2nd and 3rd rows of Ww
          "fadd scratch.4s, w_11.4s, w_31.4s\n"
          "fmul Ww21.4s, scratch.4s, half.4s\n"
          "fmla Ww21.4s, w_21.4s, half.4s\n"
          "str qU21, [%x[outptr4]]\n"
          "fmul Ww31.4s, scratch.4s, half.4s\n"
          "fmls Ww31.4s, w_21.4s, half.4s\n"
          "str qU31, [%x[outptr8]]\n"

          "fadd scratch.4s, w_12.4s, w_32.4s\n"
          "fmul Ww22.4s, scratch.4s, half.4s\n"
          "fmla Ww22.4s, w_22.4s, half.4s\n"
          "fmul Ww32.4s, scratch.4s, half.4s\n"
          "fmls Ww32.4s, w_22.4s, half.4s\n"

          "fadd scratch.4s, w_13.4s, w_33.4s\n"
          "fmul Ww23.4s, scratch.4s, half.4s\n"
          "fmla Ww23.4s, w_23.4s, half.4s\n"
          "str qU24, [%x[outptr4], %x[mstride3]]\n"
          "fmul Ww33.4s, scratch.4s, half.4s\n"
          "fmls Ww33.4s, w_23.4s, half.4s\n"
          "str qU34, [%x[outptr8], %x[mstride3]]\n"

          // Compute and store U, only need to compute the 2nd and 3rd columns
          // of U and update output pointers
          "fadd scratch.4s, Ww11.4s, Ww13.4s\n"
          "fmul U12.4s, scratch.4s, half.4s\n"
          "fmla U12.4s, Ww12.4s, half.4s\n"
          "str qU12, [%x[outptr0], %x[mstride1]]\n"
          "fmul U13.4s, scratch.4s, half.4s\n"
          "fmls U13.4s, Ww12.4s, half.4s\n"
          "str qU13, [%x[outptr0], %x[mstride2]]\n"
          "add  %x[outptr0],  %x[outptr0], #0x10\n"

          "fadd scratch.4s, Ww21.4s, Ww23.4s\n"
          "fmul U22.4s, scratch.4s, half.4s\n"
          "fmla U22.4s, Ww22.4s, half.4s\n"
          "str qU22, [%x[outptr4], %x[mstride1]]\n"
          "fmul U23.4s, scratch.4s, half.4s\n"
          "fmls U23.4s, Ww22.4s, half.4s\n"
          "str qU23, [%x[outptr4], %x[mstride2]]\n"
          "add  %x[outptr4],  %x[outptr4], #0x10\n"

          "fadd scratch.4s, Ww31.4s, Ww33.4s\n"
          "fmul U32.4s, scratch.4s, half.4s\n"
          "fmla U32.4s, Ww32.4s, half.4s\n"
          "str qU32, [%x[outptr8], %x[mstride1]]\n"
          "fmul U33.4s, scratch.4s, half.4s\n"
          "fmls U33.4s, Ww32.4s, half.4s\n"
          "str qU33, [%x[outptr8], %x[mstride2]]\n"
          "add  %x[outptr8],  %x[outptr8], #0x10\n"

          "fadd scratch.4s, Ww41.4s, Ww43.4s\n"
          "fmul U42.4s, scratch.4s, half.4s\n"
          "fmla U42.4s, Ww42.4s, half.4s\n"
          "str qU42, [%x[outptr12], %x[mstride1]]\n"
          "fmul U43.4s, scratch.4s, half.4s\n"
          "fmls U43.4s, Ww42.4s, half.4s\n"
          "str qU43, [%x[outptr12], %x[mstride2]]\n"
          "add %x[outptr12], %x[outptr12], #0x10\n"

          "subs %x[n_remaining_channels], %x[n_remaining_channels], #4\n"
          "bne 1b\n"

        // Tail size 2
        "2:"
          // Load tile of the kernel
          "ldr dw_11, [%x[inptr0]]\n"
          "str dU11, [%x[outptr0]]\n"
          "ldr dw_12, [%x[inptr0], %x[colstride1]]\n"
          "ldr dw_13, [%x[inptr0], %x[colstride2]]\n"
          "str dU14, [%x[outptr0], %x[mstride3]]\n"
          "add %x[inptr0], %x[inptr0], #0x08\n"

          "ldr dw_21, [%x[inptr1]]\n"
          "ldr dw_22, [%x[inptr1], %x[colstride1]]\n"
          "ldr dw_23, [%x[inptr1], %x[colstride2]]\n"
          "add %x[inptr1], %x[inptr1], #0x08\n"

          "ldr dw_31, [%x[inptr2]]\n"
          "str dU41, [%x[outptr12]]\n"
          "ldr dw_32, [%x[inptr2], %x[colstride1]]\n"
          "ldr dw_33, [%x[inptr2], %x[colstride2]]\n"
          "str dU44, [%x[outptr12], %x[mstride3]]\n"
          "add %x[inptr2], %x[inptr2], #0x08\n"

          // Compute 2nd and 3rd rows of Ww
          "fadd scratch.2s, w_11.2s, w_31.2s\n"
          "fmul Ww21.2s, scratch.2s, half.2s\n"
          "fmla Ww21.2s, w_21.2s, half.2s\n"
          "str dU21, [%x[outptr4]]\n"
          "fmul Ww31.2s, scratch.2s, half.2s\n"
          "fmls Ww31.2s, w_21.2s, half.2s\n"
          "str dU31, [%x[outptr8]]\n"

          "fadd scratch.2s, w_12.2s, w_32.2s\n"
          "fmul Ww22.2s, scratch.2s, half.2s\n"
          "fmla Ww22.2s, w_22.2s, half.2s\n"
          "fmul Ww32.2s, scratch.2s, half.2s\n"
          "fmls Ww32.2s, w_22.2s, half.2s\n"

          "fadd scratch.2s, w_13.2s, w_33.2s\n"
          "fmul Ww23.2s, scratch.2s, half.2s\n"
          "fmla Ww23.2s, w_23.2s, half.2s\n"
          "str dU24, [%x[outptr4], %x[mstride3]]\n"
          "fmul Ww33.2s, scratch.2s, half.2s\n"
          "fmls Ww33.2s, w_23.2s, half.2s\n"
          "str dU34, [%x[outptr8], %x[mstride3]]\n"

          // Compute and store U, only need to compute the 2nd and 3rd columns of
          // U and update output pointers
          "fadd scratch.2s, Ww11.2s, Ww13.2s\n"
          "fmul U12.2s, scratch.2s, half.2s\n"
          "fmla U12.2s, Ww12.2s, half.2s\n"
          "str dU12, [%x[outptr0], %x[mstride1]]\n"
          "fmul U13.2s, scratch.2s, half.2s\n"
          "fmls U13.2s, Ww12.2s, half.2s\n"
          "str dU13, [%x[outptr0], %x[mstride2]]\n"
          "add  %x[outptr0],  %x[outptr0], #0x08\n"

          "fadd scratch.2s, Ww21.2s, Ww23.2s\n"
          "fmul U22.2s, scratch.2s, half.2s\n"
          "fmla U22.2s, Ww22.2s, half.2s\n"
          "str dU22, [%x[outptr4], %x[mstride1]]\n"
          "fmul U23.2s, scratch.2s, half.2s\n"
          "fmls U23.2s, Ww22.2s, half.2s\n"
          "str dU23, [%x[outptr4], %x[mstride2]]\n"
          "add  %x[outptr4],  %x[outptr4], #0x08\n"

          "fadd scratch.2s, Ww31.2s, Ww33.2s\n"
          "fmul U32.2s, scratch.2s, half.2s\n"
          "fmla U32.2s, Ww32.2s, half.2s\n"
          "str dU32, [%x[outptr8], %x[mstride1]]\n"
          "fmul U33.2s, scratch.2s, half.2s\n"
          "fmls U33.2s, Ww32.2s, half.2s\n"
          "str dU33, [%x[outptr8], %x[mstride2]]\n"
          "add  %x[outptr8],  %x[outptr8], #0x08\n"

          "fadd scratch.2s, Ww41.2s, Ww43.2s\n"
          "fmul U42.2s, scratch.2s, half.2s\n"
          "fmla U42.2s, Ww42.2s, half.2s\n"
          "str dU42, [%x[outptr12], %x[mstride1]]\n"
          "fmul U43.2s, scratch.2s, half.2s\n"
          "fmls U43.2s, Ww42.2s, half.2s\n"
          "str dU43, [%x[outptr12], %x[mstride2]]\n"
          "add %x[outptr12], %x[outptr12], #0x08\n"

        // Clear aliases
        ".unreq half\n"
        ".unreq scratch\n"
        ".unreq w_11\n"  ".unreq qw_11\n" ".unreq dw_11\n"
        ".unreq w_12\n"  ".unreq qw_12\n" ".unreq dw_12\n"
        ".unreq w_13\n"  ".unreq qw_13\n" ".unreq dw_13\n"
        ".unreq w_21\n"  ".unreq qw_21\n" ".unreq dw_21\n"
        ".unreq w_22\n"  ".unreq qw_22\n" ".unreq dw_22\n"
        ".unreq w_23\n"  ".unreq qw_23\n" ".unreq dw_23\n"
        ".unreq w_31\n"  ".unreq qw_31\n" ".unreq dw_31\n"
        ".unreq w_32\n"  ".unreq qw_32\n" ".unreq dw_32\n"
        ".unreq w_33\n"  ".unreq qw_33\n" ".unreq dw_33\n"
        ".unreq Ww11\n"  ".unreq Ww12\n"  ".unreq Ww13\n"
        ".unreq Ww21\n"  ".unreq Ww22\n"  ".unreq Ww23\n"
        ".unreq Ww31\n"  ".unreq Ww32\n"  ".unreq Ww33\n"
        ".unreq Ww41\n"  ".unreq Ww42\n"  ".unreq Ww43\n"
        ".unreq U11\n"   ".unreq U12\n"   ".unreq U13\n"   ".unreq U14\n"
        ".unreq U21\n"   ".unreq U22\n"   ".unreq U23\n"   ".unreq U24\n"
        ".unreq U31\n"   ".unreq U32\n"   ".unreq U33\n"   ".unreq U34\n"
        ".unreq U41\n"   ".unreq U42\n"   ".unreq U43\n"   ".unreq U44\n"
        ".unreq qU11\n"  ".unreq qU12\n"  ".unreq qU13\n"  ".unreq qU14\n"
        ".unreq qU21\n"  ".unreq qU22\n"  ".unreq qU23\n"  ".unreq qU24\n"
        ".unreq qU31\n"  ".unreq qU32\n"  ".unreq qU33\n"  ".unreq qU34\n"
        ".unreq qU41\n"  ".unreq qU42\n"  ".unreq qU43\n"  ".unreq qU44\n"
        ".unreq dU11\n"  ".unreq dU12\n"  ".unreq dU13\n"  ".unreq dU14\n"
        ".unreq dU21\n"  ".unreq dU22\n"  ".unreq dU23\n"  ".unreq dU24\n"
        ".unreq dU31\n"  ".unreq dU32\n"  ".unreq dU33\n"  ".unreq dU34\n"
        ".unreq dU41\n"  ".unreq dU42\n"  ".unreq dU43\n"  ".unreq dU44\n"

      : [inptr0] "+r" (inptr0),
        [inptr1] "+r" (inptr1),
        [inptr2] "+r" (inptr2),
        [outptr0] "+r" (outptr0),
        [outptr4] "+r" (outptr4),
        [outptr8] "+r" (outptr8),
        [outptr12] "+r" (outptr12),
        [n_remaining_channels] "+r" (n_remaining_channels)
      : [mstride1] "r" (sizeof(float) * mstride),
        [mstride2] "r" (sizeof(float) * mstride * 2),
        [mstride3] "r" (sizeof(float) * mstride * 3),
        [colstride1] "r" (sizeof(float) * kernel_col_stride),
        [colstride2] "r" (sizeof(float) * kernel_col_stride * 2),
        [one_half] "r" (0.5f)
      : "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
        "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19",
        "v20", "v21", "v22", "v23", "v24"
    );

    // Progression to complete stride
    outptr0 += matrix_row_stride - n_output_channels;
    outptr4 += matrix_row_stride - n_output_channels;
    outptr8 += matrix_row_stride - n_output_channels;
    outptr12 += matrix_row_stride - n_output_channels;
  }
}

template <>
template <>
inline void winograd2x2_3x3_gemm_kernel_transform_impl<float>::transform_kernel<1>(
    const float* const kernel,
    const int n_input_channels,
    const int n_output_channels,
    float* const matrix_base,
    const int mstride,
    const int matrix_row_stride
) {
  // Use one input pointer for each row of the kernel, use two additional
  // offsets to extract columns.
  const int kernel_col_stride = n_input_channels * n_output_channels;
  const int kernel_row_stride = 3 * kernel_col_stride;
  const float *inptr0 = kernel;
  const float *inptr1 = kernel + kernel_row_stride;
  const float *inptr2 = kernel + kernel_row_stride*2;

  // Use four output pointers, for output matrices 0, 4, 8 and 12. Use three
  // offsets to extract further matrices.
  float  *outptr0 = matrix_base;
  float  *outptr4 = matrix_base + mstride * 4;
  float  *outptr8 = matrix_base + mstride * 8;
  float *outptr12 = matrix_base + mstride * 12;

  // For every input channel
  for (int in_c = 0; in_c < n_input_channels; in_c++) {
    int n_remaining_channels = n_output_channels;

    asm volatile (
        // Registers into which to read the kernel
        "w_11 .req v0\n"  "qw_11 .req q0\n"  "sw_11 .req s0\n"
        "w_12 .req v1\n"  "qw_12 .req q1\n"  "sw_12 .req s1\n"
        "w_13 .req v2\n"  "qw_13 .req q2\n"  "sw_13 .req s2\n"
        "w_21 .req v3\n"  "qw_21 .req q3\n"  "sw_21 .req s3\n"
        "w_22 .req v4\n"  "qw_22 .req q4\n"  "sw_22 .req s4\n"
        "w_23 .req v5\n"  "qw_23 .req q5\n"  "sw_23 .req s5\n"
        "w_31 .req v6\n"  "qw_31 .req q6\n"  "sw_31 .req s6\n"
        "w_32 .req v7\n"  "qw_32 .req q7\n"  "sw_32 .req s7\n"
        "w_33 .req v8\n"  "qw_33 .req q8\n"  "sw_33 .req s8\n"

        // Transformed matrix Ww
        "Ww11 .req w_11\n"  "Ww12 .req w_12\n"  "Ww13 .req w_13\n"
        "Ww21 .req  v9\n"   "Ww22 .req v10\n"   "Ww23 .req v11\n"
        "Ww31 .req v12\n"   "Ww32 .req v13\n"   "Ww33 .req v14\n"
        "Ww41 .req w_31\n"  "Ww42 .req w_32\n"  "Ww43 .req w_33\n"

        // Output matrix U = WwWT
        "U11 .req Ww11\n"   "U12 .req v15\n"  "U13 .req v16\n"  "U14 .req Ww13\n"
        "U21 .req Ww21\n"   "U22 .req v17\n"  "U23 .req v18\n"  "U24 .req Ww23\n"
        "U31 .req Ww31\n"   "U32 .req v19\n"  "U33 .req v20\n"  "U34 .req Ww33\n"
        "U41 .req Ww41\n"   "U42 .req v21\n"  "U43 .req v22\n"  "U44 .req Ww43\n"

        // Storage view of output matrices
        "qU11 .req   q0\n"   "qU12 .req q15\n"  "qU13 .req q16\n"  "qU14 .req   q2\n"
        "qU21 .req   q9\n"   "qU22 .req q17\n"  "qU23 .req q18\n"  "qU24 .req  q11\n"
        "qU31 .req  q12\n"   "qU32 .req q19\n"  "qU33 .req q20\n"  "qU34 .req  q14\n"
        "qU41 .req   q6\n"   "qU42 .req q21\n"  "qU43 .req q22\n"  "qU44 .req   q8\n"

        "sU11 .req   s0\n"   "sU12 .req s15\n"  "sU13 .req s16\n"  "sU14 .req   s2\n"
        "sU21 .req   s9\n"   "sU22 .req s17\n"  "sU23 .req s18\n"  "sU24 .req  s11\n"
        "sU31 .req  s12\n"   "sU32 .req s19\n"  "sU33 .req s20\n"  "sU34 .req  s14\n"
        "sU41 .req   s6\n"   "sU42 .req s21\n"  "sU43 .req s22\n"  "sU44 .req   s8\n"

        "half .req v23\n"  // {0.5, ..., 0.5}
        "dup half.4s, %w[one_half]\n"
        "scratch .req v24\n"
        
        // Subtract the tail from the number of remaining channels and jump to
        // the tail if necessary.
        "subs %x[n_remaining_channels], %x[n_remaining_channels], #1\n"
        "beq 2f\n"

        "1:"
          // Load tile of the kernel
          "ldr qw_11, [%x[inptr0]]\n"
          "str qU11, [%x[outptr0]]\n"
          "ldr qw_12, [%x[inptr0], %x[colstride1]]\n"
          "ldr qw_13, [%x[inptr0], %x[colstride2]]\n"
          "str qU14, [%x[outptr0], %x[mstride3]]\n"
          "add %x[inptr0], %x[inptr0], #0x10\n"

          "ldr qw_21, [%x[inptr1]]\n"
          "ldr qw_22, [%x[inptr1], %x[colstride1]]\n"
          "ldr qw_23, [%x[inptr1], %x[colstride2]]\n"
          "add %x[inptr1], %x[inptr1], #0x10\n"

          "ldr qw_31, [%x[inptr2]]\n"
          "str qU41, [%x[outptr12]]\n"
          "ldr qw_32, [%x[inptr2], %x[colstride1]]\n"
          "ldr qw_33, [%x[inptr2], %x[colstride2]]\n"
          "str qU44, [%x[outptr12], %x[mstride3]]\n"
          "add %x[inptr2], %x[inptr2], #0x10\n"

          // Compute 2nd and 3rd rows of Ww
          "fadd scratch.4s, w_11.4s, w_31.4s\n"
          "fmul Ww21.4s, scratch.4s, half.4s\n"
          "fmla Ww21.4s, w_21.4s, half.4s\n"
          "str qU21, [%x[outptr4]]\n"
          "fmul Ww31.4s, scratch.4s, half.4s\n"
          "fmls Ww31.4s, w_21.4s, half.4s\n"
          "str qU31, [%x[outptr8]]\n"

          "fadd scratch.4s, w_12.4s, w_32.4s\n"
          "fmul Ww22.4s, scratch.4s, half.4s\n"
          "fmla Ww22.4s, w_22.4s, half.4s\n"
          "fmul Ww32.4s, scratch.4s, half.4s\n"
          "fmls Ww32.4s, w_22.4s, half.4s\n"

          "fadd scratch.4s, w_13.4s, w_33.4s\n"
          "fmul Ww23.4s, scratch.4s, half.4s\n"
          "fmla Ww23.4s, w_23.4s, half.4s\n"
          "str qU24, [%x[outptr4], %x[mstride3]]\n"
          "fmul Ww33.4s, scratch.4s, half.4s\n"
          "fmls Ww33.4s, w_23.4s, half.4s\n"
          "str qU34, [%x[outptr8], %x[mstride3]]\n"

          // Compute and store U, only need to compute the 2nd and 3rd columns
          // of U and update output pointers
          "fadd scratch.4s, Ww11.4s, Ww13.4s\n"
          "fmul U12.4s, scratch.4s, half.4s\n"
          "fmla U12.4s, Ww12.4s, half.4s\n"
          "str qU12, [%x[outptr0], %x[mstride1]]\n"
          "fmul U13.4s, scratch.4s, half.4s\n"
          "fmls U13.4s, Ww12.4s, half.4s\n"
          "str qU13, [%x[outptr0], %x[mstride2]]\n"
          "add  %x[outptr0],  %x[outptr0], #0x10\n"

          "fadd scratch.4s, Ww21.4s, Ww23.4s\n"
          "fmul U22.4s, scratch.4s, half.4s\n"
          "fmla U22.4s, Ww22.4s, half.4s\n"
          "str qU22, [%x[outptr4], %x[mstride1]]\n"
          "fmul U23.4s, scratch.4s, half.4s\n"
          "fmls U23.4s, Ww22.4s, half.4s\n"
          "str qU23, [%x[outptr4], %x[mstride2]]\n"
          "add  %x[outptr4],  %x[outptr4], #0x10\n"

          "fadd scratch.4s, Ww31.4s, Ww33.4s\n"
          "fmul U32.4s, scratch.4s, half.4s\n"
          "fmla U32.4s, Ww32.4s, half.4s\n"
          "str qU32, [%x[outptr8], %x[mstride1]]\n"
          "fmul U33.4s, scratch.4s, half.4s\n"
          "fmls U33.4s, Ww32.4s, half.4s\n"
          "str qU33, [%x[outptr8], %x[mstride2]]\n"
          "add  %x[outptr8],  %x[outptr8], #0x10\n"

          "fadd scratch.4s, Ww41.4s, Ww43.4s\n"
          "fmul U42.4s, scratch.4s, half.4s\n"
          "fmla U42.4s, Ww42.4s, half.4s\n"
          "str qU42, [%x[outptr12], %x[mstride1]]\n"
          "fmul U43.4s, scratch.4s, half.4s\n"
          "fmls U43.4s, Ww42.4s, half.4s\n"
          "str qU43, [%x[outptr12], %x[mstride2]]\n"
          "add %x[outptr12], %x[outptr12], #0x10\n"

          "subs %x[n_remaining_channels], %x[n_remaining_channels], #4\n"
          "bne 1b\n"

        // Tail size 1
        "2:"
          // Load tile of the kernel
          "ldr sw_11, [%x[inptr0]]\n"
          "str sU11, [%x[outptr0]]\n"
          "ldr sw_12, [%x[inptr0], %x[colstride1]]\n"
          "ldr sw_13, [%x[inptr0], %x[colstride2]]\n"
          "str sU14, [%x[outptr0], %x[mstride3]]\n"
          "add %x[inptr0], %x[inptr0], #0x04\n"

          "ldr sw_21, [%x[inptr1]]\n"
          "ldr sw_22, [%x[inptr1], %x[colstride1]]\n"
          "ldr sw_23, [%x[inptr1], %x[colstride2]]\n"
          "add %x[inptr1], %x[inptr1], #0x04\n"

          "ldr sw_31, [%x[inptr2]]\n"
          "str sU41, [%x[outptr12]]\n"
          "ldr sw_32, [%x[inptr2], %x[colstride1]]\n"
          "ldr sw_33, [%x[inptr2], %x[colstride2]]\n"
          "str sU44, [%x[outptr12], %x[mstride3]]\n"
          "add %x[inptr2], %x[inptr2], #0x04\n"

          // Compute 2nd and 3rd rows of Ww
          "fadd scratch.2s, w_11.2s, w_31.2s\n"
          "fmul Ww21.2s, scratch.2s, half.2s\n"
          "fmla Ww21.2s, w_21.2s, half.2s\n"
          "str sU21, [%x[outptr4]]\n"
          "fmul Ww31.2s, scratch.2s, half.2s\n"
          "fmls Ww31.2s, w_21.2s, half.2s\n"
          "str sU31, [%x[outptr8]]\n"

          "fadd scratch.2s, w_12.2s, w_32.2s\n"
          "fmul Ww22.2s, scratch.2s, half.2s\n"
          "fmla Ww22.2s, w_22.2s, half.2s\n"
          "fmul Ww32.2s, scratch.2s, half.2s\n"
          "fmls Ww32.2s, w_22.2s, half.2s\n"

          "fadd scratch.2s, w_13.2s, w_33.2s\n"
          "fmul Ww23.2s, scratch.2s, half.2s\n"
          "fmla Ww23.2s, w_23.2s, half.2s\n"
          "str sU24, [%x[outptr4], %x[mstride3]]\n"
          "fmul Ww33.2s, scratch.2s, half.2s\n"
          "fmls Ww33.2s, w_23.2s, half.2s\n"
          "str sU34, [%x[outptr8], %x[mstride3]]\n"

          // Compute and store U, only need to compute the 2nd and 3rd columns of
          // U and update output pointers
          "fadd scratch.2s, Ww11.2s, Ww13.2s\n"
          "fmul U12.2s, scratch.2s, half.2s\n"
          "fmla U12.2s, Ww12.2s, half.2s\n"
          "str sU12, [%x[outptr0], %x[mstride1]]\n"
          "fmul U13.2s, scratch.2s, half.2s\n"
          "fmls U13.2s, Ww12.2s, half.2s\n"
          "str sU13, [%x[outptr0], %x[mstride2]]\n"
          "add  %x[outptr0],  %x[outptr0], #0x04\n"

          "fadd scratch.2s, Ww21.2s, Ww23.2s\n"
          "fmul U22.2s, scratch.2s, half.2s\n"
          "fmla U22.2s, Ww22.2s, half.2s\n"
          "str sU22, [%x[outptr4], %x[mstride1]]\n"
          "fmul U23.2s, scratch.2s, half.2s\n"
          "fmls U23.2s, Ww22.2s, half.2s\n"
          "str sU23, [%x[outptr4], %x[mstride2]]\n"
          "add  %x[outptr4],  %x[outptr4], #0x04\n"

          "fadd scratch.2s, Ww31.2s, Ww33.2s\n"
          "fmul U32.2s, scratch.2s, half.2s\n"
          "fmla U32.2s, Ww32.2s, half.2s\n"
          "str sU32, [%x[outptr8], %x[mstride1]]\n"
          "fmul U33.2s, scratch.2s, half.2s\n"
          "fmls U33.2s, Ww32.2s, half.2s\n"
          "str sU33, [%x[outptr8], %x[mstride2]]\n"
          "add  %x[outptr8],  %x[outptr8], #0x04\n"

          "fadd scratch.2s, Ww41.2s, Ww43.2s\n"
          "fmul U42.2s, scratch.2s, half.2s\n"
          "fmla U42.2s, Ww42.2s, half.2s\n"
          "str sU42, [%x[outptr12], %x[mstride1]]\n"
          "fmul U43.2s, scratch.2s, half.2s\n"
          "fmls U43.2s, Ww42.2s, half.2s\n"
          "str sU43, [%x[outptr12], %x[mstride2]]\n"
          "add %x[outptr12], %x[outptr12], #0x04\n"

        // Clear aliases
        ".unreq half\n"
        ".unreq scratch\n"
        ".unreq w_11\n"  ".unreq qw_11\n" ".unreq sw_11\n"
        ".unreq w_12\n"  ".unreq qw_12\n" ".unreq sw_12\n"
        ".unreq w_13\n"  ".unreq qw_13\n" ".unreq sw_13\n"
        ".unreq w_21\n"  ".unreq qw_21\n" ".unreq sw_21\n"
        ".unreq w_22\n"  ".unreq qw_22\n" ".unreq sw_22\n"
        ".unreq w_23\n"  ".unreq qw_23\n" ".unreq sw_23\n"
        ".unreq w_31\n"  ".unreq qw_31\n" ".unreq sw_31\n"
        ".unreq w_32\n"  ".unreq qw_32\n" ".unreq sw_32\n"
        ".unreq w_33\n"  ".unreq qw_33\n" ".unreq sw_33\n"
        ".unreq Ww11\n"  ".unreq Ww12\n"  ".unreq Ww13\n"
        ".unreq Ww21\n"  ".unreq Ww22\n"  ".unreq Ww23\n"
        ".unreq Ww31\n"  ".unreq Ww32\n"  ".unreq Ww33\n"
        ".unreq Ww41\n"  ".unreq Ww42\n"  ".unreq Ww43\n"
        ".unreq U11\n"   ".unreq U12\n"   ".unreq U13\n"   ".unreq U14\n"
        ".unreq U21\n"   ".unreq U22\n"   ".unreq U23\n"   ".unreq U24\n"
        ".unreq U31\n"   ".unreq U32\n"   ".unreq U33\n"   ".unreq U34\n"
        ".unreq U41\n"   ".unreq U42\n"   ".unreq U43\n"   ".unreq U44\n"
        ".unreq qU11\n"  ".unreq qU12\n"  ".unreq qU13\n"  ".unreq qU14\n"
        ".unreq qU21\n"  ".unreq qU22\n"  ".unreq qU23\n"  ".unreq qU24\n"
        ".unreq qU31\n"  ".unreq qU32\n"  ".unreq qU33\n"  ".unreq qU34\n"
        ".unreq qU41\n"  ".unreq qU42\n"  ".unreq qU43\n"  ".unreq qU44\n"
        ".unreq sU11\n"  ".unreq sU12\n"  ".unreq sU13\n"  ".unreq sU14\n"
        ".unreq sU21\n"  ".unreq sU22\n"  ".unreq sU23\n"  ".unreq sU24\n"
        ".unreq sU31\n"  ".unreq sU32\n"  ".unreq sU33\n"  ".unreq sU34\n"
        ".unreq sU41\n"  ".unreq sU42\n"  ".unreq sU43\n"  ".unreq sU44\n"

      : [inptr0] "+r" (inptr0),
        [inptr1] "+r" (inptr1),
        [inptr2] "+r" (inptr2),
        [outptr0] "+r" (outptr0),
        [outptr4] "+r" (outptr4),
        [outptr8] "+r" (outptr8),
        [outptr12] "+r" (outptr12),
        [n_remaining_channels] "+r" (n_remaining_channels)
      : [mstride1] "r" (sizeof(float) * mstride),
        [mstride2] "r" (sizeof(float) * mstride * 2),
        [mstride3] "r" (sizeof(float) * mstride * 3),
        [colstride1] "r" (sizeof(float) * kernel_col_stride),
        [colstride2] "r" (sizeof(float) * kernel_col_stride * 2),
        [one_half] "r" (0.5f)
      : "v0", "v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8", "v9", "v10",
        "v11", "v12", "v13", "v14", "v15", "v16", "v17", "v18", "v19",
        "v20", "v21", "v22", "v23", "v24"
    );

    // Progression to complete stride
    outptr0 += matrix_row_stride - n_output_channels;
    outptr4 += matrix_row_stride - n_output_channels;
    outptr8 += matrix_row_stride - n_output_channels;
    outptr12 += matrix_row_stride - n_output_channels;
  }
}
}
#endif  // __aarch64__