• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-gemm/c2-neon-mull-shuffle.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 
17 
xnn_qs8_gemm_minmax_rndnu_ukernel_3x8c2s4__neon_mlal(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)])18 void xnn_qs8_gemm_minmax_rndnu_ukernel_3x8c2s4__neon_mlal(
19     size_t mr,
20     size_t nc,
21     size_t kc,
22     const int8_t* restrict a,
23     size_t a_stride,
24     const void* restrict w,
25     int8_t* restrict c,
26     size_t cm_stride,
27     size_t cn_stride,
28     const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
29 {
30   assert(mr != 0);
31   assert(mr <= 3);
32   assert(nc != 0);
33   assert(kc != 0);
34   assert(kc % sizeof(int8_t) == 0);
35   assert(a != NULL);
36   assert(w != NULL);
37   assert(c != NULL);
38 
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 
54   kc = round_up_po2(kc, 8 * sizeof(int8_t));
55   do {
56     int32x4_t vacc0x0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
57     int32x4_t vacc0x4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
58     int32x4_t vacc1x0123 = vacc0x0123;
59     int32x4_t vacc1x4567 = vacc0x4567;
60     int32x4_t vacc2x0123 = vacc0x0123;
61     int32x4_t vacc2x4567 = vacc0x4567;
62 
63     size_t k = kc;
64     while (k >= 16 * sizeof(int8_t)) {
65       int8x8_t va0x0 = vld1_s8(a0); a0 += 8;
66       int8x8_t va0x1 = vld1_s8(a0); a0 += 8;
67       int8x8_t va1x0 = vld1_s8(a1); a1 += 8;
68       int8x8_t va1x1 = vld1_s8(a1); a1 += 8;
69       int8x8_t va2x0 = vld1_s8(a2); a2 += 8;
70       int8x8_t va2x1 = vld1_s8(a2); a2 += 8;
71 
72       const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const int8_t*) w + 8;
73       const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const int8_t*) w + 8;
74       const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const int8_t*) w + 8;
75       const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const int8_t*) w + 8;
76       const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const int8_t*) w + 8;
77       const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const int8_t*) w + 8;
78       const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const int8_t*) w + 8;
79       const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const int8_t*) w + 8;
80 
81       int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0x0);
82       int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1x0);
83       int16x8_t vprod2x0123c0 = vmull_s8(vb0123c0x0, va2x0);
84       const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const int8_t*) w + 8;
85       vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, va0x1);
86       vprod1x0123c0 = vmlal_s8(vprod1x0123c0, vb0123c0x1, va1x1);
87       vprod2x0123c0 = vmlal_s8(vprod2x0123c0, vb0123c0x1, va2x1);
88       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
89       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
90       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c0);
91       int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0x0);
92       int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1x0);
93       int16x8_t vprod2x4567c0 = vmull_s8(vb4567c0x0, va2x0);
94       const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const int8_t*) w + 8;
95       vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, va0x1);
96       vprod1x4567c0 = vmlal_s8(vprod1x4567c0, vb4567c0x1, va1x1);
97       vprod2x4567c0 = vmlal_s8(vprod2x4567c0, vb4567c0x1, va2x1);
98       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
99       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
100       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c0);
101       va0x0 = vext_s8(va0x0, va0x0, 2);
102       va0x1 = vext_s8(va0x1, va0x1, 2);
103       va1x0 = vext_s8(va1x0, va1x0, 2);
104       va1x1 = vext_s8(va1x1, va1x1, 2);
105       va2x0 = vext_s8(va2x0, va2x0, 2);
106       va2x1 = vext_s8(va2x1, va2x1, 2);
107       int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0x0);
108       int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1x0);
109       int16x8_t vprod2x0123c1 = vmull_s8(vb0123c1x0, va2x0);
110       const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const int8_t*) w + 8;
111       vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, va0x1);
112       vprod1x0123c1 = vmlal_s8(vprod1x0123c1, vb0123c1x1, va1x1);
113       vprod2x0123c1 = vmlal_s8(vprod2x0123c1, vb0123c1x1, va2x1);
114       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
115       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
116       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c1);
117       int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0x0);
118       int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1x0);
119       int16x8_t vprod2x4567c1 = vmull_s8(vb4567c1x0, va2x0);
120       const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const int8_t*) w + 8;
121       vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, va0x1);
122       vprod1x4567c1 = vmlal_s8(vprod1x4567c1, vb4567c1x1, va1x1);
123       vprod2x4567c1 = vmlal_s8(vprod2x4567c1, vb4567c1x1, va2x1);
124       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
125       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
126       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c1);
127       va0x0 = vext_s8(va0x0, va0x0, 2);
128       va0x1 = vext_s8(va0x1, va0x1, 2);
129       va1x0 = vext_s8(va1x0, va1x0, 2);
130       va1x1 = vext_s8(va1x1, va1x1, 2);
131       va2x0 = vext_s8(va2x0, va2x0, 2);
132       va2x1 = vext_s8(va2x1, va2x1, 2);
133       int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0x0);
134       int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1x0);
135       int16x8_t vprod2x0123c2 = vmull_s8(vb0123c2x0, va2x0);
136       const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const int8_t*) w + 8;
137       vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, va0x1);
138       vprod1x0123c2 = vmlal_s8(vprod1x0123c2, vb0123c2x1, va1x1);
139       vprod2x0123c2 = vmlal_s8(vprod2x0123c2, vb0123c2x1, va2x1);
140       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
141       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
142       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c2);
143       int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0x0);
144       int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1x0);
145       int16x8_t vprod2x4567c2 = vmull_s8(vb4567c2x0, va2x0);
146       const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const int8_t*) w + 8;
147       vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, va0x1);
148       vprod1x4567c2 = vmlal_s8(vprod1x4567c2, vb4567c2x1, va1x1);
149       vprod2x4567c2 = vmlal_s8(vprod2x4567c2, vb4567c2x1, va2x1);
150       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
151       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
152       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c2);
153       va0x0 = vext_s8(va0x0, va0x0, 2);
154       va0x1 = vext_s8(va0x1, va0x1, 2);
155       va1x0 = vext_s8(va1x0, va1x0, 2);
156       va1x1 = vext_s8(va1x1, va1x1, 2);
157       va2x0 = vext_s8(va2x0, va2x0, 2);
158       va2x1 = vext_s8(va2x1, va2x1, 2);
159       int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0x0);
160       int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1x0);
161       int16x8_t vprod2x0123c3 = vmull_s8(vb0123c3x0, va2x0);
162       const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const int8_t*) w + 8;
163       vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, va0x1);
164       vprod1x0123c3 = vmlal_s8(vprod1x0123c3, vb0123c3x1, va1x1);
165       vprod2x0123c3 = vmlal_s8(vprod2x0123c3, vb0123c3x1, va2x1);
166       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
167       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
168       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c3);
169       int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0x0);
170       int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1x0);
171       int16x8_t vprod2x4567c3 = vmull_s8(vb4567c3x0, va2x0);
172       const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const int8_t*) w + 8;
173       vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, va0x1);
174       vprod1x4567c3 = vmlal_s8(vprod1x4567c3, vb4567c3x1, va1x1);
175       vprod2x4567c3 = vmlal_s8(vprod2x4567c3, vb4567c3x1, va2x1);
176       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
177       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
178       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c3);
179 
180       k -= 16 * sizeof(int8_t);
181     }
182     if (k != 0) {
183       int8x8_t va0x0 = vld1_s8(a0); a0 += 8;
184       int8x8_t va1x0 = vld1_s8(a1); a1 += 8;
185       int8x8_t va2x0 = vld1_s8(a2); a2 += 8;
186 
187       const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const int8_t*) w + 8;
188       const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const int8_t*) w + 8;
189       const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const int8_t*) w + 8;
190       const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const int8_t*) w + 8;
191       const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const int8_t*) w + 8;
192       const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const int8_t*) w + 8;
193       const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const int8_t*) w + 8;
194       const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const int8_t*) w + 8;
195 
196       int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0x0);
197       int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1x0);
198       int16x8_t vprod2x0123c0 = vmull_s8(vb0123c0x0, va2x0);
199       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
200       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
201       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c0);
202       int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0x0);
203       int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1x0);
204       int16x8_t vprod2x4567c0 = vmull_s8(vb4567c0x0, va2x0);
205       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
206       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
207       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c0);
208       va0x0 = vext_s8(va0x0, va0x0, 2);
209       va1x0 = vext_s8(va1x0, va1x0, 2);
210       va2x0 = vext_s8(va2x0, va2x0, 2);
211       int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0x0);
212       int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1x0);
213       int16x8_t vprod2x0123c1 = vmull_s8(vb0123c1x0, va2x0);
214       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
215       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
216       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c1);
217       int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0x0);
218       int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1x0);
219       int16x8_t vprod2x4567c1 = vmull_s8(vb4567c1x0, va2x0);
220       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
221       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
222       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c1);
223       va0x0 = vext_s8(va0x0, va0x0, 2);
224       va1x0 = vext_s8(va1x0, va1x0, 2);
225       va2x0 = vext_s8(va2x0, va2x0, 2);
226       int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0x0);
227       int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1x0);
228       int16x8_t vprod2x0123c2 = vmull_s8(vb0123c2x0, va2x0);
229       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
230       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
231       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c2);
232       int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0x0);
233       int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1x0);
234       int16x8_t vprod2x4567c2 = vmull_s8(vb4567c2x0, va2x0);
235       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
236       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
237       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c2);
238       va0x0 = vext_s8(va0x0, va0x0, 2);
239       va1x0 = vext_s8(va1x0, va1x0, 2);
240       va2x0 = vext_s8(va2x0, va2x0, 2);
241       int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0x0);
242       int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1x0);
243       int16x8_t vprod2x0123c3 = vmull_s8(vb0123c3x0, va2x0);
244       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
245       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
246       vacc2x0123 = vpadalq_s16(vacc2x0123, vprod2x0123c3);
247       int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0x0);
248       int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1x0);
249       int16x8_t vprod2x4567c3 = vmull_s8(vb4567c3x0, va2x0);
250       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
251       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
252       vacc2x4567 = vpadalq_s16(vacc2x4567, vprod2x4567c3);
253 
254     }
255 
256     const int32x4_t vright_pre_shift = vld1q_dup_s32(&params->rndnu_neon.right_pre_shift);
257     const int32x4_t vmultiplier = vld1q_dup_s32(&params->rndnu_neon.multiplier);
258     const int32x4_t vright_post_shift = vld1q_dup_s32(&params->rndnu_neon.right_post_shift);
259 
260     vacc0x0123 = vqshlq_s32(vacc0x0123, vright_pre_shift);
261     vacc0x4567 = vqshlq_s32(vacc0x4567, vright_pre_shift);
262     vacc1x0123 = vqshlq_s32(vacc1x0123, vright_pre_shift);
263     vacc1x4567 = vqshlq_s32(vacc1x4567, vright_pre_shift);
264     vacc2x0123 = vqshlq_s32(vacc2x0123, vright_pre_shift);
265     vacc2x4567 = vqshlq_s32(vacc2x4567, vright_pre_shift);
266 
267     vacc0x0123 = vqdmulhq_s32(vacc0x0123, vmultiplier);
268     vacc0x4567 = vqdmulhq_s32(vacc0x4567, vmultiplier);
269     vacc1x0123 = vqdmulhq_s32(vacc1x0123, vmultiplier);
270     vacc1x4567 = vqdmulhq_s32(vacc1x4567, vmultiplier);
271     vacc2x0123 = vqdmulhq_s32(vacc2x0123, vmultiplier);
272     vacc2x4567 = vqdmulhq_s32(vacc2x4567, vmultiplier);
273 
274     vacc0x0123 = vrshlq_s32(vacc0x0123, vright_post_shift);
275     vacc0x4567 = vrshlq_s32(vacc0x4567, vright_post_shift);
276     vacc1x0123 = vrshlq_s32(vacc1x0123, vright_post_shift);
277     vacc1x4567 = vrshlq_s32(vacc1x4567, vright_post_shift);
278     vacc2x0123 = vrshlq_s32(vacc2x0123, vright_post_shift);
279     vacc2x4567 = vrshlq_s32(vacc2x4567, vright_post_shift);
280 
281     const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->rndnu_neon.output_zero_point);
282 #if XNN_ARCH_ARM64
283     int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
284     int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
285     int16x8_t vacc2x01234567 = vqmovn_high_s32(vqmovn_s32(vacc2x0123), vacc2x4567);
286 
287     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
288     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
289     vacc2x01234567 = vqaddq_s16(vacc2x01234567, voutput_zero_point);
290 
291     int8x16_t vout0x01234567_1x01234567 = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc1x01234567);
292     int8x8_t vout2x01234567 = vqmovn_s16(vacc2x01234567);
293 #else
294     int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
295     int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
296     int16x8_t vacc2x01234567 = vcombine_s16(vqmovn_s32(vacc2x0123), vqmovn_s32(vacc2x4567));
297 
298     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
299     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
300     vacc2x01234567 = vqaddq_s16(vacc2x01234567, voutput_zero_point);
301 
302     int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc1x01234567));
303     int8x8_t vout2x01234567 = vqmovn_s16(vacc2x01234567);
304 #endif
305 
306     const int8x16_t voutput_min = vld1q_dup_s8(&params->rndnu_neon.output_min);
307     vout0x01234567_1x01234567 = vmaxq_s8(vout0x01234567_1x01234567, voutput_min);
308     vout2x01234567 = vmax_s8(vout2x01234567, vget_low_s8(voutput_min));
309 
310     const int8x16_t voutput_max = vld1q_dup_s8(&params->rndnu_neon.output_max);
311     vout0x01234567_1x01234567 = vminq_s8(vout0x01234567_1x01234567, voutput_max);
312     vout2x01234567 = vmin_s8(vout2x01234567, vget_low_s8(voutput_max));
313 
314     if (nc >= 8) {
315       vst1_s8(c0 + 0, vget_low_s8(vout0x01234567_1x01234567));
316       vst1_s8(c1 + 0, vget_high_s8(vout0x01234567_1x01234567));
317       vst1_s8(c2 + 0, vout2x01234567);
318 
319       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
320       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
321       c2 = (int8_t*) ((uintptr_t) c2 + cn_stride);
322 
323       a0 = (const int8_t*) ((uintptr_t) a0 - kc);
324       a1 = (const int8_t*) ((uintptr_t) a1 - kc);
325       a2 = (const int8_t*) ((uintptr_t) a2 - kc);
326 
327       nc -= 8;
328     } else {
329       // Final case where not all of the 8 columns fit in the destination.
330       if (nc & 4) {
331         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
332         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
333         vst1_lane_u32((void*) c2, vreinterpret_u32_s8(vout2x01234567), 0); c2 += 4;
334         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
335         vout2x01234567 = vext_s8(vout2x01234567, vout2x01234567, 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         vst1_lane_u16((void*) c2, vreinterpret_u16_s8(vout2x01234567), 0); c2 += 2;
341         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
342         vout2x01234567 = vext_s8(vout2x01234567, vout2x01234567, 2);
343       }
344       if (nc & 1) {
345         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
346         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
347         vst1_lane_s8(c2, vout2x01234567, 0);
348       }
349 
350       nc = 0;
351     }
352   } while (nc != 0);
353 }
354