Debian Codegraph @

src/qd8-f32-qc4w-gemm/gen/qd8-f32-qc4w-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_f32_qc4w_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 float* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const struct xnn_f32_qc4w_minmax_params params[restrict XNN_MIN_ELEMENTS(1)],
29 const struct xnn_qd8_quantization_params quantization_params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31 assert(mr != 0);
32 assert(mr <= 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 float* c0 = c;
43 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
44 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
45 if XNN_UNPREDICTABLE(mr != 2) {
46 a1 = a0;
47 c1 = c0;
48 }
49 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
50
51 // Loop over groups of 32 columns.
52 do {
53 // Initialize accumulators with bias. 32 bias values are loaded from the
54 // weight matrix, at the start of the group of 32 columns.
55 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
56 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
57 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
58 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
59 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
60 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
61 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
62 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
63 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
64 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
65 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
66 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
67 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
68 const int32x4_t vksumGHIJ = vld1q_s32(w); w = (const int32_t*) w + 4;
69 const int32x4_t vksumzp0xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_low_s32(vinput_zero_point01), 0);
70 const int32x4_t vksumzp1xGHIJ = vmulq_lane_s32(vksumGHIJ, vget_high_s32(vinput_zero_point01), 0);
71 const int32x4_t vksumKLMN = vld1q_s32(w); w = (const int32_t*) w + 4;
72 const int32x4_t vksumzp0xKLMN = vmulq_lane_s32(vksumKLMN, vget_low_s32(vinput_zero_point01), 0);
73 const int32x4_t vksumzp1xKLMN = vmulq_lane_s32(vksumKLMN, vget_high_s32(vinput_zero_point01), 0);
74 const int32x4_t vksumOPQR = vld1q_s32(w); w = (const int32_t*) w + 4;
75 const int32x4_t vksumzp0xOPQR = vmulq_lane_s32(vksumOPQR, vget_low_s32(vinput_zero_point01), 0);
76 const int32x4_t vksumzp1xOPQR = vmulq_lane_s32(vksumOPQR, vget_high_s32(vinput_zero_point01), 0);
77 const int32x4_t vksumSTUV = vld1q_s32(w); w = (const int32_t*) w + 4;
78 const int32x4_t vksumzp0xSTUV = vmulq_lane_s32(vksumSTUV, vget_low_s32(vinput_zero_point01), 0);
79 const int32x4_t vksumzp1xSTUV = vmulq_lane_s32(vksumSTUV, vget_high_s32(vinput_zero_point01), 0);
80
81 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
82 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
83 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
84 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
85 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
86 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
87 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
88 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
89 int32x4_t vacc01xGH = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
90 int32x4_t vacc01xIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xGHIJ), vreinterpretq_u64_s32(vksumzp1xGHIJ)));
91 int32x4_t vacc01xKL = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
92 int32x4_t vacc01xMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xKLMN), vreinterpretq_u64_s32(vksumzp1xKLMN)));
93 int32x4_t vacc01xOP = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
94 int32x4_t vacc01xQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xOPQR), vreinterpretq_u64_s32(vksumzp1xOPQR)));
95 int32x4_t vacc01xST = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
96 int32x4_t vacc01xUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xSTUV), vreinterpretq_u64_s32(vksumzp1xSTUV)));
97
98 // Inner accumulation loop along the 32 columns.
99 size_t k = kc;
100 // 2x partial unrolled loop to load 8 bytes at a time.
101
102 uint64x2x2_t va01x0123456789ABCDEF;
103 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
104 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
105
106 while (k >= 16 * sizeof(int8_t)) {
107 // Load a 2x16 block of activations.
108 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
109 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
110
111 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
112 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
113
114 // Load a 16x32 block of weights.
115 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
116 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
117 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
118 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
119 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
120 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
121 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
122 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
123 const int8x16_t vbGHx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
124 const int8x16_t vbIJx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
125 const int8x16_t vbKLx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
126 const int8x16_t vbMNx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
127 const int8x16_t vbOPx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
128 const int8x16_t vbQRx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
129 const int8x16_t vbSTx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
130 const int8x16_t vbUVx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
131 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
132 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
133 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
134 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
135 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
136 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
137 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
138 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
139 const int8x16_t vbGHx01234567 = vshlq_n_s8(vbGHx0123456789ABCDEF, 4);
140 const int8x16_t vbIJx01234567 = vshlq_n_s8(vbIJx0123456789ABCDEF, 4);
141 const int8x16_t vbKLx01234567 = vshlq_n_s8(vbKLx0123456789ABCDEF, 4);
142 const int8x16_t vbMNx01234567 = vshlq_n_s8(vbMNx0123456789ABCDEF, 4);
143 const int8x16_t vbOPx01234567 = vshlq_n_s8(vbOPx0123456789ABCDEF, 4);
144 const int8x16_t vbQRx01234567 = vshlq_n_s8(vbQRx0123456789ABCDEF, 4);
145 const int8x16_t vbSTx01234567 = vshlq_n_s8(vbSTx0123456789ABCDEF, 4);
146 const int8x16_t vbUVx01234567 = vshlq_n_s8(vbUVx0123456789ABCDEF, 4);
147 const int8x16_t vb01x89ABCDEF = vandq_s8(vb01x0123456789ABCDEF, vmask);
148 const int8x16_t vb23x89ABCDEF = vandq_s8(vb23x0123456789ABCDEF, vmask);
149 const int8x16_t vb45x89ABCDEF = vandq_s8(vb45x0123456789ABCDEF, vmask);
150 const int8x16_t vb67x89ABCDEF = vandq_s8(vb67x0123456789ABCDEF, vmask);
151 const int8x16_t vb89x89ABCDEF = vandq_s8(vb89x0123456789ABCDEF, vmask);
152 const int8x16_t vbABx89ABCDEF = vandq_s8(vbABx0123456789ABCDEF, vmask);
153 const int8x16_t vbCDx89ABCDEF = vandq_s8(vbCDx0123456789ABCDEF, vmask);
154 const int8x16_t vbEFx89ABCDEF = vandq_s8(vbEFx0123456789ABCDEF, vmask);
155 const int8x16_t vbGHx89ABCDEF = vandq_s8(vbGHx0123456789ABCDEF, vmask);
156 const int8x16_t vbIJx89ABCDEF = vandq_s8(vbIJx0123456789ABCDEF, vmask);
157 const int8x16_t vbKLx89ABCDEF = vandq_s8(vbKLx0123456789ABCDEF, vmask);
158 const int8x16_t vbMNx89ABCDEF = vandq_s8(vbMNx0123456789ABCDEF, vmask);
159 const int8x16_t vbOPx89ABCDEF = vandq_s8(vbOPx0123456789ABCDEF, vmask);
160 const int8x16_t vbQRx89ABCDEF = vandq_s8(vbQRx0123456789ABCDEF, vmask);
161 const int8x16_t vbSTx89ABCDEF = vandq_s8(vbSTx0123456789ABCDEF, vmask);
162 const int8x16_t vbUVx89ABCDEF = vandq_s8(vbUVx0123456789ABCDEF, vmask);
163
164 // Multiply-accumulate: 2x8 * 8x32 --> 2x32.
165 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
166 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
167 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
168 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
169 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
170 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
171 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
172 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
173 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x01234567, vbGHx01234567);
174 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x01234567, vbIJx01234567);
175 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x01234567, vbKLx01234567);
176 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x01234567, vbMNx01234567);
177 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x01234567, vbOPx01234567);
178 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x01234567, vbQRx01234567);
179 vacc01xST = vmmlaq_s32(vacc01xST, va01x01234567, vbSTx01234567);
180 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x01234567, vbUVx01234567);
181 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
182 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
183 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
184 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
185 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
186 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
187 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
188 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
189 vacc01xGH = vmmlaq_s32(vacc01xGH, va01x89ABCDEF, vbGHx89ABCDEF);
190 vacc01xIJ = vmmlaq_s32(vacc01xIJ, va01x89ABCDEF, vbIJx89ABCDEF);
191 vacc01xKL = vmmlaq_s32(vacc01xKL, va01x89ABCDEF, vbKLx89ABCDEF);
192 vacc01xMN = vmmlaq_s32(vacc01xMN, va01x89ABCDEF, vbMNx89ABCDEF);
193 vacc01xOP = vmmlaq_s32(vacc01xOP, va01x89ABCDEF, vbOPx89ABCDEF);
194 vacc01xQR = vmmlaq_s32(vacc01xQR, va01x89ABCDEF, vbQRx89ABCDEF);
195 vacc01xST = vmmlaq_s32(vacc01xST, va01x89ABCDEF, vbSTx89ABCDEF);
196 vacc01xUV = vmmlaq_s32(vacc01xUV, va01x89ABCDEF, vbUVx89ABCDEF);
197
198 k -= 16 * sizeof(int8_t);
199 }
200 // Handle up to 8 final positions of `k`
201 if XNN_UNLIKELY(k != 0) {
202 // Load a 2x8 block of activations.
203 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
204 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
205
206 // Load a 16x32 block of weights.
207 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
208 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
209 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
210 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
211 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
212 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
213 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
214 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
215 const int8x16_t vbGHx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
216 const int8x16_t vbIJx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
217 const int8x16_t vbKLx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
218 const int8x16_t vbMNx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
219 const int8x16_t vbOPx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
220 const int8x16_t vbQRx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
221 const int8x16_t vbSTx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
222 const int8x16_t vbUVx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
223 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
224 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
225 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
226 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
227 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
228 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
229 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
230 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
231 const int8x16_t vbGHx01234567 = vshlq_n_s8(vbGHx0123456789ABCDEF, 4);
232 const int8x16_t vbIJx01234567 = vshlq_n_s8(vbIJx0123456789ABCDEF, 4);
233 const int8x16_t vbKLx01234567 = vshlq_n_s8(vbKLx0123456789ABCDEF, 4);
234 const int8x16_t vbMNx01234567 = vshlq_n_s8(vbMNx0123456789ABCDEF, 4);
235 const int8x16_t vbOPx01234567 = vshlq_n_s8(vbOPx0123456789ABCDEF, 4);
236 const int8x16_t vbQRx01234567 = vshlq_n_s8(vbQRx0123456789ABCDEF, 4);
237 const int8x16_t vbSTx01234567 = vshlq_n_s8(vbSTx0123456789ABCDEF, 4);
238 const int8x16_t vbUVx01234567 = vshlq_n_s8(vbUVx0123456789ABCDEF, 4);
239
240 // Multiply-accumulate: 2x4 * 4x32 --> 2x32.
241 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
242 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
243 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
244 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
245 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
246 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
247 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
248 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
249 vacc01xGH = vmmlaq_s32(vacc01xGH, vreinterpretq_s8_u64(va01x01234567), vbGHx01234567);
250 vacc01xIJ = vmmlaq_s32(vacc01xIJ, vreinterpretq_s8_u64(va01x01234567), vbIJx01234567);
251 vacc01xKL = vmmlaq_s32(vacc01xKL, vreinterpretq_s8_u64(va01x01234567), vbKLx01234567);
252 vacc01xMN = vmmlaq_s32(vacc01xMN, vreinterpretq_s8_u64(va01x01234567), vbMNx01234567);
253 vacc01xOP = vmmlaq_s32(vacc01xOP, vreinterpretq_s8_u64(va01x01234567), vbOPx01234567);
254 vacc01xQR = vmmlaq_s32(vacc01xQR, vreinterpretq_s8_u64(va01x01234567), vbQRx01234567);
255 vacc01xST = vmmlaq_s32(vacc01xST, vreinterpretq_s8_u64(va01x01234567), vbSTx01234567);
256 vacc01xUV = vmmlaq_s32(vacc01xUV, vreinterpretq_s8_u64(va01x01234567), vbUVx01234567);
257 }
258
259 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
260 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
261 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
262 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
263 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
264 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
265 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
266 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
267 int32x4_t vacc0xGHIJ = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
268 int32x4_t vacc1xGHIJ = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xGH), vreinterpretq_u64_s32(vacc01xIJ)));
269 int32x4_t vacc0xKLMN = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
270 int32x4_t vacc1xKLMN = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xKL), vreinterpretq_u64_s32(vacc01xMN)));
271 int32x4_t vacc0xOPQR = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
272 int32x4_t vacc1xOPQR = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xOP), vreinterpretq_u64_s32(vacc01xQR)));
273 int32x4_t vacc0xSTUV = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
274 int32x4_t vacc1xSTUV = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xST), vreinterpretq_u64_s32(vacc01xUV)));
275 float32x4_t vout0x0123 = vcvtq_n_f32_s32(vacc0x0123, 4);
276 float32x4_t vout0x4567 = vcvtq_n_f32_s32(vacc0x4567, 4);
277 float32x4_t vout0x89AB = vcvtq_n_f32_s32(vacc0x89AB, 4);
278 float32x4_t vout0xCDEF = vcvtq_n_f32_s32(vacc0xCDEF, 4);
279 float32x4_t vout0xGHIJ = vcvtq_n_f32_s32(vacc0xGHIJ, 4);
280 float32x4_t vout0xKLMN = vcvtq_n_f32_s32(vacc0xKLMN, 4);
281 float32x4_t vout0xOPQR = vcvtq_n_f32_s32(vacc0xOPQR, 4);
282 float32x4_t vout0xSTUV = vcvtq_n_f32_s32(vacc0xSTUV, 4);
283 float32x4_t vout1x0123 = vcvtq_n_f32_s32(vacc1x0123, 4);
284 float32x4_t vout1x4567 = vcvtq_n_f32_s32(vacc1x4567, 4);
285 float32x4_t vout1x89AB = vcvtq_n_f32_s32(vacc1x89AB, 4);
286 float32x4_t vout1xCDEF = vcvtq_n_f32_s32(vacc1xCDEF, 4);
287 float32x4_t vout1xGHIJ = vcvtq_n_f32_s32(vacc1xGHIJ, 4);
288 float32x4_t vout1xKLMN = vcvtq_n_f32_s32(vacc1xKLMN, 4);
289 float32x4_t vout1xOPQR = vcvtq_n_f32_s32(vacc1xOPQR, 4);
290 float32x4_t vout1xSTUV = vcvtq_n_f32_s32(vacc1xSTUV, 4);
291
292 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
293 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
294 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
295 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
296 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
297 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
298 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
299 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
300 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
301 vout0xGHIJ = vmulq_lane_f32(vout0xGHIJ, vget_low_f32(vinput_scale01), 1);
302 vout1xGHIJ = vmulq_lane_f32(vout1xGHIJ, vget_high_f32(vinput_scale01), 1);
303 vout0xKLMN = vmulq_lane_f32(vout0xKLMN, vget_low_f32(vinput_scale01), 1);
304 vout1xKLMN = vmulq_lane_f32(vout1xKLMN, vget_high_f32(vinput_scale01), 1);
305 vout0xOPQR = vmulq_lane_f32(vout0xOPQR, vget_low_f32(vinput_scale01), 1);
306 vout1xOPQR = vmulq_lane_f32(vout1xOPQR, vget_high_f32(vinput_scale01), 1);
307 vout0xSTUV = vmulq_lane_f32(vout0xSTUV, vget_low_f32(vinput_scale01), 1);
308 vout1xSTUV = vmulq_lane_f32(vout1xSTUV, vget_high_f32(vinput_scale01), 1);
309
310 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
311 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
312 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
313 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
314 const float32x4_t vfilter_output_scaleGHIJ = vld1q_f32(w); w = (const float*) w + 4;
315 const float32x4_t vfilter_output_scaleKLMN = vld1q_f32(w); w = (const float*) w + 4;
316 const float32x4_t vfilter_output_scaleOPQR = vld1q_f32(w); w = (const float*) w + 4;
317 const float32x4_t vfilter_output_scaleSTUV = vld1q_f32(w); w = (const float*) w + 4;
318
319 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
320 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
321 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
322 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
323 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
324 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
325 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
326 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
327 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
328 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
329 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
330 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
331 const float32x4_t vbiasGHIJ = vld1q_f32(w); w = (const float*) w + 4;
332 vout0xGHIJ = vfmaq_f32(vbiasGHIJ, vout0xGHIJ, vfilter_output_scaleGHIJ);
333 vout1xGHIJ = vfmaq_f32(vbiasGHIJ, vout1xGHIJ, vfilter_output_scaleGHIJ);
334 const float32x4_t vbiasKLMN = vld1q_f32(w); w = (const float*) w + 4;
335 vout0xKLMN = vfmaq_f32(vbiasKLMN, vout0xKLMN, vfilter_output_scaleKLMN);
336 vout1xKLMN = vfmaq_f32(vbiasKLMN, vout1xKLMN, vfilter_output_scaleKLMN);
337 const float32x4_t vbiasOPQR = vld1q_f32(w); w = (const float*) w + 4;
338 vout0xOPQR = vfmaq_f32(vbiasOPQR, vout0xOPQR, vfilter_output_scaleOPQR);
339 vout1xOPQR = vfmaq_f32(vbiasOPQR, vout1xOPQR, vfilter_output_scaleOPQR);
340 const float32x4_t vbiasSTUV = vld1q_f32(w); w = (const float*) w + 4;
341 vout0xSTUV = vfmaq_f32(vbiasSTUV, vout0xSTUV, vfilter_output_scaleSTUV);
342 vout1xSTUV = vfmaq_f32(vbiasSTUV, vout1xSTUV, vfilter_output_scaleSTUV);
343
344 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
345 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
346 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
347 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
348 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
349 vout0xGHIJ = vmaxq_f32(vout0xGHIJ, voutput_min);
350 vout0xKLMN = vmaxq_f32(vout0xKLMN, voutput_min);
351 vout0xOPQR = vmaxq_f32(vout0xOPQR, voutput_min);
352 vout0xSTUV = vmaxq_f32(vout0xSTUV, voutput_min);
353 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
354 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
355 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
356 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
357 vout1xGHIJ = vmaxq_f32(vout1xGHIJ, voutput_min);
358 vout1xKLMN = vmaxq_f32(vout1xKLMN, voutput_min);
359 vout1xOPQR = vmaxq_f32(vout1xOPQR, voutput_min);
360 vout1xSTUV = vmaxq_f32(vout1xSTUV, voutput_min);
361
362 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
363 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
364 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
365 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
366 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
367 vout0xGHIJ = vminq_f32(vout0xGHIJ, voutput_max);
368 vout0xKLMN = vminq_f32(vout0xKLMN, voutput_max);
369 vout0xOPQR = vminq_f32(vout0xOPQR, voutput_max);
370 vout0xSTUV = vminq_f32(vout0xSTUV, voutput_max);
371 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
372 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
373 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
374 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
375 vout1xGHIJ = vminq_f32(vout1xGHIJ, voutput_max);
376 vout1xKLMN = vminq_f32(vout1xKLMN, voutput_max);
377 vout1xOPQR = vminq_f32(vout1xOPQR, voutput_max);
378 vout1xSTUV = vminq_f32(vout1xSTUV, voutput_max);
379
380 if XNN_LIKELY(nc >= 32) {
381 vst1q_f32(c0, vout0x0123);
382 vst1q_f32(c0 + 4, vout0x4567);
383 vst1q_f32(c0 + 8, vout0x89AB);
384 vst1q_f32(c0 + 12, vout0xCDEF);
385 vst1q_f32(c0 + 16, vout0xGHIJ);
386 vst1q_f32(c0 + 20, vout0xKLMN);
387 vst1q_f32(c0 + 24, vout0xOPQR);
388 vst1q_f32(c0 + 28, vout0xSTUV);
389 vst1q_f32(c1, vout1x0123);
390 vst1q_f32(c1 + 4, vout1x4567);
391 vst1q_f32(c1 + 8, vout1x89AB);
392 vst1q_f32(c1 + 12, vout1xCDEF);
393 vst1q_f32(c1 + 16, vout1xGHIJ);
394 vst1q_f32(c1 + 20, vout1xKLMN);
395 vst1q_f32(c1 + 24, vout1xOPQR);
396 vst1q_f32(c1 + 28, vout1xSTUV);
397
398 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
399 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
400
401 c0 = (float*) ((uintptr_t) c0 + cn_stride);
402 c1 = (float*) ((uintptr_t) c1 + cn_stride);
403
404 nc -= 32;
405 } else {
406 if (nc & 16) {
407 vst1q_f32(c0, vout0x0123); c0 += 4;
408 vout0x0123 = vout0xGHIJ;
409 vst1q_f32(c1, vout1x0123); c1 += 4;
410 vout1x0123 = vout1xGHIJ;
411 vst1q_f32(c0, vout0x4567); c0 += 4;
412 vout0x4567 = vout0xKLMN;
413 vst1q_f32(c1, vout1x4567); c1 += 4;
414 vout1x4567 = vout1xKLMN;
415 vst1q_f32(c0, vout0x89AB); c0 += 4;
416 vout0x89AB = vout0xOPQR;
417 vst1q_f32(c1, vout1x89AB); c1 += 4;
418 vout1x89AB = vout1xOPQR;
419 vst1q_f32(c0, vout0xCDEF); c0 += 4;
420 vout0xCDEF = vout0xSTUV;
421 vst1q_f32(c1, vout1xCDEF); c1 += 4;
422 vout1xCDEF = vout1xSTUV;
423 }
424 if (nc & 8) {
425 vst1q_f32(c0, vout0x0123); c0 += 4;
426 vout0x0123 = vout0x89AB;
427 vst1q_f32(c1, vout1x0123); c1 += 4;
428 vout1x0123 = vout1x89AB;
429 vst1q_f32(c0, vout0x4567); c0 += 4;
430 vout0x4567 = vout0xCDEF;
431 vst1q_f32(c1, vout1x4567); c1 += 4;
432 vout1x4567 = vout1xCDEF;
433 }
434 if (nc & 4) {
435 vst1q_f32(c0, vout0x0123); c0 += 4;
436 vout0x0123 = vout0x4567;
437 vst1q_f32(c1, vout1x0123); c1 += 4;
438 vout1x0123 = vout1x4567;
439 }
440 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
441 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
442 if (nc & 2) {
443 vst1_f32(c0, vout0x01); c0 += 2;
444 vst1_f32(c1, vout1x01); c1 += 2;
445 vout0x01 = vget_high_f32(vout0x0123);
446 vout1x01 = vget_high_f32(vout1x0123);
447 }
448 if (nc & 1) {
449 vst1_lane_f32(c0, vout0x01, 0);
450 vst1_lane_f32(c1, vout1x01, 0);
451 }
452 nc = 0;
453 }
454 } while (nc != 0);
455 }