Debian Codegraph @

src/qd8-f32-qb4w-gemm/gen/qd8-f32-qb4w-gemm-4x32c8-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_f32_qb4w_gemm_minmax_ukernel_4x32c8__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 float* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const struct xnn_f32_qb4w_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 <= 4);
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 size_t bl = params->scalar.blocksize;
42 assert(bl <= kc);
43 assert(bl != 0);
44 assert(bl % 32 == 0);
45 const int8_t* a0 = a;
46 float* c0 = c;
47 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
48 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
49 if XNN_UNPREDICTABLE(mr < 2) {
50 a1 = a0;
51 c1 = c0;
52 }
53 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
54 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
55 if XNN_UNPREDICTABLE(mr <= 2) {
56 a2 = a1;
57 c2 = c1;
58 }
59 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
60 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
61 if XNN_UNPREDICTABLE(mr != 4) {
62 a3 = a2;
63 c3 = c2;
64 }
65 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
66
67 // Loop over groups of 32 columns.
68 do {
69 // Initialize accumulators with scaled vksum. 32 scaled vksum values are loaded from the
70 // weight matrix, at the start of the group of 32 columns.
71 const float32x4_t vinput_zero_point01 = vcvtq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
72 const float32x4_t vksum0123 = vld1q_f32(w); w = (const float*) w + 4;
73 float32x4_t vout0x0123 = vmulq_lane_f32(vksum0123, vget_low_f32(vinput_zero_point01), 0);
74 float32x4_t vout1x0123 = vmulq_lane_f32(vksum0123, vget_high_f32(vinput_zero_point01), 0);
75 const float32x4_t vksum4567 = vld1q_f32(w); w = (const float*) w + 4;
76 float32x4_t vout0x4567 = vmulq_lane_f32(vksum4567, vget_low_f32(vinput_zero_point01), 0);
77 float32x4_t vout1x4567 = vmulq_lane_f32(vksum4567, vget_high_f32(vinput_zero_point01), 0);
78 const float32x4_t vksum89AB = vld1q_f32(w); w = (const float*) w + 4;
79 float32x4_t vout0x89AB = vmulq_lane_f32(vksum89AB, vget_low_f32(vinput_zero_point01), 0);
80 float32x4_t vout1x89AB = vmulq_lane_f32(vksum89AB, vget_high_f32(vinput_zero_point01), 0);
81 const float32x4_t vksumCDEF = vld1q_f32(w); w = (const float*) w + 4;
82 float32x4_t vout0xCDEF = vmulq_lane_f32(vksumCDEF, vget_low_f32(vinput_zero_point01), 0);
83 float32x4_t vout1xCDEF = vmulq_lane_f32(vksumCDEF, vget_high_f32(vinput_zero_point01), 0);
84 const float32x4_t vksumGHIJ = vld1q_f32(w); w = (const float*) w + 4;
85 float32x4_t vout0xGHIJ = vmulq_lane_f32(vksumGHIJ, vget_low_f32(vinput_zero_point01), 0);
86 float32x4_t vout1xGHIJ = vmulq_lane_f32(vksumGHIJ, vget_high_f32(vinput_zero_point01), 0);
87 const float32x4_t vksumKLMN = vld1q_f32(w); w = (const float*) w + 4;
88 float32x4_t vout0xKLMN = vmulq_lane_f32(vksumKLMN, vget_low_f32(vinput_zero_point01), 0);
89 float32x4_t vout1xKLMN = vmulq_lane_f32(vksumKLMN, vget_high_f32(vinput_zero_point01), 0);
90 const float32x4_t vksumOPQR = vld1q_f32(w); w = (const float*) w + 4;
91 float32x4_t vout0xOPQR = vmulq_lane_f32(vksumOPQR, vget_low_f32(vinput_zero_point01), 0);
92 float32x4_t vout1xOPQR = vmulq_lane_f32(vksumOPQR, vget_high_f32(vinput_zero_point01), 0);
93 const float32x4_t vksumSTUV = vld1q_f32(w); w = (const float*) w + 4;
94 float32x4_t vout0xSTUV = vmulq_lane_f32(vksumSTUV, vget_low_f32(vinput_zero_point01), 0);
95 float32x4_t vout1xSTUV = vmulq_lane_f32(vksumSTUV, vget_high_f32(vinput_zero_point01), 0);
96 const float32x4_t vinput_zero_point23 = vcvtq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
97 float32x4_t vout2x0123 = vmulq_lane_f32(vksum0123, vget_low_f32(vinput_zero_point23), 0);
98 float32x4_t vout3x0123 = vmulq_lane_f32(vksum0123, vget_high_f32(vinput_zero_point23), 0);
99 float32x4_t vout2x4567 = vmulq_lane_f32(vksum4567, vget_low_f32(vinput_zero_point23), 0);
100 float32x4_t vout3x4567 = vmulq_lane_f32(vksum4567, vget_high_f32(vinput_zero_point23), 0);
101 float32x4_t vout2x89AB = vmulq_lane_f32(vksum89AB, vget_low_f32(vinput_zero_point23), 0);
102 float32x4_t vout3x89AB = vmulq_lane_f32(vksum89AB, vget_high_f32(vinput_zero_point23), 0);
103 float32x4_t vout2xCDEF = vmulq_lane_f32(vksumCDEF, vget_low_f32(vinput_zero_point23), 0);
104 float32x4_t vout3xCDEF = vmulq_lane_f32(vksumCDEF, vget_high_f32(vinput_zero_point23), 0);
105 float32x4_t vout2xGHIJ = vmulq_lane_f32(vksumGHIJ, vget_low_f32(vinput_zero_point23), 0);
106 float32x4_t vout3xGHIJ = vmulq_lane_f32(vksumGHIJ, vget_high_f32(vinput_zero_point23), 0);
107 float32x4_t vout2xKLMN = vmulq_lane_f32(vksumKLMN, vget_low_f32(vinput_zero_point23), 0);
108 float32x4_t vout3xKLMN = vmulq_lane_f32(vksumKLMN, vget_high_f32(vinput_zero_point23), 0);
109 float32x4_t vout2xOPQR = vmulq_lane_f32(vksumOPQR, vget_low_f32(vinput_zero_point23), 0);
110 float32x4_t vout3xOPQR = vmulq_lane_f32(vksumOPQR, vget_high_f32(vinput_zero_point23), 0);
111 float32x4_t vout2xSTUV = vmulq_lane_f32(vksumSTUV, vget_low_f32(vinput_zero_point23), 0);
112 float32x4_t vout3xSTUV = vmulq_lane_f32(vksumSTUV, vget_high_f32(vinput_zero_point23), 0);
113
114
115 for (size_t kb=0; kb < kc; kb += bl) {
116 int32x4_t vacc01x01 = vdupq_n_s32(0);
117 int32x4_t vacc01x23 = vdupq_n_s32(0);
118 int32x4_t vacc01x45 = vdupq_n_s32(0);
119 int32x4_t vacc01x67 = vdupq_n_s32(0);
120 int32x4_t vacc01x89 = vdupq_n_s32(0);
121 int32x4_t vacc01xAB = vdupq_n_s32(0);
122 int32x4_t vacc01xCD = vdupq_n_s32(0);
123 int32x4_t vacc01xEF = vdupq_n_s32(0);
124 int32x4_t vacc01xGH = vdupq_n_s32(0);
125 int32x4_t vacc01xIJ = vdupq_n_s32(0);
126 int32x4_t vacc01xKL = vdupq_n_s32(0);
127 int32x4_t vacc01xMN = vdupq_n_s32(0);
128 int32x4_t vacc01xOP = vdupq_n_s32(0);
129 int32x4_t vacc01xQR = vdupq_n_s32(0);
130 int32x4_t vacc01xST = vdupq_n_s32(0);
131 int32x4_t vacc01xUV = vdupq_n_s32(0);
132 int32x4_t vacc23x01 = vdupq_n_s32(0);
133 int32x4_t vacc23x23 = vdupq_n_s32(0);
134 int32x4_t vacc23x45 = vdupq_n_s32(0);
135 int32x4_t vacc23x67 = vdupq_n_s32(0);
136 int32x4_t vacc23x89 = vdupq_n_s32(0);
137 int32x4_t vacc23xAB = vdupq_n_s32(0);
138 int32x4_t vacc23xCD = vdupq_n_s32(0);
139 int32x4_t vacc23xEF = vdupq_n_s32(0);
140 int32x4_t vacc23xGH = vdupq_n_s32(0);
141 int32x4_t vacc23xIJ = vdupq_n_s32(0);
142 int32x4_t vacc23xKL = vdupq_n_s32(0);
143 int32x4_t vacc23xMN = vdupq_n_s32(0);
144 int32x4_t vacc23xOP = vdupq_n_s32(0);
145 int32x4_t vacc23xQR = vdupq_n_s32(0);
146 int32x4_t vacc23xST = vdupq_n_s32(0);
147 int32x4_t vacc23xUV = vdupq_n_s32(0);
148
149 size_t k = bl;
150 // 2x partial unrolled loop to load 8 bytes at a time.
151
152 uint64x2x2_t va01x0123456789ABCDEF;
153 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
154 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
155 uint64x2x2_t va23x0123456789ABCDEF;
156 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
157 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
158
159 while (k >= 16 * sizeof(int8_t)) {
160 // Load a 4x16 block of activations.
161 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
162 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
163 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
164 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
165
166 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
167 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
168 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
169 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
170
171 // Load a 16x32 block of weights.
172 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
173 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
174 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
175 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
176 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
177 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
178 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
179 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
180 const int8x16_t vbGHx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
181 const int8x16_t vbIJx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
182 const int8x16_t vbKLx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
183 const int8x16_t vbMNx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
184 const int8x16_t vbOPx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
185 const int8x16_t vbQRx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
186 const int8x16_t vbSTx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
187 const int8x16_t vbUVx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
188 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
189 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
190 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
191 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
192 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
193 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
194 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
195 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
196 const int8x16_t vbGHx01234567 = vshlq_n_s8(vbGHx0123456789ABCDEF, 4);
197 const int8x16_t vbIJx01234567 = vshlq_n_s8(vbIJx0123456789ABCDEF, 4);
198 const int8x16_t vbKLx01234567 = vshlq_n_s8(vbKLx0123456789ABCDEF, 4);
199 const int8x16_t vbMNx01234567 = vshlq_n_s8(vbMNx0123456789ABCDEF, 4);
200 const int8x16_t vbOPx01234567 = vshlq_n_s8(vbOPx0123456789ABCDEF, 4);
201 const int8x16_t vbQRx01234567 = vshlq_n_s8(vbQRx0123456789ABCDEF, 4);
202 const int8x16_t vbSTx01234567 = vshlq_n_s8(vbSTx0123456789ABCDEF, 4);
203 const int8x16_t vbUVx01234567 = vshlq_n_s8(vbUVx0123456789ABCDEF, 4);
204 const int8x16_t vb01x89ABCDEF = vandq_s8(vb01x0123456789ABCDEF, vmask);
205 const int8x16_t vb23x89ABCDEF = vandq_s8(vb23x0123456789ABCDEF, vmask);
206 const int8x16_t vb45x89ABCDEF = vandq_s8(vb45x0123456789ABCDEF, vmask);
207 const int8x16_t vb67x89ABCDEF = vandq_s8(vb67x0123456789ABCDEF, vmask);
208 const int8x16_t vb89x89ABCDEF = vandq_s8(vb89x0123456789ABCDEF, vmask);
209 const int8x16_t vbABx89ABCDEF = vandq_s8(vbABx0123456789ABCDEF, vmask);
210 const int8x16_t vbCDx89ABCDEF = vandq_s8(vbCDx0123456789ABCDEF, vmask);
211 const int8x16_t vbEFx89ABCDEF = vandq_s8(vbEFx0123456789ABCDEF, vmask);
212 const int8x16_t vbGHx89ABCDEF = vandq_s8(vbGHx0123456789ABCDEF, vmask);
213 const int8x16_t vbIJx89ABCDEF = vandq_s8(vbIJx0123456789ABCDEF, vmask);
214 const int8x16_t vbKLx89ABCDEF = vandq_s8(vbKLx0123456789ABCDEF, vmask);
215 const int8x16_t vbMNx89ABCDEF = vandq_s8(vbMNx0123456789ABCDEF, vmask);
216 const int8x16_t vbOPx89ABCDEF = vandq_s8(vbOPx0123456789ABCDEF, vmask);
217 const int8x16_t vbQRx89ABCDEF = vandq_s8(vbQRx0123456789ABCDEF, vmask);
218 const int8x16_t vbSTx89ABCDEF = vandq_s8(vbSTx0123456789ABCDEF, vmask);
219 const int8x16_t vbUVx89ABCDEF = vandq_s8(vbUVx0123456789ABCDEF, vmask);
220
221 // Multiply-accumulate: 4x8 * 8x32 --> 4x32.
222 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
223 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
224 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
225 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
226 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
227 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
228 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
229 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
230 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x01234567, vbGHx01234567);
231 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x01234567, vbIJx01234567);
232 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x01234567, vbKLx01234567);
233 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x01234567, vbMNx01234567);
234 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x01234567, vbOPx01234567);
235 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x01234567, vbQRx01234567);
236 vacc01xST = vmmlaq_s32(vacc01xST, va01x01234567, vbSTx01234567);
237 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x01234567, vbUVx01234567);
238 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
239 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
240 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
241 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
242 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
243 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
244 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
245 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
246 vacc23xGH = vmmlaq_s32(vacc23xGH, va23x01234567, vbGHx01234567);
247 vacc23xIJ = vmmlaq_s32(vacc23xIJ, va23x01234567, vbIJx01234567);
248 vacc23xKL = vmmlaq_s32(vacc23xKL, va23x01234567, vbKLx01234567);
249 vacc23xMN = vmmlaq_s32(vacc23xMN, va23x01234567, vbMNx01234567);
250 vacc23xOP = vmmlaq_s32(vacc23xOP, va23x01234567, vbOPx01234567);
251 vacc23xQR = vmmlaq_s32(vacc23xQR, va23x01234567, vbQRx01234567);
252 vacc23xST = vmmlaq_s32(vacc23xST, va23x01234567, vbSTx01234567);
253 vacc23xUV = vmmlaq_s32(vacc23xUV, va23x01234567, vbUVx01234567);
254 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
255 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
256 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
257 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
258 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
259 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
260 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
261 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
262 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x89ABCDEF, vbGHx89ABCDEF);
263 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x89ABCDEF, vbIJx89ABCDEF);
264 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x89ABCDEF, vbKLx89ABCDEF);
265 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x89ABCDEF, vbMNx89ABCDEF);
266 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x89ABCDEF, vbOPx89ABCDEF);
267 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x89ABCDEF, vbQRx89ABCDEF);
268 vacc01xST = vmmlaq_s32(vacc01xST, va01x89ABCDEF, vbSTx89ABCDEF);
269 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x89ABCDEF, vbUVx89ABCDEF);
270 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
271 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
272 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
273 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
274 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
275 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
276 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
277 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
278 vacc23xGH = vmmlaq_s32(vacc23xGH, va23x89ABCDEF, vbGHx89ABCDEF);
279 vacc23xIJ = vmmlaq_s32(vacc23xIJ, va23x89ABCDEF, vbIJx89ABCDEF);
280 vacc23xKL = vmmlaq_s32(vacc23xKL, va23x89ABCDEF, vbKLx89ABCDEF);
281 vacc23xMN = vmmlaq_s32(vacc23xMN, va23x89ABCDEF, vbMNx89ABCDEF);
282 vacc23xOP = vmmlaq_s32(vacc23xOP, va23x89ABCDEF, vbOPx89ABCDEF);
283 vacc23xQR = vmmlaq_s32(vacc23xQR, va23x89ABCDEF, vbQRx89ABCDEF);
284 vacc23xST = vmmlaq_s32(vacc23xST, va23x89ABCDEF, vbSTx89ABCDEF);
285 vacc23xUV = vmmlaq_s32(vacc23xUV, va23x89ABCDEF, vbUVx89ABCDEF);
286
287 k -= 16 * sizeof(int8_t);
288 }
289 // Handle up to 8 final positions of `k`
290 if XNN_UNLIKELY(k != 0) {
291 // Load a 4x8 block of activations.
292 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
293 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
294 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
295 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
296
297 // Load a 16x32 block of weights.
298 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
299 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
300 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
301 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
302 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
303 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
304 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
305 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
306 const int8x16_t vbGHx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
307 const int8x16_t vbIJx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
308 const int8x16_t vbKLx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
309 const int8x16_t vbMNx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
310 const int8x16_t vbOPx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
311 const int8x16_t vbQRx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
312 const int8x16_t vbSTx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
313 const int8x16_t vbUVx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
314 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
315 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
316 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
317 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
318 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
319 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
320 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
321 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
322 const int8x16_t vbGHx01234567 = vshlq_n_s8(vbGHx0123456789ABCDEF, 4);
323 const int8x16_t vbIJx01234567 = vshlq_n_s8(vbIJx0123456789ABCDEF, 4);
324 const int8x16_t vbKLx01234567 = vshlq_n_s8(vbKLx0123456789ABCDEF, 4);
325 const int8x16_t vbMNx01234567 = vshlq_n_s8(vbMNx0123456789ABCDEF, 4);
326 const int8x16_t vbOPx01234567 = vshlq_n_s8(vbOPx0123456789ABCDEF, 4);
327 const int8x16_t vbQRx01234567 = vshlq_n_s8(vbQRx0123456789ABCDEF, 4);
328 const int8x16_t vbSTx01234567 = vshlq_n_s8(vbSTx0123456789ABCDEF, 4);
329 const int8x16_t vbUVx01234567 = vshlq_n_s8(vbUVx0123456789ABCDEF, 4);
330
331 // Multiply-accumulate: 4x4 * 4x32 --> 4x32.
332 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
333 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
334 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
335 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
336 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
337 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
338 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
339 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
340 vacc01xGH = vmmlaq_s32(vacc01xGH, vreinterpretq_s8_u64(va01x01234567), vbGHx01234567);
341 vacc01xIJ = vmmlaq_s32(vacc01xIJ, vreinterpretq_s8_u64(va01x01234567), vbIJx01234567);
342 vacc01xKL = vmmlaq_s32(vacc01xKL, vreinterpretq_s8_u64(va01x01234567), vbKLx01234567);
343 vacc01xMN = vmmlaq_s32(vacc01xMN, vreinterpretq_s8_u64(va01x01234567), vbMNx01234567);
344 vacc01xOP = vmmlaq_s32(vacc01xOP, vreinterpretq_s8_u64(va01x01234567), vbOPx01234567);
345 vacc01xQR = vmmlaq_s32(vacc01xQR, vreinterpretq_s8_u64(va01x01234567), vbQRx01234567);
346 vacc01xST = vmmlaq_s32(vacc01xST, vreinterpretq_s8_u64(va01x01234567), vbSTx01234567);
347 vacc01xUV = vmmlaq_s32(vacc01xUV, vreinterpretq_s8_u64(va01x01234567), vbUVx01234567);
348 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
349 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
350 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
351 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
352 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
353 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
354 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
355 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
356 vacc23xGH = vmmlaq_s32(vacc23xGH, vreinterpretq_s8_u64(va23x01234567), vbGHx01234567);
357 vacc23xIJ = vmmlaq_s32(vacc23xIJ, vreinterpretq_s8_u64(va23x01234567), vbIJx01234567);
358 vacc23xKL = vmmlaq_s32(vacc23xKL, vreinterpretq_s8_u64(va23x01234567), vbKLx01234567);
359 vacc23xMN = vmmlaq_s32(vacc23xMN, vreinterpretq_s8_u64(va23x01234567), vbMNx01234567);
360 vacc23xOP = vmmlaq_s32(vacc23xOP, vreinterpretq_s8_u64(va23x01234567), vbOPx01234567);
361 vacc23xQR = vmmlaq_s32(vacc23xQR, vreinterpretq_s8_u64(va23x01234567), vbQRx01234567);
362 vacc23xST = vmmlaq_s32(vacc23xST, vreinterpretq_s8_u64(va23x01234567), vbSTx01234567);
363 vacc23xUV = vmmlaq_s32(vacc23xUV, vreinterpretq_s8_u64(va23x01234567), vbUVx01234567);
364 }
365
366 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
367 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
368 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
369 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
370 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
371 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
372 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
373 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
374 int32x4_t vacc0xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
375 int32x4_t vacc1xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
376 int32x4_t vacc0xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
377 int32x4_t vacc1xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
378 int32x4_t vacc0xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
379 int32x4_t vacc1xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
380 int32x4_t vacc0xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
381 int32x4_t vacc1xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
382 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
383 int32x4_t vacc3x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
384 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
385 int32x4_t vacc3x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
386 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
387 int32x4_t vacc3x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
388 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
389 int32x4_t vacc3xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
390 int32x4_t vacc2xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xGH), vreinterpretq_u64_s32(vacc23xIJ)));
391 int32x4_t vacc3xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xGH), vreinterpretq_u64_s32(vacc23xIJ)));
392 int32x4_t vacc2xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xKL), vreinterpretq_u64_s32(vacc23xMN)));
393 int32x4_t vacc3xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xKL), vreinterpretq_u64_s32(vacc23xMN)));
394 int32x4_t vacc2xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xOP), vreinterpretq_u64_s32(vacc23xQR)));
395 int32x4_t vacc3xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xOP), vreinterpretq_u64_s32(vacc23xQR)));
396 int32x4_t vacc2xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xST), vreinterpretq_u64_s32(vacc23xUV)));
397 int32x4_t vacc3xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xST), vreinterpretq_u64_s32(vacc23xUV)));
398 const float32x4_t vfilter_output_scale0123 = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
399 const float32x4_t vfilter_output_scale4567 = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
400 const float32x4_t vfilter_output_scale89AB = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
401 const float32x4_t vfilter_output_scaleCDEF = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
402 const float32x4_t vfilter_output_scaleGHIJ = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
403 const float32x4_t vfilter_output_scaleKLMN = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
404 const float32x4_t vfilter_output_scaleOPQR = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
405 const float32x4_t vfilter_output_scaleSTUV = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
406 float32x4_t vf0x0123 = vcvtq_f32_s32(vacc0x0123);
407 vout0x0123 = vfmaq_f32(vout0x0123, vf0x0123, vfilter_output_scale0123);
408 float32x4_t vf0x4567 = vcvtq_f32_s32(vacc0x4567);
409 vout0x4567 = vfmaq_f32(vout0x4567, vf0x4567, vfilter_output_scale4567);
410 float32x4_t vf0x89AB = vcvtq_f32_s32(vacc0x89AB);
411 vout0x89AB = vfmaq_f32(vout0x89AB, vf0x89AB, vfilter_output_scale89AB);
412 float32x4_t vf0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
413 vout0xCDEF = vfmaq_f32(vout0xCDEF, vf0xCDEF, vfilter_output_scaleCDEF);
414 float32x4_t vf0xGHIJ = vcvtq_f32_s32(vacc0xGHIJ);
415 vout0xGHIJ = vfmaq_f32(vout0xGHIJ, vf0xGHIJ, vfilter_output_scaleGHIJ);
416 float32x4_t vf0xKLMN = vcvtq_f32_s32(vacc0xKLMN);
417 vout0xKLMN = vfmaq_f32(vout0xKLMN, vf0xKLMN, vfilter_output_scaleKLMN);
418 float32x4_t vf0xOPQR = vcvtq_f32_s32(vacc0xOPQR);
419 vout0xOPQR = vfmaq_f32(vout0xOPQR, vf0xOPQR, vfilter_output_scaleOPQR);
420 float32x4_t vf0xSTUV = vcvtq_f32_s32(vacc0xSTUV);
421 vout0xSTUV = vfmaq_f32(vout0xSTUV, vf0xSTUV, vfilter_output_scaleSTUV);
422 float32x4_t vf1x0123 = vcvtq_f32_s32(vacc1x0123);
423 vout1x0123 = vfmaq_f32(vout1x0123, vf1x0123, vfilter_output_scale0123);
424 float32x4_t vf1x4567 = vcvtq_f32_s32(vacc1x4567);
425 vout1x4567 = vfmaq_f32(vout1x4567, vf1x4567, vfilter_output_scale4567);
426 float32x4_t vf1x89AB = vcvtq_f32_s32(vacc1x89AB);
427 vout1x89AB = vfmaq_f32(vout1x89AB, vf1x89AB, vfilter_output_scale89AB);
428 float32x4_t vf1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
429 vout1xCDEF = vfmaq_f32(vout1xCDEF, vf1xCDEF, vfilter_output_scaleCDEF);
430 float32x4_t vf1xGHIJ = vcvtq_f32_s32(vacc1xGHIJ);
431 vout1xGHIJ = vfmaq_f32(vout1xGHIJ, vf1xGHIJ, vfilter_output_scaleGHIJ);
432 float32x4_t vf1xKLMN = vcvtq_f32_s32(vacc1xKLMN);
433 vout1xKLMN = vfmaq_f32(vout1xKLMN, vf1xKLMN, vfilter_output_scaleKLMN);
434 float32x4_t vf1xOPQR = vcvtq_f32_s32(vacc1xOPQR);
435 vout1xOPQR = vfmaq_f32(vout1xOPQR, vf1xOPQR, vfilter_output_scaleOPQR);
436 float32x4_t vf1xSTUV = vcvtq_f32_s32(vacc1xSTUV);
437 vout1xSTUV = vfmaq_f32(vout1xSTUV, vf1xSTUV, vfilter_output_scaleSTUV);
438 float32x4_t vf2x0123 = vcvtq_f32_s32(vacc2x0123);
439 vout2x0123 = vfmaq_f32(vout2x0123, vf2x0123, vfilter_output_scale0123);
440 float32x4_t vf2x4567 = vcvtq_f32_s32(vacc2x4567);
441 vout2x4567 = vfmaq_f32(vout2x4567, vf2x4567, vfilter_output_scale4567);
442 float32x4_t vf2x89AB = vcvtq_f32_s32(vacc2x89AB);
443 vout2x89AB = vfmaq_f32(vout2x89AB, vf2x89AB, vfilter_output_scale89AB);
444 float32x4_t vf2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
445 vout2xCDEF = vfmaq_f32(vout2xCDEF, vf2xCDEF, vfilter_output_scaleCDEF);
446 float32x4_t vf2xGHIJ = vcvtq_f32_s32(vacc2xGHIJ);
447 vout2xGHIJ = vfmaq_f32(vout2xGHIJ, vf2xGHIJ, vfilter_output_scaleGHIJ);
448 float32x4_t vf2xKLMN = vcvtq_f32_s32(vacc2xKLMN);
449 vout2xKLMN = vfmaq_f32(vout2xKLMN, vf2xKLMN, vfilter_output_scaleKLMN);
450 float32x4_t vf2xOPQR = vcvtq_f32_s32(vacc2xOPQR);
451 vout2xOPQR = vfmaq_f32(vout2xOPQR, vf2xOPQR, vfilter_output_scaleOPQR);
452 float32x4_t vf2xSTUV = vcvtq_f32_s32(vacc2xSTUV);
453 vout2xSTUV = vfmaq_f32(vout2xSTUV, vf2xSTUV, vfilter_output_scaleSTUV);
454 float32x4_t vf3x0123 = vcvtq_f32_s32(vacc3x0123);
455 vout3x0123 = vfmaq_f32(vout3x0123, vf3x0123, vfilter_output_scale0123);
456 float32x4_t vf3x4567 = vcvtq_f32_s32(vacc3x4567);
457 vout3x4567 = vfmaq_f32(vout3x4567, vf3x4567, vfilter_output_scale4567);
458 float32x4_t vf3x89AB = vcvtq_f32_s32(vacc3x89AB);
459 vout3x89AB = vfmaq_f32(vout3x89AB, vf3x89AB, vfilter_output_scale89AB);
460 float32x4_t vf3xCDEF = vcvtq_f32_s32(vacc3xCDEF);
461 vout3xCDEF = vfmaq_f32(vout3xCDEF, vf3xCDEF, vfilter_output_scaleCDEF);
462 float32x4_t vf3xGHIJ = vcvtq_f32_s32(vacc3xGHIJ);
463 vout3xGHIJ = vfmaq_f32(vout3xGHIJ, vf3xGHIJ, vfilter_output_scaleGHIJ);
464 float32x4_t vf3xKLMN = vcvtq_f32_s32(vacc3xKLMN);
465 vout3xKLMN = vfmaq_f32(vout3xKLMN, vf3xKLMN, vfilter_output_scaleKLMN);
466 float32x4_t vf3xOPQR = vcvtq_f32_s32(vacc3xOPQR);
467 vout3xOPQR = vfmaq_f32(vout3xOPQR, vf3xOPQR, vfilter_output_scaleOPQR);
468 float32x4_t vf3xSTUV = vcvtq_f32_s32(vacc3xSTUV);
469 vout3xSTUV = vfmaq_f32(vout3xSTUV, vf3xSTUV, vfilter_output_scaleSTUV);
470 }
471
472 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
473 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
474 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
475 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
476 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
477 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
478 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
479 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
480 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
481 vout0xGHIJ = vmulq_lane_f32(vout0xGHIJ, vget_low_f32(vinput_scale01), 1);
482 vout1xGHIJ = vmulq_lane_f32(vout1xGHIJ, vget_high_f32(vinput_scale01), 1);
483 vout0xKLMN = vmulq_lane_f32(vout0xKLMN, vget_low_f32(vinput_scale01), 1);
484 vout1xKLMN = vmulq_lane_f32(vout1xKLMN, vget_high_f32(vinput_scale01), 1);
485 vout0xOPQR = vmulq_lane_f32(vout0xOPQR, vget_low_f32(vinput_scale01), 1);
486 vout1xOPQR = vmulq_lane_f32(vout1xOPQR, vget_high_f32(vinput_scale01), 1);
487 vout0xSTUV = vmulq_lane_f32(vout0xSTUV, vget_low_f32(vinput_scale01), 1);
488 vout1xSTUV = vmulq_lane_f32(vout1xSTUV, vget_high_f32(vinput_scale01), 1);
489 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
490 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
491 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
492 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
493 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
494 vout2x89AB = vmulq_lane_f32(vout2x89AB, vget_low_f32(vinput_scale23), 1);
495 vout3x89AB = vmulq_lane_f32(vout3x89AB, vget_high_f32(vinput_scale23), 1);
496 vout2xCDEF = vmulq_lane_f32(vout2xCDEF, vget_low_f32(vinput_scale23), 1);
497 vout3xCDEF = vmulq_lane_f32(vout3xCDEF, vget_high_f32(vinput_scale23), 1);
498 vout2xGHIJ = vmulq_lane_f32(vout2xGHIJ, vget_low_f32(vinput_scale23), 1);
499 vout3xGHIJ = vmulq_lane_f32(vout3xGHIJ, vget_high_f32(vinput_scale23), 1);
500 vout2xKLMN = vmulq_lane_f32(vout2xKLMN, vget_low_f32(vinput_scale23), 1);
501 vout3xKLMN = vmulq_lane_f32(vout3xKLMN, vget_high_f32(vinput_scale23), 1);
502 vout2xOPQR = vmulq_lane_f32(vout2xOPQR, vget_low_f32(vinput_scale23), 1);
503 vout3xOPQR = vmulq_lane_f32(vout3xOPQR, vget_high_f32(vinput_scale23), 1);
504 vout2xSTUV = vmulq_lane_f32(vout2xSTUV, vget_low_f32(vinput_scale23), 1);
505 vout3xSTUV = vmulq_lane_f32(vout3xSTUV, vget_high_f32(vinput_scale23), 1);
506
507
508 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
509 vout0x0123 = vaddq_f32(vbias0123, vout0x0123);
510 vout1x0123 = vaddq_f32(vbias0123, vout1x0123);
511 vout2x0123 = vaddq_f32(vbias0123, vout2x0123);
512 vout3x0123 = vaddq_f32(vbias0123, vout3x0123);
513 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
514 vout0x4567 = vaddq_f32(vbias4567, vout0x4567);
515 vout1x4567 = vaddq_f32(vbias4567, vout1x4567);
516 vout2x4567 = vaddq_f32(vbias4567, vout2x4567);
517 vout3x4567 = vaddq_f32(vbias4567, vout3x4567);
518 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
519 vout0x89AB = vaddq_f32(vbias89AB, vout0x89AB);
520 vout1x89AB = vaddq_f32(vbias89AB, vout1x89AB);
521 vout2x89AB = vaddq_f32(vbias89AB, vout2x89AB);
522 vout3x89AB = vaddq_f32(vbias89AB, vout3x89AB);
523 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
524 vout0xCDEF = vaddq_f32(vbiasCDEF, vout0xCDEF);
525 vout1xCDEF = vaddq_f32(vbiasCDEF, vout1xCDEF);
526 vout2xCDEF = vaddq_f32(vbiasCDEF, vout2xCDEF);
527 vout3xCDEF = vaddq_f32(vbiasCDEF, vout3xCDEF);
528 const float32x4_t vbiasGHIJ = vld1q_f32(w); w = (const float*) w + 4;
529 vout0xGHIJ = vaddq_f32(vbiasGHIJ, vout0xGHIJ);
530 vout1xGHIJ = vaddq_f32(vbiasGHIJ, vout1xGHIJ);
531 vout2xGHIJ = vaddq_f32(vbiasGHIJ, vout2xGHIJ);
532 vout3xGHIJ = vaddq_f32(vbiasGHIJ, vout3xGHIJ);
533 const float32x4_t vbiasKLMN = vld1q_f32(w); w = (const float*) w + 4;
534 vout0xKLMN = vaddq_f32(vbiasKLMN, vout0xKLMN);
535 vout1xKLMN = vaddq_f32(vbiasKLMN, vout1xKLMN);
536 vout2xKLMN = vaddq_f32(vbiasKLMN, vout2xKLMN);
537 vout3xKLMN = vaddq_f32(vbiasKLMN, vout3xKLMN);
538 const float32x4_t vbiasOPQR = vld1q_f32(w); w = (const float*) w + 4;
539 vout0xOPQR = vaddq_f32(vbiasOPQR, vout0xOPQR);
540 vout1xOPQR = vaddq_f32(vbiasOPQR, vout1xOPQR);
541 vout2xOPQR = vaddq_f32(vbiasOPQR, vout2xOPQR);
542 vout3xOPQR = vaddq_f32(vbiasOPQR, vout3xOPQR);
543 const float32x4_t vbiasSTUV = vld1q_f32(w); w = (const float*) w + 4;
544 vout0xSTUV = vaddq_f32(vbiasSTUV, vout0xSTUV);
545 vout1xSTUV = vaddq_f32(vbiasSTUV, vout1xSTUV);
546 vout2xSTUV = vaddq_f32(vbiasSTUV, vout2xSTUV);
547 vout3xSTUV = vaddq_f32(vbiasSTUV, vout3xSTUV);
548
549 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
550 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
551 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
552 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
553 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
554 vout0xGHIJ = vmaxq_f32(vout0xGHIJ, voutput_min);
555 vout0xKLMN = vmaxq_f32(vout0xKLMN, voutput_min);
556 vout0xOPQR = vmaxq_f32(vout0xOPQR, voutput_min);
557 vout0xSTUV = vmaxq_f32(vout0xSTUV, voutput_min);
558 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
559 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
560 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
561 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
562 vout1xGHIJ = vmaxq_f32(vout1xGHIJ, voutput_min);
563 vout1xKLMN = vmaxq_f32(vout1xKLMN, voutput_min);
564 vout1xOPQR = vmaxq_f32(vout1xOPQR, voutput_min);
565 vout1xSTUV = vmaxq_f32(vout1xSTUV, voutput_min);
566 vout2x0123 = vmaxq_f32(vout2x0123, voutput_min);
567 vout2x4567 = vmaxq_f32(vout2x4567, voutput_min);
568 vout2x89AB = vmaxq_f32(vout2x89AB, voutput_min);
569 vout2xCDEF = vmaxq_f32(vout2xCDEF, voutput_min);
570 vout2xGHIJ = vmaxq_f32(vout2xGHIJ, voutput_min);
571 vout2xKLMN = vmaxq_f32(vout2xKLMN, voutput_min);
572 vout2xOPQR = vmaxq_f32(vout2xOPQR, voutput_min);
573 vout2xSTUV = vmaxq_f32(vout2xSTUV, voutput_min);
574 vout3x0123 = vmaxq_f32(vout3x0123, voutput_min);
575 vout3x4567 = vmaxq_f32(vout3x4567, voutput_min);
576 vout3x89AB = vmaxq_f32(vout3x89AB, voutput_min);
577 vout3xCDEF = vmaxq_f32(vout3xCDEF, voutput_min);
578 vout3xGHIJ = vmaxq_f32(vout3xGHIJ, voutput_min);
579 vout3xKLMN = vmaxq_f32(vout3xKLMN, voutput_min);
580 vout3xOPQR = vmaxq_f32(vout3xOPQR, voutput_min);
581 vout3xSTUV = vmaxq_f32(vout3xSTUV, voutput_min);
582
583 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
584 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
585 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
586 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
587 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
588 vout0xGHIJ = vminq_f32(vout0xGHIJ, voutput_max);
589 vout0xKLMN = vminq_f32(vout0xKLMN, voutput_max);
590 vout0xOPQR = vminq_f32(vout0xOPQR, voutput_max);
591 vout0xSTUV = vminq_f32(vout0xSTUV, voutput_max);
592 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
593 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
594 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
595 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
596 vout1xGHIJ = vminq_f32(vout1xGHIJ, voutput_max);
597 vout1xKLMN = vminq_f32(vout1xKLMN, voutput_max);
598 vout1xOPQR = vminq_f32(vout1xOPQR, voutput_max);
599 vout1xSTUV = vminq_f32(vout1xSTUV, voutput_max);
600 vout2x0123 = vminq_f32(vout2x0123, voutput_max);
601 vout2x4567 = vminq_f32(vout2x4567, voutput_max);
602 vout2x89AB = vminq_f32(vout2x89AB, voutput_max);
603 vout2xCDEF = vminq_f32(vout2xCDEF, voutput_max);
604 vout2xGHIJ = vminq_f32(vout2xGHIJ, voutput_max);
605 vout2xKLMN = vminq_f32(vout2xKLMN, voutput_max);
606 vout2xOPQR = vminq_f32(vout2xOPQR, voutput_max);
607 vout2xSTUV = vminq_f32(vout2xSTUV, voutput_max);
608 vout3x0123 = vminq_f32(vout3x0123, voutput_max);
609 vout3x4567 = vminq_f32(vout3x4567, voutput_max);
610 vout3x89AB = vminq_f32(vout3x89AB, voutput_max);
611 vout3xCDEF = vminq_f32(vout3xCDEF, voutput_max);
612 vout3xGHIJ = vminq_f32(vout3xGHIJ, voutput_max);
613 vout3xKLMN = vminq_f32(vout3xKLMN, voutput_max);
614 vout3xOPQR = vminq_f32(vout3xOPQR, voutput_max);
615 vout3xSTUV = vminq_f32(vout3xSTUV, voutput_max);
616
617 if XNN_LIKELY(nc >= 32) {
618 vst1q_f32(c0, vout0x0123);
619 vst1q_f32(c0 + 4, vout0x4567);
620 vst1q_f32(c0 + 8, vout0x89AB);
621 vst1q_f32(c0 + 12, vout0xCDEF);
622 vst1q_f32(c0 + 16, vout0xGHIJ);
623 vst1q_f32(c0 + 20, vout0xKLMN);
624 vst1q_f32(c0 + 24, vout0xOPQR);
625 vst1q_f32(c0 + 28, vout0xSTUV);
626 vst1q_f32(c1, vout1x0123);
627 vst1q_f32(c1 + 4, vout1x4567);
628 vst1q_f32(c1 + 8, vout1x89AB);
629 vst1q_f32(c1 + 12, vout1xCDEF);
630 vst1q_f32(c1 + 16, vout1xGHIJ);
631 vst1q_f32(c1 + 20, vout1xKLMN);
632 vst1q_f32(c1 + 24, vout1xOPQR);
633 vst1q_f32(c1 + 28, vout1xSTUV);
634 vst1q_f32(c2, vout2x0123);
635 vst1q_f32(c2 + 4, vout2x4567);
636 vst1q_f32(c2 + 8, vout2x89AB);
637 vst1q_f32(c2 + 12, vout2xCDEF);
638 vst1q_f32(c2 + 16, vout2xGHIJ);
639 vst1q_f32(c2 + 20, vout2xKLMN);
640 vst1q_f32(c2 + 24, vout2xOPQR);
641 vst1q_f32(c2 + 28, vout2xSTUV);
642 vst1q_f32(c3, vout3x0123);
643 vst1q_f32(c3 + 4, vout3x4567);
644 vst1q_f32(c3 + 8, vout3x89AB);
645 vst1q_f32(c3 + 12, vout3xCDEF);
646 vst1q_f32(c3 + 16, vout3xGHIJ);
647 vst1q_f32(c3 + 20, vout3xKLMN);
648 vst1q_f32(c3 + 24, vout3xOPQR);
649 vst1q_f32(c3 + 28, vout3xSTUV);
650
651 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
652 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
653 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
654 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
655
656 c0 = (float*) ((uintptr_t) c0 + cn_stride);
657 c1 = (float*) ((uintptr_t) c1 + cn_stride);
658 c2 = (float*) ((uintptr_t) c2 + cn_stride);
659 c3 = (float*) ((uintptr_t) c3 + cn_stride);
660
661 nc -= 32;
662 } else {
663 if (nc & 16) {
664 vst1q_f32(c0, vout0x0123); c0 += 4;
665 vout0x0123 = vout0xGHIJ;
666 vst1q_f32(c1, vout1x0123); c1 += 4;
667 vout1x0123 = vout1xGHIJ;
668 vst1q_f32(c2, vout2x0123); c2 += 4;
669 vout2x0123 = vout2xGHIJ;
670 vst1q_f32(c3, vout3x0123); c3 += 4;
671 vout3x0123 = vout3xGHIJ;
672 vst1q_f32(c0, vout0x4567); c0 += 4;
673 vout0x4567 = vout0xKLMN;
674 vst1q_f32(c1, vout1x4567); c1 += 4;
675 vout1x4567 = vout1xKLMN;
676 vst1q_f32(c2, vout2x4567); c2 += 4;
677 vout2x4567 = vout2xKLMN;
678 vst1q_f32(c3, vout3x4567); c3 += 4;
679 vout3x4567 = vout3xKLMN;
680 vst1q_f32(c0, vout0x89AB); c0 += 4;
681 vout0x89AB = vout0xOPQR;
682 vst1q_f32(c1, vout1x89AB); c1 += 4;
683 vout1x89AB = vout1xOPQR;
684 vst1q_f32(c2, vout2x89AB); c2 += 4;
685 vout2x89AB = vout2xOPQR;
686 vst1q_f32(c3, vout3x89AB); c3 += 4;
687 vout3x89AB = vout3xOPQR;
688 vst1q_f32(c0, vout0xCDEF); c0 += 4;
689 vout0xCDEF = vout0xSTUV;
690 vst1q_f32(c1, vout1xCDEF); c1 += 4;
691 vout1xCDEF = vout1xSTUV;
692 vst1q_f32(c2, vout2xCDEF); c2 += 4;
693 vout2xCDEF = vout2xSTUV;
694 vst1q_f32(c3, vout3xCDEF); c3 += 4;
695 vout3xCDEF = vout3xSTUV;
696 }
697 if (nc & 8) {
698 vst1q_f32(c0, vout0x0123); c0 += 4;
699 vout0x0123 = vout0x89AB;
700 vst1q_f32(c1, vout1x0123); c1 += 4;
701 vout1x0123 = vout1x89AB;
702 vst1q_f32(c2, vout2x0123); c2 += 4;
703 vout2x0123 = vout2x89AB;
704 vst1q_f32(c3, vout3x0123); c3 += 4;
705 vout3x0123 = vout3x89AB;
706 vst1q_f32(c0, vout0x4567); c0 += 4;
707 vout0x4567 = vout0xCDEF;
708 vst1q_f32(c1, vout1x4567); c1 += 4;
709 vout1x4567 = vout1xCDEF;
710 vst1q_f32(c2, vout2x4567); c2 += 4;
711 vout2x4567 = vout2xCDEF;
712 vst1q_f32(c3, vout3x4567); c3 += 4;
713 vout3x4567 = vout3xCDEF;
714 }
715 if (nc & 4) {
716 vst1q_f32(c0, vout0x0123); c0 += 4;
717 vout0x0123 = vout0x4567;
718 vst1q_f32(c1, vout1x0123); c1 += 4;
719 vout1x0123 = vout1x4567;
720 vst1q_f32(c2, vout2x0123); c2 += 4;
721 vout2x0123 = vout2x4567;
722 vst1q_f32(c3, vout3x0123); c3 += 4;
723 vout3x0123 = vout3x4567;
724 }
725 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
726 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
727 float32x2_t vout2x01 = vget_low_f32(vout2x0123);
728 float32x2_t vout3x01 = vget_low_f32(vout3x0123);
729 if (nc & 2) {
730 vst1_f32(c0, vout0x01); c0 += 2;
731 vst1_f32(c1, vout1x01); c1 += 2;
732 vst1_f32(c2, vout2x01); c2 += 2;
733 vst1_f32(c3, vout3x01); c3 += 2;
734 vout0x01 = vget_high_f32(vout0x0123);
735 vout1x01 = vget_high_f32(vout1x0123);
736 vout2x01 = vget_high_f32(vout2x0123);
737 vout3x01 = vget_high_f32(vout3x0123);
738 }
739 if (nc & 1) {
740 vst1_lane_f32(c0, vout0x01, 0);
741 vst1_lane_f32(c1, vout1x01, 0);
742 vst1_lane_f32(c2, vout2x01, 0);
743 vst1_lane_f32(c3, vout3x01, 0);
744 }
745 nc = 0;
746 }
747 } while (nc != 0);
748 }