Debian Codegraph @

src/qd8-f32-qc8w-gemm/gen/qd8-f32-qc8w-gemm-2x32c8-minmax-neoni8mm.c

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