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