• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-igemm/c2-neon-mull-dup.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 <assert.h>
11 
12 #include <arm_neon.h>
13 
14 #include <xnnpack/gemm.h>
15 #include <xnnpack/math.h>
16 
xnn_qs8_igemm_minmax_rndnu_ukernel_3x16c2__neon_mlal_ld2r(size_t mr,size_t nc,size_t kc,size_t ks,const int8_t ** restrict a,const void * restrict w,int8_t * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const int8_t * zero,const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qs8_igemm_minmax_rndnu_ukernel_3x16c2__neon_mlal_ld2r(
18     size_t mr,
19     size_t nc,
20     size_t kc,
21     size_t ks,
22     const int8_t** restrict a,
23     const void* restrict w,
24     int8_t* restrict c,
25     size_t cm_stride,
26     size_t cn_stride,
27     size_t a_offset,
28     const int8_t* zero,
29     const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31   assert(mr != 0);
32   assert(mr <= 3);
33   assert(nc != 0);
34   assert(kc != 0);
35   assert(ks != 0);
36   assert(ks % (3 * sizeof(void*)) == 0);
37   assert(a_offset % sizeof(int8_t) == 0);
38   assert(a != NULL);
39   assert(w != NULL);
40   assert(c != NULL);
41 
42   kc = round_up_po2(kc, 2 * sizeof(int8_t));
43   int8_t* c0 = c;
44   int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
45   if XNN_UNPREDICTABLE(mr < 2) {
46     c1 = c0;
47   }
48   int8_t* c2 = (int8_t*) ((uintptr_t) c1 + cm_stride);
49   if XNN_UNPREDICTABLE(mr <= 2) {
50     c2 = c1;
51   }
52 
53   do {
54     int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
55     int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
56     int32x4_t vacc0x89AB = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
57     int32x4_t vacc0xCDEF = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
58     int32x4_t vacc1x0123 = vacc0x0123;
59     int32x4_t vacc1x4567 = vacc0x4567;
60     int32x4_t vacc1x89AB = vacc0x89AB;
61     int32x4_t vacc1xCDEF = vacc0xCDEF;
62     int32x4_t vacc2x0123 = vacc0x0123;
63     int32x4_t vacc2x4567 = vacc0x4567;
64     int32x4_t vacc2x89AB = vacc0x89AB;
65     int32x4_t vacc2xCDEF = vacc0xCDEF;
66 
67     size_t p = ks;
68     do {
69       const int8_t* restrict a0 = a[0];
70       if XNN_UNPREDICTABLE(a0 != zero) {
71         a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
72       }
73       const int8_t* restrict a1 = a[1];
74       if XNN_UNPREDICTABLE(a1 != zero) {
75         a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
76       }
77       const int8_t* restrict a2 = a[2];
78       if XNN_UNPREDICTABLE(a2 != zero) {
79         a2 = (const int8_t*) ((uintptr_t) a2 + a_offset);
80       }
81       a += 3;
82 
83       size_t k = kc;
84 
85       while (k >= 16 * sizeof(int8_t)) {
86         const int16x4x2_t va00x0 = vld2_dup_s16((const void*)a0);
87         const int16x4x2_t va01x0 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
88         const int16x4x2_t va00x1 = vld2_dup_s16((const void*)a0);
89         const int16x4x2_t va01x1 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
90         const int16x4x2_t va10x0 = vld2_dup_s16((const void*)a1);
91         const int16x4x2_t va11x0 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
92         const int16x4x2_t va10x1 = vld2_dup_s16((const void*)a1);
93         const int16x4x2_t va11x1 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
94         const int16x4x2_t va20x0 = vld2_dup_s16((const void*)a2);
95         const int16x4x2_t va21x0 = vld2_dup_s16((const void*)(a2 + 4)); a2 += 8;
96         const int16x4x2_t va20x1 = vld2_dup_s16((const void*)a2);
97         const int16x4x2_t va21x1 = vld2_dup_s16((const void*)(a2 + 4)); a2 += 8;
98 
99         const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
100         const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
101         const int8x8_t vb89ABc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
102         const int8x8_t vbCDEFc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
103         const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
104         const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
105         const int8x8_t vb89ABc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
106         const int8x8_t vbCDEFc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
107         const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
108         const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
109         const int8x8_t vb89ABc2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
110         const int8x8_t vbCDEFc2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
111         const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
112         const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
113         const int8x8_t vb89ABc3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
114         const int8x8_t vbCDEFc3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
115 
116         const int8x8_t va0c0x0 = vreinterpret_s8_s16(va00x0.val[0]);
117         const int8x8_t va0c0x1 = vreinterpret_s8_s16(va00x1.val[0]);
118         const int8x8_t va1c0x0 = vreinterpret_s8_s16(va10x0.val[0]);
119         const int8x8_t va1c0x1 = vreinterpret_s8_s16(va10x1.val[0]);
120         const int8x8_t va2c0x0 = vreinterpret_s8_s16(va20x0.val[0]);
121         const int8x8_t va2c0x1 = vreinterpret_s8_s16(va20x1.val[0]);
122 
123         int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0c0x0);
124         int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1c0x0);
125         int16x8_t vprod2x0123c0 = vmull_s8(vb0123c0x0, va2c0x0);
126         const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
127         vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, va0c0x1);
128         vprod1x0123c0 = vmlal_s8(vprod1x0123c0, vb0123c0x1, va1c0x1);
129         vprod2x0123c0 = vmlal_s8(vprod2x0123c0, vb0123c0x1, va2c0x1);
130         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
131         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
132         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c0);
133         int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0c0x0);
134         int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1c0x0);
135         int16x8_t vprod2x4567c0 = vmull_s8(vb4567c0x0, va2c0x0);
136         const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
137         vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, va0c0x1);
138         vprod1x4567c0 = vmlal_s8(vprod1x4567c0, vb4567c0x1, va1c0x1);
139         vprod2x4567c0 = vmlal_s8(vprod2x4567c0, vb4567c0x1, va2c0x1);
140         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
141         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
142         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c0);
143         int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0x0, va0c0x0);
144         int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0x0, va1c0x0);
145         int16x8_t vprod2x89ABc0 = vmull_s8(vb89ABc0x0, va2c0x0);
146         const int8x8_t vb89ABc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
147         vprod0x89ABc0 = vmlal_s8(vprod0x89ABc0, vb89ABc0x1, va0c0x1);
148         vprod1x89ABc0 = vmlal_s8(vprod1x89ABc0, vb89ABc0x1, va1c0x1);
149         vprod2x89ABc0 = vmlal_s8(vprod2x89ABc0, vb89ABc0x1, va2c0x1);
150         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
151         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
152         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc0);
153         int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0x0, va0c0x0);
154         int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0x0, va1c0x0);
155         int16x8_t vprod2xCDEFc0 = vmull_s8(vbCDEFc0x0, va2c0x0);
156         const int8x8_t vbCDEFc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
157         vprod0xCDEFc0 = vmlal_s8(vprod0xCDEFc0, vbCDEFc0x1, va0c0x1);
158         vprod1xCDEFc0 = vmlal_s8(vprod1xCDEFc0, vbCDEFc0x1, va1c0x1);
159         vprod2xCDEFc0 = vmlal_s8(vprod2xCDEFc0, vbCDEFc0x1, va2c0x1);
160         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
161         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
162         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc0);
163         const int8x8_t va0c1x0 = vreinterpret_s8_s16(va00x0.val[1]);
164         const int8x8_t va0c1x1 = vreinterpret_s8_s16(va00x1.val[1]);
165         const int8x8_t va1c1x0 = vreinterpret_s8_s16(va10x0.val[1]);
166         const int8x8_t va1c1x1 = vreinterpret_s8_s16(va10x1.val[1]);
167         const int8x8_t va2c1x0 = vreinterpret_s8_s16(va20x0.val[1]);
168         const int8x8_t va2c1x1 = vreinterpret_s8_s16(va20x1.val[1]);
169 
170         int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0c1x0);
171         int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1c1x0);
172         int16x8_t vprod2x0123c1 = vmull_s8(vb0123c1x0, va2c1x0);
173         const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
174         vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, va0c1x1);
175         vprod1x0123c1 = vmlal_s8(vprod1x0123c1, vb0123c1x1, va1c1x1);
176         vprod2x0123c1 = vmlal_s8(vprod2x0123c1, vb0123c1x1, va2c1x1);
177         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
178         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
179         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c1);
180         int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0c1x0);
181         int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1c1x0);
182         int16x8_t vprod2x4567c1 = vmull_s8(vb4567c1x0, va2c1x0);
183         const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
184         vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, va0c1x1);
185         vprod1x4567c1 = vmlal_s8(vprod1x4567c1, vb4567c1x1, va1c1x1);
186         vprod2x4567c1 = vmlal_s8(vprod2x4567c1, vb4567c1x1, va2c1x1);
187         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
188         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
189         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c1);
190         int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1x0, va0c1x0);
191         int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1x0, va1c1x0);
192         int16x8_t vprod2x89ABc1 = vmull_s8(vb89ABc1x0, va2c1x0);
193         const int8x8_t vb89ABc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
194         vprod0x89ABc1 = vmlal_s8(vprod0x89ABc1, vb89ABc1x1, va0c1x1);
195         vprod1x89ABc1 = vmlal_s8(vprod1x89ABc1, vb89ABc1x1, va1c1x1);
196         vprod2x89ABc1 = vmlal_s8(vprod2x89ABc1, vb89ABc1x1, va2c1x1);
197         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
198         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
199         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc1);
200         int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1x0, va0c1x0);
201         int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1x0, va1c1x0);
202         int16x8_t vprod2xCDEFc1 = vmull_s8(vbCDEFc1x0, va2c1x0);
203         const int8x8_t vbCDEFc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
204         vprod0xCDEFc1 = vmlal_s8(vprod0xCDEFc1, vbCDEFc1x1, va0c1x1);
205         vprod1xCDEFc1 = vmlal_s8(vprod1xCDEFc1, vbCDEFc1x1, va1c1x1);
206         vprod2xCDEFc1 = vmlal_s8(vprod2xCDEFc1, vbCDEFc1x1, va2c1x1);
207         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
208         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
209         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc1);
210         const int8x8_t va0c2x0 = vreinterpret_s8_s16(va01x0.val[0]);
211         const int8x8_t va0c2x1 = vreinterpret_s8_s16(va01x1.val[0]);
212         const int8x8_t va1c2x0 = vreinterpret_s8_s16(va11x0.val[0]);
213         const int8x8_t va1c2x1 = vreinterpret_s8_s16(va11x1.val[0]);
214         const int8x8_t va2c2x0 = vreinterpret_s8_s16(va21x0.val[0]);
215         const int8x8_t va2c2x1 = vreinterpret_s8_s16(va21x1.val[0]);
216 
217         int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0c2x0);
218         int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1c2x0);
219         int16x8_t vprod2x0123c2 = vmull_s8(vb0123c2x0, va2c2x0);
220         const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
221         vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, va0c2x1);
222         vprod1x0123c2 = vmlal_s8(vprod1x0123c2, vb0123c2x1, va1c2x1);
223         vprod2x0123c2 = vmlal_s8(vprod2x0123c2, vb0123c2x1, va2c2x1);
224         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
225         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
226         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c2);
227         int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0c2x0);
228         int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1c2x0);
229         int16x8_t vprod2x4567c2 = vmull_s8(vb4567c2x0, va2c2x0);
230         const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
231         vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, va0c2x1);
232         vprod1x4567c2 = vmlal_s8(vprod1x4567c2, vb4567c2x1, va1c2x1);
233         vprod2x4567c2 = vmlal_s8(vprod2x4567c2, vb4567c2x1, va2c2x1);
234         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
235         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
236         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c2);
237         int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2x0, va0c2x0);
238         int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2x0, va1c2x0);
239         int16x8_t vprod2x89ABc2 = vmull_s8(vb89ABc2x0, va2c2x0);
240         const int8x8_t vb89ABc2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
241         vprod0x89ABc2 = vmlal_s8(vprod0x89ABc2, vb89ABc2x1, va0c2x1);
242         vprod1x89ABc2 = vmlal_s8(vprod1x89ABc2, vb89ABc2x1, va1c2x1);
243         vprod2x89ABc2 = vmlal_s8(vprod2x89ABc2, vb89ABc2x1, va2c2x1);
244         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
245         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
246         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc2);
247         int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2x0, va0c2x0);
248         int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2x0, va1c2x0);
249         int16x8_t vprod2xCDEFc2 = vmull_s8(vbCDEFc2x0, va2c2x0);
250         const int8x8_t vbCDEFc2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
251         vprod0xCDEFc2 = vmlal_s8(vprod0xCDEFc2, vbCDEFc2x1, va0c2x1);
252         vprod1xCDEFc2 = vmlal_s8(vprod1xCDEFc2, vbCDEFc2x1, va1c2x1);
253         vprod2xCDEFc2 = vmlal_s8(vprod2xCDEFc2, vbCDEFc2x1, va2c2x1);
254         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
255         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
256         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc2);
257         const int8x8_t va0c3x0 = vreinterpret_s8_s16(va01x0.val[1]);
258         const int8x8_t va0c3x1 = vreinterpret_s8_s16(va01x1.val[1]);
259         const int8x8_t va1c3x0 = vreinterpret_s8_s16(va11x0.val[1]);
260         const int8x8_t va1c3x1 = vreinterpret_s8_s16(va11x1.val[1]);
261         const int8x8_t va2c3x0 = vreinterpret_s8_s16(va21x0.val[1]);
262         const int8x8_t va2c3x1 = vreinterpret_s8_s16(va21x1.val[1]);
263 
264         int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0c3x0);
265         int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1c3x0);
266         int16x8_t vprod2x0123c3 = vmull_s8(vb0123c3x0, va2c3x0);
267         const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
268         vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, va0c3x1);
269         vprod1x0123c3 = vmlal_s8(vprod1x0123c3, vb0123c3x1, va1c3x1);
270         vprod2x0123c3 = vmlal_s8(vprod2x0123c3, vb0123c3x1, va2c3x1);
271         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
272         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
273         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c3);
274         int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0c3x0);
275         int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1c3x0);
276         int16x8_t vprod2x4567c3 = vmull_s8(vb4567c3x0, va2c3x0);
277         const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
278         vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, va0c3x1);
279         vprod1x4567c3 = vmlal_s8(vprod1x4567c3, vb4567c3x1, va1c3x1);
280         vprod2x4567c3 = vmlal_s8(vprod2x4567c3, vb4567c3x1, va2c3x1);
281         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
282         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
283         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c3);
284         int16x8_t vprod0x89ABc3 = vmull_s8(vb89ABc3x0, va0c3x0);
285         int16x8_t vprod1x89ABc3 = vmull_s8(vb89ABc3x0, va1c3x0);
286         int16x8_t vprod2x89ABc3 = vmull_s8(vb89ABc3x0, va2c3x0);
287         const int8x8_t vb89ABc3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
288         vprod0x89ABc3 = vmlal_s8(vprod0x89ABc3, vb89ABc3x1, va0c3x1);
289         vprod1x89ABc3 = vmlal_s8(vprod1x89ABc3, vb89ABc3x1, va1c3x1);
290         vprod2x89ABc3 = vmlal_s8(vprod2x89ABc3, vb89ABc3x1, va2c3x1);
291         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc3);
292         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc3);
293         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc3);
294         int16x8_t vprod0xCDEFc3 = vmull_s8(vbCDEFc3x0, va0c3x0);
295         int16x8_t vprod1xCDEFc3 = vmull_s8(vbCDEFc3x0, va1c3x0);
296         int16x8_t vprod2xCDEFc3 = vmull_s8(vbCDEFc3x0, va2c3x0);
297         const int8x8_t vbCDEFc3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
298         vprod0xCDEFc3 = vmlal_s8(vprod0xCDEFc3, vbCDEFc3x1, va0c3x1);
299         vprod1xCDEFc3 = vmlal_s8(vprod1xCDEFc3, vbCDEFc3x1, va1c3x1);
300         vprod2xCDEFc3 = vmlal_s8(vprod2xCDEFc3, vbCDEFc3x1, va2c3x1);
301         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc3);
302         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc3);
303         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc3);
304 
305         k -= 16 * sizeof(int8_t);
306       }
307 
308       if (k >= 8 * sizeof(int8_t)) {
309         const int16x4x2_t va00 = vld2_dup_s16((const void*)a0);
310         const int16x4x2_t va01 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
311         const int16x4x2_t va10 = vld2_dup_s16((const void*)a1);
312         const int16x4x2_t va11 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
313         const int16x4x2_t va20 = vld2_dup_s16((const void*)a2);
314         const int16x4x2_t va21 = vld2_dup_s16((const void*)(a2 + 4)); a2 += 8;
315 
316         const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
317         const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
318         const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
319         const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
320         const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
321         const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
322         const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
323         const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
324         const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
325         const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
326         const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
327         const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
328         const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
329         const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
330         const int8x8_t vb89ABc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
331         const int8x8_t vbCDEFc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
332 
333         const int8x8_t va0c0 = vreinterpret_s8_s16(va00.val[0]);
334         const int8x8_t va1c0 = vreinterpret_s8_s16(va10.val[0]);
335         const int8x8_t va2c0 = vreinterpret_s8_s16(va20.val[0]);
336 
337         const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
338         const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
339         const int16x8_t vprod2x0123c0 = vmull_s8(vb0123c0, va2c0);
340         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
341         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
342         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c0);
343         const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
344         const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
345         const int16x8_t vprod2x4567c0 = vmull_s8(vb4567c0, va2c0);
346         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
347         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
348         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c0);
349         const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, va0c0);
350         const int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0, va1c0);
351         const int16x8_t vprod2x89ABc0 = vmull_s8(vb89ABc0, va2c0);
352         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
353         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
354         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc0);
355         const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, va0c0);
356         const int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0, va1c0);
357         const int16x8_t vprod2xCDEFc0 = vmull_s8(vbCDEFc0, va2c0);
358         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
359         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
360         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc0);
361         const int8x8_t va0c1 = vreinterpret_s8_s16(va00.val[1]);
362         const int8x8_t va1c1 = vreinterpret_s8_s16(va10.val[1]);
363         const int8x8_t va2c1 = vreinterpret_s8_s16(va20.val[1]);
364 
365         const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
366         const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
367         const int16x8_t vprod2x0123c1 = vmull_s8(vb0123c1, va2c1);
368         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
369         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
370         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c1);
371         const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
372         const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
373         const int16x8_t vprod2x4567c1 = vmull_s8(vb4567c1, va2c1);
374         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
375         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
376         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c1);
377         const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, va0c1);
378         const int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1, va1c1);
379         const int16x8_t vprod2x89ABc1 = vmull_s8(vb89ABc1, va2c1);
380         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
381         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
382         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc1);
383         const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, va0c1);
384         const int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1, va1c1);
385         const int16x8_t vprod2xCDEFc1 = vmull_s8(vbCDEFc1, va2c1);
386         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
387         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
388         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc1);
389         const int8x8_t va0c2 = vreinterpret_s8_s16(va01.val[0]);
390         const int8x8_t va1c2 = vreinterpret_s8_s16(va11.val[0]);
391         const int8x8_t va2c2 = vreinterpret_s8_s16(va21.val[0]);
392 
393         const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
394         const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
395         const int16x8_t vprod2x0123c2 = vmull_s8(vb0123c2, va2c2);
396         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
397         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
398         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c2);
399         const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
400         const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
401         const int16x8_t vprod2x4567c2 = vmull_s8(vb4567c2, va2c2);
402         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
403         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
404         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c2);
405         const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, va0c2);
406         const int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2, va1c2);
407         const int16x8_t vprod2x89ABc2 = vmull_s8(vb89ABc2, va2c2);
408         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
409         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
410         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc2);
411         const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, va0c2);
412         const int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2, va1c2);
413         const int16x8_t vprod2xCDEFc2 = vmull_s8(vbCDEFc2, va2c2);
414         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
415         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
416         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc2);
417         const int8x8_t va0c3 = vreinterpret_s8_s16(va01.val[1]);
418         const int8x8_t va1c3 = vreinterpret_s8_s16(va11.val[1]);
419         const int8x8_t va2c3 = vreinterpret_s8_s16(va21.val[1]);
420 
421         const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3);
422         const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3);
423         const int16x8_t vprod2x0123c3 = vmull_s8(vb0123c3, va2c3);
424         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
425         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
426         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c3);
427         const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3);
428         const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3);
429         const int16x8_t vprod2x4567c3 = vmull_s8(vb4567c3, va2c3);
430         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
431         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
432         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c3);
433         const int16x8_t vprod0x89ABc3 = vmull_s8(vb89ABc3, va0c3);
434         const int16x8_t vprod1x89ABc3 = vmull_s8(vb89ABc3, va1c3);
435         const int16x8_t vprod2x89ABc3 = vmull_s8(vb89ABc3, va2c3);
436         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc3);
437         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc3);
438         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc3);
439         const int16x8_t vprod0xCDEFc3 = vmull_s8(vbCDEFc3, va0c3);
440         const int16x8_t vprod1xCDEFc3 = vmull_s8(vbCDEFc3, va1c3);
441         const int16x8_t vprod2xCDEFc3 = vmull_s8(vbCDEFc3, va2c3);
442         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc3);
443         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc3);
444         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc3);
445 
446         k -= 8 * sizeof(int8_t);
447       }
448 
449       if XNN_UNLIKELY(k != 0) {
450         const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
451         const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
452         const int8x8_t va2 = vld1_s8(a2); a2 = (const int8_t*) ((uintptr_t) a2 + k);
453 
454         const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
455         const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
456         const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
457         const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
458 
459         const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
460         const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
461         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
462         const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
463         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
464         const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, va0c0);
465         vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
466         const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, va0c0);
467         vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
468         const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
469         const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
470         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
471         const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
472         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
473         const int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0, va1c0);
474         vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
475         const int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0, va1c0);
476         vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
477         const int8x8_t va2c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va2), 0));
478         const int16x8_t vprod2x0123c0 = vmull_s8(vb0123c0, va2c0);
479         vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c0);
480         const int16x8_t vprod2x4567c0 = vmull_s8(vb4567c0, va2c0);
481         vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c0);
482         const int16x8_t vprod2x89ABc0 = vmull_s8(vb89ABc0, va2c0);
483         vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc0);
484         const int16x8_t vprod2xCDEFc0 = vmull_s8(vbCDEFc0, va2c0);
485         vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc0);
486 
487         if (k > 2 * sizeof(int8_t)) {
488           const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
489           const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
490           const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
491           const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
492 
493           const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
494           const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
495           vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
496           const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
497           vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
498           const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, va0c1);
499           vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
500           const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, va0c1);
501           vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
502           const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
503           const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
504           vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
505           const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
506           vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
507           const int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1, va1c1);
508           vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
509           const int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1, va1c1);
510           vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
511           const int8x8_t va2c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va2), 1));
512           const int16x8_t vprod2x0123c1 = vmull_s8(vb0123c1, va2c1);
513           vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c1);
514           const int16x8_t vprod2x4567c1 = vmull_s8(vb4567c1, va2c1);
515           vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c1);
516           const int16x8_t vprod2x89ABc1 = vmull_s8(vb89ABc1, va2c1);
517           vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc1);
518           const int16x8_t vprod2xCDEFc1 = vmull_s8(vbCDEFc1, va2c1);
519           vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc1);
520 
521           if (k > 4 * sizeof(int8_t)) {
522             const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
523             const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
524             const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
525             const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
526 
527             const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
528             const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
529             vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
530             const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
531             vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
532             const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, va0c2);
533             vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
534             const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, va0c2);
535             vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
536             const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
537             const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
538             vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
539             const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
540             vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
541             const int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2, va1c2);
542             vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
543             const int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2, va1c2);
544             vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
545             const int8x8_t va2c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va2), 2));
546             const int16x8_t vprod2x0123c2 = vmull_s8(vb0123c2, va2c2);
547             vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c2);
548             const int16x8_t vprod2x4567c2 = vmull_s8(vb4567c2, va2c2);
549             vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c2);
550             const int16x8_t vprod2x89ABc2 = vmull_s8(vb89ABc2, va2c2);
551             vacc2x89AB = vpadalq_s16(vacc2x89AB, vprod2x89ABc2);
552             const int16x8_t vprod2xCDEFc2 = vmull_s8(vbCDEFc2, va2c2);
553             vacc2xCDEF = vpadalq_s16(vacc2xCDEF, vprod2xCDEFc2);
554           }
555         }
556       }
557       p -= 3 * sizeof(void*);
558     } while (p != 0);
559 
560     const int32x4_t vright_pre_shift = vld1q_dup_s32(&params->rndnu_neon.right_pre_shift);
561     const int32x4_t vmultiplier = vld1q_dup_s32(&params->rndnu_neon.multiplier);
562     const int32x4_t vright_post_shift = vld1q_dup_s32(&params->rndnu_neon.right_post_shift);
563 
564     vacc0x0123 = vqshlq_s32(vacc0x0123, vright_pre_shift);
565     vacc0x4567 = vqshlq_s32(vacc0x4567, vright_pre_shift);
566     vacc0x89AB = vqshlq_s32(vacc0x89AB, vright_pre_shift);
567     vacc0xCDEF = vqshlq_s32(vacc0xCDEF, vright_pre_shift);
568     vacc1x0123 = vqshlq_s32(vacc1x0123, vright_pre_shift);
569     vacc1x4567 = vqshlq_s32(vacc1x4567, vright_pre_shift);
570     vacc1x89AB = vqshlq_s32(vacc1x89AB, vright_pre_shift);
571     vacc1xCDEF = vqshlq_s32(vacc1xCDEF, vright_pre_shift);
572     vacc2x0123 = vqshlq_s32(vacc2x0123, vright_pre_shift);
573     vacc2x4567 = vqshlq_s32(vacc2x4567, vright_pre_shift);
574     vacc2x89AB = vqshlq_s32(vacc2x89AB, vright_pre_shift);
575     vacc2xCDEF = vqshlq_s32(vacc2xCDEF, vright_pre_shift);
576 
577     vacc0x0123 = vqdmulhq_s32(vacc0x0123, vmultiplier);
578     vacc0x4567 = vqdmulhq_s32(vacc0x4567, vmultiplier);
579     vacc0x89AB = vqdmulhq_s32(vacc0x89AB, vmultiplier);
580     vacc0xCDEF = vqdmulhq_s32(vacc0xCDEF, vmultiplier);
581     vacc1x0123 = vqdmulhq_s32(vacc1x0123, vmultiplier);
582     vacc1x4567 = vqdmulhq_s32(vacc1x4567, vmultiplier);
583     vacc1x89AB = vqdmulhq_s32(vacc1x89AB, vmultiplier);
584     vacc1xCDEF = vqdmulhq_s32(vacc1xCDEF, vmultiplier);
585     vacc2x0123 = vqdmulhq_s32(vacc2x0123, vmultiplier);
586     vacc2x4567 = vqdmulhq_s32(vacc2x4567, vmultiplier);
587     vacc2x89AB = vqdmulhq_s32(vacc2x89AB, vmultiplier);
588     vacc2xCDEF = vqdmulhq_s32(vacc2xCDEF, vmultiplier);
589 
590     vacc0x0123 = vrshlq_s32(vacc0x0123, vright_post_shift);
591     vacc0x4567 = vrshlq_s32(vacc0x4567, vright_post_shift);
592     vacc0x89AB = vrshlq_s32(vacc0x89AB, vright_post_shift);
593     vacc0xCDEF = vrshlq_s32(vacc0xCDEF, vright_post_shift);
594     vacc1x0123 = vrshlq_s32(vacc1x0123, vright_post_shift);
595     vacc1x4567 = vrshlq_s32(vacc1x4567, vright_post_shift);
596     vacc1x89AB = vrshlq_s32(vacc1x89AB, vright_post_shift);
597     vacc1xCDEF = vrshlq_s32(vacc1xCDEF, vright_post_shift);
598     vacc2x0123 = vrshlq_s32(vacc2x0123, vright_post_shift);
599     vacc2x4567 = vrshlq_s32(vacc2x4567, vright_post_shift);
600     vacc2x89AB = vrshlq_s32(vacc2x89AB, vright_post_shift);
601     vacc2xCDEF = vrshlq_s32(vacc2xCDEF, vright_post_shift);
602 
603     const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->rndnu_neon.output_zero_point);
604 #if XNN_ARCH_ARM64
605     int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
606     int16x8_t vacc0x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF);
607     int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
608     int16x8_t vacc1x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc1x89AB), vacc1xCDEF);
609     int16x8_t vacc2x01234567 = vqmovn_high_s32(vqmovn_s32(vacc2x0123), vacc2x4567);
610     int16x8_t vacc2x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc2x89AB), vacc2xCDEF);
611 
612     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
613     vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
614     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
615     vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
616     vacc2x01234567 = vqaddq_s16(vacc2x01234567, voutput_zero_point);
617     vacc2x89ABCDEF = vqaddq_s16(vacc2x89ABCDEF, voutput_zero_point);
618 
619     int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF);
620     int8x16_t vout1x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc1x01234567), vacc1x89ABCDEF);
621     int8x16_t vout2x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc2x01234567), vacc2x89ABCDEF);
622 #else
623     int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
624     int16x8_t vacc0x89ABCDEF = vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF));
625     int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
626     int16x8_t vacc1x89ABCDEF = vcombine_s16(vqmovn_s32(vacc1x89AB), vqmovn_s32(vacc1xCDEF));
627     int16x8_t vacc2x01234567 = vcombine_s16(vqmovn_s32(vacc2x0123), vqmovn_s32(vacc2x4567));
628     int16x8_t vacc2x89ABCDEF = vcombine_s16(vqmovn_s32(vacc2x89AB), vqmovn_s32(vacc2xCDEF));
629 
630     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
631     vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
632     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
633     vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
634     vacc2x01234567 = vqaddq_s16(vacc2x01234567, voutput_zero_point);
635     vacc2x89ABCDEF = vqaddq_s16(vacc2x89ABCDEF, voutput_zero_point);
636 
637     int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF));
638     int8x16_t vout1x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc1x01234567), vqmovn_s16(vacc1x89ABCDEF));
639     int8x16_t vout2x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc2x01234567), vqmovn_s16(vacc2x89ABCDEF));
640 #endif
641 
642     const int8x16_t voutput_min = vld1q_dup_s8(&params->rndnu_neon.output_min);
643     vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min);
644     vout1x0123456789ABCDEF = vmaxq_s8(vout1x0123456789ABCDEF, voutput_min);
645     vout2x0123456789ABCDEF = vmaxq_s8(vout2x0123456789ABCDEF, voutput_min);
646 
647     const int8x16_t voutput_max = vld1q_dup_s8(&params->rndnu_neon.output_max);
648     vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max);
649     vout1x0123456789ABCDEF = vminq_s8(vout1x0123456789ABCDEF, voutput_max);
650     vout2x0123456789ABCDEF = vminq_s8(vout2x0123456789ABCDEF, voutput_max);
651 
652     if (nc >= 16) {
653       vst1q_s8(c2 + 0, vout2x0123456789ABCDEF);
654       vst1q_s8(c1 + 0, vout1x0123456789ABCDEF);
655       vst1q_s8(c0 + 0, vout0x0123456789ABCDEF);
656 
657       c2 = (int8_t*) ((uintptr_t) c2 + cn_stride);
658       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
659       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
660 
661       a = (const int8_t**restrict) ((uintptr_t) a - ks);
662 
663       nc -= 16;
664     } else {
665       int8x8_t vout2x01234567 = vget_low_s8(vout2x0123456789ABCDEF);
666       int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vget_low_s8(vout0x0123456789ABCDEF), vget_low_s8(vout1x0123456789ABCDEF));
667       if (nc & 8) {
668         vst1_s8(c2, vout2x01234567); c2 += 8;
669         vst1_s8(c1, vget_high_s8(vout0x01234567_1x01234567)); c1 += 8;
670         vst1_s8(c0, vget_low_s8(vout0x01234567_1x01234567)); c0 += 8;
671         vout2x01234567 = vget_high_s8(vout2x0123456789ABCDEF);
672         vout0x01234567_1x01234567 = vcombine_s8(vget_high_s8(vout0x0123456789ABCDEF), vget_high_s8(vout1x0123456789ABCDEF));
673       }
674       if (nc & 4) {
675         vst1_lane_u32((void*) c2, vreinterpret_u32_s8(vout2x01234567), 0); c2 += 4;
676         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
677         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
678         vout2x01234567 = vext_s8(vout2x01234567, vout2x01234567, 4);
679         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
680       }
681       if (nc & 2) {
682         vst1_lane_u16((void*) c2, vreinterpret_u16_s8(vout2x01234567), 0); c2 += 2;
683         vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
684         vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
685         vout2x01234567 = vext_s8(vout2x01234567, vout2x01234567, 2);
686         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
687       }
688       if (nc & 1) {
689         vst1_lane_s8(c2, vout2x01234567, 0);
690         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
691         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
692       }
693 
694       nc = 0;
695     }
696   } while (nc != 0);
697 }
698