xref: /aosp_15_r20/external/XNNPACK/src/qc8-dwconv/gen/up8x25-minmax-fp32-neon-mul16.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/qs8-dwconv/unipass-neon-mul16.c.in
3 //   Generator: tools/xngen
4 //
5 // Copyright 2020 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/dwconv.h>
15 
16 
xnn_qc8_dwconv_minmax_fp32_ukernel_up8x25__neon_mul16(size_t channels,size_t output_width,const int8_t ** input,const void * weights,int8_t * output,size_t input_stride,size_t output_increment,size_t input_offset,const int8_t * zero,const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qc8_dwconv_minmax_fp32_ukernel_up8x25__neon_mul16(
18     size_t channels,
19     size_t output_width,
20     const int8_t** input,
21     const void* weights,
22     int8_t* output,
23     size_t input_stride,
24     size_t output_increment,
25     size_t input_offset,
26     const int8_t* zero,
27     const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
28 {
29   assert(channels != 0);
30   assert(output_width != 0);
31 
32   const float32x4_t vmagic_bias = vld1q_dup_f32(&params->fp32_neon.magic_bias);
33   const int32x4_t vmagic_bias_less_output_zero_point = vld1q_dup_s32(&params->fp32_neon.magic_bias_less_output_zero_point);
34   const int8x8_t voutput_min = vld1_dup_s8(&params->fp32_neon.output_min);
35   const int8x8_t voutput_max = vld1_dup_s8(&params->fp32_neon.output_max);
36   do {
37     const int8_t* i0 = input[0];
38     assert(i0 != NULL);
39     if XNN_UNPREDICTABLE(i0 != zero) {
40       i0 = (const int8_t*) ((uintptr_t) i0 + input_offset);
41     }
42     const int8_t* i1 = input[1];
43     assert(i1 != NULL);
44     if XNN_UNPREDICTABLE(i1 != zero) {
45       i1 = (const int8_t*) ((uintptr_t) i1 + input_offset);
46     }
47     const int8_t* i2 = input[2];
48     assert(i2 != NULL);
49     if XNN_UNPREDICTABLE(i2 != zero) {
50       i2 = (const int8_t*) ((uintptr_t) i2 + input_offset);
51     }
52     const int8_t* i3 = input[3];
53     assert(i3 != NULL);
54     if XNN_UNPREDICTABLE(i3 != zero) {
55       i3 = (const int8_t*) ((uintptr_t) i3 + input_offset);
56     }
57     const int8_t* i4 = input[4];
58     assert(i4 != NULL);
59     if XNN_UNPREDICTABLE(i4 != zero) {
60       i4 = (const int8_t*) ((uintptr_t) i4 + input_offset);
61     }
62     const int8_t* i5 = input[5];
63     assert(i5 != NULL);
64     if XNN_UNPREDICTABLE(i5 != zero) {
65       i5 = (const int8_t*) ((uintptr_t) i5 + input_offset);
66     }
67     const int8_t* i6 = input[6];
68     assert(i6 != NULL);
69     if XNN_UNPREDICTABLE(i6 != zero) {
70       i6 = (const int8_t*) ((uintptr_t) i6 + input_offset);
71     }
72     const int8_t* i7 = input[7];
73     assert(i7 != NULL);
74     if XNN_UNPREDICTABLE(i7 != zero) {
75       i7 = (const int8_t*) ((uintptr_t) i7 + input_offset);
76     }
77     const int8_t* i8 = input[8];
78     assert(i8 != NULL);
79     if XNN_UNPREDICTABLE(i8 != zero) {
80       i8 = (const int8_t*) ((uintptr_t) i8 + input_offset);
81     }
82     const int8_t* i9 = input[9];
83     assert(i9 != NULL);
84     if XNN_UNPREDICTABLE(i9 != zero) {
85       i9 = (const int8_t*) ((uintptr_t) i9 + input_offset);
86     }
87     const int8_t* i10 = input[10];
88     assert(i10 != NULL);
89     if XNN_UNPREDICTABLE(i10 != zero) {
90       i10 = (const int8_t*) ((uintptr_t) i10 + input_offset);
91     }
92     const int8_t* i11 = input[11];
93     assert(i11 != NULL);
94     if XNN_UNPREDICTABLE(i11 != zero) {
95       i11 = (const int8_t*) ((uintptr_t) i11 + input_offset);
96     }
97     const int8_t* i12 = input[12];
98     assert(i12 != NULL);
99     if XNN_UNPREDICTABLE(i12 != zero) {
100       i12 = (const int8_t*) ((uintptr_t) i12 + input_offset);
101     }
102     const int8_t* i13 = input[13];
103     assert(i13 != NULL);
104     if XNN_UNPREDICTABLE(i13 != zero) {
105       i13 = (const int8_t*) ((uintptr_t) i13 + input_offset);
106     }
107     const int8_t* i14 = input[14];
108     assert(i14 != NULL);
109     if XNN_UNPREDICTABLE(i14 != zero) {
110       i14 = (const int8_t*) ((uintptr_t) i14 + input_offset);
111     }
112     const int8_t* i15 = input[15];
113     assert(i15 != NULL);
114     if XNN_UNPREDICTABLE(i15 != zero) {
115       i15 = (const int8_t*) ((uintptr_t) i15 + input_offset);
116     }
117     const int8_t* i16 = input[16];
118     assert(i16 != NULL);
119     if XNN_UNPREDICTABLE(i16 != zero) {
120       i16 = (const int8_t*) ((uintptr_t) i16 + input_offset);
121     }
122     const int8_t* i17 = input[17];
123     assert(i17 != NULL);
124     if XNN_UNPREDICTABLE(i17 != zero) {
125       i17 = (const int8_t*) ((uintptr_t) i17 + input_offset);
126     }
127     const int8_t* i18 = input[18];
128     assert(i18 != NULL);
129     if XNN_UNPREDICTABLE(i18 != zero) {
130       i18 = (const int8_t*) ((uintptr_t) i18 + input_offset);
131     }
132     const int8_t* i19 = input[19];
133     assert(i19 != NULL);
134     if XNN_UNPREDICTABLE(i19 != zero) {
135       i19 = (const int8_t*) ((uintptr_t) i19 + input_offset);
136     }
137     const int8_t* i20 = input[20];
138     assert(i20 != NULL);
139     if XNN_UNPREDICTABLE(i20 != zero) {
140       i20 = (const int8_t*) ((uintptr_t) i20 + input_offset);
141     }
142     const int8_t* i21 = input[21];
143     assert(i21 != NULL);
144     if XNN_UNPREDICTABLE(i21 != zero) {
145       i21 = (const int8_t*) ((uintptr_t) i21 + input_offset);
146     }
147     const int8_t* i22 = input[22];
148     assert(i22 != NULL);
149     if XNN_UNPREDICTABLE(i22 != zero) {
150       i22 = (const int8_t*) ((uintptr_t) i22 + input_offset);
151     }
152     const int8_t* i23 = input[23];
153     assert(i23 != NULL);
154     if XNN_UNPREDICTABLE(i23 != zero) {
155       i23 = (const int8_t*) ((uintptr_t) i23 + input_offset);
156     }
157     const int8_t* i24 = input[24];
158     assert(i24 != NULL);
159     if XNN_UNPREDICTABLE(i24 != zero) {
160       i24 = (const int8_t*) ((uintptr_t) i24 + input_offset);
161     }
162     input = (const int8_t**) ((uintptr_t) input + input_stride);
163 
164     size_t c = channels;
165     const void* w = weights;
166     for (; c >= 8; c -= 8) {
167       int32x4_t vacc0123 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
168       int32x4_t vacc4567 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
169 
170 
171       const int16x8_t vi0x01234567 = vmovl_s8(vld1_s8(i0)); i0 += 8;
172       const int16x8_t vk0x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
173 
174       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi0x01234567), vget_low_s16(vk0x01234567));
175       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi0x01234567), vget_high_s16(vk0x01234567));
176 
177       const int16x8_t vi1x01234567 = vmovl_s8(vld1_s8(i1)); i1 += 8;
178       const int16x8_t vk1x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
179 
180       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi1x01234567), vget_low_s16(vk1x01234567));
181       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi1x01234567), vget_high_s16(vk1x01234567));
182 
183       const int16x8_t vi2x01234567 = vmovl_s8(vld1_s8(i2)); i2 += 8;
184       const int16x8_t vk2x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
185 
186       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi2x01234567), vget_low_s16(vk2x01234567));
187       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi2x01234567), vget_high_s16(vk2x01234567));
188 
189       const int16x8_t vi3x01234567 = vmovl_s8(vld1_s8(i3)); i3 += 8;
190       const int16x8_t vk3x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
191 
192       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi3x01234567), vget_low_s16(vk3x01234567));
193       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi3x01234567), vget_high_s16(vk3x01234567));
194 
195       const int16x8_t vi4x01234567 = vmovl_s8(vld1_s8(i4)); i4 += 8;
196       const int16x8_t vk4x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
197 
198       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi4x01234567), vget_low_s16(vk4x01234567));
199       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi4x01234567), vget_high_s16(vk4x01234567));
200 
201       const int16x8_t vi5x01234567 = vmovl_s8(vld1_s8(i5)); i5 += 8;
202       const int16x8_t vk5x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
203 
204       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi5x01234567), vget_low_s16(vk5x01234567));
205       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi5x01234567), vget_high_s16(vk5x01234567));
206 
207       const int16x8_t vi6x01234567 = vmovl_s8(vld1_s8(i6)); i6 += 8;
208       const int16x8_t vk6x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
209 
210       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi6x01234567), vget_low_s16(vk6x01234567));
211       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi6x01234567), vget_high_s16(vk6x01234567));
212 
213       const int16x8_t vi7x01234567 = vmovl_s8(vld1_s8(i7)); i7 += 8;
214       const int16x8_t vk7x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
215 
216       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi7x01234567), vget_low_s16(vk7x01234567));
217       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi7x01234567), vget_high_s16(vk7x01234567));
218 
219       const int16x8_t vi8x01234567 = vmovl_s8(vld1_s8(i8)); i8 += 8;
220       const int16x8_t vk8x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
221 
222       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi8x01234567), vget_low_s16(vk8x01234567));
223       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi8x01234567), vget_high_s16(vk8x01234567));
224 
225       const int16x8_t vi9x01234567 = vmovl_s8(vld1_s8(i9)); i9 += 8;
226       const int16x8_t vk9x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
227 
228       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi9x01234567), vget_low_s16(vk9x01234567));
229       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi9x01234567), vget_high_s16(vk9x01234567));
230 
231       const int16x8_t vi10x01234567 = vmovl_s8(vld1_s8(i10)); i10 += 8;
232       const int16x8_t vk10x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
233 
234       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi10x01234567), vget_low_s16(vk10x01234567));
235       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi10x01234567), vget_high_s16(vk10x01234567));
236 
237       const int16x8_t vi11x01234567 = vmovl_s8(vld1_s8(i11)); i11 += 8;
238       const int16x8_t vk11x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
239 
240       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi11x01234567), vget_low_s16(vk11x01234567));
241       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi11x01234567), vget_high_s16(vk11x01234567));
242 
243       const int16x8_t vi12x01234567 = vmovl_s8(vld1_s8(i12)); i12 += 8;
244       const int16x8_t vk12x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
245 
246       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi12x01234567), vget_low_s16(vk12x01234567));
247       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi12x01234567), vget_high_s16(vk12x01234567));
248 
249       const int16x8_t vi13x01234567 = vmovl_s8(vld1_s8(i13)); i13 += 8;
250       const int16x8_t vk13x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
251 
252       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi13x01234567), vget_low_s16(vk13x01234567));
253       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi13x01234567), vget_high_s16(vk13x01234567));
254 
255       const int16x8_t vi14x01234567 = vmovl_s8(vld1_s8(i14)); i14 += 8;
256       const int16x8_t vk14x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
257 
258       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi14x01234567), vget_low_s16(vk14x01234567));
259       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi14x01234567), vget_high_s16(vk14x01234567));
260 
261       const int16x8_t vi15x01234567 = vmovl_s8(vld1_s8(i15)); i15 += 8;
262       const int16x8_t vk15x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
263 
264       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi15x01234567), vget_low_s16(vk15x01234567));
265       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi15x01234567), vget_high_s16(vk15x01234567));
266 
267       const int16x8_t vi16x01234567 = vmovl_s8(vld1_s8(i16)); i16 += 8;
268       const int16x8_t vk16x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
269 
270       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi16x01234567), vget_low_s16(vk16x01234567));
271       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi16x01234567), vget_high_s16(vk16x01234567));
272 
273       const int16x8_t vi17x01234567 = vmovl_s8(vld1_s8(i17)); i17 += 8;
274       const int16x8_t vk17x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
275 
276       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi17x01234567), vget_low_s16(vk17x01234567));
277       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi17x01234567), vget_high_s16(vk17x01234567));
278 
279       const int16x8_t vi18x01234567 = vmovl_s8(vld1_s8(i18)); i18 += 8;
280       const int16x8_t vk18x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
281 
282       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi18x01234567), vget_low_s16(vk18x01234567));
283       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi18x01234567), vget_high_s16(vk18x01234567));
284 
285       const int16x8_t vi19x01234567 = vmovl_s8(vld1_s8(i19)); i19 += 8;
286       const int16x8_t vk19x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
287 
288       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi19x01234567), vget_low_s16(vk19x01234567));
289       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi19x01234567), vget_high_s16(vk19x01234567));
290 
291       const int16x8_t vi20x01234567 = vmovl_s8(vld1_s8(i20)); i20 += 8;
292       const int16x8_t vk20x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
293 
294       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi20x01234567), vget_low_s16(vk20x01234567));
295       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi20x01234567), vget_high_s16(vk20x01234567));
296 
297       const int16x8_t vi21x01234567 = vmovl_s8(vld1_s8(i21)); i21 += 8;
298       const int16x8_t vk21x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
299 
300       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi21x01234567), vget_low_s16(vk21x01234567));
301       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi21x01234567), vget_high_s16(vk21x01234567));
302 
303       const int16x8_t vi22x01234567 = vmovl_s8(vld1_s8(i22)); i22 += 8;
304       const int16x8_t vk22x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
305 
306       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi22x01234567), vget_low_s16(vk22x01234567));
307       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi22x01234567), vget_high_s16(vk22x01234567));
308 
309       const int16x8_t vi23x01234567 = vmovl_s8(vld1_s8(i23)); i23 += 8;
310       const int16x8_t vk23x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
311 
312       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi23x01234567), vget_low_s16(vk23x01234567));
313       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi23x01234567), vget_high_s16(vk23x01234567));
314 
315       const int16x8_t vi24x01234567 = vmovl_s8(vld1_s8(i24)); i24 += 8;
316       const int16x8_t vk24x01234567 = vmovl_s8(vld1_s8(w)); w = (const void*) ((const int8_t*) w + 8);
317 
318       vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi24x01234567), vget_low_s16(vk24x01234567));
319       vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi24x01234567), vget_high_s16(vk24x01234567));
320 
321       float32x4_t vfpacc0123 = vcvtq_f32_s32(vacc0123);
322       float32x4_t vfpacc4567 = vcvtq_f32_s32(vacc4567);
323 
324       const float32x4_t vscale0123 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
325       const float32x4_t vscale4567 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
326 
327       vfpacc0123 = vmulq_f32(vfpacc0123, vscale0123);
328       vfpacc4567 = vmulq_f32(vfpacc4567, vscale4567);
329 
330       vacc0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0123, vmagic_bias));
331       vacc4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc4567, vmagic_bias));
332 
333       vacc0123 = vqsubq_s32(vacc0123, vmagic_bias_less_output_zero_point);
334       vacc4567 = vqsubq_s32(vacc4567, vmagic_bias_less_output_zero_point);
335 
336 #if XNN_ARCH_ARM64
337       int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
338 
339 
340       int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
341 #else  // !XNN_ARCH_ARM64
342       int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
343 
344 
345       int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
346 #endif  // !XNN_ARCH_ARM64
347 
348       vout01234567 = vmax_s8(vout01234567, voutput_min);
349 
350       vout01234567 = vmin_s8(vout01234567, voutput_max);
351 
352       vst1_s8(output, vout01234567); output += 8;
353     }
354     if XNN_UNLIKELY(c != 0) {
355       {
356         int32x4_t vacc0123 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
357         int32x4_t vacc4567 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
358 
359         const int16x8_t vi0x01234567 = vmovl_s8(vld1_s8(i0));
360         const int16x8_t vk0x01234567 = vmovl_s8(vld1_s8(w));
361 
362         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi0x01234567), vget_low_s16(vk0x01234567));
363         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi0x01234567), vget_high_s16(vk0x01234567));
364         const int16x8_t vi1x01234567 = vmovl_s8(vld1_s8(i1));
365         const int16x8_t vk1x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 8)));
366 
367         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi1x01234567), vget_low_s16(vk1x01234567));
368         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi1x01234567), vget_high_s16(vk1x01234567));
369         const int16x8_t vi2x01234567 = vmovl_s8(vld1_s8(i2));
370         const int16x8_t vk2x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 16)));
371 
372         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi2x01234567), vget_low_s16(vk2x01234567));
373         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi2x01234567), vget_high_s16(vk2x01234567));
374         const int16x8_t vi3x01234567 = vmovl_s8(vld1_s8(i3));
375         const int16x8_t vk3x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 24)));
376 
377         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi3x01234567), vget_low_s16(vk3x01234567));
378         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi3x01234567), vget_high_s16(vk3x01234567));
379         const int16x8_t vi4x01234567 = vmovl_s8(vld1_s8(i4));
380         const int16x8_t vk4x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 32)));
381 
382         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi4x01234567), vget_low_s16(vk4x01234567));
383         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi4x01234567), vget_high_s16(vk4x01234567));
384         const int16x8_t vi5x01234567 = vmovl_s8(vld1_s8(i5));
385         const int16x8_t vk5x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 40)));
386 
387         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi5x01234567), vget_low_s16(vk5x01234567));
388         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi5x01234567), vget_high_s16(vk5x01234567));
389         const int16x8_t vi6x01234567 = vmovl_s8(vld1_s8(i6));
390         const int16x8_t vk6x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 48)));
391 
392         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi6x01234567), vget_low_s16(vk6x01234567));
393         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi6x01234567), vget_high_s16(vk6x01234567));
394         const int16x8_t vi7x01234567 = vmovl_s8(vld1_s8(i7));
395         const int16x8_t vk7x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 56)));
396 
397         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi7x01234567), vget_low_s16(vk7x01234567));
398         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi7x01234567), vget_high_s16(vk7x01234567));
399         const int16x8_t vi8x01234567 = vmovl_s8(vld1_s8(i8));
400         const int16x8_t vk8x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 64)));
401 
402         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi8x01234567), vget_low_s16(vk8x01234567));
403         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi8x01234567), vget_high_s16(vk8x01234567));
404         const int16x8_t vi9x01234567 = vmovl_s8(vld1_s8(i9));
405         const int16x8_t vk9x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 72)));
406 
407         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi9x01234567), vget_low_s16(vk9x01234567));
408         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi9x01234567), vget_high_s16(vk9x01234567));
409         const int16x8_t vi10x01234567 = vmovl_s8(vld1_s8(i10));
410         const int16x8_t vk10x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 80)));
411 
412         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi10x01234567), vget_low_s16(vk10x01234567));
413         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi10x01234567), vget_high_s16(vk10x01234567));
414         const int16x8_t vi11x01234567 = vmovl_s8(vld1_s8(i11));
415         const int16x8_t vk11x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 88)));
416 
417         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi11x01234567), vget_low_s16(vk11x01234567));
418         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi11x01234567), vget_high_s16(vk11x01234567));
419         const int16x8_t vi12x01234567 = vmovl_s8(vld1_s8(i12));
420         const int16x8_t vk12x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 96)));
421 
422         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi12x01234567), vget_low_s16(vk12x01234567));
423         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi12x01234567), vget_high_s16(vk12x01234567));
424         const int16x8_t vi13x01234567 = vmovl_s8(vld1_s8(i13));
425         const int16x8_t vk13x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 104)));
426 
427         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi13x01234567), vget_low_s16(vk13x01234567));
428         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi13x01234567), vget_high_s16(vk13x01234567));
429         const int16x8_t vi14x01234567 = vmovl_s8(vld1_s8(i14));
430         const int16x8_t vk14x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 112)));
431 
432         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi14x01234567), vget_low_s16(vk14x01234567));
433         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi14x01234567), vget_high_s16(vk14x01234567));
434         const int16x8_t vi15x01234567 = vmovl_s8(vld1_s8(i15));
435         const int16x8_t vk15x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 120)));
436 
437         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi15x01234567), vget_low_s16(vk15x01234567));
438         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi15x01234567), vget_high_s16(vk15x01234567));
439         const int16x8_t vi16x01234567 = vmovl_s8(vld1_s8(i16));
440         const int16x8_t vk16x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 128)));
441 
442         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi16x01234567), vget_low_s16(vk16x01234567));
443         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi16x01234567), vget_high_s16(vk16x01234567));
444         const int16x8_t vi17x01234567 = vmovl_s8(vld1_s8(i17));
445         const int16x8_t vk17x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 136)));
446 
447         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi17x01234567), vget_low_s16(vk17x01234567));
448         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi17x01234567), vget_high_s16(vk17x01234567));
449         const int16x8_t vi18x01234567 = vmovl_s8(vld1_s8(i18));
450         const int16x8_t vk18x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 144)));
451 
452         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi18x01234567), vget_low_s16(vk18x01234567));
453         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi18x01234567), vget_high_s16(vk18x01234567));
454         const int16x8_t vi19x01234567 = vmovl_s8(vld1_s8(i19));
455         const int16x8_t vk19x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 152)));
456 
457         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi19x01234567), vget_low_s16(vk19x01234567));
458         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi19x01234567), vget_high_s16(vk19x01234567));
459         const int16x8_t vi20x01234567 = vmovl_s8(vld1_s8(i20));
460         const int16x8_t vk20x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 160)));
461 
462         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi20x01234567), vget_low_s16(vk20x01234567));
463         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi20x01234567), vget_high_s16(vk20x01234567));
464         const int16x8_t vi21x01234567 = vmovl_s8(vld1_s8(i21));
465         const int16x8_t vk21x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 168)));
466 
467         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi21x01234567), vget_low_s16(vk21x01234567));
468         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi21x01234567), vget_high_s16(vk21x01234567));
469         const int16x8_t vi22x01234567 = vmovl_s8(vld1_s8(i22));
470         const int16x8_t vk22x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 176)));
471 
472         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi22x01234567), vget_low_s16(vk22x01234567));
473         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi22x01234567), vget_high_s16(vk22x01234567));
474         const int16x8_t vi23x01234567 = vmovl_s8(vld1_s8(i23));
475         const int16x8_t vk23x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 184)));
476 
477         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi23x01234567), vget_low_s16(vk23x01234567));
478         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi23x01234567), vget_high_s16(vk23x01234567));
479         const int16x8_t vi24x01234567 = vmovl_s8(vld1_s8(i24));
480         const int16x8_t vk24x01234567 = vmovl_s8(vld1_s8((const void*) ((const int8_t*) w + 192)));
481 
482         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi24x01234567), vget_low_s16(vk24x01234567));
483         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi24x01234567), vget_high_s16(vk24x01234567));
484 
485         float32x4_t vfpacc0123 = vcvtq_f32_s32(vacc0123);
486         float32x4_t vfpacc4567 = vcvtq_f32_s32(vacc4567);
487 
488         const float32x4_t vscale0123 = vld1q_f32((const float*) ((uintptr_t) w + 0 * sizeof(int32_t) + 200 * sizeof(int8_t)));
489         const float32x4_t vscale4567 = vld1q_f32((const float*) ((uintptr_t) w + 0 * sizeof(int32_t) + 200 * sizeof(int8_t) + 4 * sizeof(float)));
490         vfpacc0123 = vmulq_f32(vfpacc0123, vscale0123);
491         vfpacc4567 = vmulq_f32(vfpacc4567, vscale4567);
492 
493         vacc0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0123, vmagic_bias));
494         vacc4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc4567, vmagic_bias));
495 
496         vacc0123 = vqsubq_s32(vacc0123, vmagic_bias_less_output_zero_point);
497         vacc4567 = vqsubq_s32(vacc4567, vmagic_bias_less_output_zero_point);
498 
499 #if XNN_ARCH_ARM64
500         int16x8_t vacc01234567 = vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567);
501 #else
502         int16x8_t vacc01234567 = vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567));
503 #endif
504 
505         int8x8_t vout01234567 = vqmovn_s16(vacc01234567);
506         vout01234567 = vmax_s8(vout01234567, voutput_min);
507         vout01234567 = vmin_s8(vout01234567, voutput_max);
508 
509         if (c & 4) {
510           vst1_lane_u32((void*) output, vreinterpret_u32_s8(vout01234567), 0); output += 4;
511           vout01234567 = vext_s8(vout01234567, vout01234567, 4);
512         }
513         if (c & 2) {
514           vst1_lane_u16((void*) output, vreinterpret_u16_s8(vout01234567), 0); output += 2;
515           vout01234567 = vext_s8(vout01234567, vout01234567, 2);
516         }
517         if (c & 1) {
518           vst1_lane_s8(output, vout01234567, 0); output += 1;
519         }
520       }
521     }
522 
523     output = (int8_t*) ((uintptr_t) output + output_increment);
524   } while (--output_width != 0);
525 }
526