• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-igemm/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_qc8_igemm_minmax_fp32_ukernel_2x8c2__neon_mlal_dup(size_t mr,size_t nc,size_t kc,size_t ks,const int8_t ** restrict a,const void * restrict w,int8_t * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const int8_t * zero,const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qc8_igemm_minmax_fp32_ukernel_2x8c2__neon_mlal_dup(
18     size_t mr,
19     size_t nc,
20     size_t kc,
21     size_t ks,
22     const int8_t** restrict a,
23     const void* restrict w,
24     int8_t* restrict c,
25     size_t cm_stride,
26     size_t cn_stride,
27     size_t a_offset,
28     const int8_t* zero,
29     const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31   assert(mr != 0);
32   assert(mr <= 2);
33   assert(nc != 0);
34   assert(kc != 0);
35   assert(ks != 0);
36   assert(ks % (2 * sizeof(void*)) == 0);
37   assert(a_offset % sizeof(int8_t) == 0);
38   assert(a != NULL);
39   assert(w != NULL);
40   assert(c != NULL);
41 
42   kc = round_up_po2(kc, 2 * sizeof(int8_t));
43   int8_t* c0 = c;
44   int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
45   if XNN_UNPREDICTABLE(mr != 2) {
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 p = ks;
56     do {
57       const int8_t* restrict a0 = a[0];
58       if XNN_UNPREDICTABLE(a0 != zero) {
59         a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
60       }
61       const int8_t* restrict a1 = a[1];
62       if XNN_UNPREDICTABLE(a1 != zero) {
63         a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
64       }
65       a += 2;
66 
67       size_t k = kc;
68 
69       while (k >= 16 * sizeof(int8_t)) {
70         const int8x8_t va0x0 = vld1_s8(a0); a0 += 8;
71         const int8x8_t va0x1 = vld1_s8(a0); a0 += 8;
72         const int8x8_t va1x0 = vld1_s8(a1); a1 += 8;
73         const int8x8_t va1x1 = vld1_s8(a1); a1 += 8;
74 
75         const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
76         const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
77         const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
78         const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
79         const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
80         const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
81         const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
82         const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
83 
84         const int8x8_t va0c0x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 0));
85         const int8x8_t va0c0x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 0));
86         const int8x8_t va1c0x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x0), 0));
87         const int8x8_t va1c0x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x1), 0));
88 
89         int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0c0x0);
90         int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1c0x0);
91         const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
92         vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, va0c0x1);
93         vprod1x0123c0 = vmlal_s8(vprod1x0123c0, vb0123c0x1, va1c0x1);
94         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
95         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
96         int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0c0x0);
97         int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1c0x0);
98         const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
99         vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, va0c0x1);
100         vprod1x4567c0 = vmlal_s8(vprod1x4567c0, vb4567c0x1, va1c0x1);
101         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
102         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
103         const int8x8_t va0c1x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 1));
104         const int8x8_t va0c1x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 1));
105         const int8x8_t va1c1x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x0), 1));
106         const int8x8_t va1c1x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x1), 1));
107 
108         int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0c1x0);
109         int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1c1x0);
110         const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
111         vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, va0c1x1);
112         vprod1x0123c1 = vmlal_s8(vprod1x0123c1, vb0123c1x1, va1c1x1);
113         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
114         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
115         int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0c1x0);
116         int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1c1x0);
117         const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
118         vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, va0c1x1);
119         vprod1x4567c1 = vmlal_s8(vprod1x4567c1, vb4567c1x1, va1c1x1);
120         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
121         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
122         const int8x8_t va0c2x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 2));
123         const int8x8_t va0c2x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 2));
124         const int8x8_t va1c2x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x0), 2));
125         const int8x8_t va1c2x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x1), 2));
126 
127         int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0c2x0);
128         int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1c2x0);
129         const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
130         vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, va0c2x1);
131         vprod1x0123c2 = vmlal_s8(vprod1x0123c2, vb0123c2x1, va1c2x1);
132         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
133         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
134         int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0c2x0);
135         int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1c2x0);
136         const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
137         vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, va0c2x1);
138         vprod1x4567c2 = vmlal_s8(vprod1x4567c2, vb4567c2x1, va1c2x1);
139         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
140         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
141         const int8x8_t va0c3x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x0), 3));
142         const int8x8_t va0c3x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0x1), 3));
143         const int8x8_t va1c3x0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x0), 3));
144         const int8x8_t va1c3x1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1x1), 3));
145 
146         int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0c3x0);
147         int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1c3x0);
148         const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
149         vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, va0c3x1);
150         vprod1x0123c3 = vmlal_s8(vprod1x0123c3, vb0123c3x1, va1c3x1);
151         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
152         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
153         int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0c3x0);
154         int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1c3x0);
155         const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
156         vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, va0c3x1);
157         vprod1x4567c3 = vmlal_s8(vprod1x4567c3, vb4567c3x1, va1c3x1);
158         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
159         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
160 
161         k -= 16 * sizeof(int8_t);
162       }
163 
164       if (k >= 8 * sizeof(int8_t)) {
165         const int8x8_t va0 = vld1_s8(a0); a0 += 8;
166         const int8x8_t va1 = vld1_s8(a1); a1 += 8;
167 
168         const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
169         const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
170         const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
171         const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
172         const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
173         const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
174         const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
175         const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
176 
177         const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
178         const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
179 
180         const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
181         const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
182         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
183         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
184         const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
185         const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
186         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
187         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
188         const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
189         const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
190 
191         const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
192         const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
193         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
194         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
195         const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
196         const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
197         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
198         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
199         const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
200         const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
201 
202         const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
203         const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
204         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
205         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
206         const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
207         const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
208         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
209         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
210         const int8x8_t va0c3 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 3));
211         const int8x8_t va1c3 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 3));
212 
213         const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3);
214         const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3);
215         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
216         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
217         const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3);
218         const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3);
219         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
220         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
221 
222         k -= 8 * sizeof(int8_t);
223       }
224 
225       if XNN_UNLIKELY(k != 0) {
226         const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
227         const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
228 
229         const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
230         const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
231 
232         const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
233         const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
234         vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
235         const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
236         vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
237         const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
238         const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
239         vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
240         const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
241         vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
242 
243         if (k > 2 * sizeof(int8_t)) {
244           const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
245           const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
246 
247           const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
248           const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
249           vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
250           const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
251           vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
252           const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
253           const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
254           vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
255           const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
256           vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
257 
258           if (k > 4 * sizeof(int8_t)) {
259             const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
260             const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
261 
262             const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
263             const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
264             vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
265             const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
266             vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
267             const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
268             const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
269             vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
270             const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
271             vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
272           }
273         }
274       }
275       p -= 2 * sizeof(void*);
276     } while (p != 0);
277 
278     float32x4_t vfpacc0x0123 = vcvtq_f32_s32(vacc0x0123);
279     float32x4_t vfpacc0x4567 = vcvtq_f32_s32(vacc0x4567);
280     float32x4_t vfpacc1x0123 = vcvtq_f32_s32(vacc1x0123);
281     float32x4_t vfpacc1x4567 = vcvtq_f32_s32(vacc1x4567);
282 
283     const float32x4_t vscale0123 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
284     vfpacc0x0123 = vmulq_f32(vfpacc0x0123, vscale0123);
285     vfpacc1x0123 = vmulq_f32(vfpacc1x0123, vscale0123);
286     const float32x4_t vscale4567 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
287     vfpacc0x4567 = vmulq_f32(vfpacc0x4567, vscale4567);
288     vfpacc1x4567 = vmulq_f32(vfpacc1x4567, vscale4567);
289 
290     const float32x4_t vmagic_bias = vld1q_dup_f32(&params->fp32_neon.magic_bias);
291     vacc0x0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0x0123, vmagic_bias));
292     vacc0x4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0x4567, vmagic_bias));
293     vacc1x0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc1x0123, vmagic_bias));
294     vacc1x4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc1x4567, vmagic_bias));
295 
296     const int32x4_t vmagic_bias_less_output_zero_point = vld1q_dup_s32(&params->fp32_neon.magic_bias_less_output_zero_point);
297     vacc0x0123 = vqsubq_s32(vacc0x0123, vmagic_bias_less_output_zero_point);
298     vacc0x4567 = vqsubq_s32(vacc0x4567, vmagic_bias_less_output_zero_point);
299     vacc1x0123 = vqsubq_s32(vacc1x0123, vmagic_bias_less_output_zero_point);
300     vacc1x4567 = vqsubq_s32(vacc1x4567, vmagic_bias_less_output_zero_point);
301 
302 #if XNN_ARCH_ARM64
303     int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
304     int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
305 
306 
307     int8x16_t vout0x01234567_1x01234567 = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc1x01234567);
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 
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_neon.output_min);
317     vout0x01234567_1x01234567 = vmaxq_s8(vout0x01234567_1x01234567, voutput_min);
318 
319     const int8x16_t voutput_max = vld1q_dup_s8(&params->fp32_neon.output_max);
320     vout0x01234567_1x01234567 = vminq_s8(vout0x01234567_1x01234567, voutput_max);
321 
322     if (nc >= 8) {
323       vst1_s8(c1 + 0, vget_high_s8(vout0x01234567_1x01234567));
324       vst1_s8(c0 + 0, vget_low_s8(vout0x01234567_1x01234567));
325 
326       c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
327       c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
328 
329       a = (const int8_t**restrict) ((uintptr_t) a - ks);
330 
331       nc -= 8;
332     } else {
333       if (nc & 4) {
334         vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
335         vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
336         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
337       }
338       if (nc & 2) {
339         vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
340         vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
341         vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
342       }
343       if (nc & 1) {
344         vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
345         vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
346       }
347 
348       nc = 0;
349     }
350   } while (nc != 0);
351 }
352