• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-igemm/c4-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 
17 
xnn_qs8_igemm_minmax_rndnu_ukernel_3x16c4__neon_mlal_ld1r(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)])18 void xnn_qs8_igemm_minmax_rndnu_ukernel_3x16c4__neon_mlal_ld1r(
19     size_t mr,
20     size_t nc,
21     size_t kc,
22     size_t ks,
23     const int8_t** restrict a,
24     const void* restrict w,
25     int8_t* restrict c,
26     size_t cm_stride,
27     size_t cn_stride,
28     size_t a_offset,
29     const int8_t* zero,
30     const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
31 {
32   assert(mr != 0);
33   assert(mr <= 3);
34   assert(nc != 0);
35   assert(kc != 0);
36   assert(ks != 0);
37   assert(ks % (3 * sizeof(void*)) == 0);
38   assert(a_offset % sizeof(int8_t) == 0);
39   assert(a != NULL);
40   assert(w != NULL);
41   assert(c != NULL);
42 
43   kc = round_up_po2(kc, 4 * sizeof(int8_t));
44   int8_t* c0 = c;
45   int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
46   if XNN_UNPREDICTABLE(mr < 2) {
47     c1 = c0;
48   }
49   int8_t* c2 = (int8_t*) ((uintptr_t) c1 + cm_stride);
50   if XNN_UNPREDICTABLE(mr <= 2) {
51     c2 = c1;
52   }
53 
54   do {
55     int32x4_t vacc0x01 = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
56     int32x4_t vacc0x23 = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
57     int32x4_t vacc0x45 = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
58     int32x4_t vacc0x67 = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
59     int32x4_t vacc0x89 = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
60     int32x4_t vacc0xAB = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
61     int32x4_t vacc0xCD = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
62     int32x4_t vacc0xEF = vreinterpretq_s32_u64(vmovl_u32(vld1_u32(w))); w = (const void*) ((uintptr_t) w + 2 * sizeof(int32_t));
63     int32x4_t vacc1x01 = vacc0x01;
64     int32x4_t vacc1x23 = vacc0x23;
65     int32x4_t vacc1x45 = vacc0x45;
66     int32x4_t vacc1x67 = vacc0x67;
67     int32x4_t vacc1x89 = vacc0x89;
68     int32x4_t vacc1xAB = vacc0xAB;
69     int32x4_t vacc1xCD = vacc0xCD;
70     int32x4_t vacc1xEF = vacc0xEF;
71     int32x4_t vacc2x01 = vacc0x01;
72     int32x4_t vacc2x23 = vacc0x23;
73     int32x4_t vacc2x45 = vacc0x45;
74     int32x4_t vacc2x67 = vacc0x67;
75     int32x4_t vacc2x89 = vacc0x89;
76     int32x4_t vacc2xAB = vacc0xAB;
77     int32x4_t vacc2xCD = vacc0xCD;
78     int32x4_t vacc2xEF = vacc0xEF;
79 
80     size_t p = ks;
81     do {
82       const int8_t* restrict a0 = a[0];
83       if XNN_UNPREDICTABLE(a0 != zero) {
84         a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
85       }
86       const int8_t* restrict a1 = a[1];
87       if XNN_UNPREDICTABLE(a1 != zero) {
88         a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
89       }
90       const int8_t* restrict a2 = a[2];
91       if XNN_UNPREDICTABLE(a2 != zero) {
92         a2 = (const int8_t*) ((uintptr_t) a2 + a_offset);
93       }
94       a += 3;
95 
96       size_t k = kc;
97 
98       while (k >= 16 * sizeof(int8_t)) {
99         const int32x2_t va00x0 = vld1_dup_s32((const void*)a0);
100         const int32x2_t va01x0 = vld1_dup_s32((const void*)(a0 + 4)); a0 += 8;
101         const int32x2_t va00x1 = vld1_dup_s32((const void*)a0);
102         const int32x2_t va01x1 = vld1_dup_s32((const void*)(a0 + 4)); a0 += 8;
103         const int32x2_t va10x0 = vld1_dup_s32((const void*)a1);
104         const int32x2_t va11x0 = vld1_dup_s32((const void*)(a1 + 4)); a1 += 8;
105         const int32x2_t va10x1 = vld1_dup_s32((const void*)a1);
106         const int32x2_t va11x1 = vld1_dup_s32((const void*)(a1 + 4)); a1 += 8;
107         const int32x2_t va20x0 = vld1_dup_s32((const void*)a2);
108         const int32x2_t va21x0 = vld1_dup_s32((const void*)(a2 + 4)); a2 += 8;
109         const int32x2_t va20x1 = vld1_dup_s32((const void*)a2);
110         const int32x2_t va21x1 = vld1_dup_s32((const void*)(a2 + 4)); a2 += 8;
111 
112         const int8x8_t vb01c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
113         const int8x8_t vb23c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
114         const int8x8_t vb45c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
115         const int8x8_t vb67c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
116         const int8x8_t vb89c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
117         const int8x8_t vbABc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
118         const int8x8_t vbCDc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
119         const int8x8_t vbEFc0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
120         const int8x8_t vb01c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
121         const int8x8_t vb23c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
122         const int8x8_t vb45c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
123         const int8x8_t vb67c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
124         const int8x8_t vb89c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
125         const int8x8_t vbABc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
126         const int8x8_t vbCDc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
127         const int8x8_t vbEFc1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
128 
129         const int8x8_t va0c0x0 = vreinterpret_s8_s32(va00x0);
130         const int8x8_t va0c0x1 = vreinterpret_s8_s32(va00x1);
131         const int8x8_t va1c0x0 = vreinterpret_s8_s32(va10x0);
132         const int8x8_t va1c0x1 = vreinterpret_s8_s32(va10x1);
133         const int8x8_t va2c0x0 = vreinterpret_s8_s32(va20x0);
134         const int8x8_t va2c0x1 = vreinterpret_s8_s32(va20x1);
135 
136         int16x8_t vprod0x01c0 = vmull_s8(vb01c0x0, va0c0x0);
137         int16x8_t vprod1x01c0 = vmull_s8(vb01c0x0, va1c0x0);
138         int16x8_t vprod2x01c0 = vmull_s8(vb01c0x0, va2c0x0);
139         const int8x8_t vb01c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
140         vprod0x01c0 = vmlal_s8(vprod0x01c0, vb01c0x1, va0c0x1);
141         vprod1x01c0 = vmlal_s8(vprod1x01c0, vb01c0x1, va1c0x1);
142         vprod2x01c0 = vmlal_s8(vprod2x01c0, vb01c0x1, va2c0x1);
143         vacc0x01 = vpadalq_s16(vacc0x01, vprod0x01c0);
144         vacc1x01 = vpadalq_s16(vacc1x01, vprod1x01c0);
145         vacc2x01 = vpadalq_s16(vacc2x01, vprod2x01c0);
146         int16x8_t vprod0x23c0 = vmull_s8(vb23c0x0, va0c0x0);
147         int16x8_t vprod1x23c0 = vmull_s8(vb23c0x0, va1c0x0);
148         int16x8_t vprod2x23c0 = vmull_s8(vb23c0x0, va2c0x0);
149         const int8x8_t vb23c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
150         vprod0x23c0 = vmlal_s8(vprod0x23c0, vb23c0x1, va0c0x1);
151         vprod1x23c0 = vmlal_s8(vprod1x23c0, vb23c0x1, va1c0x1);
152         vprod2x23c0 = vmlal_s8(vprod2x23c0, vb23c0x1, va2c0x1);
153         vacc0x23 = vpadalq_s16(vacc0x23, vprod0x23c0);
154         vacc1x23 = vpadalq_s16(vacc1x23, vprod1x23c0);
155         vacc2x23 = vpadalq_s16(vacc2x23, vprod2x23c0);
156         int16x8_t vprod0x45c0 = vmull_s8(vb45c0x0, va0c0x0);
157         int16x8_t vprod1x45c0 = vmull_s8(vb45c0x0, va1c0x0);
158         int16x8_t vprod2x45c0 = vmull_s8(vb45c0x0, va2c0x0);
159         const int8x8_t vb45c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
160         vprod0x45c0 = vmlal_s8(vprod0x45c0, vb45c0x1, va0c0x1);
161         vprod1x45c0 = vmlal_s8(vprod1x45c0, vb45c0x1, va1c0x1);
162         vprod2x45c0 = vmlal_s8(vprod2x45c0, vb45c0x1, va2c0x1);
163         vacc0x45 = vpadalq_s16(vacc0x45, vprod0x45c0);
164         vacc1x45 = vpadalq_s16(vacc1x45, vprod1x45c0);
165         vacc2x45 = vpadalq_s16(vacc2x45, vprod2x45c0);
166         int16x8_t vprod0x67c0 = vmull_s8(vb67c0x0, va0c0x0);
167         int16x8_t vprod1x67c0 = vmull_s8(vb67c0x0, va1c0x0);
168         int16x8_t vprod2x67c0 = vmull_s8(vb67c0x0, va2c0x0);
169         const int8x8_t vb67c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
170         vprod0x67c0 = vmlal_s8(vprod0x67c0, vb67c0x1, va0c0x1);
171         vprod1x67c0 = vmlal_s8(vprod1x67c0, vb67c0x1, va1c0x1);
172         vprod2x67c0 = vmlal_s8(vprod2x67c0, vb67c0x1, va2c0x1);
173         vacc0x67 = vpadalq_s16(vacc0x67, vprod0x67c0);
174         vacc1x67 = vpadalq_s16(vacc1x67, vprod1x67c0);
175         vacc2x67 = vpadalq_s16(vacc2x67, vprod2x67c0);
176         int16x8_t vprod0x89c0 = vmull_s8(vb89c0x0, va0c0x0);
177         int16x8_t vprod1x89c0 = vmull_s8(vb89c0x0, va1c0x0);
178         int16x8_t vprod2x89c0 = vmull_s8(vb89c0x0, va2c0x0);
179         const int8x8_t vb89c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
180         vprod0x89c0 = vmlal_s8(vprod0x89c0, vb89c0x1, va0c0x1);
181         vprod1x89c0 = vmlal_s8(vprod1x89c0, vb89c0x1, va1c0x1);
182         vprod2x89c0 = vmlal_s8(vprod2x89c0, vb89c0x1, va2c0x1);
183         vacc0x89 = vpadalq_s16(vacc0x89, vprod0x89c0);
184         vacc1x89 = vpadalq_s16(vacc1x89, vprod1x89c0);
185         vacc2x89 = vpadalq_s16(vacc2x89, vprod2x89c0);
186         int16x8_t vprod0xABc0 = vmull_s8(vbABc0x0, va0c0x0);
187         int16x8_t vprod1xABc0 = vmull_s8(vbABc0x0, va1c0x0);
188         int16x8_t vprod2xABc0 = vmull_s8(vbABc0x0, va2c0x0);
189         const int8x8_t vbABc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
190         vprod0xABc0 = vmlal_s8(vprod0xABc0, vbABc0x1, va0c0x1);
191         vprod1xABc0 = vmlal_s8(vprod1xABc0, vbABc0x1, va1c0x1);
192         vprod2xABc0 = vmlal_s8(vprod2xABc0, vbABc0x1, va2c0x1);
193         vacc0xAB = vpadalq_s16(vacc0xAB, vprod0xABc0);
194         vacc1xAB = vpadalq_s16(vacc1xAB, vprod1xABc0);
195         vacc2xAB = vpadalq_s16(vacc2xAB, vprod2xABc0);
196         int16x8_t vprod0xCDc0 = vmull_s8(vbCDc0x0, va0c0x0);
197         int16x8_t vprod1xCDc0 = vmull_s8(vbCDc0x0, va1c0x0);
198         int16x8_t vprod2xCDc0 = vmull_s8(vbCDc0x0, va2c0x0);
199         const int8x8_t vbCDc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
200         vprod0xCDc0 = vmlal_s8(vprod0xCDc0, vbCDc0x1, va0c0x1);
201         vprod1xCDc0 = vmlal_s8(vprod1xCDc0, vbCDc0x1, va1c0x1);
202         vprod2xCDc0 = vmlal_s8(vprod2xCDc0, vbCDc0x1, va2c0x1);
203         vacc0xCD = vpadalq_s16(vacc0xCD, vprod0xCDc0);
204         vacc1xCD = vpadalq_s16(vacc1xCD, vprod1xCDc0);
205         vacc2xCD = vpadalq_s16(vacc2xCD, vprod2xCDc0);
206         int16x8_t vprod0xEFc0 = vmull_s8(vbEFc0x0, va0c0x0);
207         int16x8_t vprod1xEFc0 = vmull_s8(vbEFc0x0, va1c0x0);
208         int16x8_t vprod2xEFc0 = vmull_s8(vbEFc0x0, va2c0x0);
209         const int8x8_t vbEFc0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
210         vprod0xEFc0 = vmlal_s8(vprod0xEFc0, vbEFc0x1, va0c0x1);
211         vprod1xEFc0 = vmlal_s8(vprod1xEFc0, vbEFc0x1, va1c0x1);
212         vprod2xEFc0 = vmlal_s8(vprod2xEFc0, vbEFc0x1, va2c0x1);
213         vacc0xEF = vpadalq_s16(vacc0xEF, vprod0xEFc0);
214         vacc1xEF = vpadalq_s16(vacc1xEF, vprod1xEFc0);
215         vacc2xEF = vpadalq_s16(vacc2xEF, vprod2xEFc0);
216         const int8x8_t va0c1x0 = vreinterpret_s8_s32(va01x0);
217         const int8x8_t va0c1x1 = vreinterpret_s8_s32(va01x1);
218         const int8x8_t va1c1x0 = vreinterpret_s8_s32(va11x0);
219         const int8x8_t va1c1x1 = vreinterpret_s8_s32(va11x1);
220         const int8x8_t va2c1x0 = vreinterpret_s8_s32(va21x0);
221         const int8x8_t va2c1x1 = vreinterpret_s8_s32(va21x1);
222 
223         int16x8_t vprod0x01c1 = vmull_s8(vb01c1x0, va0c1x0);
224         int16x8_t vprod1x01c1 = vmull_s8(vb01c1x0, va1c1x0);
225         int16x8_t vprod2x01c1 = vmull_s8(vb01c1x0, va2c1x0);
226         const int8x8_t vb01c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
227         vprod0x01c1 = vmlal_s8(vprod0x01c1, vb01c1x1, va0c1x1);
228         vprod1x01c1 = vmlal_s8(vprod1x01c1, vb01c1x1, va1c1x1);
229         vprod2x01c1 = vmlal_s8(vprod2x01c1, vb01c1x1, va2c1x1);
230         vacc0x01 = vpadalq_s16(vacc0x01, vprod0x01c1);
231         vacc1x01 = vpadalq_s16(vacc1x01, vprod1x01c1);
232         vacc2x01 = vpadalq_s16(vacc2x01, vprod2x01c1);
233         int16x8_t vprod0x23c1 = vmull_s8(vb23c1x0, va0c1x0);
234         int16x8_t vprod1x23c1 = vmull_s8(vb23c1x0, va1c1x0);
235         int16x8_t vprod2x23c1 = vmull_s8(vb23c1x0, va2c1x0);
236         const int8x8_t vb23c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
237         vprod0x23c1 = vmlal_s8(vprod0x23c1, vb23c1x1, va0c1x1);
238         vprod1x23c1 = vmlal_s8(vprod1x23c1, vb23c1x1, va1c1x1);
239         vprod2x23c1 = vmlal_s8(vprod2x23c1, vb23c1x1, va2c1x1);
240         vacc0x23 = vpadalq_s16(vacc0x23, vprod0x23c1);
241         vacc1x23 = vpadalq_s16(vacc1x23, vprod1x23c1);
242         vacc2x23 = vpadalq_s16(vacc2x23, vprod2x23c1);
243         int16x8_t vprod0x45c1 = vmull_s8(vb45c1x0, va0c1x0);
244         int16x8_t vprod1x45c1 = vmull_s8(vb45c1x0, va1c1x0);
245         int16x8_t vprod2x45c1 = vmull_s8(vb45c1x0, va2c1x0);
246         const int8x8_t vb45c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
247         vprod0x45c1 = vmlal_s8(vprod0x45c1, vb45c1x1, va0c1x1);
248         vprod1x45c1 = vmlal_s8(vprod1x45c1, vb45c1x1, va1c1x1);
249         vprod2x45c1 = vmlal_s8(vprod2x45c1, vb45c1x1, va2c1x1);
250         vacc0x45 = vpadalq_s16(vacc0x45, vprod0x45c1);
251         vacc1x45 = vpadalq_s16(vacc1x45, vprod1x45c1);
252         vacc2x45 = vpadalq_s16(vacc2x45, vprod2x45c1);
253         int16x8_t vprod0x67c1 = vmull_s8(vb67c1x0, va0c1x0);
254         int16x8_t vprod1x67c1 = vmull_s8(vb67c1x0, va1c1x0);
255         int16x8_t vprod2x67c1 = vmull_s8(vb67c1x0, va2c1x0);
256         const int8x8_t vb67c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
257         vprod0x67c1 = vmlal_s8(vprod0x67c1, vb67c1x1, va0c1x1);
258         vprod1x67c1 = vmlal_s8(vprod1x67c1, vb67c1x1, va1c1x1);
259         vprod2x67c1 = vmlal_s8(vprod2x67c1, vb67c1x1, va2c1x1);
260         vacc0x67 = vpadalq_s16(vacc0x67, vprod0x67c1);
261         vacc1x67 = vpadalq_s16(vacc1x67, vprod1x67c1);
262         vacc2x67 = vpadalq_s16(vacc2x67, vprod2x67c1);
263         int16x8_t vprod0x89c1 = vmull_s8(vb89c1x0, va0c1x0);
264         int16x8_t vprod1x89c1 = vmull_s8(vb89c1x0, va1c1x0);
265         int16x8_t vprod2x89c1 = vmull_s8(vb89c1x0, va2c1x0);
266         const int8x8_t vb89c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
267         vprod0x89c1 = vmlal_s8(vprod0x89c1, vb89c1x1, va0c1x1);
268         vprod1x89c1 = vmlal_s8(vprod1x89c1, vb89c1x1, va1c1x1);
269         vprod2x89c1 = vmlal_s8(vprod2x89c1, vb89c1x1, va2c1x1);
270         vacc0x89 = vpadalq_s16(vacc0x89, vprod0x89c1);
271         vacc1x89 = vpadalq_s16(vacc1x89, vprod1x89c1);
272         vacc2x89 = vpadalq_s16(vacc2x89, vprod2x89c1);
273         int16x8_t vprod0xABc1 = vmull_s8(vbABc1x0, va0c1x0);
274         int16x8_t vprod1xABc1 = vmull_s8(vbABc1x0, va1c1x0);
275         int16x8_t vprod2xABc1 = vmull_s8(vbABc1x0, va2c1x0);
276         const int8x8_t vbABc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
277         vprod0xABc1 = vmlal_s8(vprod0xABc1, vbABc1x1, va0c1x1);
278         vprod1xABc1 = vmlal_s8(vprod1xABc1, vbABc1x1, va1c1x1);
279         vprod2xABc1 = vmlal_s8(vprod2xABc1, vbABc1x1, va2c1x1);
280         vacc0xAB = vpadalq_s16(vacc0xAB, vprod0xABc1);
281         vacc1xAB = vpadalq_s16(vacc1xAB, vprod1xABc1);
282         vacc2xAB = vpadalq_s16(vacc2xAB, vprod2xABc1);
283         int16x8_t vprod0xCDc1 = vmull_s8(vbCDc1x0, va0c1x0);
284         int16x8_t vprod1xCDc1 = vmull_s8(vbCDc1x0, va1c1x0);
285         int16x8_t vprod2xCDc1 = vmull_s8(vbCDc1x0, va2c1x0);
286         const int8x8_t vbCDc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
287         vprod0xCDc1 = vmlal_s8(vprod0xCDc1, vbCDc1x1, va0c1x1);
288         vprod1xCDc1 = vmlal_s8(vprod1xCDc1, vbCDc1x1, va1c1x1);
289         vprod2xCDc1 = vmlal_s8(vprod2xCDc1, vbCDc1x1, va2c1x1);
290         vacc0xCD = vpadalq_s16(vacc0xCD, vprod0xCDc1);
291         vacc1xCD = vpadalq_s16(vacc1xCD, vprod1xCDc1);
292         vacc2xCD = vpadalq_s16(vacc2xCD, vprod2xCDc1);
293         int16x8_t vprod0xEFc1 = vmull_s8(vbEFc1x0, va0c1x0);
294         int16x8_t vprod1xEFc1 = vmull_s8(vbEFc1x0, va1c1x0);
295         int16x8_t vprod2xEFc1 = vmull_s8(vbEFc1x0, va2c1x0);
296         const int8x8_t vbEFc1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
297         vprod0xEFc1 = vmlal_s8(vprod0xEFc1, vbEFc1x1, va0c1x1);
298         vprod1xEFc1 = vmlal_s8(vprod1xEFc1, vbEFc1x1, va1c1x1);
299         vprod2xEFc1 = vmlal_s8(vprod2xEFc1, vbEFc1x1, va2c1x1);
300         vacc0xEF = vpadalq_s16(vacc0xEF, vprod0xEFc1);
301         vacc1xEF = vpadalq_s16(vacc1xEF, vprod1xEFc1);
302         vacc2xEF = vpadalq_s16(vacc2xEF, vprod2xEFc1);
303 
304         k -= 16 * sizeof(int8_t);
305       }
306 
307       if (k >= 8 * sizeof(int8_t)) {
308         const int32x2_t va00 = vld1_dup_s32((const void*)a0);
309         const int32x2_t va01 = vld1_dup_s32((const void*)(a0 + 4)); a0 += 8;
310         const int32x2_t va10 = vld1_dup_s32((const void*)a1);
311         const int32x2_t va11 = vld1_dup_s32((const void*)(a1 + 4)); a1 += 8;
312         const int32x2_t va20 = vld1_dup_s32((const void*)a2);
313         const int32x2_t va21 = vld1_dup_s32((const void*)(a2 + 4)); a2 += 8;
314 
315         const int8x8_t vb01c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
316         const int8x8_t vb23c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
317         const int8x8_t vb45c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
318         const int8x8_t vb67c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
319         const int8x8_t vb89c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
320         const int8x8_t vbABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
321         const int8x8_t vbCDc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
322         const int8x8_t vbEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
323         const int8x8_t vb01c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
324         const int8x8_t vb23c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
325         const int8x8_t vb45c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
326         const int8x8_t vb67c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
327         const int8x8_t vb89c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
328         const int8x8_t vbABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
329         const int8x8_t vbCDc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
330         const int8x8_t vbEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
331 
332         const int8x8_t va0c0 = vreinterpret_s8_s32(va00);
333         const int8x8_t va1c0 = vreinterpret_s8_s32(va10);
334         const int8x8_t va2c0 = vreinterpret_s8_s32(va20);
335 
336         const int16x8_t vprod0x01c0 = vmull_s8(vb01c0, va0c0);
337         const int16x8_t vprod1x01c0 = vmull_s8(vb01c0, va1c0);
338         const int16x8_t vprod2x01c0 = vmull_s8(vb01c0, va2c0);
339         vacc0x01 = vpadalq_s16(vacc0x01, vprod0x01c0);
340         vacc1x01 = vpadalq_s16(vacc1x01, vprod1x01c0);
341         vacc2x01 = vpadalq_s16(vacc2x01, vprod2x01c0);
342         const int16x8_t vprod0x23c0 = vmull_s8(vb23c0, va0c0);
343         const int16x8_t vprod1x23c0 = vmull_s8(vb23c0, va1c0);
344         const int16x8_t vprod2x23c0 = vmull_s8(vb23c0, va2c0);
345         vacc0x23 = vpadalq_s16(vacc0x23, vprod0x23c0);
346         vacc1x23 = vpadalq_s16(vacc1x23, vprod1x23c0);
347         vacc2x23 = vpadalq_s16(vacc2x23, vprod2x23c0);
348         const int16x8_t vprod0x45c0 = vmull_s8(vb45c0, va0c0);
349         const int16x8_t vprod1x45c0 = vmull_s8(vb45c0, va1c0);
350         const int16x8_t vprod2x45c0 = vmull_s8(vb45c0, va2c0);
351         vacc0x45 = vpadalq_s16(vacc0x45, vprod0x45c0);
352         vacc1x45 = vpadalq_s16(vacc1x45, vprod1x45c0);
353         vacc2x45 = vpadalq_s16(vacc2x45, vprod2x45c0);
354         const int16x8_t vprod0x67c0 = vmull_s8(vb67c0, va0c0);
355         const int16x8_t vprod1x67c0 = vmull_s8(vb67c0, va1c0);
356         const int16x8_t vprod2x67c0 = vmull_s8(vb67c0, va2c0);
357         vacc0x67 = vpadalq_s16(vacc0x67, vprod0x67c0);
358         vacc1x67 = vpadalq_s16(vacc1x67, vprod1x67c0);
359         vacc2x67 = vpadalq_s16(vacc2x67, vprod2x67c0);
360         const int16x8_t vprod0x89c0 = vmull_s8(vb89c0, va0c0);
361         const int16x8_t vprod1x89c0 = vmull_s8(vb89c0, va1c0);
362         const int16x8_t vprod2x89c0 = vmull_s8(vb89c0, va2c0);
363         vacc0x89 = vpadalq_s16(vacc0x89, vprod0x89c0);
364         vacc1x89 = vpadalq_s16(vacc1x89, vprod1x89c0);
365         vacc2x89 = vpadalq_s16(vacc2x89, vprod2x89c0);
366         const int16x8_t vprod0xABc0 = vmull_s8(vbABc0, va0c0);
367         const int16x8_t vprod1xABc0 = vmull_s8(vbABc0, va1c0);
368         const int16x8_t vprod2xABc0 = vmull_s8(vbABc0, va2c0);
369         vacc0xAB = vpadalq_s16(vacc0xAB, vprod0xABc0);
370         vacc1xAB = vpadalq_s16(vacc1xAB, vprod1xABc0);
371         vacc2xAB = vpadalq_s16(vacc2xAB, vprod2xABc0);
372         const int16x8_t vprod0xCDc0 = vmull_s8(vbCDc0, va0c0);
373         const int16x8_t vprod1xCDc0 = vmull_s8(vbCDc0, va1c0);
374         const int16x8_t vprod2xCDc0 = vmull_s8(vbCDc0, va2c0);
375         vacc0xCD = vpadalq_s16(vacc0xCD, vprod0xCDc0);
376         vacc1xCD = vpadalq_s16(vacc1xCD, vprod1xCDc0);
377         vacc2xCD = vpadalq_s16(vacc2xCD, vprod2xCDc0);
378         const int16x8_t vprod0xEFc0 = vmull_s8(vbEFc0, va0c0);
379         const int16x8_t vprod1xEFc0 = vmull_s8(vbEFc0, va1c0);
380         const int16x8_t vprod2xEFc0 = vmull_s8(vbEFc0, va2c0);
381         vacc0xEF = vpadalq_s16(vacc0xEF, vprod0xEFc0);
382         vacc1xEF = vpadalq_s16(vacc1xEF, vprod1xEFc0);
383         vacc2xEF = vpadalq_s16(vacc2xEF, vprod2xEFc0);
384         const int8x8_t va0c1 = vreinterpret_s8_s32(va01);
385         const int8x8_t va1c1 = vreinterpret_s8_s32(va11);
386         const int8x8_t va2c1 = vreinterpret_s8_s32(va21);
387 
388         const int16x8_t vprod0x01c1 = vmull_s8(vb01c1, va0c1);
389         const int16x8_t vprod1x01c1 = vmull_s8(vb01c1, va1c1);
390         const int16x8_t vprod2x01c1 = vmull_s8(vb01c1, va2c1);
391         vacc0x01 = vpadalq_s16(vacc0x01, vprod0x01c1);
392         vacc1x01 = vpadalq_s16(vacc1x01, vprod1x01c1);
393         vacc2x01 = vpadalq_s16(vacc2x01, vprod2x01c1);
394         const int16x8_t vprod0x23c1 = vmull_s8(vb23c1, va0c1);
395         const int16x8_t vprod1x23c1 = vmull_s8(vb23c1, va1c1);
396         const int16x8_t vprod2x23c1 = vmull_s8(vb23c1, va2c1);
397         vacc0x23 = vpadalq_s16(vacc0x23, vprod0x23c1);
398         vacc1x23 = vpadalq_s16(vacc1x23, vprod1x23c1);
399         vacc2x23 = vpadalq_s16(vacc2x23, vprod2x23c1);
400         const int16x8_t vprod0x45c1 = vmull_s8(vb45c1, va0c1);
401         const int16x8_t vprod1x45c1 = vmull_s8(vb45c1, va1c1);
402         const int16x8_t vprod2x45c1 = vmull_s8(vb45c1, va2c1);
403         vacc0x45 = vpadalq_s16(vacc0x45, vprod0x45c1);
404         vacc1x45 = vpadalq_s16(vacc1x45, vprod1x45c1);
405         vacc2x45 = vpadalq_s16(vacc2x45, vprod2x45c1);
406         const int16x8_t vprod0x67c1 = vmull_s8(vb67c1, va0c1);
407         const int16x8_t vprod1x67c1 = vmull_s8(vb67c1, va1c1);
408         const int16x8_t vprod2x67c1 = vmull_s8(vb67c1, va2c1);
409         vacc0x67 = vpadalq_s16(vacc0x67, vprod0x67c1);
410         vacc1x67 = vpadalq_s16(vacc1x67, vprod1x67c1);
411         vacc2x67 = vpadalq_s16(vacc2x67, vprod2x67c1);
412         const int16x8_t vprod0x89c1 = vmull_s8(vb89c1, va0c1);
413         const int16x8_t vprod1x89c1 = vmull_s8(vb89c1, va1c1);
414         const int16x8_t vprod2x89c1 = vmull_s8(vb89c1, va2c1);
415         vacc0x89 = vpadalq_s16(vacc0x89, vprod0x89c1);
416         vacc1x89 = vpadalq_s16(vacc1x89, vprod1x89c1);
417         vacc2x89 = vpadalq_s16(vacc2x89, vprod2x89c1);
418         const int16x8_t vprod0xABc1 = vmull_s8(vbABc1, va0c1);
419         const int16x8_t vprod1xABc1 = vmull_s8(vbABc1, va1c1);
420         const int16x8_t vprod2xABc1 = vmull_s8(vbABc1, va2c1);
421         vacc0xAB = vpadalq_s16(vacc0xAB, vprod0xABc1);
422         vacc1xAB = vpadalq_s16(vacc1xAB, vprod1xABc1);
423         vacc2xAB = vpadalq_s16(vacc2xAB, vprod2xABc1);
424         const int16x8_t vprod0xCDc1 = vmull_s8(vbCDc1, va0c1);
425         const int16x8_t vprod1xCDc1 = vmull_s8(vbCDc1, va1c1);
426         const int16x8_t vprod2xCDc1 = vmull_s8(vbCDc1, va2c1);
427         vacc0xCD = vpadalq_s16(vacc0xCD, vprod0xCDc1);
428         vacc1xCD = vpadalq_s16(vacc1xCD, vprod1xCDc1);
429         vacc2xCD = vpadalq_s16(vacc2xCD, vprod2xCDc1);
430         const int16x8_t vprod0xEFc1 = vmull_s8(vbEFc1, va0c1);
431         const int16x8_t vprod1xEFc1 = vmull_s8(vbEFc1, va1c1);
432         const int16x8_t vprod2xEFc1 = vmull_s8(vbEFc1, va2c1);
433         vacc0xEF = vpadalq_s16(vacc0xEF, vprod0xEFc1);
434         vacc1xEF = vpadalq_s16(vacc1xEF, vprod1xEFc1);
435         vacc2xEF = vpadalq_s16(vacc2xEF, vprod2xEFc1);
436 
437         k -= 8 * sizeof(int8_t);
438       }
439 
440       if XNN_UNLIKELY(k != 0) {
441         const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
442         const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
443         const int8x8_t va2 = vld1_s8(a2); a2 = (const int8_t*) ((uintptr_t) a2 + k);
444 
445         const int8x8_t vb01c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
446         const int8x8_t vb23c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
447         const int8x8_t vb45c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
448         const int8x8_t vb67c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
449         const int8x8_t vb89c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
450         const int8x8_t vbABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
451         const int8x8_t vbCDc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
452         const int8x8_t vbEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
453 
454         const int8x8_t va0c0 = vreinterpret_s8_s32(vdup_lane_s32(vreinterpret_s32_s8(va0), 0));
455         const int16x8_t vprod0x01c0 = vmull_s8(vb01c0, va0c0);
456         vacc0x01 = vpadalq_s16(vacc0x01, vprod0x01c0);
457         const int16x8_t vprod0x23c0 = vmull_s8(vb23c0, va0c0);
458         vacc0x23 = vpadalq_s16(vacc0x23, vprod0x23c0);
459         const int16x8_t vprod0x45c0 = vmull_s8(vb45c0, va0c0);
460         vacc0x45 = vpadalq_s16(vacc0x45, vprod0x45c0);
461         const int16x8_t vprod0x67c0 = vmull_s8(vb67c0, va0c0);
462         vacc0x67 = vpadalq_s16(vacc0x67, vprod0x67c0);
463         const int16x8_t vprod0x89c0 = vmull_s8(vb89c0, va0c0);
464         vacc0x89 = vpadalq_s16(vacc0x89, vprod0x89c0);
465         const int16x8_t vprod0xABc0 = vmull_s8(vbABc0, va0c0);
466         vacc0xAB = vpadalq_s16(vacc0xAB, vprod0xABc0);
467         const int16x8_t vprod0xCDc0 = vmull_s8(vbCDc0, va0c0);
468         vacc0xCD = vpadalq_s16(vacc0xCD, vprod0xCDc0);
469         const int16x8_t vprod0xEFc0 = vmull_s8(vbEFc0, va0c0);
470         vacc0xEF = vpadalq_s16(vacc0xEF, vprod0xEFc0);
471         const int8x8_t va1c0 = vreinterpret_s8_s32(vdup_lane_s32(vreinterpret_s32_s8(va1), 0));
472         const int16x8_t vprod1x01c0 = vmull_s8(vb01c0, va1c0);
473         vacc1x01 = vpadalq_s16(vacc1x01, vprod1x01c0);
474         const int16x8_t vprod1x23c0 = vmull_s8(vb23c0, va1c0);
475         vacc1x23 = vpadalq_s16(vacc1x23, vprod1x23c0);
476         const int16x8_t vprod1x45c0 = vmull_s8(vb45c0, va1c0);
477         vacc1x45 = vpadalq_s16(vacc1x45, vprod1x45c0);
478         const int16x8_t vprod1x67c0 = vmull_s8(vb67c0, va1c0);
479         vacc1x67 = vpadalq_s16(vacc1x67, vprod1x67c0);
480         const int16x8_t vprod1x89c0 = vmull_s8(vb89c0, va1c0);
481         vacc1x89 = vpadalq_s16(vacc1x89, vprod1x89c0);
482         const int16x8_t vprod1xABc0 = vmull_s8(vbABc0, va1c0);
483         vacc1xAB = vpadalq_s16(vacc1xAB, vprod1xABc0);
484         const int16x8_t vprod1xCDc0 = vmull_s8(vbCDc0, va1c0);
485         vacc1xCD = vpadalq_s16(vacc1xCD, vprod1xCDc0);
486         const int16x8_t vprod1xEFc0 = vmull_s8(vbEFc0, va1c0);
487         vacc1xEF = vpadalq_s16(vacc1xEF, vprod1xEFc0);
488         const int8x8_t va2c0 = vreinterpret_s8_s32(vdup_lane_s32(vreinterpret_s32_s8(va2), 0));
489         const int16x8_t vprod2x01c0 = vmull_s8(vb01c0, va2c0);
490         vacc2x01 = vpadalq_s16(vacc2x01, vprod2x01c0);
491         const int16x8_t vprod2x23c0 = vmull_s8(vb23c0, va2c0);
492         vacc2x23 = vpadalq_s16(vacc2x23, vprod2x23c0);
493         const int16x8_t vprod2x45c0 = vmull_s8(vb45c0, va2c0);
494         vacc2x45 = vpadalq_s16(vacc2x45, vprod2x45c0);
495         const int16x8_t vprod2x67c0 = vmull_s8(vb67c0, va2c0);
496         vacc2x67 = vpadalq_s16(vacc2x67, vprod2x67c0);
497         const int16x8_t vprod2x89c0 = vmull_s8(vb89c0, va2c0);
498         vacc2x89 = vpadalq_s16(vacc2x89, vprod2x89c0);
499         const int16x8_t vprod2xABc0 = vmull_s8(vbABc0, va2c0);
500         vacc2xAB = vpadalq_s16(vacc2xAB, vprod2xABc0);
501         const int16x8_t vprod2xCDc0 = vmull_s8(vbCDc0, va2c0);
502         vacc2xCD = vpadalq_s16(vacc2xCD, vprod2xCDc0);
503         const int16x8_t vprod2xEFc0 = vmull_s8(vbEFc0, va2c0);
504         vacc2xEF = vpadalq_s16(vacc2xEF, vprod2xEFc0);
505       }
506       p -= 3 * sizeof(void*);
507     } while (p != 0);
508 
509 #if XNN_ARCH_ARM64
510     int32x4_t vacc0x0123 = vpaddq_s32(vacc0x01, vacc0x23);
511     int32x4_t vacc0x4567 = vpaddq_s32(vacc0x45, vacc0x67);
512     int32x4_t vacc0x89AB = vpaddq_s32(vacc0x89, vacc0xAB);
513     int32x4_t vacc0xCDEF = vpaddq_s32(vacc0xCD, vacc0xEF);
514     int32x4_t vacc1x0123 = vpaddq_s32(vacc1x01, vacc1x23);
515     int32x4_t vacc1x4567 = vpaddq_s32(vacc1x45, vacc1x67);
516     int32x4_t vacc1x89AB = vpaddq_s32(vacc1x89, vacc1xAB);
517     int32x4_t vacc1xCDEF = vpaddq_s32(vacc1xCD, vacc1xEF);
518     int32x4_t vacc2x0123 = vpaddq_s32(vacc2x01, vacc2x23);
519     int32x4_t vacc2x4567 = vpaddq_s32(vacc2x45, vacc2x67);
520     int32x4_t vacc2x89AB = vpaddq_s32(vacc2x89, vacc2xAB);
521     int32x4_t vacc2xCDEF = vpaddq_s32(vacc2xCD, vacc2xEF);
522 #else
523     const int32x2_t vsum0x01 = vpadd_s32(vget_low_s32(vacc0x01), vget_high_s32(vacc0x01));
524     const int32x2_t vsum0x23 = vpadd_s32(vget_low_s32(vacc0x23), vget_high_s32(vacc0x23));
525     int32x4_t vacc0x0123 = vcombine_s32(vsum0x01, vsum0x23);
526     const int32x2_t vsum0x45 = vpadd_s32(vget_low_s32(vacc0x45), vget_high_s32(vacc0x45));
527     const int32x2_t vsum0x67 = vpadd_s32(vget_low_s32(vacc0x67), vget_high_s32(vacc0x67));
528     int32x4_t vacc0x4567 = vcombine_s32(vsum0x45, vsum0x67);
529     const int32x2_t vsum0x89 = vpadd_s32(vget_low_s32(vacc0x89), vget_high_s32(vacc0x89));
530     const int32x2_t vsum0xAB = vpadd_s32(vget_low_s32(vacc0xAB), vget_high_s32(vacc0xAB));
531     int32x4_t vacc0x89AB = vcombine_s32(vsum0x89, vsum0xAB);
532     const int32x2_t vsum0xCD = vpadd_s32(vget_low_s32(vacc0xCD), vget_high_s32(vacc0xCD));
533     const int32x2_t vsum0xEF = vpadd_s32(vget_low_s32(vacc0xEF), vget_high_s32(vacc0xEF));
534     int32x4_t vacc0xCDEF = vcombine_s32(vsum0xCD, vsum0xEF);
535     const int32x2_t vsum1x01 = vpadd_s32(vget_low_s32(vacc1x01), vget_high_s32(vacc1x01));
536     const int32x2_t vsum1x23 = vpadd_s32(vget_low_s32(vacc1x23), vget_high_s32(vacc1x23));
537     int32x4_t vacc1x0123 = vcombine_s32(vsum1x01, vsum1x23);
538     const int32x2_t vsum1x45 = vpadd_s32(vget_low_s32(vacc1x45), vget_high_s32(vacc1x45));
539     const int32x2_t vsum1x67 = vpadd_s32(vget_low_s32(vacc1x67), vget_high_s32(vacc1x67));
540     int32x4_t vacc1x4567 = vcombine_s32(vsum1x45, vsum1x67);
541     const int32x2_t vsum1x89 = vpadd_s32(vget_low_s32(vacc1x89), vget_high_s32(vacc1x89));
542     const int32x2_t vsum1xAB = vpadd_s32(vget_low_s32(vacc1xAB), vget_high_s32(vacc1xAB));
543     int32x4_t vacc1x89AB = vcombine_s32(vsum1x89, vsum1xAB);
544     const int32x2_t vsum1xCD = vpadd_s32(vget_low_s32(vacc1xCD), vget_high_s32(vacc1xCD));
545     const int32x2_t vsum1xEF = vpadd_s32(vget_low_s32(vacc1xEF), vget_high_s32(vacc1xEF));
546     int32x4_t vacc1xCDEF = vcombine_s32(vsum1xCD, vsum1xEF);
547     const int32x2_t vsum2x01 = vpadd_s32(vget_low_s32(vacc2x01), vget_high_s32(vacc2x01));
548     const int32x2_t vsum2x23 = vpadd_s32(vget_low_s32(vacc2x23), vget_high_s32(vacc2x23));
549     int32x4_t vacc2x0123 = vcombine_s32(vsum2x01, vsum2x23);
550     const int32x2_t vsum2x45 = vpadd_s32(vget_low_s32(vacc2x45), vget_high_s32(vacc2x45));
551     const int32x2_t vsum2x67 = vpadd_s32(vget_low_s32(vacc2x67), vget_high_s32(vacc2x67));
552     int32x4_t vacc2x4567 = vcombine_s32(vsum2x45, vsum2x67);
553     const int32x2_t vsum2x89 = vpadd_s32(vget_low_s32(vacc2x89), vget_high_s32(vacc2x89));
554     const int32x2_t vsum2xAB = vpadd_s32(vget_low_s32(vacc2xAB), vget_high_s32(vacc2xAB));
555     int32x4_t vacc2x89AB = vcombine_s32(vsum2x89, vsum2xAB);
556     const int32x2_t vsum2xCD = vpadd_s32(vget_low_s32(vacc2xCD), vget_high_s32(vacc2xCD));
557     const int32x2_t vsum2xEF = vpadd_s32(vget_low_s32(vacc2xEF), vget_high_s32(vacc2xEF));
558     int32x4_t vacc2xCDEF = vcombine_s32(vsum2xCD, vsum2xEF);
559 #endif
560 
561     const int32x4_t vright_pre_shift = vld1q_dup_s32(&params->rndnu_neon.right_pre_shift);
562     const int32x4_t vmultiplier = vld1q_dup_s32(&params->rndnu_neon.multiplier);
563     const int32x4_t vright_post_shift = vld1q_dup_s32(&params->rndnu_neon.right_post_shift);
564 
565     vacc0x0123 = vqshlq_s32(vacc0x0123, vright_pre_shift);
566     vacc0x4567 = vqshlq_s32(vacc0x4567, vright_pre_shift);
567     vacc0x89AB = vqshlq_s32(vacc0x89AB, vright_pre_shift);
568     vacc0xCDEF = vqshlq_s32(vacc0xCDEF, vright_pre_shift);
569     vacc1x0123 = vqshlq_s32(vacc1x0123, vright_pre_shift);
570     vacc1x4567 = vqshlq_s32(vacc1x4567, vright_pre_shift);
571     vacc1x89AB = vqshlq_s32(vacc1x89AB, vright_pre_shift);
572     vacc1xCDEF = vqshlq_s32(vacc1xCDEF, vright_pre_shift);
573     vacc2x0123 = vqshlq_s32(vacc2x0123, vright_pre_shift);
574     vacc2x4567 = vqshlq_s32(vacc2x4567, vright_pre_shift);
575     vacc2x89AB = vqshlq_s32(vacc2x89AB, vright_pre_shift);
576     vacc2xCDEF = vqshlq_s32(vacc2xCDEF, vright_pre_shift);
577 
578     vacc0x0123 = vqdmulhq_s32(vacc0x0123, vmultiplier);
579     vacc0x4567 = vqdmulhq_s32(vacc0x4567, vmultiplier);
580     vacc0x89AB = vqdmulhq_s32(vacc0x89AB, vmultiplier);
581     vacc0xCDEF = vqdmulhq_s32(vacc0xCDEF, vmultiplier);
582     vacc1x0123 = vqdmulhq_s32(vacc1x0123, vmultiplier);
583     vacc1x4567 = vqdmulhq_s32(vacc1x4567, vmultiplier);
584     vacc1x89AB = vqdmulhq_s32(vacc1x89AB, vmultiplier);
585     vacc1xCDEF = vqdmulhq_s32(vacc1xCDEF, vmultiplier);
586     vacc2x0123 = vqdmulhq_s32(vacc2x0123, vmultiplier);
587     vacc2x4567 = vqdmulhq_s32(vacc2x4567, vmultiplier);
588     vacc2x89AB = vqdmulhq_s32(vacc2x89AB, vmultiplier);
589     vacc2xCDEF = vqdmulhq_s32(vacc2xCDEF, vmultiplier);
590 
591     vacc0x0123 = vrshlq_s32(vacc0x0123, vright_post_shift);
592     vacc0x4567 = vrshlq_s32(vacc0x4567, vright_post_shift);
593     vacc0x89AB = vrshlq_s32(vacc0x89AB, vright_post_shift);
594     vacc0xCDEF = vrshlq_s32(vacc0xCDEF, vright_post_shift);
595     vacc1x0123 = vrshlq_s32(vacc1x0123, vright_post_shift);
596     vacc1x4567 = vrshlq_s32(vacc1x4567, vright_post_shift);
597     vacc1x89AB = vrshlq_s32(vacc1x89AB, vright_post_shift);
598     vacc1xCDEF = vrshlq_s32(vacc1xCDEF, vright_post_shift);
599     vacc2x0123 = vrshlq_s32(vacc2x0123, vright_post_shift);
600     vacc2x4567 = vrshlq_s32(vacc2x4567, vright_post_shift);
601     vacc2x89AB = vrshlq_s32(vacc2x89AB, vright_post_shift);
602     vacc2xCDEF = vrshlq_s32(vacc2xCDEF, vright_post_shift);
603 
604     const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->rndnu_neon.output_zero_point);
605 #if XNN_ARCH_ARM64
606     int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
607     int16x8_t vacc0x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF);
608     int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
609     int16x8_t vacc1x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc1x89AB), vacc1xCDEF);
610     int16x8_t vacc2x01234567 = vqmovn_high_s32(vqmovn_s32(vacc2x0123), vacc2x4567);
611     int16x8_t vacc2x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc2x89AB), vacc2xCDEF);
612 
613     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
614     vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
615     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
616     vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
617     vacc2x01234567 = vqaddq_s16(vacc2x01234567, voutput_zero_point);
618     vacc2x89ABCDEF = vqaddq_s16(vacc2x89ABCDEF, voutput_zero_point);
619 
620     int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF);
621     int8x16_t vout1x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc1x01234567), vacc1x89ABCDEF);
622     int8x16_t vout2x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc2x01234567), vacc2x89ABCDEF);
623 #else
624     int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
625     int16x8_t vacc0x89ABCDEF = vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF));
626     int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
627     int16x8_t vacc1x89ABCDEF = vcombine_s16(vqmovn_s32(vacc1x89AB), vqmovn_s32(vacc1xCDEF));
628     int16x8_t vacc2x01234567 = vcombine_s16(vqmovn_s32(vacc2x0123), vqmovn_s32(vacc2x4567));
629     int16x8_t vacc2x89ABCDEF = vcombine_s16(vqmovn_s32(vacc2x89AB), vqmovn_s32(vacc2xCDEF));
630 
631     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
632     vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
633     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
634     vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
635     vacc2x01234567 = vqaddq_s16(vacc2x01234567, voutput_zero_point);
636     vacc2x89ABCDEF = vqaddq_s16(vacc2x89ABCDEF, voutput_zero_point);
637 
638     int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF));
639     int8x16_t vout1x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc1x01234567), vqmovn_s16(vacc1x89ABCDEF));
640     int8x16_t vout2x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc2x01234567), vqmovn_s16(vacc2x89ABCDEF));
641 #endif
642 
643     const int8x16_t voutput_min = vld1q_dup_s8(&params->rndnu_neon.output_min);
644     vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min);
645     vout1x0123456789ABCDEF = vmaxq_s8(vout1x0123456789ABCDEF, voutput_min);
646     vout2x0123456789ABCDEF = vmaxq_s8(vout2x0123456789ABCDEF, voutput_min);
647 
648     const int8x16_t voutput_max = vld1q_dup_s8(&params->rndnu_neon.output_max);
649     vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max);
650     vout1x0123456789ABCDEF = vminq_s8(vout1x0123456789ABCDEF, voutput_max);
651     vout2x0123456789ABCDEF = vminq_s8(vout2x0123456789ABCDEF, voutput_max);
652 
653     if (nc >= 16) {
654       vst1q_s8(c2 + 0, vout2x0123456789ABCDEF);
655       vst1q_s8(c1 + 0, vout1x0123456789ABCDEF);
656       vst1q_s8(c0 + 0, vout0x0123456789ABCDEF);
657 
658       c2 = (int8_t*) ((uintptr_t) c2 + cn_stride);
659       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
660       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
661 
662       a = (const int8_t**restrict) ((uintptr_t) a - ks);
663 
664       nc -= 16;
665     } else {
666       int8x8_t vout2x01234567 = vget_low_s8(vout2x0123456789ABCDEF);
667       int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vget_low_s8(vout0x0123456789ABCDEF), vget_low_s8(vout1x0123456789ABCDEF));
668       if (nc & 8) {
669         vst1_s8(c2, vout2x01234567); c2 += 8;
670         vst1_s8(c1, vget_high_s8(vout0x01234567_1x01234567)); c1 += 8;
671         vst1_s8(c0, vget_low_s8(vout0x01234567_1x01234567)); c0 += 8;
672         vout2x01234567 = vget_high_s8(vout2x0123456789ABCDEF);
673         vout0x01234567_1x01234567 = vcombine_s8(vget_high_s8(vout0x0123456789ABCDEF), vget_high_s8(vout1x0123456789ABCDEF));
674       }
675       if (nc & 4) {
676         vst1_lane_u32((void*) c2, vreinterpret_u32_s8(vout2x01234567), 0); c2 += 4;
677         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
678         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
679         vout2x01234567 = vext_s8(vout2x01234567, vout2x01234567, 4);
680         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
681       }
682       if (nc & 2) {
683         vst1_lane_u16((void*) c2, vreinterpret_u16_s8(vout2x01234567), 0); c2 += 2;
684         vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
685         vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
686         vout2x01234567 = vext_s8(vout2x01234567, vout2x01234567, 2);
687         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
688       }
689       if (nc & 1) {
690         vst1_lane_s8(c2, vout2x01234567, 0);
691         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
692         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
693       }
694 
695       nc = 0;
696     }
697   } while (nc != 0);
698 }
699