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