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_2x16c2__neon_mull_ld2r(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_2x16c2__neon_mull_ld2r(
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 <= 2);
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
48 do {
49 int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
50 int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
51 int32x4_t vacc0x89AB = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
52 int32x4_t vacc0xCDEF = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
53 int32x4_t vacc1x0123 = vacc0x0123;
54 int32x4_t vacc1x4567 = vacc0x4567;
55 int32x4_t vacc1x89AB = vacc0x89AB;
56 int32x4_t vacc1xCDEF = vacc0xCDEF;
57
58 size_t k = kc;
59
60
61 while (k >= 8 * sizeof(int8_t)) {
62 const int16x4x2_t va00 = vld2_dup_s16((const void*)a0);
63 const int16x4x2_t va01 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
64 const int16x4x2_t va10 = vld2_dup_s16((const void*)a1);
65 const int16x4x2_t va11 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
66
67 const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
68 const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
69 const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
70 const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
71 const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
72 const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
73 const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
74 const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
75 const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
76 const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
77 const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
78 const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
79 const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
80 const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
81 const int8x8_t vb89ABc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
82 const int8x8_t vbCDEFc3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
83
84 const int8x8_t va0c0 = vreinterpret_s8_s16(va00.val[0]);
85 const int8x8_t va1c0 = vreinterpret_s8_s16(va10.val[0]);
86
87 const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
88 const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
89 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
90 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
91 const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
92 const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
93 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
94 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
95 const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, va0c0);
96 const int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0, va1c0);
97 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
98 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
99 const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, va0c0);
100 const int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0, va1c0);
101 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
102 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
103 const int8x8_t va0c1 = vreinterpret_s8_s16(va00.val[1]);
104 const int8x8_t va1c1 = vreinterpret_s8_s16(va10.val[1]);
105
106 const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
107 const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
108 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
109 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
110 const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
111 const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
112 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
113 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
114 const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, va0c1);
115 const int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1, va1c1);
116 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
117 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
118 const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, va0c1);
119 const int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1, va1c1);
120 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
121 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
122 const int8x8_t va0c2 = vreinterpret_s8_s16(va01.val[0]);
123 const int8x8_t va1c2 = vreinterpret_s8_s16(va11.val[0]);
124
125 const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
126 const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
127 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
128 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
129 const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
130 const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
131 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
132 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
133 const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, va0c2);
134 const int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2, va1c2);
135 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
136 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
137 const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, va0c2);
138 const int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2, va1c2);
139 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
140 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
141 const int8x8_t va0c3 = vreinterpret_s8_s16(va01.val[1]);
142 const int8x8_t va1c3 = vreinterpret_s8_s16(va11.val[1]);
143
144 const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3);
145 const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3);
146 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
147 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
148 const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3);
149 const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3);
150 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
151 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
152 const int16x8_t vprod0x89ABc3 = vmull_s8(vb89ABc3, va0c3);
153 const int16x8_t vprod1x89ABc3 = vmull_s8(vb89ABc3, va1c3);
154 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc3);
155 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc3);
156 const int16x8_t vprod0xCDEFc3 = vmull_s8(vbCDEFc3, va0c3);
157 const int16x8_t vprod1xCDEFc3 = vmull_s8(vbCDEFc3, va1c3);
158 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc3);
159 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc3);
160
161 k -= 8 * sizeof(int8_t);
162 }
163
164 if XNN_UNLIKELY(k != 0) {
165 const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
166 const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
167
168 const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
169 const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
170 const int8x8_t vb89ABc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
171 const int8x8_t vbCDEFc0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
172
173 const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
174 const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
175 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
176 const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
177 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
178 const int16x8_t vprod0x89ABc0 = vmull_s8(vb89ABc0, va0c0);
179 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc0);
180 const int16x8_t vprod0xCDEFc0 = vmull_s8(vbCDEFc0, va0c0);
181 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc0);
182 const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
183 const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
184 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
185 const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
186 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
187 const int16x8_t vprod1x89ABc0 = vmull_s8(vb89ABc0, va1c0);
188 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc0);
189 const int16x8_t vprod1xCDEFc0 = vmull_s8(vbCDEFc0, va1c0);
190 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc0);
191
192 if (k > 2 * sizeof(int8_t)) {
193 const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
194 const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
195 const int8x8_t vb89ABc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
196 const int8x8_t vbCDEFc1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
197
198 const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
199 const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
200 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
201 const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
202 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
203 const int16x8_t vprod0x89ABc1 = vmull_s8(vb89ABc1, va0c1);
204 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc1);
205 const int16x8_t vprod0xCDEFc1 = vmull_s8(vbCDEFc1, va0c1);
206 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc1);
207 const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
208 const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
209 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
210 const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
211 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
212 const int16x8_t vprod1x89ABc1 = vmull_s8(vb89ABc1, va1c1);
213 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc1);
214 const int16x8_t vprod1xCDEFc1 = vmull_s8(vbCDEFc1, va1c1);
215 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc1);
216
217 if (k > 4 * sizeof(int8_t)) {
218 const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
219 const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
220 const int8x8_t vb89ABc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
221 const int8x8_t vbCDEFc2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
222
223 const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
224 const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
225 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
226 const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
227 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
228 const int16x8_t vprod0x89ABc2 = vmull_s8(vb89ABc2, va0c2);
229 vacc0x89AB = vpadalq_s16(vacc0x89AB, vprod0x89ABc2);
230 const int16x8_t vprod0xCDEFc2 = vmull_s8(vbCDEFc2, va0c2);
231 vacc0xCDEF = vpadalq_s16(vacc0xCDEF, vprod0xCDEFc2);
232 const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
233 const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
234 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
235 const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
236 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
237 const int16x8_t vprod1x89ABc2 = vmull_s8(vb89ABc2, va1c2);
238 vacc1x89AB = vpadalq_s16(vacc1x89AB, vprod1x89ABc2);
239 const int16x8_t vprod1xCDEFc2 = vmull_s8(vbCDEFc2, va1c2);
240 vacc1xCDEF = vpadalq_s16(vacc1xCDEF, vprod1xCDEFc2);
241 }
242 }
243 }
244
245 const int32x4_t vright_pre_shift = vld1q_dup_s32(¶ms->rndnu_neon.right_pre_shift);
246 const int32x4_t vmultiplier = vld1q_dup_s32(¶ms->rndnu_neon.multiplier);
247 const int32x4_t vright_post_shift = vld1q_dup_s32(¶ms->rndnu_neon.right_post_shift);
248
249 vacc0x0123 = vqshlq_s32(vacc0x0123, vright_pre_shift);
250 vacc0x4567 = vqshlq_s32(vacc0x4567, vright_pre_shift);
251 vacc0x89AB = vqshlq_s32(vacc0x89AB, vright_pre_shift);
252 vacc0xCDEF = vqshlq_s32(vacc0xCDEF, vright_pre_shift);
253 vacc1x0123 = vqshlq_s32(vacc1x0123, vright_pre_shift);
254 vacc1x4567 = vqshlq_s32(vacc1x4567, vright_pre_shift);
255 vacc1x89AB = vqshlq_s32(vacc1x89AB, vright_pre_shift);
256 vacc1xCDEF = vqshlq_s32(vacc1xCDEF, vright_pre_shift);
257
258 vacc0x0123 = vqdmulhq_s32(vacc0x0123, vmultiplier);
259 vacc0x4567 = vqdmulhq_s32(vacc0x4567, vmultiplier);
260 vacc0x89AB = vqdmulhq_s32(vacc0x89AB, vmultiplier);
261 vacc0xCDEF = vqdmulhq_s32(vacc0xCDEF, vmultiplier);
262 vacc1x0123 = vqdmulhq_s32(vacc1x0123, vmultiplier);
263 vacc1x4567 = vqdmulhq_s32(vacc1x4567, vmultiplier);
264 vacc1x89AB = vqdmulhq_s32(vacc1x89AB, vmultiplier);
265 vacc1xCDEF = vqdmulhq_s32(vacc1xCDEF, vmultiplier);
266
267 vacc0x0123 = vrshlq_s32(vacc0x0123, vright_post_shift);
268 vacc0x4567 = vrshlq_s32(vacc0x4567, vright_post_shift);
269 vacc0x89AB = vrshlq_s32(vacc0x89AB, vright_post_shift);
270 vacc0xCDEF = vrshlq_s32(vacc0xCDEF, vright_post_shift);
271 vacc1x0123 = vrshlq_s32(vacc1x0123, vright_post_shift);
272 vacc1x4567 = vrshlq_s32(vacc1x4567, vright_post_shift);
273 vacc1x89AB = vrshlq_s32(vacc1x89AB, vright_post_shift);
274 vacc1xCDEF = vrshlq_s32(vacc1xCDEF, vright_post_shift);
275
276 const int16x8_t voutput_zero_point = vld1q_dup_s16(¶ms->rndnu_neon.output_zero_point);
277 #if XNN_ARCH_ARM64
278 int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
279 int16x8_t vacc0x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF);
280 int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
281 int16x8_t vacc1x89ABCDEF = vqmovn_high_s32(vqmovn_s32(vacc1x89AB), vacc1xCDEF);
282
283 vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
284 vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
285 vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
286 vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
287
288 int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF);
289 int8x16_t vout1x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc1x01234567), vacc1x89ABCDEF);
290 #else
291 int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
292 int16x8_t vacc0x89ABCDEF = vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF));
293 int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
294 int16x8_t vacc1x89ABCDEF = vcombine_s16(vqmovn_s32(vacc1x89AB), vqmovn_s32(vacc1xCDEF));
295
296 vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
297 vacc0x89ABCDEF = vqaddq_s16(vacc0x89ABCDEF, voutput_zero_point);
298 vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
299 vacc1x89ABCDEF = vqaddq_s16(vacc1x89ABCDEF, voutput_zero_point);
300
301 int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF));
302 int8x16_t vout1x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc1x01234567), vqmovn_s16(vacc1x89ABCDEF));
303 #endif
304
305 const int8x16_t voutput_min = vld1q_dup_s8(¶ms->rndnu_neon.output_min);
306 vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min);
307 vout1x0123456789ABCDEF = vmaxq_s8(vout1x0123456789ABCDEF, voutput_min);
308
309 const int8x16_t voutput_max = vld1q_dup_s8(¶ms->rndnu_neon.output_max);
310 vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max);
311 vout1x0123456789ABCDEF = vminq_s8(vout1x0123456789ABCDEF, voutput_max);
312
313 if (nc >= 16) {
314 vst1q_s8(c0 + 0, vout0x0123456789ABCDEF);
315 vst1q_s8(c1 + 0, vout1x0123456789ABCDEF);
316
317 c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
318 c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
319
320 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
321 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
322
323 nc -= 16;
324 } else {
325 // Final case where not all of the 16 columns fit in the destination.
326 int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vget_low_s8(vout0x0123456789ABCDEF), vget_low_s8(vout1x0123456789ABCDEF));
327 if (nc & 8) {
328 vst1_s8(c0, vget_low_s8(vout0x01234567_1x01234567)); c0 += 8;
329 vst1_s8(c1, vget_high_s8(vout0x01234567_1x01234567)); c1 += 8;
330 vout0x01234567_1x01234567 = vcombine_s8(vget_high_s8(vout0x0123456789ABCDEF), vget_high_s8(vout1x0123456789ABCDEF));
331 }
332 if (nc & 4) {
333 vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
334 vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
335 vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
336 }
337 if (nc & 2) {
338 vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
339 vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
340 vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
341 }
342 if (nc & 1) {
343 vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
344 vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
345 }
346
347 nc = 0;
348 }
349 } while (nc != 0);
350 }
351