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