• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/intrinsics-polyfill.h>
16 #include <xnnpack/math.h>
17 
xnn_qs8_gemm_minmax_fp32_ukernel_2x8c2__neonv8_mlal_ld1r(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_fp32_ukernel_2x8c2__neonv8_mlal_ld1r(
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 <= 2);
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   kc = round_up_po2(kc, 2 * sizeof(int8_t));
40   const int8_t* a0 = a;
41   int8_t* c0 = c;
42   const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
43   int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
44   if XNN_UNPREDICTABLE(mr != 2) {
45     a1 = a0;
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 vacc1x0123 = vacc0x0123;
53     int32x4_t vacc1x4567 = vacc0x4567;
54 
55     size_t k = kc;
56 
57     while (k >= 16 * sizeof(int8_t)) {
58       const int16x4_t va00x0 = vld1_dup_s16((const void*)a0);
59       const int16x4_t va01x0 = vld1_dup_s16((const void*)(a0 + 2));
60       const int16x4_t va02x0 = vld1_dup_s16((const void*)(a0 + 4));
61       const int16x4_t va03x0 = vld1_dup_s16((const void*)(a0 + 6)); a0 += 8;
62       const int16x4_t va00x1 = vld1_dup_s16((const void*)a0);
63       const int16x4_t va01x1 = vld1_dup_s16((const void*)(a0 + 2));
64       const int16x4_t va02x1 = vld1_dup_s16((const void*)(a0 + 4));
65       const int16x4_t va03x1 = vld1_dup_s16((const void*)(a0 + 6)); a0 += 8;
66       const int16x4_t va10x0 = vld1_dup_s16((const void*)a1);
67       const int16x4_t va11x0 = vld1_dup_s16((const void*)(a1 + 2));
68       const int16x4_t va12x0 = vld1_dup_s16((const void*)(a1 + 4));
69       const int16x4_t va13x0 = vld1_dup_s16((const void*)(a1 + 6)); a1 += 8;
70       const int16x4_t va10x1 = vld1_dup_s16((const void*)a1);
71       const int16x4_t va11x1 = vld1_dup_s16((const void*)(a1 + 2));
72       const int16x4_t va12x1 = vld1_dup_s16((const void*)(a1 + 4));
73       const int16x4_t va13x1 = vld1_dup_s16((const void*)(a1 + 6)); a1 += 8;
74       const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
75       const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
76       const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
77       const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
78       const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
79       const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
80       const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
81       const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
82 
83       const int8x8_t va0c0x0 = vreinterpret_s8_s16(va00x0);
84       const int8x8_t va0c0x1 = vreinterpret_s8_s16(va00x1);
85       const int8x8_t va1c0x0 = vreinterpret_s8_s16(va10x0);
86       const int8x8_t va1c0x1 = vreinterpret_s8_s16(va10x1);
87 
88       int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0c0x0);
89       int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1c0x0);
90       const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
91       vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, va0c0x1);
92       vprod1x0123c0 = vmlal_s8(vprod1x0123c0, vb0123c0x1, va1c0x1);
93       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
94       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
95       int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0c0x0);
96       int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1c0x0);
97       const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
98       vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, va0c0x1);
99       vprod1x4567c0 = vmlal_s8(vprod1x4567c0, vb4567c0x1, va1c0x1);
100       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
101       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
102       const int8x8_t va0c1x0 = vreinterpret_s8_s16(va01x0);
103       const int8x8_t va0c1x1 = vreinterpret_s8_s16(va01x1);
104       const int8x8_t va1c1x0 = vreinterpret_s8_s16(va11x0);
105       const int8x8_t va1c1x1 = vreinterpret_s8_s16(va11x1);
106 
107       int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0c1x0);
108       int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1c1x0);
109       const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
110       vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, va0c1x1);
111       vprod1x0123c1 = vmlal_s8(vprod1x0123c1, vb0123c1x1, va1c1x1);
112       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
113       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
114       int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0c1x0);
115       int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1c1x0);
116       const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
117       vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, va0c1x1);
118       vprod1x4567c1 = vmlal_s8(vprod1x4567c1, vb4567c1x1, va1c1x1);
119       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
120       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
121       const int8x8_t va0c2x0 = vreinterpret_s8_s16(va02x0);
122       const int8x8_t va0c2x1 = vreinterpret_s8_s16(va02x1);
123       const int8x8_t va1c2x0 = vreinterpret_s8_s16(va12x0);
124       const int8x8_t va1c2x1 = vreinterpret_s8_s16(va12x1);
125 
126       int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0c2x0);
127       int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1c2x0);
128       const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
129       vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, va0c2x1);
130       vprod1x0123c2 = vmlal_s8(vprod1x0123c2, vb0123c2x1, va1c2x1);
131       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
132       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
133       int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0c2x0);
134       int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1c2x0);
135       const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
136       vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, va0c2x1);
137       vprod1x4567c2 = vmlal_s8(vprod1x4567c2, vb4567c2x1, va1c2x1);
138       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
139       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
140       const int8x8_t va0c3x0 = vreinterpret_s8_s16(va03x0);
141       const int8x8_t va0c3x1 = vreinterpret_s8_s16(va03x1);
142       const int8x8_t va1c3x0 = vreinterpret_s8_s16(va13x0);
143       const int8x8_t va1c3x1 = vreinterpret_s8_s16(va13x1);
144 
145       int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0c3x0);
146       int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1c3x0);
147       const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
148       vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, va0c3x1);
149       vprod1x0123c3 = vmlal_s8(vprod1x0123c3, vb0123c3x1, va1c3x1);
150       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
151       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
152       int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0c3x0);
153       int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1c3x0);
154       const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
155       vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, va0c3x1);
156       vprod1x4567c3 = vmlal_s8(vprod1x4567c3, vb4567c3x1, va1c3x1);
157       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
158       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
159 
160       k -= 16 * sizeof(int8_t);
161     }
162 
163     if (k >= 8 * sizeof(int8_t)) {
164       const int16x4_t va00 = vld1_dup_s16((const void*)a0);
165       const int16x4_t va01 = vld1_dup_s16((const void*)(a0 + 2));
166       const int16x4_t va02 = vld1_dup_s16((const void*)(a0 + 4));
167       const int16x4_t va03 = vld1_dup_s16((const void*)(a0 + 6)); a0 += 8;
168       const int16x4_t va10 = vld1_dup_s16((const void*)a1);
169       const int16x4_t va11 = vld1_dup_s16((const void*)(a1 + 2));
170       const int16x4_t va12 = vld1_dup_s16((const void*)(a1 + 4));
171       const int16x4_t va13 = vld1_dup_s16((const void*)(a1 + 6)); a1 += 8;
172 
173       const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
174       const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
175       const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
176       const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
177       const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
178       const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
179       const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
180       const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
181 
182       const int8x8_t va0c0 = vreinterpret_s8_s16(va00);
183       const int8x8_t va1c0 = vreinterpret_s8_s16(va10);
184 
185       const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
186       const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
187       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
188       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
189       const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
190       const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
191       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
192       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
193       const int8x8_t va0c1 = vreinterpret_s8_s16(va01);
194       const int8x8_t va1c1 = vreinterpret_s8_s16(va11);
195 
196       const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
197       const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
198       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
199       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
200       const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
201       const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
202       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
203       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
204       const int8x8_t va0c2 = vreinterpret_s8_s16(va02);
205       const int8x8_t va1c2 = vreinterpret_s8_s16(va12);
206 
207       const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
208       const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
209       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
210       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
211       const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
212       const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
213       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
214       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
215       const int8x8_t va0c3 = vreinterpret_s8_s16(va03);
216       const int8x8_t va1c3 = vreinterpret_s8_s16(va13);
217 
218       const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3);
219       const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3);
220       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
221       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
222       const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3);
223       const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3);
224       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
225       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
226 
227       k -= 8 * sizeof(int8_t);
228     }
229 
230     if XNN_UNLIKELY(k != 0) {
231       const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
232       const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
233 
234       const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
235       const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
236 
237       const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
238       const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
239       vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
240       const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
241       vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
242       const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
243       const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
244       vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
245       const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
246       vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
247 
248       if (k > 2 * sizeof(int8_t)) {
249         const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
250         const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
251 
252         const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
253         const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
254         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
255         const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
256         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
257         const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
258         const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
259         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
260         const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
261         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
262 
263         if (k > 4 * sizeof(int8_t)) {
264           const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
265           const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
266 
267           const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
268           const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
269           vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
270           const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
271           vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
272           const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
273           const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
274           vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
275           const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
276           vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
277         }
278       }
279     }
280 
281     float32x4_t vfpacc0x0123 = vcvtq_f32_s32(vacc0x0123);
282     float32x4_t vfpacc0x4567 = vcvtq_f32_s32(vacc0x4567);
283     float32x4_t vfpacc1x0123 = vcvtq_f32_s32(vacc1x0123);
284     float32x4_t vfpacc1x4567 = vcvtq_f32_s32(vacc1x4567);
285 
286     const float32x4_t vscale = vld1q_dup_f32(&params->fp32_neonv8.scale);
287     vfpacc0x0123 = vmulq_f32(vfpacc0x0123, vscale);
288     vfpacc0x4567 = vmulq_f32(vfpacc0x4567, vscale);
289     vfpacc1x0123 = vmulq_f32(vfpacc1x0123, vscale);
290     vfpacc1x4567 = vmulq_f32(vfpacc1x4567, vscale);
291 
292     vacc0x0123 = vcvtnq_s32_f32(vfpacc0x0123);
293     vacc0x4567 = vcvtnq_s32_f32(vfpacc0x4567);
294     vacc1x0123 = vcvtnq_s32_f32(vfpacc1x0123);
295     vacc1x4567 = vcvtnq_s32_f32(vfpacc1x4567);
296 
297     const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->fp32_neonv8.output_zero_point);
298 #if XNN_ARCH_ARM64
299     int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
300     int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
301 
302     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
303     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
304 
305     int8x16_t vout0x01234567_1x01234567 = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc1x01234567);
306 #else
307     int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
308     int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
309 
310     vacc0x01234567 = vqaddq_s16(vacc0x01234567, voutput_zero_point);
311     vacc1x01234567 = vqaddq_s16(vacc1x01234567, voutput_zero_point);
312 
313     int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc1x01234567));
314 #endif
315 
316     const int8x16_t voutput_min = vld1q_dup_s8(&params->fp32_neonv8.output_min);
317     vout0x01234567_1x01234567 = vmaxq_s8(vout0x01234567_1x01234567, voutput_min);
318 
319     const int8x16_t voutput_max = vld1q_dup_s8(&params->fp32_neonv8.output_max);
320     vout0x01234567_1x01234567 = vminq_s8(vout0x01234567_1x01234567, voutput_max);
321 
322     if (nc >= 8) {
323       vst1_s8(c0 + 0, vget_low_s8(vout0x01234567_1x01234567));
324       vst1_s8(c1 + 0, vget_high_s8(vout0x01234567_1x01234567));
325 
326       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
327       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
328 
329       a0 = (const int8_t*) ((uintptr_t) a0 - kc);
330       a1 = (const int8_t*) ((uintptr_t) a1 - kc);
331 
332       nc -= 8;
333     } else {
334       // Final case where not all of the 8 columns fit in the destination.
335       if (nc & 4) {
336         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
337         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
338         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
339       }
340       if (nc & 2) {
341         vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
342         vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
343         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
344       }
345       if (nc & 1) {
346         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
347         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
348       }
349 
350       nc = 0;
351     }
352   } while (nc != 0);
353 }
354