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