Debian Codegraph @

src/qd8-f16-qc4w-gemm/gen/qd8-f16-qc4w-gemm-6x8c8-minmax-neoni8mm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/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/gemm.h"
15 #include "xnnpack/math.h"
16
17
18 void xnn_qd8_f16_qc4w_gemm_minmax_ukernel_6x8c8__neoni8mm(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const int8_t* restrict a,
23 size_t a_stride,
24 const void* restrict w,
25 xnn_float16* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const struct xnn_f16_qc4w_minmax_params params[restrict XNN_MIN_ELEMENTS(1)],
29 const struct xnn_qd8_quantization_params quantization_params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31 assert(mr != 0);
32 assert(mr <= 6);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(int8_t) == 0);
36 assert(a != NULL);
37 assert(w != NULL);
38 assert(c != NULL);
39
40 kc = round_up_po2(kc, 8 * sizeof(int8_t));
41 const int8_t* a0 = a;
42 uint16_t* c0 = (uint16_t*) c;
43 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
44 uint16_t* c1 = (uint16_t*) ((uintptr_t) c0 + cm_stride);
45 if XNN_UNPREDICTABLE(mr < 2) {
46 a1 = a0;
47 c1 = c0;
48 }
49 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
50 uint16_t* c2 = (uint16_t*) ((uintptr_t) c1 + cm_stride);
51 if XNN_UNPREDICTABLE(mr <= 2) {
52 a2 = a1;
53 c2 = c1;
54 }
55 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
56 uint16_t* c3 = (uint16_t*) ((uintptr_t) c2 + cm_stride);
57 if XNN_UNPREDICTABLE(mr < 4) {
58 a3 = a2;
59 c3 = c2;
60 }
61 const int8_t* a4 = (const int8_t*) ((uintptr_t) a3 + a_stride);
62 uint16_t* c4 = (uint16_t*) ((uintptr_t) c3 + cm_stride);
63 if XNN_UNPREDICTABLE(mr <= 4) {
64 a4 = a3;
65 c4 = c3;
66 }
67 const int8_t* a5 = (const int8_t*) ((uintptr_t) a4 + a_stride);
68 uint16_t* c5 = (uint16_t*) ((uintptr_t) c4 + cm_stride);
69 if XNN_UNPREDICTABLE(mr != 6) {
70 a5 = a4;
71 c5 = c4;
72 }
73 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
74
75 // Loop over groups of 8 columns.
76 do {
77 // Initialize accumulators with bias. 8 bias values are loaded from the
78 // weight matrix, at the start of the group of 8 columns.
79 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
80 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
81 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
82 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
83 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
84 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
85 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
86 const int32x4_t vinput_zero_point23 = vld1q_s32(&quantization_params[2].zero_point);
87 const int32x4_t vksumzp2x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point23), 0);
88 const int32x4_t vksumzp3x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point23), 0);
89 const int32x4_t vksumzp2x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point23), 0);
90 const int32x4_t vksumzp3x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point23), 0);
91 const int32x4_t vinput_zero_point45 = vld1q_s32(&quantization_params[4].zero_point);
92 const int32x4_t vksumzp4x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point45), 0);
93 const int32x4_t vksumzp5x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point45), 0);
94 const int32x4_t vksumzp4x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point45), 0);
95 const int32x4_t vksumzp5x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point45), 0);
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
110 // Inner accumulation loop along the 8 columns.
111 size_t k = kc;
112 // 2x partial unrolled loop to load 8 bytes at a time.
113
114 uint64x2x2_t va01x0123456789ABCDEF;
115 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
116 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
117 uint64x2x2_t va23x0123456789ABCDEF;
118 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
119 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
120 uint64x2x2_t va45x0123456789ABCDEF;
121 va45x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
122 va45x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
123
124 while (k >= 16 * sizeof(int8_t)) {
125 // Load a 6x16 block of activations.
126 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
127 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
128 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a4, va45x0123456789ABCDEF, 0); a4 += 16;
129 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
130 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
131 va45x0123456789ABCDEF = vld2q_lane_u64((const void*) a5, va45x0123456789ABCDEF, 1); a5 += 16;
132
133 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
134 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
135 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
136 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
137 const int8x16_t va45x01234567 = vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[0]);
138 const int8x16_t va45x89ABCDEF = vreinterpretq_s8_u64(va45x0123456789ABCDEF.val[1]);
139
140 // Load a 16x8 block of weights.
141 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
142 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
143 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
144 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
145 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
146 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
147 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
148 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
149 const int8x16_t vb01x89ABCDEF = vandq_s8(vb01x0123456789ABCDEF, vmask);
150 const int8x16_t vb23x89ABCDEF = vandq_s8(vb23x0123456789ABCDEF, vmask);
151 const int8x16_t vb45x89ABCDEF = vandq_s8(vb45x0123456789ABCDEF, vmask);
152 const int8x16_t vb67x89ABCDEF = vandq_s8(vb67x0123456789ABCDEF, vmask);
153
154 // Multiply-accumulate: 6x8 * 8x8 --> 6x8.
155 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
156 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
157 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
158 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
159 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
160 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
161 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
162 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
163 vacc45x01 = vmmlaq_s32(vacc45x01, va45x01234567, vb01x01234567);
164 vacc45x23 = vmmlaq_s32(vacc45x23, va45x01234567, vb23x01234567);
165 vacc45x45 = vmmlaq_s32(vacc45x45, va45x01234567, vb45x01234567);
166 vacc45x67 = vmmlaq_s32(vacc45x67, va45x01234567, vb67x01234567);
167 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
168 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
169 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
170 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
171 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
172 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
173 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
174 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
175 vacc45x01 = vmmlaq_s32(vacc45x01, va45x89ABCDEF, vb01x89ABCDEF);
176 vacc45x23 = vmmlaq_s32(vacc45x23, va45x89ABCDEF, vb23x89ABCDEF);
177 vacc45x45 = vmmlaq_s32(vacc45x45, va45x89ABCDEF, vb45x89ABCDEF);
178 vacc45x67 = vmmlaq_s32(vacc45x67, va45x89ABCDEF, vb67x89ABCDEF);
179
180 k -= 16 * sizeof(int8_t);
181 }
182 // Handle up to 8 final positions of `k`
183 if XNN_UNLIKELY(k != 0) {
184 // Load a 6x8 block of activations.
185 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
186 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
187 uint64x2_t va45x01234567 = vld1q_dup_u64((const void*) a4); a4 += 8;
188 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
189 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
190 va45x01234567 = vld1q_lane_u64((const void*) a5, va45x01234567, 1); a5 += 8;
191
192 // Load a 16x8 block of weights.
193 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
194 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
198 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
199 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
200 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
201
202 // Multiply-accumulate: 6x4 * 4x8 --> 6x8.
203 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
204 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
205 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
206 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
207 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
208 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
209 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
210 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
211 vacc45x01 = vmmlaq_s32(vacc45x01, vreinterpretq_s8_u64(va45x01234567), vb01x01234567);
212 vacc45x23 = vmmlaq_s32(vacc45x23, vreinterpretq_s8_u64(va45x01234567), vb23x01234567);
213 vacc45x45 = vmmlaq_s32(vacc45x45, vreinterpretq_s8_u64(va45x01234567), vb45x01234567);
214 vacc45x67 = vmmlaq_s32(vacc45x67, vreinterpretq_s8_u64(va45x01234567), vb67x01234567);
215 }
216
217 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
218 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
219 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
220 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
221 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
222 int32x4_t vacc3x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
223 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
224 int32x4_t vacc3x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
225 int32x4_t vacc4x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x01), vreinterpretq_u64_s32(vacc45x23)));
226 int32x4_t vacc5x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x01), vreinterpretq_u64_s32(vacc45x23)));
227 int32x4_t vacc4x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc45x45), vreinterpretq_u64_s32(vacc45x67)));
228 int32x4_t vacc5x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc45x45), vreinterpretq_u64_s32(vacc45x67)));
229 float32x4_t vout0x0123 = vcvtq_n_f32_s32(vacc0x0123, 4);
230 float32x4_t vout0x4567 = vcvtq_n_f32_s32(vacc0x4567, 4);
231 float32x4_t vout1x0123 = vcvtq_n_f32_s32(vacc1x0123, 4);
232 float32x4_t vout1x4567 = vcvtq_n_f32_s32(vacc1x4567, 4);
233 float32x4_t vout2x0123 = vcvtq_n_f32_s32(vacc2x0123, 4);
234 float32x4_t vout2x4567 = vcvtq_n_f32_s32(vacc2x4567, 4);
235 float32x4_t vout3x0123 = vcvtq_n_f32_s32(vacc3x0123, 4);
236 float32x4_t vout3x4567 = vcvtq_n_f32_s32(vacc3x4567, 4);
237 float32x4_t vout4x0123 = vcvtq_n_f32_s32(vacc4x0123, 4);
238 float32x4_t vout4x4567 = vcvtq_n_f32_s32(vacc4x4567, 4);
239 float32x4_t vout5x0123 = vcvtq_n_f32_s32(vacc5x0123, 4);
240 float32x4_t vout5x4567 = vcvtq_n_f32_s32(vacc5x4567, 4);
241
242 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
243 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
244 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
245 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
246 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
247 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
248 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
249 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
250 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
251 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
252 const float32x4_t vinput_scale45 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[4].zero_point));
253 vout4x0123 = vmulq_lane_f32(vout4x0123, vget_low_f32(vinput_scale45), 1);
254 vout5x0123 = vmulq_lane_f32(vout5x0123, vget_high_f32(vinput_scale45), 1);
255 vout4x4567 = vmulq_lane_f32(vout4x4567, vget_low_f32(vinput_scale45), 1);
256 vout5x4567 = vmulq_lane_f32(vout5x4567, vget_high_f32(vinput_scale45), 1);
257
258 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
259 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
260
261 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
262 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
263 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
264 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
265 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
266 vout4x0123 = vfmaq_f32(vbias0123, vout4x0123, vfilter_output_scale0123);
267 vout5x0123 = vfmaq_f32(vbias0123, vout5x0123, vfilter_output_scale0123);
268 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
269 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
270 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
271 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
272 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
273 vout4x4567 = vfmaq_f32(vbias4567, vout4x4567, vfilter_output_scale4567);
274 vout5x4567 = vfmaq_f32(vbias4567, vout5x4567, vfilter_output_scale4567);
275
276 float16x8_t vfp16out0x01234567 = vcombine_f16(vcvt_f16_f32(vout0x0123), vcvt_f16_f32(vout0x4567));
277 float16x8_t vfp16out1x01234567 = vcombine_f16(vcvt_f16_f32(vout1x0123), vcvt_f16_f32(vout1x4567));
278 float16x8_t vfp16out2x01234567 = vcombine_f16(vcvt_f16_f32(vout2x0123), vcvt_f16_f32(vout2x4567));
279 float16x8_t vfp16out3x01234567 = vcombine_f16(vcvt_f16_f32(vout3x0123), vcvt_f16_f32(vout3x4567));
280 float16x8_t vfp16out4x01234567 = vcombine_f16(vcvt_f16_f32(vout4x0123), vcvt_f16_f32(vout4x4567));
281 float16x8_t vfp16out5x01234567 = vcombine_f16(vcvt_f16_f32(vout5x0123), vcvt_f16_f32(vout5x4567));
282
283 const float16x8_t voutput_min = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
284 vfp16out0x01234567 = vmaxq_f16(vfp16out0x01234567, voutput_min);
285 vfp16out1x01234567 = vmaxq_f16(vfp16out1x01234567, voutput_min);
286 vfp16out2x01234567 = vmaxq_f16(vfp16out2x01234567, voutput_min);
287 vfp16out3x01234567 = vmaxq_f16(vfp16out3x01234567, voutput_min);
288 vfp16out4x01234567 = vmaxq_f16(vfp16out4x01234567, voutput_min);
289 vfp16out5x01234567 = vmaxq_f16(vfp16out5x01234567, voutput_min);
290 const float16x8_t voutput_max = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
291 vfp16out0x01234567 = vminq_f16(vfp16out0x01234567, voutput_max);
292 vfp16out1x01234567 = vminq_f16(vfp16out1x01234567, voutput_max);
293 vfp16out2x01234567 = vminq_f16(vfp16out2x01234567, voutput_max);
294 vfp16out3x01234567 = vminq_f16(vfp16out3x01234567, voutput_max);
295 vfp16out4x01234567 = vminq_f16(vfp16out4x01234567, voutput_max);
296 vfp16out5x01234567 = vminq_f16(vfp16out5x01234567, voutput_max);
297 if XNN_LIKELY(nc >= 8) {
298 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567));
299 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567));
300 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567));
301 vst1q_u16(c3, vreinterpretq_u16_f16(vfp16out3x01234567));
302 vst1q_u16(c4, vreinterpretq_u16_f16(vfp16out4x01234567));
303 vst1q_u16(c5, vreinterpretq_u16_f16(vfp16out5x01234567));
304
305 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
306 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
307 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
308 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
309 a4 = (const int8_t*) ((uintptr_t) a4 - kc);
310 a5 = (const int8_t*) ((uintptr_t) a5 - kc);
311
312 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
313 c1 = (uint16_t*) ((uintptr_t) c1 + cn_stride);
314 c2 = (uint16_t*) ((uintptr_t) c2 + cn_stride);
315 c3 = (uint16_t*) ((uintptr_t) c3 + cn_stride);
316 c4 = (uint16_t*) ((uintptr_t) c4 + cn_stride);
317 c5 = (uint16_t*) ((uintptr_t) c5 + cn_stride);
318
319 nc -= 8;
320 } else {
321 float16x4_t vfp16out0x0123 = vget_low_f16(vfp16out0x01234567);
322 float16x4_t vfp16out1x0123 = vget_low_f16(vfp16out1x01234567);
323 float16x4_t vfp16out2x0123 = vget_low_f16(vfp16out2x01234567);
324 float16x4_t vfp16out3x0123 = vget_low_f16(vfp16out3x01234567);
325 float16x4_t vfp16out4x0123 = vget_low_f16(vfp16out4x01234567);
326 float16x4_t vfp16out5x0123 = vget_low_f16(vfp16out5x01234567);
327 if (nc & 4) {
328 vst1_u16(c0, vreinterpret_u16_f16(vfp16out0x0123)); c0 += 4;
329 vst1_u16(c1, vreinterpret_u16_f16(vfp16out1x0123)); c1 += 4;
330 vst1_u16(c2, vreinterpret_u16_f16(vfp16out2x0123)); c2 += 4;
331 vst1_u16(c3, vreinterpret_u16_f16(vfp16out3x0123)); c3 += 4;
332 vst1_u16(c4, vreinterpret_u16_f16(vfp16out4x0123)); c4 += 4;
333 vst1_u16(c5, vreinterpret_u16_f16(vfp16out5x0123)); c5 += 4;
334 vfp16out0x0123 = vget_high_f16(vfp16out0x01234567);
335 vfp16out1x0123 = vget_high_f16(vfp16out1x01234567);
336 vfp16out2x0123 = vget_high_f16(vfp16out2x01234567);
337 vfp16out3x0123 = vget_high_f16(vfp16out3x01234567);
338 vfp16out4x0123 = vget_high_f16(vfp16out4x01234567);
339 vfp16out5x0123 = vget_high_f16(vfp16out5x01234567);
340 }
341 if (nc & 2) {
342 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vfp16out0x0123), 0); c0 += 2;
343 vst1_lane_u32((void*) c1, vreinterpret_u32_f16(vfp16out1x0123), 0); c1 += 2;
344 vst1_lane_u32((void*) c2, vreinterpret_u32_f16(vfp16out2x0123), 0); c2 += 2;
345 vst1_lane_u32((void*) c3, vreinterpret_u32_f16(vfp16out3x0123), 0); c3 += 2;
346 vst1_lane_u32((void*) c4, vreinterpret_u32_f16(vfp16out4x0123), 0); c4 += 2;
347 vst1_lane_u32((void*) c5, vreinterpret_u32_f16(vfp16out5x0123), 0); c5 += 2;
348 vfp16out0x0123 = vext_f16(vfp16out0x0123, vfp16out0x0123, 2);
349 vfp16out1x0123 = vext_f16(vfp16out1x0123, vfp16out1x0123, 2);
350 vfp16out2x0123 = vext_f16(vfp16out2x0123, vfp16out2x0123, 2);
351 vfp16out3x0123 = vext_f16(vfp16out3x0123, vfp16out3x0123, 2);
352 vfp16out4x0123 = vext_f16(vfp16out4x0123, vfp16out4x0123, 2);
353 vfp16out5x0123 = vext_f16(vfp16out5x0123, vfp16out5x0123, 2);
354 }
355 if (nc & 1) {
356 vst1_lane_u16(c0, vreinterpret_u16_f16(vfp16out0x0123), 0);
357 vst1_lane_u16(c1, vreinterpret_u16_f16(vfp16out1x0123), 0);
358 vst1_lane_u16(c2, vreinterpret_u16_f16(vfp16out2x0123), 0);
359 vst1_lane_u16(c3, vreinterpret_u16_f16(vfp16out3x0123), 0);
360 vst1_lane_u16(c4, vreinterpret_u16_f16(vfp16out4x0123), 0);
361 vst1_lane_u16(c5, vreinterpret_u16_f16(vfp16out5x0123), 0);
362 }
363 nc = 0;
364 }
365 } while (nc != 0);
366 }