xref: /aosp_15_r20/external/XNNPACK/src/qu8-dwconv/gen/up16x9-minmax-rndnu-neon-mul8.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Auto-generated file. Do not edit!
2 //   Template: src/qu8-dwconv/unipass-neon-mul8.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_qu8_dwconv_minmax_rndnu_ukernel_up16x9__neon_mul8(size_t channels,size_t output_width,const uint8_t ** input,const void * weights,uint8_t * output,size_t input_stride,size_t output_increment,size_t input_offset,const uint8_t * zero,const union xnn_qu8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qu8_dwconv_minmax_rndnu_ukernel_up16x9__neon_mul8(
18     size_t channels,
19     size_t output_width,
20     const uint8_t** input,
21     const void* weights,
22     uint8_t* output,
23     size_t input_stride,
24     size_t output_increment,
25     size_t input_offset,
26     const uint8_t* zero,
27     const union xnn_qu8_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 uint8x8_t vkernel_zero_point = vld1_dup_u8(params->rndnu_neon.kernel_zero_point);
33   const uint16x8_t vkernel_zero_point16 = vmovl_u8(vkernel_zero_point);
34   const int32x4_t vright_pre_shift = vld1q_dup_s32(&params->rndnu_neon.right_pre_shift);
35   const int32x4_t vmultiplier = vld1q_dup_s32(&params->rndnu_neon.multiplier);
36   const int32x4_t vright_post_shift = vld1q_dup_s32(&params->rndnu_neon.right_post_shift);
37   const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->rndnu_neon.output_zero_point);
38   const uint8x16_t voutput_min = vld1q_dup_u8(&params->rndnu_neon.output_min);
39   const uint8x16_t voutput_max = vld1q_dup_u8(&params->rndnu_neon.output_max);
40   do {
41     const uint8_t* i0 = input[0];
42     assert(i0 != NULL);
43     if XNN_UNPREDICTABLE(i0 != zero) {
44       i0 = (const uint8_t*) ((uintptr_t) i0 + input_offset);
45     }
46     const uint8_t* i1 = input[1];
47     assert(i1 != NULL);
48     if XNN_UNPREDICTABLE(i1 != zero) {
49       i1 = (const uint8_t*) ((uintptr_t) i1 + input_offset);
50     }
51     const uint8_t* i2 = input[2];
52     assert(i2 != NULL);
53     if XNN_UNPREDICTABLE(i2 != zero) {
54       i2 = (const uint8_t*) ((uintptr_t) i2 + input_offset);
55     }
56     const uint8_t* i3 = input[3];
57     assert(i3 != NULL);
58     if XNN_UNPREDICTABLE(i3 != zero) {
59       i3 = (const uint8_t*) ((uintptr_t) i3 + input_offset);
60     }
61     const uint8_t* i4 = input[4];
62     assert(i4 != NULL);
63     if XNN_UNPREDICTABLE(i4 != zero) {
64       i4 = (const uint8_t*) ((uintptr_t) i4 + input_offset);
65     }
66     const uint8_t* i5 = input[5];
67     assert(i5 != NULL);
68     if XNN_UNPREDICTABLE(i5 != zero) {
69       i5 = (const uint8_t*) ((uintptr_t) i5 + input_offset);
70     }
71     const uint8_t* i6 = input[6];
72     assert(i6 != NULL);
73     if XNN_UNPREDICTABLE(i6 != zero) {
74       i6 = (const uint8_t*) ((uintptr_t) i6 + input_offset);
75     }
76     const uint8_t* i7 = input[7];
77     assert(i7 != NULL);
78     if XNN_UNPREDICTABLE(i7 != zero) {
79       i7 = (const uint8_t*) ((uintptr_t) i7 + input_offset);
80     }
81     const uint8_t* i8 = input[8];
82     assert(i8 != NULL);
83     if XNN_UNPREDICTABLE(i8 != zero) {
84       i8 = (const uint8_t*) ((uintptr_t) i8 + input_offset);
85     }
86     input = (const uint8_t**) ((uintptr_t) input + input_stride);
87 
88 
89     size_t c = channels;
90     const void* w = weights;
91     for (; c >= 16; c -= 16) {
92       int32x4_t vacc0123 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
93       int32x4_t vacc4567 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
94       int32x4_t vacc89AB = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
95       int32x4_t vaccCDEF = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
96 
97 
98       const uint8x8_t vi0x01234567 = vld1_u8(i0); i0 += 8;
99       const uint8x8_t vk0x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
100       const uint8x8_t vi0x89ABCDEF = vld1_u8(i0); i0 += 8;
101       const uint8x8_t vk0x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
102 
103       uint16x8_t vprod01234567 = vmull_u8(vi0x01234567, vk0x01234567);
104       uint16x8_t vprod89ABCDEF = vmull_u8(vi0x89ABCDEF, vk0x89ABCDEF);
105 
106       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
107       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
108       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
109       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
110       const uint8x8_t vi1x01234567 = vld1_u8(i1); i1 += 8;
111       const uint8x8_t vk1x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
112       const uint8x8_t vi1x89ABCDEF = vld1_u8(i1); i1 += 8;
113       const uint8x8_t vk1x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
114 
115       vprod01234567 = vmull_u8(vi1x01234567, vk1x01234567);
116       uint16x8_t vsum01234567 = vaddl_u8(vi0x01234567, vi1x01234567);
117       vprod89ABCDEF = vmull_u8(vi1x89ABCDEF, vk1x89ABCDEF);
118       uint16x8_t vsum89ABCDEF = vaddl_u8(vi0x89ABCDEF, vi1x89ABCDEF);
119 
120       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
121       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
122       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
123       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
124       const uint8x8_t vi2x01234567 = vld1_u8(i2); i2 += 8;
125       const uint8x8_t vk2x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
126       const uint8x8_t vi2x89ABCDEF = vld1_u8(i2); i2 += 8;
127       const uint8x8_t vk2x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
128 
129       vprod01234567 = vmull_u8(vi2x01234567, vk2x01234567);
130       vsum01234567 = vaddw_u8(vsum01234567, vi2x01234567);
131       vprod89ABCDEF = vmull_u8(vi2x89ABCDEF, vk2x89ABCDEF);
132       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi2x89ABCDEF);
133 
134       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
135       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
136       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
137       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
138       const uint8x8_t vi3x01234567 = vld1_u8(i3); i3 += 8;
139       const uint8x8_t vk3x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
140       const uint8x8_t vi3x89ABCDEF = vld1_u8(i3); i3 += 8;
141       const uint8x8_t vk3x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
142 
143       vprod01234567 = vmull_u8(vi3x01234567, vk3x01234567);
144       vsum01234567 = vaddw_u8(vsum01234567, vi3x01234567);
145       vprod89ABCDEF = vmull_u8(vi3x89ABCDEF, vk3x89ABCDEF);
146       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi3x89ABCDEF);
147 
148       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
149       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
150       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
151       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
152       const uint8x8_t vi4x01234567 = vld1_u8(i4); i4 += 8;
153       const uint8x8_t vk4x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
154       const uint8x8_t vi4x89ABCDEF = vld1_u8(i4); i4 += 8;
155       const uint8x8_t vk4x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
156 
157       vprod01234567 = vmull_u8(vi4x01234567, vk4x01234567);
158       vsum01234567 = vaddw_u8(vsum01234567, vi4x01234567);
159       vprod89ABCDEF = vmull_u8(vi4x89ABCDEF, vk4x89ABCDEF);
160       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi4x89ABCDEF);
161 
162       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
163       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
164       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
165       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
166       const uint8x8_t vi5x01234567 = vld1_u8(i5); i5 += 8;
167       const uint8x8_t vk5x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
168       const uint8x8_t vi5x89ABCDEF = vld1_u8(i5); i5 += 8;
169       const uint8x8_t vk5x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
170 
171       vprod01234567 = vmull_u8(vi5x01234567, vk5x01234567);
172       vsum01234567 = vaddw_u8(vsum01234567, vi5x01234567);
173       vprod89ABCDEF = vmull_u8(vi5x89ABCDEF, vk5x89ABCDEF);
174       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi5x89ABCDEF);
175 
176       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
177       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
178       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
179       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
180       const uint8x8_t vi6x01234567 = vld1_u8(i6); i6 += 8;
181       const uint8x8_t vk6x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
182       const uint8x8_t vi6x89ABCDEF = vld1_u8(i6); i6 += 8;
183       const uint8x8_t vk6x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
184 
185       vprod01234567 = vmull_u8(vi6x01234567, vk6x01234567);
186       vsum01234567 = vaddw_u8(vsum01234567, vi6x01234567);
187       vprod89ABCDEF = vmull_u8(vi6x89ABCDEF, vk6x89ABCDEF);
188       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi6x89ABCDEF);
189 
190       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
191       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
192       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
193       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
194       const uint8x8_t vi7x01234567 = vld1_u8(i7); i7 += 8;
195       const uint8x8_t vk7x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
196       const uint8x8_t vi7x89ABCDEF = vld1_u8(i7); i7 += 8;
197       const uint8x8_t vk7x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
198 
199       vprod01234567 = vmull_u8(vi7x01234567, vk7x01234567);
200       vsum01234567 = vaddw_u8(vsum01234567, vi7x01234567);
201       vprod89ABCDEF = vmull_u8(vi7x89ABCDEF, vk7x89ABCDEF);
202       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi7x89ABCDEF);
203 
204       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
205       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
206       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
207       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
208       const uint8x8_t vi8x01234567 = vld1_u8(i8); i8 += 8;
209       const uint8x8_t vk8x01234567 = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
210       const uint8x8_t vi8x89ABCDEF = vld1_u8(i8); i8 += 8;
211       const uint8x8_t vk8x89ABCDEF = vld1_u8(w); w = (const void*) ((const int8_t*) w + 8);
212 
213       vprod01234567 = vmull_u8(vi8x01234567, vk8x01234567);
214       vsum01234567 = vaddw_u8(vsum01234567, vi8x01234567);
215       vprod89ABCDEF = vmull_u8(vi8x89ABCDEF, vk8x89ABCDEF);
216       vsum89ABCDEF = vaddw_u8(vsum89ABCDEF, vi8x89ABCDEF);
217 
218       vacc0123 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vprod01234567)));
219       vacc4567 = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vprod01234567)));
220       vacc89AB = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vprod89ABCDEF)));
221       vaccCDEF = vreinterpretq_s32_u32(vaddw_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vprod89ABCDEF)));
222 
223       vacc0123 = vreinterpretq_s32_u32(vmlsl_u16(vreinterpretq_u32_s32(vacc0123), vget_low_u16(vsum01234567), vget_low_u16(vkernel_zero_point16)));
224       vacc4567 = vreinterpretq_s32_u32(vmlsl_u16(vreinterpretq_u32_s32(vacc4567), vget_high_u16(vsum01234567), vget_high_u16(vkernel_zero_point16)));
225       vacc89AB = vreinterpretq_s32_u32(vmlsl_u16(vreinterpretq_u32_s32(vacc89AB), vget_low_u16(vsum89ABCDEF), vget_low_u16(vkernel_zero_point16)));
226       vaccCDEF = vreinterpretq_s32_u32(vmlsl_u16(vreinterpretq_u32_s32(vaccCDEF), vget_high_u16(vsum89ABCDEF), vget_high_u16(vkernel_zero_point16)));
227 
228       vacc0123 = vshlq_s32(vacc0123, vright_pre_shift);
229       vacc4567 = vshlq_s32(vacc4567, vright_pre_shift);
230       vacc89AB = vshlq_s32(vacc89AB, vright_pre_shift);
231       vaccCDEF = vshlq_s32(vaccCDEF, vright_pre_shift);
232 
233       vacc0123 = vqdmulhq_s32(vacc0123, vmultiplier);
234       vacc4567 = vqdmulhq_s32(vacc4567, vmultiplier);
235       vacc89AB = vqdmulhq_s32(vacc89AB, vmultiplier);
236       vaccCDEF = vqdmulhq_s32(vaccCDEF, vmultiplier);
237 
238       vacc0123 = vrshlq_s32(vacc0123, vright_post_shift);
239       vacc4567 = vrshlq_s32(vacc4567, vright_post_shift);
240       vacc89AB = vrshlq_s32(vacc89AB, vright_post_shift);
241       vaccCDEF = vrshlq_s32(vaccCDEF, vright_post_shift);
242 
243 #if XNN_ARCH_ARM64
244       const int16x8_t vacc01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567), voutput_zero_point);
245       const int16x8_t vacc89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc89AB), vaccCDEF), voutput_zero_point);
246 
247       uint8x16_t vout0123456789ABCDEF = vqmovun_high_s16(vqmovun_s16(vacc01234567), vacc89ABCDEF);
248 #else
249       const int16x8_t vacc01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567)), voutput_zero_point);
250       const int16x8_t vacc89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc89AB), vqmovn_s32(vaccCDEF)), voutput_zero_point);
251 
252       uint8x16_t vout0123456789ABCDEF = vcombine_u8(vqmovun_s16(vacc01234567), vqmovun_s16(vacc89ABCDEF));
253 #endif
254 
255       vout0123456789ABCDEF = vmaxq_u8(vout0123456789ABCDEF, voutput_min);
256 
257       vout0123456789ABCDEF = vminq_u8(vout0123456789ABCDEF, voutput_max);
258 
259       vst1q_u8(output, vout0123456789ABCDEF); output += 16;
260     }
261     if XNN_UNLIKELY(c != 0) {
262       const uint8_t* k = (const uint8_t*) ((const int32_t*) w + 16);
263       do {
264         int32x4_t vacc0123 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
265         int32x4_t vacc4567 = vld1q_s32(w); w = (const void*) ((const int32_t*) w + 4);
266 
267         const int16x8_t vi0x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i0))); i0 += 8;
268         const int16x8_t vk0x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8(k), vkernel_zero_point)); k += 8;
269 
270         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi0x01234567), vget_low_s16(vk0x01234567));
271         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi0x01234567), vget_high_s16(vk0x01234567));
272         const int16x8_t vi1x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i1))); i1 += 8;
273         const int16x8_t vk1x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 8)), vkernel_zero_point));
274 
275         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi1x01234567), vget_low_s16(vk1x01234567));
276         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi1x01234567), vget_high_s16(vk1x01234567));
277         const int16x8_t vi2x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i2))); i2 += 8;
278         const int16x8_t vk2x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 24)), vkernel_zero_point));
279 
280         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi2x01234567), vget_low_s16(vk2x01234567));
281         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi2x01234567), vget_high_s16(vk2x01234567));
282         const int16x8_t vi3x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i3))); i3 += 8;
283         const int16x8_t vk3x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 40)), vkernel_zero_point));
284 
285         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi3x01234567), vget_low_s16(vk3x01234567));
286         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi3x01234567), vget_high_s16(vk3x01234567));
287         const int16x8_t vi4x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i4))); i4 += 8;
288         const int16x8_t vk4x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 56)), vkernel_zero_point));
289 
290         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi4x01234567), vget_low_s16(vk4x01234567));
291         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi4x01234567), vget_high_s16(vk4x01234567));
292         const int16x8_t vi5x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i5))); i5 += 8;
293         const int16x8_t vk5x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 72)), vkernel_zero_point));
294 
295         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi5x01234567), vget_low_s16(vk5x01234567));
296         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi5x01234567), vget_high_s16(vk5x01234567));
297         const int16x8_t vi6x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i6))); i6 += 8;
298         const int16x8_t vk6x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 88)), vkernel_zero_point));
299 
300         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi6x01234567), vget_low_s16(vk6x01234567));
301         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi6x01234567), vget_high_s16(vk6x01234567));
302         const int16x8_t vi7x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i7))); i7 += 8;
303         const int16x8_t vk7x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 104)), vkernel_zero_point));
304 
305         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi7x01234567), vget_low_s16(vk7x01234567));
306         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi7x01234567), vget_high_s16(vk7x01234567));
307         const int16x8_t vi8x01234567 = vreinterpretq_s16_u16(vmovl_u8(vld1_u8(i8))); i8 += 8;
308         const int16x8_t vk8x01234567 = vreinterpretq_s16_u16(vsubl_u8(vld1_u8((const void*) (k + 120)), vkernel_zero_point));
309 
310         vacc0123 = vmlal_s16(vacc0123, vget_low_s16(vi8x01234567), vget_low_s16(vk8x01234567));
311         vacc4567 = vmlal_s16(vacc4567, vget_high_s16(vi8x01234567), vget_high_s16(vk8x01234567));
312 
313         vacc0123 = vrshlq_s32(vacc0123, vright_pre_shift);
314         vacc4567 = vrshlq_s32(vacc4567, vright_pre_shift);
315 
316         vacc0123 = vqdmulhq_s32(vacc0123, vmultiplier);
317         vacc4567 = vqdmulhq_s32(vacc4567, vmultiplier);
318 
319         vacc0123 = vrshlq_s32(vacc0123, vright_post_shift);
320         vacc4567 = vrshlq_s32(vacc4567, vright_post_shift);
321 
322 #if XNN_ARCH_ARM64
323         const int16x8_t vacc01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0123), vacc4567), voutput_zero_point);
324         uint8x8_t vout01234567 = vqmovun_s16(vacc01234567);
325 #else
326         const int16x8_t vacc01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0123), vqmovn_s32(vacc4567)), voutput_zero_point);
327         uint8x8_t vout01234567 = vqmovun_s16(vacc01234567);
328 #endif
329 
330         vout01234567 = vmax_u8(vout01234567, vget_low_u8(voutput_min));
331         vout01234567 = vmin_u8(vout01234567, vget_low_u8(voutput_max));
332 
333         if XNN_LIKELY(c >= 8) {
334           vst1_u8(output, vout01234567); output += 8;
335           c -= 8;
336         } else {
337           if (c & 4) {
338             vst1_lane_u32((void*) output, vreinterpret_u32_u8(vout01234567), 0); output += 4;
339             vout01234567 = vext_u8(vout01234567, vout01234567, 4);
340           }
341           if (c & 2) {
342             vst1_lane_u16((void*) output, vreinterpret_u16_u8(vout01234567), 0); output += 2;
343             vout01234567 = vext_u8(vout01234567, vout01234567, 2);
344           }
345           if (c & 1) {
346             vst1_lane_u8(output, vout01234567, 0); output += 1;
347           }
348           c = 0;
349         }
350       } while (c != 0);
351     }
352 
353     output = (uint8_t*) ((uintptr_t) output + output_increment);
354   } while (--output_width != 0);
355 }
356