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