Debian Codegraph @

src/qd8-f16-qc8w-igemm/gen/qd8-f16-qc8w-igemm-8x8c8-minmax-neoni8mm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-igemm/c8-neoni8mm.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 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/igemm.h"
15 #include "xnnpack/math.h"
16
17
18 void xnn_qd8_f16_qc8w_igemm_minmax_ukernel_8x8c8__neoni8mm(
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 xnn_float16* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 size_t a_offset,
29 const int8_t* zero,
30 const int8_t* zero_data,
31 const union xnn_f16_minmax_params params[restrict XNN_MIN_ELEMENTS(1)],
32 const struct xnn_qd8_quantization_params quantization_params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
33 {
34 assert(mr != 0);
35 assert(mr <= 8);
36 assert(nc != 0);
37 assert(kc != 0);
38 assert(ks != 0);
39 assert(ks % (8 * sizeof(void*)) == 0);
40 assert(a_offset % sizeof(int8_t) == 0);
41 assert(a != NULL);
42 assert(w != NULL);
43 assert(c != NULL);
44
45 kc = round_up_po2(kc, 8 * sizeof(int8_t));
46 uint16_t* c0 = (uint16_t*) c;
47 uint16_t* c1 = (uint16_t*) ((uintptr_t) c0 + cm_stride);
48 if XNN_UNPREDICTABLE(mr < 2) {
49 c1 = c0;
50 }
51 uint16_t* c2 = (uint16_t*) ((uintptr_t) c1 + cm_stride);
52 if XNN_UNPREDICTABLE(mr <= 2) {
53 c2 = c1;
54 }
55 uint16_t* c3 = (uint16_t*) ((uintptr_t) c2 + cm_stride);
56 if XNN_UNPREDICTABLE(mr < 4) {
57 c3 = c2;
58 }
59 uint16_t* c4 = (uint16_t*) ((uintptr_t) c3 + cm_stride);
60 if XNN_UNPREDICTABLE(mr <= 4) {
61 c4 = c3;
62 }
63 uint16_t* c5 = (uint16_t*) ((uintptr_t) c4 + cm_stride);
64 if XNN_UNPREDICTABLE(mr < 6) {
65 c5 = c4;
66 }
67 uint16_t* c6 = (uint16_t*) ((uintptr_t) c5 + cm_stride);
68 if XNN_UNPREDICTABLE(mr <= 6) {
69 c6 = c5;
70 }
71 uint16_t* c7 = (uint16_t*) ((uintptr_t) c6 + cm_stride);
72 if XNN_UNPREDICTABLE(mr != 8) {
73 c7 = c6;
74 }
75
76 do {
77 const int32x4_t vinput_zero_point = vld1q_dup_s32(&quantization_params->zero_point);
78 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
79 const int32x4_t vksumzp0x0123 = vmulq_s32(vksum0123, vinput_zero_point);
80 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
81 const int32x4_t vksumzp0x4567 = vmulq_s32(vksum4567, vinput_zero_point);
82 const int32x4_t vksumzp1x0123 = vksumzp0x0123;
83 const int32x4_t vksumzp1x4567 = vksumzp0x4567;
84 const int32x4_t vksumzp2x0123 = vksumzp0x0123;
85 const int32x4_t vksumzp2x4567 = vksumzp0x4567;
86 const int32x4_t vksumzp3x0123 = vksumzp0x0123;
87 const int32x4_t vksumzp3x4567 = vksumzp0x4567;
88 const int32x4_t vksumzp4x0123 = vksumzp0x0123;
89 const int32x4_t vksumzp4x4567 = vksumzp0x4567;
90 const int32x4_t vksumzp5x0123 = vksumzp0x0123;
91 const int32x4_t vksumzp5x4567 = vksumzp0x4567;
92 const int32x4_t vksumzp6x0123 = vksumzp0x0123;
93 const int32x4_t vksumzp6x4567 = vksumzp0x4567;
94 const int32x4_t vksumzp7x0123 = vksumzp0x0123;
95 const int32x4_t vksumzp7x4567 = vksumzp0x4567;
96
97 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
98 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
99 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
100 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
101 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
102 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
103 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
104 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
105 int32x4_t vacc45x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
106 int32x4_t vacc45x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
107 int32x4_t vacc45x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
108 int32x4_t vacc45x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
109 int32x4_t vacc67x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x0123), vreinterpretq_u64_s32(vksumzp7x0123)));
110 int32x4_t vacc67x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x0123), vreinterpretq_u64_s32(vksumzp7x0123)));
111 int32x4_t vacc67x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp6x4567), vreinterpretq_u64_s32(vksumzp7x4567)));
112 int32x4_t vacc67x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp6x4567), vreinterpretq_u64_s32(vksumzp7x4567)));
113
114 size_t p = ks;
115 do {
116 const int8_t* restrict a0 = a[0];
117 if XNN_UNPREDICTABLE(a0 != zero) {
118 a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
119 } else {
120 a0 = zero_data;
121 }
122 const int8_t* restrict a1 = a[1];
123 if XNN_UNPREDICTABLE(a1 != zero) {
124 a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
125 } else {
126 a1 = zero_data;
127 }
128 const int8_t* restrict a2 = a[2];
129 if XNN_UNPREDICTABLE(a2 != zero) {
130 a2 = (const int8_t*) ((uintptr_t) a2 + a_offset);
131 } else {
132 a2 = zero_data;
133 }
134 const int8_t* restrict a3 = a[3];
135 if XNN_UNPREDICTABLE(a3 != zero) {
136 a3 = (const int8_t*) ((uintptr_t) a3 + a_offset);
137 } else {
138 a3 = zero_data;
139 }
140 const int8_t* restrict a4 = a[4];
141 if XNN_UNPREDICTABLE(a4 != zero) {
142 a4 = (const int8_t*) ((uintptr_t) a4 + a_offset);
143 } else {
144 a4 = zero_data;
145 }
146 const int8_t* restrict a5 = a[5];
147 if XNN_UNPREDICTABLE(a5 != zero) {
148 a5 = (const int8_t*) ((uintptr_t) a5 + a_offset);
149 } else {
150 a5 = zero_data;
151 }
152 const int8_t* restrict a6 = a[6];
153 if XNN_UNPREDICTABLE(a6 != zero) {
154 a6 = (const int8_t*) ((uintptr_t) a6 + a_offset);
155 } else {
156 a6 = zero_data;
157 }
158 const int8_t* restrict a7 = a[7];
159 if XNN_UNPREDICTABLE(a7 != zero) {
160 a7 = (const int8_t*) ((uintptr_t) a7 + a_offset);
161 } else {
162 a7 = zero_data;
163 }
164 a += 8;
165
166 uint64x2x2_t va01x0123456789ABCDEF;
167 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
168 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
169 uint64x2x2_t va23x0123456789ABCDEF;
170 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
171 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
172 uint64x2x2_t va45x0123456789ABCDEF;
173 va45x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
174 va45x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
175 uint64x2x2_t va67x0123456789ABCDEF;
176 va67x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
177 va67x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
178
179 // Inner accumulation loop along the 8 columns.
180 size_t k = kc;
181 // 2x partial unrolled loop to load 8 bytes at a time.
182 while (k >= 16 * sizeof(int8_t)) {
183 // Load a 8x16 block of activations.
184 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
185 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
186 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a4, va45x0123456789ABCDEF, 0); a4 += 16;
187 va67x0123456789ABCDEF = vld2q_lane_u64((const void*) a6, va67x0123456789ABCDEF, 0); a6 += 16;
188 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
189 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
190 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a5, va45x0123456789ABCDEF, 1); a5 += 16;
191 va67x0123456789ABCDEF = vld2q_lane_u64((const void*) a7, va67x0123456789ABCDEF, 1); a7 += 16;
192
193 // Load a 16x8 block of weights.
194 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
198 const int8x16_t vb01x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
199 const int8x16_t vb23x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
200 const int8x16_t vb45x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
201 const int8x16_t vb67x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
202
203 // Multiply-accumulate: 8x16 * 16x8 --> 8x8.
204 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb01x01234567);
205 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb23x01234567);
206 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb45x01234567);
207 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb67x01234567);
208 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb01x01234567);
209 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb23x01234567);
210 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb45x01234567);
211 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb67x01234567);
212 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb01x01234567);
213 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb23x01234567);
214 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb45x01234567);
215 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb67x01234567);
216 vacc67x01 = vmmlaq_s32(vacc67x01, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[0]), vb01x01234567);
217 vacc67x23 = vmmlaq_s32(vacc67x23, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[0]), vb23x01234567);
218 vacc67x45 = vmmlaq_s32(vacc67x45, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[0]), vb45x01234567);
219 vacc67x67 = vmmlaq_s32(vacc67x67, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[0]), vb67x01234567);
220 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
221 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
222 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
223 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
224 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
225 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
226 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
227 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
228 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
229 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
230 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
231 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
232 vacc67x01 = vmmlaq_s32(vacc67x01, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
233 vacc67x23 = vmmlaq_s32(vacc67x23, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
234 vacc67x45 = vmmlaq_s32(vacc67x45, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
235 vacc67x67 = vmmlaq_s32(vacc67x67, vreinterpretq_s8_u64(va67x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
236
237 k -= 16 * sizeof(int8_t);
238 }
239 // Handle up to 8 final positions of `k`
240 if XNN_UNLIKELY(k != 0) {
241 // Load a 8x8 block of activations.
242 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
243 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
244 uint64x2_t va45x01234567 = vld1q_dup_u64((const void*) a4); a4 += 8;
245 uint64x2_t va67x01234567 = vld1q_dup_u64((const void*) a6); a6 += 8;
246 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
247 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
248 va45x01234567 = vld1q_lane_u64((const void*) a5, va45x01234567, 1); a5 += 8;
249 va67x01234567 = vld1q_lane_u64((const void*) a7, va67x01234567, 1); a7 += 8;
250
251 // Load a 16x8 block of weights.
252 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
253 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
254 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
255 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
256
257 // Multiply-accumulate: 8x4 * 4x8 --> 8x8.
258 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
259 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
260 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
261 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
262 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
263 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
264 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
265 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
266 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x01234567), vb01x01234567);
267 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x01234567), vb23x01234567);
268 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x01234567), vb45x01234567);
269 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x01234567), vb67x01234567);
270 vacc67x01 = vmmlaq_s32(vacc67x01, vreinterpretq_s8_u64(va67x01234567), vb01x01234567);
271 vacc67x23 = vmmlaq_s32(vacc67x23, vreinterpretq_s8_u64(va67x01234567), vb23x01234567);
272 vacc67x45 = vmmlaq_s32(vacc67x45, vreinterpretq_s8_u64(va67x01234567), vb45x01234567);
273 vacc67x67 = vmmlaq_s32(vacc67x67, vreinterpretq_s8_u64(va67x01234567), vb67x01234567);
274 }
275
276 p -= 8 * sizeof(void*);
277 } while (p != 0);
278
279 int32x4_t vacc0x0123 = vcombine_s32(vget_low_s32(vacc01x01), vget_low_s32(vacc01x23));
280 int32x4_t vacc1x0123 = vcombine_s32(vget_high_s32(vacc01x01), vget_high_s32(vacc01x23));
281 int32x4_t vacc0x4567 = vcombine_s32(vget_low_s32(vacc01x45), vget_low_s32(vacc01x67));
282 int32x4_t vacc1x4567 = vcombine_s32(vget_high_s32(vacc01x45), vget_high_s32(vacc01x67));
283 int32x4_t vacc2x0123 = vcombine_s32(vget_low_s32(vacc23x01), vget_low_s32(vacc23x23));
284 int32x4_t vacc3x0123 = vcombine_s32(vget_high_s32(vacc23x01), vget_high_s32(vacc23x23));
285 int32x4_t vacc2x4567 = vcombine_s32(vget_low_s32(vacc23x45), vget_low_s32(vacc23x67));
286 int32x4_t vacc3x4567 = vcombine_s32(vget_high_s32(vacc23x45), vget_high_s32(vacc23x67));
287 int32x4_t vacc4x0123 = vcombine_s32(vget_low_s32(vacc45x01), vget_low_s32(vacc45x23));
288 int32x4_t vacc5x0123 = vcombine_s32(vget_high_s32(vacc45x01), vget_high_s32(vacc45x23));
289 int32x4_t vacc4x4567 = vcombine_s32(vget_low_s32(vacc45x45), vget_low_s32(vacc45x67));
290 int32x4_t vacc5x4567 = vcombine_s32(vget_high_s32(vacc45x45), vget_high_s32(vacc45x67));
291 int32x4_t vacc6x0123 = vcombine_s32(vget_low_s32(vacc67x01), vget_low_s32(vacc67x23));
292 int32x4_t vacc7x0123 = vcombine_s32(vget_high_s32(vacc67x01), vget_high_s32(vacc67x23));
293 int32x4_t vacc6x4567 = vcombine_s32(vget_low_s32(vacc67x45), vget_low_s32(vacc67x67));
294 int32x4_t vacc7x4567 = vcombine_s32(vget_high_s32(vacc67x45), vget_high_s32(vacc67x67));
295
296 const float32x4_t vinput_scale = vld1q_dup_f32(&quantization_params->inv_scale);
297 float32x4_t vout0x0123 = vcvtq_f32_s32(vacc0x0123);
298 float32x4_t vout0x4567 = vcvtq_f32_s32(vacc0x4567);
299 float32x4_t vout1x0123 = vcvtq_f32_s32(vacc1x0123);
300 float32x4_t vout1x4567 = vcvtq_f32_s32(vacc1x4567);
301 float32x4_t vout2x0123 = vcvtq_f32_s32(vacc2x0123);
302 float32x4_t vout2x4567 = vcvtq_f32_s32(vacc2x4567);
303 float32x4_t vout3x0123 = vcvtq_f32_s32(vacc3x0123);
304 float32x4_t vout3x4567 = vcvtq_f32_s32(vacc3x4567);
305 float32x4_t vout4x0123 = vcvtq_f32_s32(vacc4x0123);
306 float32x4_t vout4x4567 = vcvtq_f32_s32(vacc4x4567);
307 float32x4_t vout5x0123 = vcvtq_f32_s32(vacc5x0123);
308 float32x4_t vout5x4567 = vcvtq_f32_s32(vacc5x4567);
309 float32x4_t vout6x0123 = vcvtq_f32_s32(vacc6x0123);
310 float32x4_t vout6x4567 = vcvtq_f32_s32(vacc6x4567);
311 float32x4_t vout7x0123 = vcvtq_f32_s32(vacc7x0123);
312 float32x4_t vout7x4567 = vcvtq_f32_s32(vacc7x4567);
313 vout0x0123 = vmulq_f32(vout0x0123, vinput_scale);
314 vout1x0123 = vmulq_f32(vout1x0123, vinput_scale);
315 vout0x4567 = vmulq_f32(vout0x4567, vinput_scale);
316 vout1x4567 = vmulq_f32(vout1x4567, vinput_scale);
317 vout2x0123 = vmulq_f32(vout2x0123, vinput_scale);
318 vout3x0123 = vmulq_f32(vout3x0123, vinput_scale);
319 vout2x4567 = vmulq_f32(vout2x4567, vinput_scale);
320 vout3x4567 = vmulq_f32(vout3x4567, vinput_scale);
321 vout4x0123 = vmulq_f32(vout4x0123, vinput_scale);
322 vout5x0123 = vmulq_f32(vout5x0123, vinput_scale);
323 vout4x4567 = vmulq_f32(vout4x4567, vinput_scale);
324 vout5x4567 = vmulq_f32(vout5x4567, vinput_scale);
325 vout6x0123 = vmulq_f32(vout6x0123, vinput_scale);
326 vout7x0123 = vmulq_f32(vout7x0123, vinput_scale);
327 vout6x4567 = vmulq_f32(vout6x4567, vinput_scale);
328 vout7x4567 = vmulq_f32(vout7x4567, vinput_scale);
329
330 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
331 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
332
333 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
334 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
335 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
336 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
337 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
338 vout4x0123 = vfmaq_f32(vbias0123, vout4x0123, vfilter_output_scale0123);
339 vout5x0123 = vfmaq_f32(vbias0123, vout5x0123, vfilter_output_scale0123);
340 vout6x0123 = vfmaq_f32(vbias0123, vout6x0123, vfilter_output_scale0123);
341 vout7x0123 = vfmaq_f32(vbias0123, vout7x0123, vfilter_output_scale0123);
342 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
343 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
344 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
345 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
346 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
347 vout4x4567 = vfmaq_f32(vbias4567, vout4x4567, vfilter_output_scale4567);
348 vout5x4567 = vfmaq_f32(vbias4567, vout5x4567, vfilter_output_scale4567);
349 vout6x4567 = vfmaq_f32(vbias4567, vout6x4567, vfilter_output_scale4567);
350 vout7x4567 = vfmaq_f32(vbias4567, vout7x4567, vfilter_output_scale4567);
351
352 float16x8_t vfp16out7x01234567 = vcombine_f16(vcvt_f16_f32(vout7x0123), vcvt_f16_f32(vout7x4567));
353 float16x8_t vfp16out6x01234567 = vcombine_f16(vcvt_f16_f32(vout6x0123), vcvt_f16_f32(vout6x4567));
354 float16x8_t vfp16out5x01234567 = vcombine_f16(vcvt_f16_f32(vout5x0123), vcvt_f16_f32(vout5x4567));
355 float16x8_t vfp16out4x01234567 = vcombine_f16(vcvt_f16_f32(vout4x0123), vcvt_f16_f32(vout4x4567));
356 float16x8_t vfp16out3x01234567 = vcombine_f16(vcvt_f16_f32(vout3x0123), vcvt_f16_f32(vout3x4567));
357 float16x8_t vfp16out2x01234567 = vcombine_f16(vcvt_f16_f32(vout2x0123), vcvt_f16_f32(vout2x4567));
358 float16x8_t vfp16out1x01234567 = vcombine_f16(vcvt_f16_f32(vout1x0123), vcvt_f16_f32(vout1x4567));
359 float16x8_t vfp16out0x01234567 = vcombine_f16(vcvt_f16_f32(vout0x0123), vcvt_f16_f32(vout0x4567));
360 const float16x8_t voutput_min = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
361 vfp16out7x01234567 = vmaxq_f16(vfp16out7x01234567, voutput_min);
362 vfp16out6x01234567 = vmaxq_f16(vfp16out6x01234567, voutput_min);
363 vfp16out5x01234567 = vmaxq_f16(vfp16out5x01234567, voutput_min);
364 vfp16out4x01234567 = vmaxq_f16(vfp16out4x01234567, voutput_min);
365 vfp16out3x01234567 = vmaxq_f16(vfp16out3x01234567, voutput_min);
366 vfp16out2x01234567 = vmaxq_f16(vfp16out2x01234567, voutput_min);
367 vfp16out1x01234567 = vmaxq_f16(vfp16out1x01234567, voutput_min);
368 vfp16out0x01234567 = vmaxq_f16(vfp16out0x01234567, voutput_min);
369 const float16x8_t voutput_max = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
370 vfp16out7x01234567 = vminq_f16(vfp16out7x01234567, voutput_max);
371 vfp16out6x01234567 = vminq_f16(vfp16out6x01234567, voutput_max);
372 vfp16out5x01234567 = vminq_f16(vfp16out5x01234567, voutput_max);
373 vfp16out4x01234567 = vminq_f16(vfp16out4x01234567, voutput_max);
374 vfp16out3x01234567 = vminq_f16(vfp16out3x01234567, voutput_max);
375 vfp16out2x01234567 = vminq_f16(vfp16out2x01234567, voutput_max);
376 vfp16out1x01234567 = vminq_f16(vfp16out1x01234567, voutput_max);
377 vfp16out0x01234567 = vminq_f16(vfp16out0x01234567, voutput_max);
378
379 if XNN_LIKELY(nc >= 8) {
380 vst1q_u16(c7, vreinterpretq_u16_f16(vfp16out7x01234567));
381 vst1q_u16(c6, vreinterpretq_u16_f16(vfp16out6x01234567));
382 vst1q_u16(c5, vreinterpretq_u16_f16(vfp16out5x01234567));
383 vst1q_u16(c4, vreinterpretq_u16_f16(vfp16out4x01234567));
384 vst1q_u16(c3, vreinterpretq_u16_f16(vfp16out3x01234567));
385 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567));
386 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567));
387 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567));
388
389 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
390 c1 = (uint16_t*) ((uintptr_t) c1 + cn_stride);
391 c2 = (uint16_t*) ((uintptr_t) c2 + cn_stride);
392 c3 = (uint16_t*) ((uintptr_t) c3 + cn_stride);
393 c4 = (uint16_t*) ((uintptr_t) c4 + cn_stride);
394 c5 = (uint16_t*) ((uintptr_t) c5 + cn_stride);
395 c6 = (uint16_t*) ((uintptr_t) c6 + cn_stride);
396 c7 = (uint16_t*) ((uintptr_t) c7 + cn_stride);
397
398 a = (const int8_t**restrict) ((uintptr_t) a - ks);
399
400 nc -= 8;
401 } else {
402 float16x4_t vfp16out7x0123 = vget_low_f16(vfp16out7x01234567);
403 float16x4_t vfp16out6x0123 = vget_low_f16(vfp16out6x01234567);
404 float16x4_t vfp16out5x0123 = vget_low_f16(vfp16out5x01234567);
405 float16x4_t vfp16out4x0123 = vget_low_f16(vfp16out4x01234567);
406 float16x4_t vfp16out3x0123 = vget_low_f16(vfp16out3x01234567);
407 float16x4_t vfp16out2x0123 = vget_low_f16(vfp16out2x01234567);
408 float16x4_t vfp16out1x0123 = vget_low_f16(vfp16out1x01234567);
409 float16x4_t vfp16out0x0123 = vget_low_f16(vfp16out0x01234567);
410 if (nc & 4) {
411 vst1_u16(c7, vreinterpret_u16_f16(vfp16out7x0123)); c7 += 4;
412 vst1_u16(c6, vreinterpret_u16_f16(vfp16out6x0123)); c6 += 4;
413 vst1_u16(c5, vreinterpret_u16_f16(vfp16out5x0123)); c5 += 4;
414 vst1_u16(c4, vreinterpret_u16_f16(vfp16out4x0123)); c4 += 4;
415 vst1_u16(c3, vreinterpret_u16_f16(vfp16out3x0123)); c3 += 4;
416 vst1_u16(c2, vreinterpret_u16_f16(vfp16out2x0123)); c2 += 4;
417 vst1_u16(c1, vreinterpret_u16_f16(vfp16out1x0123)); c1 += 4;
418 vst1_u16(c0, vreinterpret_u16_f16(vfp16out0x0123)); c0 += 4;
419 vfp16out7x0123 = vget_high_f16(vfp16out7x01234567);
420 vfp16out6x0123 = vget_high_f16(vfp16out6x01234567);
421 vfp16out5x0123 = vget_high_f16(vfp16out5x01234567);
422 vfp16out4x0123 = vget_high_f16(vfp16out4x01234567);
423 vfp16out3x0123 = vget_high_f16(vfp16out3x01234567);
424 vfp16out2x0123 = vget_high_f16(vfp16out2x01234567);
425 vfp16out1x0123 = vget_high_f16(vfp16out1x01234567);
426 vfp16out0x0123 = vget_high_f16(vfp16out0x01234567);
427 }
428 if (nc & 2) {
429 vst1_lane_u32((void*) c7, vreinterpret_u32_f16(vfp16out7x0123), 0); c7 += 2;
430 vst1_lane_u32((void*) c6, vreinterpret_u32_f16(vfp16out6x0123), 0); c6 += 2;
431 vst1_lane_u32((void*) c5, vreinterpret_u32_f16(vfp16out5x0123), 0); c5 += 2;
432 vst1_lane_u32((void*) c4, vreinterpret_u32_f16(vfp16out4x0123), 0); c4 += 2;
433 vst1_lane_u32((void*) c3, vreinterpret_u32_f16(vfp16out3x0123), 0); c3 += 2;
434 vst1_lane_u32((void*) c2, vreinterpret_u32_f16(vfp16out2x0123), 0); c2 += 2;
435 vst1_lane_u32((void*) c1, vreinterpret_u32_f16(vfp16out1x0123), 0); c1 += 2;
436 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vfp16out0x0123), 0); c0 += 2;
437 vfp16out7x0123 = vext_f16(vfp16out7x0123, vfp16out7x0123, 2);
438 vfp16out6x0123 = vext_f16(vfp16out6x0123, vfp16out6x0123, 2);
439 vfp16out5x0123 = vext_f16(vfp16out5x0123, vfp16out5x0123, 2);
440 vfp16out4x0123 = vext_f16(vfp16out4x0123, vfp16out4x0123, 2);
441 vfp16out3x0123 = vext_f16(vfp16out3x0123, vfp16out3x0123, 2);
442 vfp16out2x0123 = vext_f16(vfp16out2x0123, vfp16out2x0123, 2);
443 vfp16out1x0123 = vext_f16(vfp16out1x0123, vfp16out1x0123, 2);
444 vfp16out0x0123 = vext_f16(vfp16out0x0123, vfp16out0x0123, 2);
445 }
446 if (nc & 1) {
447 vst1_lane_u16(c7, vreinterpret_u16_f16(vfp16out7x0123), 0);
448 vst1_lane_u16(c6, vreinterpret_u16_f16(vfp16out6x0123), 0);
449 vst1_lane_u16(c5, vreinterpret_u16_f16(vfp16out5x0123), 0);
450 vst1_lane_u16(c4, vreinterpret_u16_f16(vfp16out4x0123), 0);
451 vst1_lane_u16(c3, vreinterpret_u16_f16(vfp16out3x0123), 0);
452 vst1_lane_u16(c2, vreinterpret_u16_f16(vfp16out2x0123), 0);
453 vst1_lane_u16(c1, vreinterpret_u16_f16(vfp16out1x0123), 0);
454 vst1_lane_u16(c0, vreinterpret_u16_f16(vfp16out0x0123), 0);
455 }
456 nc = 0;
457 }
458 } while (nc != 0);
459 }