Debian Codegraph @

src/qd8-f16-qc8w-gemm/gen/qd8-f16-qc8w-gemm-2x32c8-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_qc8w_gemm_minmax_ukernel_2x32c8__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 union xnn_f16_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 <= 2);
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
50 // Loop over groups of 32 columns.
51 do {
52 // Initialize accumulators with bias. 32 bias values are loaded from the
53 // weight matrix, at the start of the group of 32 columns.
54 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
55 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
56 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
57 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
58 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
59 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
60 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
61 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
62 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
63 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
64 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
65 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
66 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
67 const int32x4_t vksumGHIJ = vld1q_s32(w); w = (const int32_t*) w + 4;
68 const int32x4_t vksumzp0xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_low_s32(vinput_zero_point01), 0);
69 const int32x4_t vksumzp1xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_high_s32(vinput_zero_point01), 0);
70 const int32x4_t vksumKLMN = vld1q_s32(w); w = (const int32_t*) w + 4;
71 const int32x4_t vksumzp0xKLMN = vmulq_lane_s32(vksumKLMN, vget_low_s32(vinput_zero_point01), 0);
72 const int32x4_t vksumzp1xKLMN = vmulq_lane_s32(vksumKLMN, vget_high_s32(vinput_zero_point01), 0);
73 const int32x4_t vksumOPQR = vld1q_s32(w); w = (const int32_t*) w + 4;
74 const int32x4_t vksumzp0xOPQR = vmulq_lane_s32(vksumOPQR, vget_low_s32(vinput_zero_point01), 0);
75 const int32x4_t vksumzp1xOPQR = vmulq_lane_s32(vksumOPQR, vget_high_s32(vinput_zero_point01), 0);
76 const int32x4_t vksumSTUV = vld1q_s32(w); w = (const int32_t*) w + 4;
77 const int32x4_t vksumzp0xSTUV = vmulq_lane_s32(vksumSTUV, vget_low_s32(vinput_zero_point01), 0);
78 const int32x4_t vksumzp1xSTUV = vmulq_lane_s32(vksumSTUV, vget_high_s32(vinput_zero_point01), 0);
79
80 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
81 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
82 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
83 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
84 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
85 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
86 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
87 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
88 int32x4_t vacc01xGH = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
89 int32x4_t vacc01xIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
90 int32x4_t vacc01xKL = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
91 int32x4_t vacc01xMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
92 int32x4_t vacc01xOP = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
93 int32x4_t vacc01xQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
94 int32x4_t vacc01xST = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
95 int32x4_t vacc01xUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
96
97 // Inner accumulation loop along the 32 columns.
98 size_t k = kc;
99 // 2x partial unrolled loop to load 8 bytes at a time.
100
101 uint64x2x2_t va01x0123456789ABCDEF;
102 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
103 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
104
105 while (k >= 16 * sizeof(int8_t)) {
106 // Load a 2x16 block of activations.
107 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
108 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
109
110 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
111 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
112
113 // Load a 16x32 block of weights.
114 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
115 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
116 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
117 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
118 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
119 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
120 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
121 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
122 const int8x16_t vbGHx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
123 const int8x16_t vbIJx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
124 const int8x16_t vbKLx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
125 const int8x16_t vbMNx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
126 const int8x16_t vbOPx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
127 const int8x16_t vbQRx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
128 const int8x16_t vbSTx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
129 const int8x16_t vbUVx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
130 const int8x16_t vb01x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
131 const int8x16_t vb23x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
132 const int8x16_t vb45x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
133 const int8x16_t vb67x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
134 const int8x16_t vb89x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
135 const int8x16_t vbABx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
136 const int8x16_t vbCDx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
137 const int8x16_t vbEFx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
138 const int8x16_t vbGHx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
139 const int8x16_t vbIJx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
140 const int8x16_t vbKLx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
141 const int8x16_t vbMNx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
142 const int8x16_t vbOPx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
143 const int8x16_t vbQRx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
144 const int8x16_t vbSTx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
145 const int8x16_t vbUVx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
146
147 // Multiply-accumulate: 2x8 * 8x32 --> 2x32.
148 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
149 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
150 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
151 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
152 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
153 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
154 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
155 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
156 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x01234567, vbGHx01234567);
157 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x01234567, vbIJx01234567);
158 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x01234567, vbKLx01234567);
159 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x01234567, vbMNx01234567);
160 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x01234567, vbOPx01234567);
161 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x01234567, vbQRx01234567);
162 vacc01xST = vmmlaq_s32(vacc01xST, va01x01234567, vbSTx01234567);
163 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x01234567, vbUVx01234567);
164 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
165 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
166 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
167 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
168 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
169 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
170 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
171 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
172 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x89ABCDEF, vbGHx89ABCDEF);
173 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x89ABCDEF, vbIJx89ABCDEF);
174 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x89ABCDEF, vbKLx89ABCDEF);
175 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x89ABCDEF, vbMNx89ABCDEF);
176 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x89ABCDEF, vbOPx89ABCDEF);
177 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x89ABCDEF, vbQRx89ABCDEF);
178 vacc01xST = vmmlaq_s32(vacc01xST, va01x89ABCDEF, vbSTx89ABCDEF);
179 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x89ABCDEF, vbUVx89ABCDEF);
180
181 k -= 16 * sizeof(int8_t);
182 }
183 // Handle up to 8 final positions of `k`
184 if XNN_UNLIKELY(k != 0) {
185 // Load a 2x8 block of activations.
186 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
187 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
188
189 // Load a 16x32 block of weights.
190 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
191 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
192 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
193 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
194 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
198 const int8x16_t vbGHx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
199 const int8x16_t vbIJx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
200 const int8x16_t vbKLx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
201 const int8x16_t vbMNx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
202 const int8x16_t vbOPx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
203 const int8x16_t vbQRx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
204 const int8x16_t vbSTx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
205 const int8x16_t vbUVx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
206
207 // Multiply-accumulate: 2x4 * 4x32 --> 2x32.
208 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
209 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
210 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
211 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
212 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
213 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
214 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
215 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
216 vacc01xGH = vmmlaq_s32(vacc01xGH, vreinterpretq_s8_u64(va01x01234567), vbGHx01234567);
217 vacc01xIJ = vmmlaq_s32(vacc01xIJ, vreinterpretq_s8_u64(va01x01234567), vbIJx01234567);
218 vacc01xKL = vmmlaq_s32(vacc01xKL, vreinterpretq_s8_u64(va01x01234567), vbKLx01234567);
219 vacc01xMN = vmmlaq_s32(vacc01xMN, vreinterpretq_s8_u64(va01x01234567), vbMNx01234567);
220 vacc01xOP = vmmlaq_s32(vacc01xOP, vreinterpretq_s8_u64(va01x01234567), vbOPx01234567);
221 vacc01xQR = vmmlaq_s32(vacc01xQR, vreinterpretq_s8_u64(va01x01234567), vbQRx01234567);
222 vacc01xST = vmmlaq_s32(vacc01xST, vreinterpretq_s8_u64(va01x01234567), vbSTx01234567);
223 vacc01xUV = vmmlaq_s32(vacc01xUV, vreinterpretq_s8_u64(va01x01234567), vbUVx01234567);
224 }
225
226 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
227 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
228 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
229 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
230 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
231 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
232 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
233 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
234 int32x4_t vacc0xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
235 int32x4_t vacc1xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
236 int32x4_t vacc0xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
237 int32x4_t vacc1xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
238 int32x4_t vacc0xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
239 int32x4_t vacc1xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
240 int32x4_t vacc0xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
241 int32x4_t vacc1xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
242 float32x4_t vout0x0123 = vcvtq_f32_s32(vacc0x0123);
243 float32x4_t vout0x4567 = vcvtq_f32_s32(vacc0x4567);
244 float32x4_t vout0x89AB = vcvtq_f32_s32(vacc0x89AB);
245 float32x4_t vout0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
246 float32x4_t vout0xGHIJ = vcvtq_f32_s32(vacc0xGHIJ);
247 float32x4_t vout0xKLMN = vcvtq_f32_s32(vacc0xKLMN);
248 float32x4_t vout0xOPQR = vcvtq_f32_s32(vacc0xOPQR);
249 float32x4_t vout0xSTUV = vcvtq_f32_s32(vacc0xSTUV);
250 float32x4_t vout1x0123 = vcvtq_f32_s32(vacc1x0123);
251 float32x4_t vout1x4567 = vcvtq_f32_s32(vacc1x4567);
252 float32x4_t vout1x89AB = vcvtq_f32_s32(vacc1x89AB);
253 float32x4_t vout1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
254 float32x4_t vout1xGHIJ = vcvtq_f32_s32(vacc1xGHIJ);
255 float32x4_t vout1xKLMN = vcvtq_f32_s32(vacc1xKLMN);
256 float32x4_t vout1xOPQR = vcvtq_f32_s32(vacc1xOPQR);
257 float32x4_t vout1xSTUV = vcvtq_f32_s32(vacc1xSTUV);
258
259 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
260 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
261 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
262 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
263 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
264 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
265 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
266 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
267 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
268 vout0xGHIJ = vmulq_lane_f32(vout0xGHIJ, vget_low_f32(vinput_scale01), 1);
269 vout1xGHIJ = vmulq_lane_f32(vout1xGHIJ, vget_high_f32(vinput_scale01), 1);
270 vout0xKLMN = vmulq_lane_f32(vout0xKLMN, vget_low_f32(vinput_scale01), 1);
271 vout1xKLMN = vmulq_lane_f32(vout1xKLMN, vget_high_f32(vinput_scale01), 1);
272 vout0xOPQR = vmulq_lane_f32(vout0xOPQR, vget_low_f32(vinput_scale01), 1);
273 vout1xOPQR = vmulq_lane_f32(vout1xOPQR, vget_high_f32(vinput_scale01), 1);
274 vout0xSTUV = vmulq_lane_f32(vout0xSTUV, vget_low_f32(vinput_scale01), 1);
275 vout1xSTUV = vmulq_lane_f32(vout1xSTUV, vget_high_f32(vinput_scale01), 1);
276
277 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
278 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
279 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
280 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
281 const float32x4_t vfilter_output_scaleGHIJ = vld1q_f32(w); w = (const float*) w + 4;
282 const float32x4_t vfilter_output_scaleKLMN = vld1q_f32(w); w = (const float*) w + 4;
283 const float32x4_t vfilter_output_scaleOPQR = vld1q_f32(w); w = (const float*) w + 4;
284 const float32x4_t vfilter_output_scaleSTUV = vld1q_f32(w); w = (const float*) w + 4;
285
286 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
287 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
288 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
289 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
290 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
291 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
292 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
293 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
294 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
295 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
296 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
297 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
298 const float32x4_t vbiasGHIJ = vld1q_f32(w); w = (const float*) w + 4;
299 vout0xGHIJ = vfmaq_f32(vbiasGHIJ, vout0xGHIJ, vfilter_output_scaleGHIJ);
300 vout1xGHIJ = vfmaq_f32(vbiasGHIJ, vout1xGHIJ, vfilter_output_scaleGHIJ);
301 const float32x4_t vbiasKLMN = vld1q_f32(w); w = (const float*) w + 4;
302 vout0xKLMN = vfmaq_f32(vbiasKLMN, vout0xKLMN, vfilter_output_scaleKLMN);
303 vout1xKLMN = vfmaq_f32(vbiasKLMN, vout1xKLMN, vfilter_output_scaleKLMN);
304 const float32x4_t vbiasOPQR = vld1q_f32(w); w = (const float*) w + 4;
305 vout0xOPQR = vfmaq_f32(vbiasOPQR, vout0xOPQR, vfilter_output_scaleOPQR);
306 vout1xOPQR = vfmaq_f32(vbiasOPQR, vout1xOPQR, vfilter_output_scaleOPQR);
307 const float32x4_t vbiasSTUV = vld1q_f32(w); w = (const float*) w + 4;
308 vout0xSTUV = vfmaq_f32(vbiasSTUV, vout0xSTUV, vfilter_output_scaleSTUV);
309 vout1xSTUV = vfmaq_f32(vbiasSTUV, vout1xSTUV, vfilter_output_scaleSTUV);
310
311 float16x8_t vfp16out0x01234567 = vcombine_f16(vcvt_f16_f32(vout0x0123), vcvt_f16_f32(vout0x4567));
312 float16x8_t vfp16out0x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout0x89AB), vcvt_f16_f32(vout0xCDEF));
313 float16x8_t vfp16out0xGHIJKLMN = vcombine_f16(vcvt_f16_f32(vout0xGHIJ), vcvt_f16_f32(vout0xKLMN));
314 float16x8_t vfp16out0xOPQRSTUV = vcombine_f16(vcvt_f16_f32(vout0xOPQR), vcvt_f16_f32(vout0xSTUV));
315 float16x8_t vfp16out1x01234567 = vcombine_f16(vcvt_f16_f32(vout1x0123), vcvt_f16_f32(vout1x4567));
316 float16x8_t vfp16out1x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout1x89AB), vcvt_f16_f32(vout1xCDEF));
317 float16x8_t vfp16out1xGHIJKLMN = vcombine_f16(vcvt_f16_f32(vout1xGHIJ), vcvt_f16_f32(vout1xKLMN));
318 float16x8_t vfp16out1xOPQRSTUV = vcombine_f16(vcvt_f16_f32(vout1xOPQR), vcvt_f16_f32(vout1xSTUV));
319
320 const float16x8_t voutput_min = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
321 vfp16out0x01234567 = vmaxq_f16(vfp16out0x01234567, voutput_min);
322 vfp16out0x89ABCDEF = vmaxq_f16(vfp16out0x89ABCDEF, voutput_min);
323 vfp16out0xGHIJKLMN = vmaxq_f16(vfp16out0xGHIJKLMN, voutput_min);
324 vfp16out0xOPQRSTUV = vmaxq_f16(vfp16out0xOPQRSTUV, voutput_min);
325 vfp16out1x01234567 = vmaxq_f16(vfp16out1x01234567, voutput_min);
326 vfp16out1x89ABCDEF = vmaxq_f16(vfp16out1x89ABCDEF, voutput_min);
327 vfp16out1xGHIJKLMN = vmaxq_f16(vfp16out1xGHIJKLMN, voutput_min);
328 vfp16out1xOPQRSTUV = vmaxq_f16(vfp16out1xOPQRSTUV, voutput_min);
329 const float16x8_t voutput_max = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
330 vfp16out0x01234567 = vminq_f16(vfp16out0x01234567, voutput_max);
331 vfp16out0x89ABCDEF = vminq_f16(vfp16out0x89ABCDEF, voutput_max);
332 vfp16out0xGHIJKLMN = vminq_f16(vfp16out0xGHIJKLMN, voutput_max);
333 vfp16out0xOPQRSTUV = vminq_f16(vfp16out0xOPQRSTUV, voutput_max);
334 vfp16out1x01234567 = vminq_f16(vfp16out1x01234567, voutput_max);
335 vfp16out1x89ABCDEF = vminq_f16(vfp16out1x89ABCDEF, voutput_max);
336 vfp16out1xGHIJKLMN = vminq_f16(vfp16out1xGHIJKLMN, voutput_max);
337 vfp16out1xOPQRSTUV = vminq_f16(vfp16out1xOPQRSTUV, voutput_max);
338 if XNN_LIKELY(nc >= 32) {
339 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567));
340 vst1q_u16(c0 + 8, vreinterpretq_u16_f16(vfp16out0x89ABCDEF));
341 vst1q_u16(c0 + 16, vreinterpretq_u16_f16(vfp16out0xGHIJKLMN));
342 vst1q_u16(c0 + 24, vreinterpretq_u16_f16(vfp16out0xOPQRSTUV));
343 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567));
344 vst1q_u16(c1 + 8, vreinterpretq_u16_f16(vfp16out1x89ABCDEF));
345 vst1q_u16(c1 + 16, vreinterpretq_u16_f16(vfp16out1xGHIJKLMN));
346 vst1q_u16(c1 + 24, vreinterpretq_u16_f16(vfp16out1xOPQRSTUV));
347
348 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
349 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
350
351 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
352 c1 = (uint16_t*) ((uintptr_t) c1 + cn_stride);
353
354 nc -= 32;
355 } else {
356 if (nc & 16) {
357 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567)); c0 += 8;
358 vfp16out0x01234567 = vfp16out0xGHIJKLMN;
359 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567)); c1 += 8;
360 vfp16out1x01234567 = vfp16out1xGHIJKLMN;
361 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x89ABCDEF)); c0 += 8;
362 vfp16out0x89ABCDEF = vfp16out0xOPQRSTUV;
363 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x89ABCDEF)); c1 += 8;
364 vfp16out1x89ABCDEF = vfp16out1xOPQRSTUV;
365 }
366 if (nc & 8) {
367 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567)); c0 += 8;
368 vfp16out0x01234567 = vfp16out0x89ABCDEF;
369 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567)); c1 += 8;
370 vfp16out1x01234567 = vfp16out1x89ABCDEF;
371 }
372 float16x4_t vfp16out0x0123 = vget_low_f16(vfp16out0x01234567);
373 float16x4_t vfp16out1x0123 = vget_low_f16(vfp16out1x01234567);
374 if (nc & 4) {
375 vst1_u16(c0, vreinterpret_u16_f16(vfp16out0x0123)); c0 += 4;
376 vst1_u16(c1, vreinterpret_u16_f16(vfp16out1x0123)); c1 += 4;
377 vfp16out0x0123 = vget_high_f16(vfp16out0x01234567);
378 vfp16out1x0123 = vget_high_f16(vfp16out1x01234567);
379 }
380 if (nc & 2) {
381 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vfp16out0x0123), 0); c0 += 2;
382 vst1_lane_u32((void*) c1, vreinterpret_u32_f16(vfp16out1x0123), 0); c1 += 2;
383 vfp16out0x0123 = vext_f16(vfp16out0x0123, vfp16out0x0123, 2);
384 vfp16out1x0123 = vext_f16(vfp16out1x0123, vfp16out1x0123, 2);
385 }
386 if (nc & 1) {
387 vst1_lane_u16(c0, vreinterpret_u16_f16(vfp16out0x0123), 0);
388 vst1_lane_u16(c1, vreinterpret_u16_f16(vfp16out1x0123), 0);
389 }
390 nc = 0;
391 }
392 } while (nc != 0);
393 }