Debian Codegraph @

src/qd8-f16-qc8w-igemm/gen/qd8-f16-qc8w-igemm-6x8c8-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_6x8c8__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 <= 6);
36 assert(nc != 0);
37 assert(kc != 0);
38 assert(ks != 0);
39 assert(ks % (6 * 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
68 do {
69 const int32x4_t vinput_zero_point = vld1q_dup_s32(&quantization_params->zero_point);
70 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
71 const int32x4_t vksumzp0x0123 = vmulq_s32(vksum0123, vinput_zero_point);
72 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
73 const int32x4_t vksumzp0x4567 = vmulq_s32(vksum4567, vinput_zero_point);
74 const int32x4_t vksumzp1x0123 = vksumzp0x0123;
75 const int32x4_t vksumzp1x4567 = vksumzp0x4567;
76 const int32x4_t vksumzp2x0123 = vksumzp0x0123;
77 const int32x4_t vksumzp2x4567 = vksumzp0x4567;
78 const int32x4_t vksumzp3x0123 = vksumzp0x0123;
79 const int32x4_t vksumzp3x4567 = vksumzp0x4567;
80 const int32x4_t vksumzp4x0123 = vksumzp0x0123;
81 const int32x4_t vksumzp4x4567 = vksumzp0x4567;
82 const int32x4_t vksumzp5x0123 = vksumzp0x0123;
83 const int32x4_t vksumzp5x4567 = vksumzp0x4567;
84
85 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
86 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
87 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
88 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
89 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
90 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
91 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
92 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
93 int32x4_t vacc45x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
94 int32x4_t vacc45x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x0123), vreinterpretq_u64_s32(vksumzp5x0123)));
95 int32x4_t vacc45x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
96 int32x4_t vacc45x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp4x4567), vreinterpretq_u64_s32(vksumzp5x4567)));
97
98 size_t p = ks;
99 do {
100 const int8_t* restrict a0 = a[0];
101 if XNN_UNPREDICTABLE(a0 != zero) {
102 a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
103 } else {
104 a0 = zero_data;
105 }
106 const int8_t* restrict a1 = a[1];
107 if XNN_UNPREDICTABLE(a1 != zero) {
108 a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
109 } else {
110 a1 = zero_data;
111 }
112 const int8_t* restrict a2 = a[2];
113 if XNN_UNPREDICTABLE(a2 != zero) {
114 a2 = (const int8_t*) ((uintptr_t) a2 + a_offset);
115 } else {
116 a2 = zero_data;
117 }
118 const int8_t* restrict a3 = a[3];
119 if XNN_UNPREDICTABLE(a3 != zero) {
120 a3 = (const int8_t*) ((uintptr_t) a3 + a_offset);
121 } else {
122 a3 = zero_data;
123 }
124 const int8_t* restrict a4 = a[4];
125 if XNN_UNPREDICTABLE(a4 != zero) {
126 a4 = (const int8_t*) ((uintptr_t) a4 + a_offset);
127 } else {
128 a4 = zero_data;
129 }
130 const int8_t* restrict a5 = a[5];
131 if XNN_UNPREDICTABLE(a5 != zero) {
132 a5 = (const int8_t*) ((uintptr_t) a5 + a_offset);
133 } else {
134 a5 = zero_data;
135 }
136 a += 6;
137
138 uint64x2x2_t va01x0123456789ABCDEF;
139 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
140 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
141 uint64x2x2_t va23x0123456789ABCDEF;
142 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
143 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
144 uint64x2x2_t va45x0123456789ABCDEF;
145 va45x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
146 va45x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
147
148 // Inner accumulation loop along the 8 columns.
149 size_t k = kc;
150 // 2x partial unrolled loop to load 8 bytes at a time.
151 while (k >= 16 * sizeof(int8_t)) {
152 // Load a 6x16 block of activations.
153 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
154 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
155 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a4, va45x0123456789ABCDEF, 0); a4 += 16;
156 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
157 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
158 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a5, va45x0123456789ABCDEF, 1); a5 += 16;
159
160 // Load a 16x8 block of weights.
161 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
162 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
163 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
164 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
165 const int8x16_t vb01x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
166 const int8x16_t vb23x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
167 const int8x16_t vb45x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
168 const int8x16_t vb67x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
169
170 // Multiply-accumulate: 6x16 * 16x8 --> 6x8.
171 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb01x01234567);
172 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb23x01234567);
173 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb45x01234567);
174 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb67x01234567);
175 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb01x01234567);
176 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb23x01234567);
177 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb45x01234567);
178 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb67x01234567);
179 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb01x01234567);
180 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb23x01234567);
181 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb45x01234567);
182 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]), vb67x01234567);
183 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
184 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
185 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
186 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
187 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
188 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
189 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
190 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
191 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
192 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
193 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
194 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
195
196 k -= 16 * sizeof(int8_t);
197 }
198 // Handle up to 8 final positions of `k`
199 if XNN_UNLIKELY(k != 0) {
200 // Load a 6x8 block of activations.
201 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
202 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
203 uint64x2_t va45x01234567 = vld1q_dup_u64((const void*) a4); a4 += 8;
204 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
205 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
206 va45x01234567 = vld1q_lane_u64((const void*) a5, va45x01234567, 1); a5 += 8;
207
208 // Load a 16x8 block of weights.
209 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
210 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
211 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
212 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
213
214 // Multiply-accumulate: 6x4 * 4x8 --> 6x8.
215 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
216 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
217 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
218 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
219 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
220 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
221 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
222 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
223 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x01234567), vb01x01234567);
224 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x01234567), vb23x01234567);
225 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x01234567), vb45x01234567);
226 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x01234567), vb67x01234567);
227 }
228
229 p -= 6 * sizeof(void*);
230 } while (p != 0);
231
232 int32x4_t vacc0x0123 = vcombine_s32(vget_low_s32(vacc01x01), vget_low_s32(vacc01x23));
233 int32x4_t vacc1x0123 = vcombine_s32(vget_high_s32(vacc01x01), vget_high_s32(vacc01x23));
234 int32x4_t vacc0x4567 = vcombine_s32(vget_low_s32(vacc01x45), vget_low_s32(vacc01x67));
235 int32x4_t vacc1x4567 = vcombine_s32(vget_high_s32(vacc01x45), vget_high_s32(vacc01x67));
236 int32x4_t vacc2x0123 = vcombine_s32(vget_low_s32(vacc23x01), vget_low_s32(vacc23x23));
237 int32x4_t vacc3x0123 = vcombine_s32(vget_high_s32(vacc23x01), vget_high_s32(vacc23x23));
238 int32x4_t vacc2x4567 = vcombine_s32(vget_low_s32(vacc23x45), vget_low_s32(vacc23x67));
239 int32x4_t vacc3x4567 = vcombine_s32(vget_high_s32(vacc23x45), vget_high_s32(vacc23x67));
240 int32x4_t vacc4x0123 = vcombine_s32(vget_low_s32(vacc45x01), vget_low_s32(vacc45x23));
241 int32x4_t vacc5x0123 = vcombine_s32(vget_high_s32(vacc45x01), vget_high_s32(vacc45x23));
242 int32x4_t vacc4x4567 = vcombine_s32(vget_low_s32(vacc45x45), vget_low_s32(vacc45x67));
243 int32x4_t vacc5x4567 = vcombine_s32(vget_high_s32(vacc45x45), vget_high_s32(vacc45x67));
244
245 const float32x4_t vinput_scale = vld1q_dup_f32(&quantization_params->inv_scale);
246 float32x4_t vout0x0123 = vcvtq_f32_s32(vacc0x0123);
247 float32x4_t vout0x4567 = vcvtq_f32_s32(vacc0x4567);
248 float32x4_t vout1x0123 = vcvtq_f32_s32(vacc1x0123);
249 float32x4_t vout1x4567 = vcvtq_f32_s32(vacc1x4567);
250 float32x4_t vout2x0123 = vcvtq_f32_s32(vacc2x0123);
251 float32x4_t vout2x4567 = vcvtq_f32_s32(vacc2x4567);
252 float32x4_t vout3x0123 = vcvtq_f32_s32(vacc3x0123);
253 float32x4_t vout3x4567 = vcvtq_f32_s32(vacc3x4567);
254 float32x4_t vout4x0123 = vcvtq_f32_s32(vacc4x0123);
255 float32x4_t vout4x4567 = vcvtq_f32_s32(vacc4x4567);
256 float32x4_t vout5x0123 = vcvtq_f32_s32(vacc5x0123);
257 float32x4_t vout5x4567 = vcvtq_f32_s32(vacc5x4567);
258 vout0x0123 = vmulq_f32(vout0x0123, vinput_scale);
259 vout1x0123 = vmulq_f32(vout1x0123, vinput_scale);
260 vout0x4567 = vmulq_f32(vout0x4567, vinput_scale);
261 vout1x4567 = vmulq_f32(vout1x4567, vinput_scale);
262 vout2x0123 = vmulq_f32(vout2x0123, vinput_scale);
263 vout3x0123 = vmulq_f32(vout3x0123, vinput_scale);
264 vout2x4567 = vmulq_f32(vout2x4567, vinput_scale);
265 vout3x4567 = vmulq_f32(vout3x4567, vinput_scale);
266 vout4x0123 = vmulq_f32(vout4x0123, vinput_scale);
267 vout5x0123 = vmulq_f32(vout5x0123, vinput_scale);
268 vout4x4567 = vmulq_f32(vout4x4567, vinput_scale);
269 vout5x4567 = vmulq_f32(vout5x4567, vinput_scale);
270
271 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
272 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
273
274 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
275 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
276 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
277 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
278 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
279 vout4x0123 = vfmaq_f32(vbias0123, vout4x0123, vfilter_output_scale0123);
280 vout5x0123 = vfmaq_f32(vbias0123, vout5x0123, vfilter_output_scale0123);
281 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
282 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
283 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
284 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
285 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
286 vout4x4567 = vfmaq_f32(vbias4567, vout4x4567, vfilter_output_scale4567);
287 vout5x4567 = vfmaq_f32(vbias4567, vout5x4567, vfilter_output_scale4567);
288
289 float16x8_t vfp16out5x01234567 = vcombine_f16(vcvt_f16_f32(vout5x0123), vcvt_f16_f32(vout5x4567));
290 float16x8_t vfp16out4x01234567 = vcombine_f16(vcvt_f16_f32(vout4x0123), vcvt_f16_f32(vout4x4567));
291 float16x8_t vfp16out3x01234567 = vcombine_f16(vcvt_f16_f32(vout3x0123), vcvt_f16_f32(vout3x4567));
292 float16x8_t vfp16out2x01234567 = vcombine_f16(vcvt_f16_f32(vout2x0123), vcvt_f16_f32(vout2x4567));
293 float16x8_t vfp16out1x01234567 = vcombine_f16(vcvt_f16_f32(vout1x0123), vcvt_f16_f32(vout1x4567));
294 float16x8_t vfp16out0x01234567 = vcombine_f16(vcvt_f16_f32(vout0x0123), vcvt_f16_f32(vout0x4567));
295 const float16x8_t voutput_min = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
296 vfp16out5x01234567 = vmaxq_f16(vfp16out5x01234567, voutput_min);
297 vfp16out4x01234567 = vmaxq_f16(vfp16out4x01234567, voutput_min);
298 vfp16out3x01234567 = vmaxq_f16(vfp16out3x01234567, voutput_min);
299 vfp16out2x01234567 = vmaxq_f16(vfp16out2x01234567, voutput_min);
300 vfp16out1x01234567 = vmaxq_f16(vfp16out1x01234567, voutput_min);
301 vfp16out0x01234567 = vmaxq_f16(vfp16out0x01234567, voutput_min);
302 const float16x8_t voutput_max = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
303 vfp16out5x01234567 = vminq_f16(vfp16out5x01234567, voutput_max);
304 vfp16out4x01234567 = vminq_f16(vfp16out4x01234567, voutput_max);
305 vfp16out3x01234567 = vminq_f16(vfp16out3x01234567, voutput_max);
306 vfp16out2x01234567 = vminq_f16(vfp16out2x01234567, voutput_max);
307 vfp16out1x01234567 = vminq_f16(vfp16out1x01234567, voutput_max);
308 vfp16out0x01234567 = vminq_f16(vfp16out0x01234567, voutput_max);
309
310 if XNN_LIKELY(nc >= 8) {
311 vst1q_u16(c5, vreinterpretq_u16_f16(vfp16out5x01234567));
312 vst1q_u16(c4, vreinterpretq_u16_f16(vfp16out4x01234567));
313 vst1q_u16(c3, vreinterpretq_u16_f16(vfp16out3x01234567));
314 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567));
315 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567));
316 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567));
317
318 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
319 c1 = (uint16_t*) ((uintptr_t) c1 + cn_stride);
320 c2 = (uint16_t*) ((uintptr_t) c2 + cn_stride);
321 c3 = (uint16_t*) ((uintptr_t) c3 + cn_stride);
322 c4 = (uint16_t*) ((uintptr_t) c4 + cn_stride);
323 c5 = (uint16_t*) ((uintptr_t) c5 + cn_stride);
324
325 a = (const int8_t**restrict) ((uintptr_t) a - ks);
326
327 nc -= 8;
328 } else {
329 float16x4_t vfp16out5x0123 = vget_low_f16(vfp16out5x01234567);
330 float16x4_t vfp16out4x0123 = vget_low_f16(vfp16out4x01234567);
331 float16x4_t vfp16out3x0123 = vget_low_f16(vfp16out3x01234567);
332 float16x4_t vfp16out2x0123 = vget_low_f16(vfp16out2x01234567);
333 float16x4_t vfp16out1x0123 = vget_low_f16(vfp16out1x01234567);
334 float16x4_t vfp16out0x0123 = vget_low_f16(vfp16out0x01234567);
335 if (nc & 4) {
336 vst1_u16(c5, vreinterpret_u16_f16(vfp16out5x0123)); c5 += 4;
337 vst1_u16(c4, vreinterpret_u16_f16(vfp16out4x0123)); c4 += 4;
338 vst1_u16(c3, vreinterpret_u16_f16(vfp16out3x0123)); c3 += 4;
339 vst1_u16(c2, vreinterpret_u16_f16(vfp16out2x0123)); c2 += 4;
340 vst1_u16(c1, vreinterpret_u16_f16(vfp16out1x0123)); c1 += 4;
341 vst1_u16(c0, vreinterpret_u16_f16(vfp16out0x0123)); c0 += 4;
342 vfp16out5x0123 = vget_high_f16(vfp16out5x01234567);
343 vfp16out4x0123 = vget_high_f16(vfp16out4x01234567);
344 vfp16out3x0123 = vget_high_f16(vfp16out3x01234567);
345 vfp16out2x0123 = vget_high_f16(vfp16out2x01234567);
346 vfp16out1x0123 = vget_high_f16(vfp16out1x01234567);
347 vfp16out0x0123 = vget_high_f16(vfp16out0x01234567);
348 }
349 if (nc & 2) {
350 vst1_lane_u32((void*) c5, vreinterpret_u32_f16(vfp16out5x0123), 0); c5 += 2;
351 vst1_lane_u32((void*) c4, vreinterpret_u32_f16(vfp16out4x0123), 0); c4 += 2;
352 vst1_lane_u32((void*) c3, vreinterpret_u32_f16(vfp16out3x0123), 0); c3 += 2;
353 vst1_lane_u32((void*) c2, vreinterpret_u32_f16(vfp16out2x0123), 0); c2 += 2;
354 vst1_lane_u32((void*) c1, vreinterpret_u32_f16(vfp16out1x0123), 0); c1 += 2;
355 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vfp16out0x0123), 0); c0 += 2;
356 vfp16out5x0123 = vext_f16(vfp16out5x0123, vfp16out5x0123, 2);
357 vfp16out4x0123 = vext_f16(vfp16out4x0123, vfp16out4x0123, 2);
358 vfp16out3x0123 = vext_f16(vfp16out3x0123, vfp16out3x0123, 2);
359 vfp16out2x0123 = vext_f16(vfp16out2x0123, vfp16out2x0123, 2);
360 vfp16out1x0123 = vext_f16(vfp16out1x0123, vfp16out1x0123, 2);
361 vfp16out0x0123 = vext_f16(vfp16out0x0123, vfp16out0x0123, 2);
362 }
363 if (nc & 1) {
364 vst1_lane_u16(c5, vreinterpret_u16_f16(vfp16out5x0123), 0);
365 vst1_lane_u16(c4, vreinterpret_u16_f16(vfp16out4x0123), 0);
366 vst1_lane_u16(c3, vreinterpret_u16_f16(vfp16out3x0123), 0);
367 vst1_lane_u16(c2, vreinterpret_u16_f16(vfp16out2x0123), 0);
368 vst1_lane_u16(c1, vreinterpret_u16_f16(vfp16out1x0123), 0);
369 vst1_lane_u16(c0, vreinterpret_u16_f16(vfp16out0x0123), 0);
370 }
371 nc = 0;
372 }
373 } while (nc != 0);
374 }