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