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