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