Debian Codegraph @

src/qd8-f16-qc8w-gemm/gen/qd8-f16-qc8w-gemm-3x32c8-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_3x32c8__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 <= 3);
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
56 // Loop over groups of 32 columns.
57 do {
58 // Initialize accumulators with bias. 32 bias values are loaded from the
59 // weight matrix, at the start of the group of 32 columns.
60 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
61 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
62 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
63 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
64 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
65 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
66 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
67 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
68 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
69 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
70 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
71 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
72 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
73 const int32x4_t vksumGHIJ = vld1q_s32(w); w = (const int32_t*) w + 4;
74 const int32x4_t vksumzp0xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_low_s32(vinput_zero_point01), 0);
75 const int32x4_t vksumzp1xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_high_s32(vinput_zero_point01), 0);
76 const int32x4_t vksumKLMN = vld1q_s32(w); w = (const int32_t*) w + 4;
77 const int32x4_t vksumzp0xKLMN = vmulq_lane_s32(vksumKLMN, vget_low_s32(vinput_zero_point01), 0);
78 const int32x4_t vksumzp1xKLMN = vmulq_lane_s32(vksumKLMN, vget_high_s32(vinput_zero_point01), 0);
79 const int32x4_t vksumOPQR = vld1q_s32(w); w = (const int32_t*) w + 4;
80 const int32x4_t vksumzp0xOPQR = vmulq_lane_s32(vksumOPQR, vget_low_s32(vinput_zero_point01), 0);
81 const int32x4_t vksumzp1xOPQR = vmulq_lane_s32(vksumOPQR, vget_high_s32(vinput_zero_point01), 0);
82 const int32x4_t vksumSTUV = vld1q_s32(w); w = (const int32_t*) w + 4;
83 const int32x4_t vksumzp0xSTUV = vmulq_lane_s32(vksumSTUV, vget_low_s32(vinput_zero_point01), 0);
84 const int32x4_t vksumzp1xSTUV = vmulq_lane_s32(vksumSTUV, vget_high_s32(vinput_zero_point01), 0);
85 const int32x4_t vinput_zero_point23 = vld1q_dup_s32(&quantization_params[2].zero_point);
86 const int32x4_t vksumzp2x0123 = vmulq_s32(vksum0123, vinput_zero_point23);
87 const int32x4_t vksumzp2x4567 = vmulq_s32(vksum4567, vinput_zero_point23);
88 const int32x4_t vksumzp2x89AB = vmulq_s32(vksum89AB, vinput_zero_point23);
89 const int32x4_t vksumzp2xCDEF = vmulq_s32(vksumCDEF, vinput_zero_point23);
90 const int32x4_t vksumzp2xGHIJ = vmulq_s32(vksumGHIJ, vinput_zero_point23);
91 const int32x4_t vksumzp2xKLMN = vmulq_s32(vksumKLMN, vinput_zero_point23);
92 const int32x4_t vksumzp2xOPQR = vmulq_s32(vksumOPQR, vinput_zero_point23);
93 const int32x4_t vksumzp2xSTUV = vmulq_s32(vksumSTUV, vinput_zero_point23);
94
95 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
96 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
97 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
98 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
99 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
100 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
101 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
102 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
103 int32x4_t vacc01xGH = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
104 int32x4_t vacc01xIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
105 int32x4_t vacc01xKL = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
106 int32x4_t vacc01xMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
107 int32x4_t vacc01xOP = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
108 int32x4_t vacc01xQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
109 int32x4_t vacc01xST = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
110 int32x4_t vacc01xUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
111 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp2x0123)));
112 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp2x0123)));
113 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp2x4567)));
114 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp2x4567)));
115 int32x4_t vacc23x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp2x89AB)));
116 int32x4_t vacc23xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp2x89AB)));
117 int32x4_t vacc23xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp2xCDEF)));
118 int32x4_t vacc23xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp2xCDEF)));
119 int32x4_t vacc23xGH = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xGHIJ), vreinterpretq_u64_s32(vksumzp2xGHIJ)));
120 int32x4_t vacc23xIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xGHIJ), vreinterpretq_u64_s32(vksumzp2xGHIJ)));
121 int32x4_t vacc23xKL = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xKLMN), vreinterpretq_u64_s32(vksumzp2xKLMN)));
122 int32x4_t vacc23xMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xKLMN), vreinterpretq_u64_s32(vksumzp2xKLMN)));
123 int32x4_t vacc23xOP = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xOPQR), vreinterpretq_u64_s32(vksumzp2xOPQR)));
124 int32x4_t vacc23xQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xOPQR), vreinterpretq_u64_s32(vksumzp2xOPQR)));
125 int32x4_t vacc23xST = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xSTUV), vreinterpretq_u64_s32(vksumzp2xSTUV)));
126 int32x4_t vacc23xUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xSTUV), vreinterpretq_u64_s32(vksumzp2xSTUV)));
127
128 // Inner accumulation loop along the 32 columns.
129 size_t k = kc;
130 // 2x partial unrolled loop to load 8 bytes at a time.
131
132 uint64x2x2_t va01x0123456789ABCDEF;
133 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
134 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
135 uint64x2x2_t va23x0123456789ABCDEF;
136 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
137 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
138
139 while (k >= 16 * sizeof(int8_t)) {
140 // Load a 3x16 block of activations.
141 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
142 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
143 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
144
145 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
146 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
147 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
148 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
149
150 // Load a 16x32 block of weights.
151 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
152 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
153 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
154 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
155 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
156 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
157 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
158 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
159 const int8x16_t vbGHx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
160 const int8x16_t vbIJx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
161 const int8x16_t vbKLx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
162 const int8x16_t vbMNx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
163 const int8x16_t vbOPx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
164 const int8x16_t vbQRx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
165 const int8x16_t vbSTx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
166 const int8x16_t vbUVx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
167 const int8x16_t vb01x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
168 const int8x16_t vb23x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
169 const int8x16_t vb45x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
170 const int8x16_t vb67x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
171 const int8x16_t vb89x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
172 const int8x16_t vbABx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
173 const int8x16_t vbCDx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
174 const int8x16_t vbEFx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
175 const int8x16_t vbGHx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
176 const int8x16_t vbIJx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
177 const int8x16_t vbKLx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
178 const int8x16_t vbMNx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
179 const int8x16_t vbOPx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
180 const int8x16_t vbQRx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
181 const int8x16_t vbSTx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
182 const int8x16_t vbUVx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
183
184 // Multiply-accumulate: 3x8 * 8x32 --> 3x32.
185 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
186 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
187 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
188 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
189 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
190 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
191 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
192 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
193 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x01234567, vbGHx01234567);
194 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x01234567, vbIJx01234567);
195 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x01234567, vbKLx01234567);
196 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x01234567, vbMNx01234567);
197 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x01234567, vbOPx01234567);
198 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x01234567, vbQRx01234567);
199 vacc01xST = vmmlaq_s32(vacc01xST, va01x01234567, vbSTx01234567);
200 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x01234567, vbUVx01234567);
201 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
202 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
203 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
204 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
205 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
206 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
207 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
208 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
209 vacc23xGH = vmmlaq_s32(vacc23xGH, va23x01234567, vbGHx01234567);
210 vacc23xIJ = vmmlaq_s32(vacc23xIJ, va23x01234567, vbIJx01234567);
211 vacc23xKL = vmmlaq_s32(vacc23xKL, va23x01234567, vbKLx01234567);
212 vacc23xMN = vmmlaq_s32(vacc23xMN, va23x01234567, vbMNx01234567);
213 vacc23xOP = vmmlaq_s32(vacc23xOP, va23x01234567, vbOPx01234567);
214 vacc23xQR = vmmlaq_s32(vacc23xQR, va23x01234567, vbQRx01234567);
215 vacc23xST = vmmlaq_s32(vacc23xST, va23x01234567, vbSTx01234567);
216 vacc23xUV = vmmlaq_s32(vacc23xUV, va23x01234567, vbUVx01234567);
217 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
218 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
219 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
220 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
221 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
222 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
223 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
224 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
225 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x89ABCDEF, vbGHx89ABCDEF);
226 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x89ABCDEF, vbIJx89ABCDEF);
227 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x89ABCDEF, vbKLx89ABCDEF);
228 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x89ABCDEF, vbMNx89ABCDEF);
229 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x89ABCDEF, vbOPx89ABCDEF);
230 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x89ABCDEF, vbQRx89ABCDEF);
231 vacc01xST = vmmlaq_s32(vacc01xST, va01x89ABCDEF, vbSTx89ABCDEF);
232 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x89ABCDEF, vbUVx89ABCDEF);
233 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
234 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
235 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
236 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
237 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
238 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
239 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
240 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
241 vacc23xGH = vmmlaq_s32(vacc23xGH, va23x89ABCDEF, vbGHx89ABCDEF);
242 vacc23xIJ = vmmlaq_s32(vacc23xIJ, va23x89ABCDEF, vbIJx89ABCDEF);
243 vacc23xKL = vmmlaq_s32(vacc23xKL, va23x89ABCDEF, vbKLx89ABCDEF);
244 vacc23xMN = vmmlaq_s32(vacc23xMN, va23x89ABCDEF, vbMNx89ABCDEF);
245 vacc23xOP = vmmlaq_s32(vacc23xOP, va23x89ABCDEF, vbOPx89ABCDEF);
246 vacc23xQR = vmmlaq_s32(vacc23xQR, va23x89ABCDEF, vbQRx89ABCDEF);
247 vacc23xST = vmmlaq_s32(vacc23xST, va23x89ABCDEF, vbSTx89ABCDEF);
248 vacc23xUV = vmmlaq_s32(vacc23xUV, va23x89ABCDEF, vbUVx89ABCDEF);
249
250 k -= 16 * sizeof(int8_t);
251 }
252 // Handle up to 8 final positions of `k`
253 if XNN_UNLIKELY(k != 0) {
254 // Load a 3x8 block of activations.
255 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
256 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
257 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
258
259 // Load a 16x32 block of weights.
260 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
261 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
262 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
263 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
264 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
265 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
266 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
267 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
268 const int8x16_t vbGHx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
269 const int8x16_t vbIJx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
270 const int8x16_t vbKLx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
271 const int8x16_t vbMNx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
272 const int8x16_t vbOPx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
273 const int8x16_t vbQRx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
274 const int8x16_t vbSTx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
275 const int8x16_t vbUVx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
276
277 // Multiply-accumulate: 3x4 * 4x32 --> 3x32.
278 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
279 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
280 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
281 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
282 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
283 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
284 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
285 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
286 vacc01xGH = vmmlaq_s32(vacc01xGH, vreinterpretq_s8_u64(va01x01234567), vbGHx01234567);
287 vacc01xIJ = vmmlaq_s32(vacc01xIJ, vreinterpretq_s8_u64(va01x01234567), vbIJx01234567);
288 vacc01xKL = vmmlaq_s32(vacc01xKL, vreinterpretq_s8_u64(va01x01234567), vbKLx01234567);
289 vacc01xMN = vmmlaq_s32(vacc01xMN, vreinterpretq_s8_u64(va01x01234567), vbMNx01234567);
290 vacc01xOP = vmmlaq_s32(vacc01xOP, vreinterpretq_s8_u64(va01x01234567), vbOPx01234567);
291 vacc01xQR = vmmlaq_s32(vacc01xQR, vreinterpretq_s8_u64(va01x01234567), vbQRx01234567);
292 vacc01xST = vmmlaq_s32(vacc01xST, vreinterpretq_s8_u64(va01x01234567), vbSTx01234567);
293 vacc01xUV = vmmlaq_s32(vacc01xUV, vreinterpretq_s8_u64(va01x01234567), vbUVx01234567);
294 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
295 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
296 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
297 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
298 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
299 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
300 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
301 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
302 vacc23xGH = vmmlaq_s32(vacc23xGH, vreinterpretq_s8_u64(va23x01234567), vbGHx01234567);
303 vacc23xIJ = vmmlaq_s32(vacc23xIJ, vreinterpretq_s8_u64(va23x01234567), vbIJx01234567);
304 vacc23xKL = vmmlaq_s32(vacc23xKL, vreinterpretq_s8_u64(va23x01234567), vbKLx01234567);
305 vacc23xMN = vmmlaq_s32(vacc23xMN, vreinterpretq_s8_u64(va23x01234567), vbMNx01234567);
306 vacc23xOP = vmmlaq_s32(vacc23xOP, vreinterpretq_s8_u64(va23x01234567), vbOPx01234567);
307 vacc23xQR = vmmlaq_s32(vacc23xQR, vreinterpretq_s8_u64(va23x01234567), vbQRx01234567);
308 vacc23xST = vmmlaq_s32(vacc23xST, vreinterpretq_s8_u64(va23x01234567), vbSTx01234567);
309 vacc23xUV = vmmlaq_s32(vacc23xUV, vreinterpretq_s8_u64(va23x01234567), vbUVx01234567);
310 }
311
312 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
313 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
314 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
315 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
316 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
317 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
318 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
319 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
320 int32x4_t vacc0xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
321 int32x4_t vacc1xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
322 int32x4_t vacc0xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
323 int32x4_t vacc1xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
324 int32x4_t vacc0xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
325 int32x4_t vacc1xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
326 int32x4_t vacc0xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
327 int32x4_t vacc1xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
328 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
329 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
330 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
331 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
332 int32x4_t vacc2xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xGH), vreinterpretq_u64_s32(vacc23xIJ)));
333 int32x4_t vacc2xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xKL), vreinterpretq_u64_s32(vacc23xMN)));
334 int32x4_t vacc2xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xOP), vreinterpretq_u64_s32(vacc23xQR)));
335 int32x4_t vacc2xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xST), vreinterpretq_u64_s32(vacc23xUV)));
336 float32x4_t vout0x0123 = vcvtq_f32_s32(vacc0x0123);
337 float32x4_t vout0x4567 = vcvtq_f32_s32(vacc0x4567);
338 float32x4_t vout0x89AB = vcvtq_f32_s32(vacc0x89AB);
339 float32x4_t vout0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
340 float32x4_t vout0xGHIJ = vcvtq_f32_s32(vacc0xGHIJ);
341 float32x4_t vout0xKLMN = vcvtq_f32_s32(vacc0xKLMN);
342 float32x4_t vout0xOPQR = vcvtq_f32_s32(vacc0xOPQR);
343 float32x4_t vout0xSTUV = vcvtq_f32_s32(vacc0xSTUV);
344 float32x4_t vout1x0123 = vcvtq_f32_s32(vacc1x0123);
345 float32x4_t vout1x4567 = vcvtq_f32_s32(vacc1x4567);
346 float32x4_t vout1x89AB = vcvtq_f32_s32(vacc1x89AB);
347 float32x4_t vout1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
348 float32x4_t vout1xGHIJ = vcvtq_f32_s32(vacc1xGHIJ);
349 float32x4_t vout1xKLMN = vcvtq_f32_s32(vacc1xKLMN);
350 float32x4_t vout1xOPQR = vcvtq_f32_s32(vacc1xOPQR);
351 float32x4_t vout1xSTUV = vcvtq_f32_s32(vacc1xSTUV);
352 float32x4_t vout2x0123 = vcvtq_f32_s32(vacc2x0123);
353 float32x4_t vout2x4567 = vcvtq_f32_s32(vacc2x4567);
354 float32x4_t vout2x89AB = vcvtq_f32_s32(vacc2x89AB);
355 float32x4_t vout2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
356 float32x4_t vout2xGHIJ = vcvtq_f32_s32(vacc2xGHIJ);
357 float32x4_t vout2xKLMN = vcvtq_f32_s32(vacc2xKLMN);
358 float32x4_t vout2xOPQR = vcvtq_f32_s32(vacc2xOPQR);
359 float32x4_t vout2xSTUV = vcvtq_f32_s32(vacc2xSTUV);
360
361 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
362 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
363 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
364 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
365 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
366 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
367 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
368 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
369 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
370 vout0xGHIJ = vmulq_lane_f32(vout0xGHIJ, vget_low_f32(vinput_scale01), 1);
371 vout1xGHIJ = vmulq_lane_f32(vout1xGHIJ, vget_high_f32(vinput_scale01), 1);
372 vout0xKLMN = vmulq_lane_f32(vout0xKLMN, vget_low_f32(vinput_scale01), 1);
373 vout1xKLMN = vmulq_lane_f32(vout1xKLMN, vget_high_f32(vinput_scale01), 1);
374 vout0xOPQR = vmulq_lane_f32(vout0xOPQR, vget_low_f32(vinput_scale01), 1);
375 vout1xOPQR = vmulq_lane_f32(vout1xOPQR, vget_high_f32(vinput_scale01), 1);
376 vout0xSTUV = vmulq_lane_f32(vout0xSTUV, vget_low_f32(vinput_scale01), 1);
377 vout1xSTUV = vmulq_lane_f32(vout1xSTUV, vget_high_f32(vinput_scale01), 1);
378 const float32x4_t vinput_scale2 = vld1q_dup_f32(&quantization_params[2].inv_scale);
379 vout2x0123 = vmulq_f32(vout2x0123, vinput_scale2);
380 vout2x4567 = vmulq_f32(vout2x4567, vinput_scale2);
381 vout2x89AB = vmulq_f32(vout2x89AB, vinput_scale2);
382 vout2xCDEF = vmulq_f32(vout2xCDEF, vinput_scale2);
383 vout2xGHIJ = vmulq_f32(vout2xGHIJ, vinput_scale2);
384 vout2xKLMN = vmulq_f32(vout2xKLMN, vinput_scale2);
385 vout2xOPQR = vmulq_f32(vout2xOPQR, vinput_scale2);
386 vout2xSTUV = vmulq_f32(vout2xSTUV, vinput_scale2);
387
388 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
389 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
390 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
391 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
392 const float32x4_t vfilter_output_scaleGHIJ = vld1q_f32(w); w = (const float*) w + 4;
393 const float32x4_t vfilter_output_scaleKLMN = vld1q_f32(w); w = (const float*) w + 4;
394 const float32x4_t vfilter_output_scaleOPQR = vld1q_f32(w); w = (const float*) w + 4;
395 const float32x4_t vfilter_output_scaleSTUV = vld1q_f32(w); w = (const float*) w + 4;
396
397 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
398 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
399 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
400 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
401 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
402 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
403 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
404 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
405 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
406 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
407 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
408 vout2x89AB = vfmaq_f32(vbias89AB, vout2x89AB, vfilter_output_scale89AB);
409 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
410 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
411 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
412 vout2xCDEF = vfmaq_f32(vbiasCDEF, vout2xCDEF, vfilter_output_scaleCDEF);
413 const float32x4_t vbiasGHIJ = vld1q_f32(w); w = (const float*) w + 4;
414 vout0xGHIJ = vfmaq_f32(vbiasGHIJ, vout0xGHIJ, vfilter_output_scaleGHIJ);
415 vout1xGHIJ = vfmaq_f32(vbiasGHIJ, vout1xGHIJ, vfilter_output_scaleGHIJ);
416 vout2xGHIJ = vfmaq_f32(vbiasGHIJ, vout2xGHIJ, vfilter_output_scaleGHIJ);
417 const float32x4_t vbiasKLMN = vld1q_f32(w); w = (const float*) w + 4;
418 vout0xKLMN = vfmaq_f32(vbiasKLMN, vout0xKLMN, vfilter_output_scaleKLMN);
419 vout1xKLMN = vfmaq_f32(vbiasKLMN, vout1xKLMN, vfilter_output_scaleKLMN);
420 vout2xKLMN = vfmaq_f32(vbiasKLMN, vout2xKLMN, vfilter_output_scaleKLMN);
421 const float32x4_t vbiasOPQR = vld1q_f32(w); w = (const float*) w + 4;
422 vout0xOPQR = vfmaq_f32(vbiasOPQR, vout0xOPQR, vfilter_output_scaleOPQR);
423 vout1xOPQR = vfmaq_f32(vbiasOPQR, vout1xOPQR, vfilter_output_scaleOPQR);
424 vout2xOPQR = vfmaq_f32(vbiasOPQR, vout2xOPQR, vfilter_output_scaleOPQR);
425 const float32x4_t vbiasSTUV = vld1q_f32(w); w = (const float*) w + 4;
426 vout0xSTUV = vfmaq_f32(vbiasSTUV, vout0xSTUV, vfilter_output_scaleSTUV);
427 vout1xSTUV = vfmaq_f32(vbiasSTUV, vout1xSTUV, vfilter_output_scaleSTUV);
428 vout2xSTUV = vfmaq_f32(vbiasSTUV, vout2xSTUV, vfilter_output_scaleSTUV);
429
430 float16x8_t vfp16out0x01234567 = vcombine_f16(vcvt_f16_f32(vout0x0123), vcvt_f16_f32(vout0x4567));
431 float16x8_t vfp16out0x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout0x89AB), vcvt_f16_f32(vout0xCDEF));
432 float16x8_t vfp16out0xGHIJKLMN = vcombine_f16(vcvt_f16_f32(vout0xGHIJ), vcvt_f16_f32(vout0xKLMN));
433 float16x8_t vfp16out0xOPQRSTUV = vcombine_f16(vcvt_f16_f32(vout0xOPQR), vcvt_f16_f32(vout0xSTUV));
434 float16x8_t vfp16out1x01234567 = vcombine_f16(vcvt_f16_f32(vout1x0123), vcvt_f16_f32(vout1x4567));
435 float16x8_t vfp16out1x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout1x89AB), vcvt_f16_f32(vout1xCDEF));
436 float16x8_t vfp16out1xGHIJKLMN = vcombine_f16(vcvt_f16_f32(vout1xGHIJ), vcvt_f16_f32(vout1xKLMN));
437 float16x8_t vfp16out1xOPQRSTUV = vcombine_f16(vcvt_f16_f32(vout1xOPQR), vcvt_f16_f32(vout1xSTUV));
438 float16x8_t vfp16out2x01234567 = vcombine_f16(vcvt_f16_f32(vout2x0123), vcvt_f16_f32(vout2x4567));
439 float16x8_t vfp16out2x89ABCDEF = vcombine_f16(vcvt_f16_f32(vout2x89AB), vcvt_f16_f32(vout2xCDEF));
440 float16x8_t vfp16out2xGHIJKLMN = vcombine_f16(vcvt_f16_f32(vout2xGHIJ), vcvt_f16_f32(vout2xKLMN));
441 float16x8_t vfp16out2xOPQRSTUV = vcombine_f16(vcvt_f16_f32(vout2xOPQR), vcvt_f16_f32(vout2xSTUV));
442
443 const float16x8_t voutput_min = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.min));
444 vfp16out0x01234567 = vmaxq_f16(vfp16out0x01234567, voutput_min);
445 vfp16out0x89ABCDEF = vmaxq_f16(vfp16out0x89ABCDEF, voutput_min);
446 vfp16out0xGHIJKLMN = vmaxq_f16(vfp16out0xGHIJKLMN, voutput_min);
447 vfp16out0xOPQRSTUV = vmaxq_f16(vfp16out0xOPQRSTUV, voutput_min);
448 vfp16out1x01234567 = vmaxq_f16(vfp16out1x01234567, voutput_min);
449 vfp16out1x89ABCDEF = vmaxq_f16(vfp16out1x89ABCDEF, voutput_min);
450 vfp16out1xGHIJKLMN = vmaxq_f16(vfp16out1xGHIJKLMN, voutput_min);
451 vfp16out1xOPQRSTUV = vmaxq_f16(vfp16out1xOPQRSTUV, voutput_min);
452 vfp16out2x01234567 = vmaxq_f16(vfp16out2x01234567, voutput_min);
453 vfp16out2x89ABCDEF = vmaxq_f16(vfp16out2x89ABCDEF, voutput_min);
454 vfp16out2xGHIJKLMN = vmaxq_f16(vfp16out2xGHIJKLMN, voutput_min);
455 vfp16out2xOPQRSTUV = vmaxq_f16(vfp16out2xOPQRSTUV, voutput_min);
456 const float16x8_t voutput_max = vreinterpretq_f16_u16(vld1q_dup_u16((const uint16_t*) &params->scalar.max));
457 vfp16out0x01234567 = vminq_f16(vfp16out0x01234567, voutput_max);
458 vfp16out0x89ABCDEF = vminq_f16(vfp16out0x89ABCDEF, voutput_max);
459 vfp16out0xGHIJKLMN = vminq_f16(vfp16out0xGHIJKLMN, voutput_max);
460 vfp16out0xOPQRSTUV = vminq_f16(vfp16out0xOPQRSTUV, voutput_max);
461 vfp16out1x01234567 = vminq_f16(vfp16out1x01234567, voutput_max);
462 vfp16out1x89ABCDEF = vminq_f16(vfp16out1x89ABCDEF, voutput_max);
463 vfp16out1xGHIJKLMN = vminq_f16(vfp16out1xGHIJKLMN, voutput_max);
464 vfp16out1xOPQRSTUV = vminq_f16(vfp16out1xOPQRSTUV, voutput_max);
465 vfp16out2x01234567 = vminq_f16(vfp16out2x01234567, voutput_max);
466 vfp16out2x89ABCDEF = vminq_f16(vfp16out2x89ABCDEF, voutput_max);
467 vfp16out2xGHIJKLMN = vminq_f16(vfp16out2xGHIJKLMN, voutput_max);
468 vfp16out2xOPQRSTUV = vminq_f16(vfp16out2xOPQRSTUV, voutput_max);
469 if XNN_LIKELY(nc >= 32) {
470 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567));
471 vst1q_u16(c0 + 8, vreinterpretq_u16_f16(vfp16out0x89ABCDEF));
472 vst1q_u16(c0 + 16, vreinterpretq_u16_f16(vfp16out0xGHIJKLMN));
473 vst1q_u16(c0 + 24, vreinterpretq_u16_f16(vfp16out0xOPQRSTUV));
474 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567));
475 vst1q_u16(c1 + 8, vreinterpretq_u16_f16(vfp16out1x89ABCDEF));
476 vst1q_u16(c1 + 16, vreinterpretq_u16_f16(vfp16out1xGHIJKLMN));
477 vst1q_u16(c1 + 24, vreinterpretq_u16_f16(vfp16out1xOPQRSTUV));
478 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567));
479 vst1q_u16(c2 + 8, vreinterpretq_u16_f16(vfp16out2x89ABCDEF));
480 vst1q_u16(c2 + 16, vreinterpretq_u16_f16(vfp16out2xGHIJKLMN));
481 vst1q_u16(c2 + 24, vreinterpretq_u16_f16(vfp16out2xOPQRSTUV));
482
483 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
484 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
485 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
486
487 c0 = (uint16_t*) ((uintptr_t) c0 + cn_stride);
488 c1 = (uint16_t*) ((uintptr_t) c1 + cn_stride);
489 c2 = (uint16_t*) ((uintptr_t) c2 + cn_stride);
490
491 nc -= 32;
492 } else {
493 if (nc & 16) {
494 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567)); c0 += 8;
495 vfp16out0x01234567 = vfp16out0xGHIJKLMN;
496 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567)); c1 += 8;
497 vfp16out1x01234567 = vfp16out1xGHIJKLMN;
498 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567)); c2 += 8;
499 vfp16out2x01234567 = vfp16out2xGHIJKLMN;
500 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x89ABCDEF)); c0 += 8;
501 vfp16out0x89ABCDEF = vfp16out0xOPQRSTUV;
502 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x89ABCDEF)); c1 += 8;
503 vfp16out1x89ABCDEF = vfp16out1xOPQRSTUV;
504 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x89ABCDEF)); c2 += 8;
505 vfp16out2x89ABCDEF = vfp16out2xOPQRSTUV;
506 }
507 if (nc & 8) {
508 vst1q_u16(c0, vreinterpretq_u16_f16(vfp16out0x01234567)); c0 += 8;
509 vfp16out0x01234567 = vfp16out0x89ABCDEF;
510 vst1q_u16(c1, vreinterpretq_u16_f16(vfp16out1x01234567)); c1 += 8;
511 vfp16out1x01234567 = vfp16out1x89ABCDEF;
512 vst1q_u16(c2, vreinterpretq_u16_f16(vfp16out2x01234567)); c2 += 8;
513 vfp16out2x01234567 = vfp16out2x89ABCDEF;
514 }
515 float16x4_t vfp16out0x0123 = vget_low_f16(vfp16out0x01234567);
516 float16x4_t vfp16out1x0123 = vget_low_f16(vfp16out1x01234567);
517 float16x4_t vfp16out2x0123 = vget_low_f16(vfp16out2x01234567);
518 if (nc & 4) {
519 vst1_u16(c0, vreinterpret_u16_f16(vfp16out0x0123)); c0 += 4;
520 vst1_u16(c1, vreinterpret_u16_f16(vfp16out1x0123)); c1 += 4;
521 vst1_u16(c2, vreinterpret_u16_f16(vfp16out2x0123)); c2 += 4;
522 vfp16out0x0123 = vget_high_f16(vfp16out0x01234567);
523 vfp16out1x0123 = vget_high_f16(vfp16out1x01234567);
524 vfp16out2x0123 = vget_high_f16(vfp16out2x01234567);
525 }
526 if (nc & 2) {
527 vst1_lane_u32((void*) c0, vreinterpret_u32_f16(vfp16out0x0123), 0); c0 += 2;
528 vst1_lane_u32((void*) c1, vreinterpret_u32_f16(vfp16out1x0123), 0); c1 += 2;
529 vst1_lane_u32((void*) c2, vreinterpret_u32_f16(vfp16out2x0123), 0); c2 += 2;
530 vfp16out0x0123 = vext_f16(vfp16out0x0123, vfp16out0x0123, 2);
531 vfp16out1x0123 = vext_f16(vfp16out1x0123, vfp16out1x0123, 2);
532 vfp16out2x0123 = vext_f16(vfp16out2x0123, vfp16out2x0123, 2);
533 }
534 if (nc & 1) {
535 vst1_lane_u16(c0, vreinterpret_u16_f16(vfp16out0x0123), 0);
536 vst1_lane_u16(c1, vreinterpret_u16_f16(vfp16out1x0123), 0);
537 vst1_lane_u16(c2, vreinterpret_u16_f16(vfp16out2x0123), 0);
538 }
539 nc = 0;
540 }
541 } while (nc != 0);
542 }