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