Debian Codegraph @

src/qd8-f32-qb4w-gemm/gen/qd8-f32-qb4w-gemm-6x16c4-minmax-neondot.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/c4-neondot.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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_6x16c4__neondot(
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 <= 6);
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, 4 * 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 int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
50 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
51 if XNN_UNPREDICTABLE(mr <= 2) {
52 a2 = a1;
53 c2 = c1;
54 }
55 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
56 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
57 if XNN_UNPREDICTABLE(mr < 4) {
58 a3 = a2;
59 c3 = c2;
60 }
61 const int8_t* a4 = (const int8_t*) ((uintptr_t) a3 + a_stride);
62 float* c4 = (float*) ((uintptr_t) c3 + cm_stride);
63 if XNN_UNPREDICTABLE(mr <= 4) {
64 a4 = a3;
65 c4 = c3;
66 }
67 const int8_t* a5 = (const int8_t*) ((uintptr_t) a4 + a_stride);
68 float* c5 = (float*) ((uintptr_t) c4 + cm_stride);
69 if XNN_UNPREDICTABLE(mr != 6) {
70 a5 = a4;
71 c5 = c4;
72 }
73
74 size_t bl = params->scalar.blocksize;
75 assert(bl <= kc);
76 assert(bl != 0);
77 assert(bl % 32 == 0);
78 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
79 // Loop over groups of 16 columns.
80 do {
81 // Initialize accumulators with bias. 16 bias values are loaded from the
82 // weight matrix, at the start of the group of 16 columns.
83 const float32x4_t vinput_zero_point01 = vcvtq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
84 const float32x4_t vksum0123 = vld1q_f32(w); w = (const float*) w + 4;
85 float32x4_t vout0x0123 = vmulq_lane_f32(vksum0123, vget_low_f32(vinput_zero_point01), 0);
86 float32x4_t vout1x0123 = vmulq_lane_f32(vksum0123, vget_high_f32(vinput_zero_point01), 0);
87 const float32x4_t vksum4567 = vld1q_f32(w); w = (const float*) w + 4;
88 float32x4_t vout0x4567 = vmulq_lane_f32(vksum4567, vget_low_f32(vinput_zero_point01), 0);
89 float32x4_t vout1x4567 = vmulq_lane_f32(vksum4567, vget_high_f32(vinput_zero_point01), 0);
90 const float32x4_t vksum89AB = vld1q_f32(w); w = (const float*) w + 4;
91 float32x4_t vout0x89AB = vmulq_lane_f32(vksum89AB, vget_low_f32(vinput_zero_point01), 0);
92 float32x4_t vout1x89AB = vmulq_lane_f32(vksum89AB, vget_high_f32(vinput_zero_point01), 0);
93 const float32x4_t vksumCDEF = vld1q_f32(w); w = (const float*) w + 4;
94 float32x4_t vout0xCDEF = vmulq_lane_f32(vksumCDEF, vget_low_f32(vinput_zero_point01), 0);
95 float32x4_t vout1xCDEF = vmulq_lane_f32(vksumCDEF, 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 const float32x4_t vinput_zero_point45 = vcvtq_f32_s32(vld1q_s32(&quantization_params[4].zero_point));
106 float32x4_t vout4x0123 = vmulq_lane_f32(vksum0123, vget_low_f32(vinput_zero_point45), 0);
107 float32x4_t vout5x0123 = vmulq_lane_f32(vksum0123, vget_high_f32(vinput_zero_point45), 0);
108 float32x4_t vout4x4567 = vmulq_lane_f32(vksum4567, vget_low_f32(vinput_zero_point45), 0);
109 float32x4_t vout5x4567 = vmulq_lane_f32(vksum4567, vget_high_f32(vinput_zero_point45), 0);
110 float32x4_t vout4x89AB = vmulq_lane_f32(vksum89AB, vget_low_f32(vinput_zero_point45), 0);
111 float32x4_t vout5x89AB = vmulq_lane_f32(vksum89AB, vget_high_f32(vinput_zero_point45), 0);
112 float32x4_t vout4xCDEF = vmulq_lane_f32(vksumCDEF, vget_low_f32(vinput_zero_point45), 0);
113 float32x4_t vout5xCDEF = vmulq_lane_f32(vksumCDEF, vget_high_f32(vinput_zero_point45), 0);
114
115 for (size_t kb=0; kb < kc; kb += bl) {
116 int32x4_t vacc0x0123 = vdupq_n_s32(0);
117 int32x4_t vacc1x0123 = vdupq_n_s32(0);
118 int32x4_t vacc0x4567 = vdupq_n_s32(0);
119 int32x4_t vacc1x4567 = vdupq_n_s32(0);
120 int32x4_t vacc0x89AB = vdupq_n_s32(0);
121 int32x4_t vacc1x89AB = vdupq_n_s32(0);
122 int32x4_t vacc0xCDEF = vdupq_n_s32(0);
123 int32x4_t vacc1xCDEF = vdupq_n_s32(0);
124 int32x4_t vacc2x0123 = vdupq_n_s32(0);
125 int32x4_t vacc3x0123 = vdupq_n_s32(0);
126 int32x4_t vacc2x4567 = vdupq_n_s32(0);
127 int32x4_t vacc3x4567 = vdupq_n_s32(0);
128 int32x4_t vacc2x89AB = vdupq_n_s32(0);
129 int32x4_t vacc3x89AB = vdupq_n_s32(0);
130 int32x4_t vacc2xCDEF = vdupq_n_s32(0);
131 int32x4_t vacc3xCDEF = vdupq_n_s32(0);
132 int32x4_t vacc4x0123 = vdupq_n_s32(0);
133 int32x4_t vacc5x0123 = vdupq_n_s32(0);
134 int32x4_t vacc4x4567 = vdupq_n_s32(0);
135 int32x4_t vacc5x4567 = vdupq_n_s32(0);
136 int32x4_t vacc4x89AB = vdupq_n_s32(0);
137 int32x4_t vacc5x89AB = vdupq_n_s32(0);
138 int32x4_t vacc4xCDEF = vdupq_n_s32(0);
139 int32x4_t vacc5xCDEF = vdupq_n_s32(0);
140 // Inner accumulation loop along the 16 columns.
141 size_t k = bl;
142 // 2x partial unrolled loop to load 8 bytes at a time.
143 while (k >= 8 * sizeof(int8_t)) {
144 // Load a 6x8 block of activations.
145 const int8x8_t va0x01234567 = vld1_s8(a0); a0 += 8;
146 const int8x8_t va1x01234567 = vld1_s8(a1); a1 += 8;
147 const int8x8_t va2x01234567 = vld1_s8(a2); a2 += 8;
148 const int8x8_t va3x01234567 = vld1_s8(a3); a3 += 8;
149 const int8x8_t va4x01234567 = vld1_s8(a4); a4 += 8;
150 const int8x8_t va5x01234567 = vld1_s8(a5); a5 += 8;
151
152 // Load a 8x16 block of weights.
153 const int8x16_t vb01234567x0123 = vld1q_s8(w); w = (const int8_t*) w + 16;
154 const int8x16_t vb01234567x4567 = vld1q_s8(w); w = (const int8_t*) w + 16;
155 const int8x16_t vb01234567x89AB = vld1q_s8(w); w = (const int8_t*) w + 16;
156 const int8x16_t vb01234567xCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
157 const int8x16_t vb0123x0123 = vshlq_n_s8(vb01234567x0123, 4);
158 const int8x16_t vb0123x4567 = vshlq_n_s8(vb01234567x4567, 4);
159 const int8x16_t vb0123x89AB = vshlq_n_s8(vb01234567x89AB, 4);
160 const int8x16_t vb0123xCDEF = vshlq_n_s8(vb01234567xCDEF, 4);
161 const int8x16_t vb4567x0123 = vandq_s8(vb01234567x0123, vmask);
162 const int8x16_t vb4567x4567 = vandq_s8(vb01234567x4567, vmask);
163 const int8x16_t vb4567x89AB = vandq_s8(vb01234567x89AB, vmask);
164 const int8x16_t vb4567xCDEF = vandq_s8(vb01234567xCDEF, vmask);
165
166 // Multiply-accumulate: 6x8 * 8x16 --> 6x16.
167 vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
168 vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb0123x4567, va0x01234567, 0);
169 vacc0x89AB = vdotq_lane_s32(vacc0x89AB, vb0123x89AB, va0x01234567, 0);
170 vacc0xCDEF = vdotq_lane_s32(vacc0xCDEF, vb0123xCDEF, va0x01234567, 0);
171 vacc1x0123 = vdotq_lane_s32(vacc1x0123, vb0123x0123, va1x01234567, 0);
172 vacc1x4567 = vdotq_lane_s32(vacc1x4567, vb0123x4567, va1x01234567, 0);
173 vacc1x89AB = vdotq_lane_s32(vacc1x89AB, vb0123x89AB, va1x01234567, 0);
174 vacc1xCDEF = vdotq_lane_s32(vacc1xCDEF, vb0123xCDEF, va1x01234567, 0);
175 vacc2x0123 = vdotq_lane_s32(vacc2x0123, vb0123x0123, va2x01234567, 0);
176 vacc2x4567 = vdotq_lane_s32(vacc2x4567, vb0123x4567, va2x01234567, 0);
177 vacc2x89AB = vdotq_lane_s32(vacc2x89AB, vb0123x89AB, va2x01234567, 0);
178 vacc2xCDEF = vdotq_lane_s32(vacc2xCDEF, vb0123xCDEF, va2x01234567, 0);
179 vacc3x0123 = vdotq_lane_s32(vacc3x0123, vb0123x0123, va3x01234567, 0);
180 vacc3x4567 = vdotq_lane_s32(vacc3x4567, vb0123x4567, va3x01234567, 0);
181 vacc3x89AB = vdotq_lane_s32(vacc3x89AB, vb0123x89AB, va3x01234567, 0);
182 vacc3xCDEF = vdotq_lane_s32(vacc3xCDEF, vb0123xCDEF, va3x01234567, 0);
183 vacc4x0123 = vdotq_lane_s32(vacc4x0123, vb0123x0123, va4x01234567, 0);
184 vacc4x4567 = vdotq_lane_s32(vacc4x4567, vb0123x4567, va4x01234567, 0);
185 vacc4x89AB = vdotq_lane_s32(vacc4x89AB, vb0123x89AB, va4x01234567, 0);
186 vacc4xCDEF = vdotq_lane_s32(vacc4xCDEF, vb0123xCDEF, va4x01234567, 0);
187 vacc5x0123 = vdotq_lane_s32(vacc5x0123, vb0123x0123, va5x01234567, 0);
188 vacc5x4567 = vdotq_lane_s32(vacc5x4567, vb0123x4567, va5x01234567, 0);
189 vacc5x89AB = vdotq_lane_s32(vacc5x89AB, vb0123x89AB, va5x01234567, 0);
190 vacc5xCDEF = vdotq_lane_s32(vacc5xCDEF, vb0123xCDEF, va5x01234567, 0);
191 vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb4567x0123, va0x01234567, 1);
192 vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb4567x4567, va0x01234567, 1);
193 vacc0x89AB = vdotq_lane_s32(vacc0x89AB, vb4567x89AB, va0x01234567, 1);
194 vacc0xCDEF = vdotq_lane_s32(vacc0xCDEF, vb4567xCDEF, va0x01234567, 1);
195 vacc1x0123 = vdotq_lane_s32(vacc1x0123, vb4567x0123, va1x01234567, 1);
196 vacc1x4567 = vdotq_lane_s32(vacc1x4567, vb4567x4567, va1x01234567, 1);
197 vacc1x89AB = vdotq_lane_s32(vacc1x89AB, vb4567x89AB, va1x01234567, 1);
198 vacc1xCDEF = vdotq_lane_s32(vacc1xCDEF, vb4567xCDEF, va1x01234567, 1);
199 vacc2x0123 = vdotq_lane_s32(vacc2x0123, vb4567x0123, va2x01234567, 1);
200 vacc2x4567 = vdotq_lane_s32(vacc2x4567, vb4567x4567, va2x01234567, 1);
201 vacc2x89AB = vdotq_lane_s32(vacc2x89AB, vb4567x89AB, va2x01234567, 1);
202 vacc2xCDEF = vdotq_lane_s32(vacc2xCDEF, vb4567xCDEF, va2x01234567, 1);
203 vacc3x0123 = vdotq_lane_s32(vacc3x0123, vb4567x0123, va3x01234567, 1);
204 vacc3x4567 = vdotq_lane_s32(vacc3x4567, vb4567x4567, va3x01234567, 1);
205 vacc3x89AB = vdotq_lane_s32(vacc3x89AB, vb4567x89AB, va3x01234567, 1);
206 vacc3xCDEF = vdotq_lane_s32(vacc3xCDEF, vb4567xCDEF, va3x01234567, 1);
207 vacc4x0123 = vdotq_lane_s32(vacc4x0123, vb4567x0123, va4x01234567, 1);
208 vacc4x4567 = vdotq_lane_s32(vacc4x4567, vb4567x4567, va4x01234567, 1);
209 vacc4x89AB = vdotq_lane_s32(vacc4x89AB, vb4567x89AB, va4x01234567, 1);
210 vacc4xCDEF = vdotq_lane_s32(vacc4xCDEF, vb4567xCDEF, va4x01234567, 1);
211 vacc5x0123 = vdotq_lane_s32(vacc5x0123, vb4567x0123, va5x01234567, 1);
212 vacc5x4567 = vdotq_lane_s32(vacc5x4567, vb4567x4567, va5x01234567, 1);
213 vacc5x89AB = vdotq_lane_s32(vacc5x89AB, vb4567x89AB, va5x01234567, 1);
214 vacc5xCDEF = vdotq_lane_s32(vacc5xCDEF, vb4567xCDEF, va5x01234567, 1);
215
216 k -= 8 * sizeof(int8_t);
217 }
218 // Handle up to 4 final positions of `k`
219 if XNN_UNLIKELY(k != 0) {
220 // Load a 6x4 block of activations.
221 const int8x8_t va0x01234567 = vld1_s8(a0); a0 += 4;
222 const int8x8_t va1x01234567 = vld1_s8(a1); a1 += 4;
223 const int8x8_t va2x01234567 = vld1_s8(a2); a2 += 4;
224 const int8x8_t va3x01234567 = vld1_s8(a3); a3 += 4;
225 const int8x8_t va4x01234567 = vld1_s8(a4); a4 += 4;
226 const int8x8_t va5x01234567 = vld1_s8(a5); a5 += 4;
227
228 // Load a 4x16 block of weights.
229 const int8x16_t vb0123x0123 = vld1q_s8(w); w = (const int8_t*) w + 16;
230 const int8x16_t vb0123x4567 = vld1q_s8(w); w = (const int8_t*) w + 16;
231 const int8x16_t vb0123x89AB = vld1q_s8(w); w = (const int8_t*) w + 16;
232 const int8x16_t vb0123xCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
233
234 // Multiply-accumulate: 6x4 * 4x16 --> 6x16.
235 vacc0x0123 = vdotq_lane_s32(vacc0x0123, vb0123x0123, va0x01234567, 0);
236 vacc0x4567 = vdotq_lane_s32(vacc0x4567, vb0123x4567, va0x01234567, 0);
237 vacc0x89AB = vdotq_lane_s32(vacc0x89AB, vb0123x89AB, va0x01234567, 0);
238 vacc0xCDEF = vdotq_lane_s32(vacc0xCDEF, vb0123xCDEF, va0x01234567, 0);
239 vacc1x0123 = vdotq_lane_s32(vacc1x0123, vb0123x0123, va1x01234567, 0);
240 vacc1x4567 = vdotq_lane_s32(vacc1x4567, vb0123x4567, va1x01234567, 0);
241 vacc1x89AB = vdotq_lane_s32(vacc1x89AB, vb0123x89AB, va1x01234567, 0);
242 vacc1xCDEF = vdotq_lane_s32(vacc1xCDEF, vb0123xCDEF, va1x01234567, 0);
243 vacc2x0123 = vdotq_lane_s32(vacc2x0123, vb0123x0123, va2x01234567, 0);
244 vacc2x4567 = vdotq_lane_s32(vacc2x4567, vb0123x4567, va2x01234567, 0);
245 vacc2x89AB = vdotq_lane_s32(vacc2x89AB, vb0123x89AB, va2x01234567, 0);
246 vacc2xCDEF = vdotq_lane_s32(vacc2xCDEF, vb0123xCDEF, va2x01234567, 0);
247 vacc3x0123 = vdotq_lane_s32(vacc3x0123, vb0123x0123, va3x01234567, 0);
248 vacc3x4567 = vdotq_lane_s32(vacc3x4567, vb0123x4567, va3x01234567, 0);
249 vacc3x89AB = vdotq_lane_s32(vacc3x89AB, vb0123x89AB, va3x01234567, 0);
250 vacc3xCDEF = vdotq_lane_s32(vacc3xCDEF, vb0123xCDEF, va3x01234567, 0);
251 vacc4x0123 = vdotq_lane_s32(vacc4x0123, vb0123x0123, va4x01234567, 0);
252 vacc4x4567 = vdotq_lane_s32(vacc4x4567, vb0123x4567, va4x01234567, 0);
253 vacc4x89AB = vdotq_lane_s32(vacc4x89AB, vb0123x89AB, va4x01234567, 0);
254 vacc4xCDEF = vdotq_lane_s32(vacc4xCDEF, vb0123xCDEF, va4x01234567, 0);
255 vacc5x0123 = vdotq_lane_s32(vacc5x0123, vb0123x0123, va5x01234567, 0);
256 vacc5x4567 = vdotq_lane_s32(vacc5x4567, vb0123x4567, va5x01234567, 0);
257 vacc5x89AB = vdotq_lane_s32(vacc5x89AB, vb0123x89AB, va5x01234567, 0);
258 vacc5xCDEF = vdotq_lane_s32(vacc5xCDEF, vb0123xCDEF, va5x01234567, 0);
259 }
260 const float32x4_t vfilter_output_scale0123 = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
261 const float32x4_t vfilter_output_scale4567 = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
262 const float32x4_t vfilter_output_scale89AB = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
263 const float32x4_t vfilter_output_scaleCDEF = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
264
265 float32x4_t vf0x0123 = vcvtq_f32_s32(vacc0x0123);
266 float32x4_t vf1x0123 = vcvtq_f32_s32(vacc1x0123);
267 vout0x0123 = vfmaq_f32(vout0x0123, vf0x0123, vfilter_output_scale0123);
268 vout1x0123 = vfmaq_f32(vout1x0123, vf1x0123, vfilter_output_scale0123);
269 float32x4_t vf0x4567 = vcvtq_f32_s32(vacc0x4567);
270 float32x4_t vf1x4567 = vcvtq_f32_s32(vacc1x4567);
271 vout0x4567 = vfmaq_f32(vout0x4567, vf0x4567, vfilter_output_scale4567);
272 vout1x4567 = vfmaq_f32(vout1x4567, vf1x4567, vfilter_output_scale4567);
273 float32x4_t vf0x89AB = vcvtq_f32_s32(vacc0x89AB);
274 float32x4_t vf1x89AB = vcvtq_f32_s32(vacc1x89AB);
275 vout0x89AB = vfmaq_f32(vout0x89AB, vf0x89AB, vfilter_output_scale89AB);
276 vout1x89AB = vfmaq_f32(vout1x89AB, vf1x89AB, vfilter_output_scale89AB);
277 float32x4_t vf0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
278 float32x4_t vf1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
279 vout0xCDEF = vfmaq_f32(vout0xCDEF, vf0xCDEF, vfilter_output_scaleCDEF);
280 vout1xCDEF = vfmaq_f32(vout1xCDEF, vf1xCDEF, vfilter_output_scaleCDEF);
281 float32x4_t vf2x0123 = vcvtq_f32_s32(vacc2x0123);
282 float32x4_t vf3x0123 = vcvtq_f32_s32(vacc3x0123);
283 vout2x0123 = vfmaq_f32(vout2x0123, vf2x0123, vfilter_output_scale0123);
284 vout3x0123 = vfmaq_f32(vout3x0123, vf3x0123, vfilter_output_scale0123);
285 float32x4_t vf2x4567 = vcvtq_f32_s32(vacc2x4567);
286 float32x4_t vf3x4567 = vcvtq_f32_s32(vacc3x4567);
287 vout2x4567 = vfmaq_f32(vout2x4567, vf2x4567, vfilter_output_scale4567);
288 vout3x4567 = vfmaq_f32(vout3x4567, vf3x4567, vfilter_output_scale4567);
289 float32x4_t vf2x89AB = vcvtq_f32_s32(vacc2x89AB);
290 float32x4_t vf3x89AB = vcvtq_f32_s32(vacc3x89AB);
291 vout2x89AB = vfmaq_f32(vout2x89AB, vf2x89AB, vfilter_output_scale89AB);
292 vout3x89AB = vfmaq_f32(vout3x89AB, vf3x89AB, vfilter_output_scale89AB);
293 float32x4_t vf2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
294 float32x4_t vf3xCDEF = vcvtq_f32_s32(vacc3xCDEF);
295 vout2xCDEF = vfmaq_f32(vout2xCDEF, vf2xCDEF, vfilter_output_scaleCDEF);
296 vout3xCDEF = vfmaq_f32(vout3xCDEF, vf3xCDEF, vfilter_output_scaleCDEF);
297 float32x4_t vf4x0123 = vcvtq_f32_s32(vacc4x0123);
298 float32x4_t vf5x0123 = vcvtq_f32_s32(vacc5x0123);
299 vout4x0123 = vfmaq_f32(vout4x0123, vf4x0123, vfilter_output_scale0123);
300 vout5x0123 = vfmaq_f32(vout5x0123, vf5x0123, vfilter_output_scale0123);
301 float32x4_t vf4x4567 = vcvtq_f32_s32(vacc4x4567);
302 float32x4_t vf5x4567 = vcvtq_f32_s32(vacc5x4567);
303 vout4x4567 = vfmaq_f32(vout4x4567, vf4x4567, vfilter_output_scale4567);
304 vout5x4567 = vfmaq_f32(vout5x4567, vf5x4567, vfilter_output_scale4567);
305 float32x4_t vf4x89AB = vcvtq_f32_s32(vacc4x89AB);
306 float32x4_t vf5x89AB = vcvtq_f32_s32(vacc5x89AB);
307 vout4x89AB = vfmaq_f32(vout4x89AB, vf4x89AB, vfilter_output_scale89AB);
308 vout5x89AB = vfmaq_f32(vout5x89AB, vf5x89AB, vfilter_output_scale89AB);
309 float32x4_t vf4xCDEF = vcvtq_f32_s32(vacc4xCDEF);
310 float32x4_t vf5xCDEF = vcvtq_f32_s32(vacc5xCDEF);
311 vout4xCDEF = vfmaq_f32(vout4xCDEF, vf4xCDEF, vfilter_output_scaleCDEF);
312 vout5xCDEF = vfmaq_f32(vout5xCDEF, vf5xCDEF, vfilter_output_scaleCDEF);
313 }
314
315 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
316 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
317 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
318 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
319 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
320 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
321 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
322 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
323 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
324 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
325 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
326 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
327 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
328 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
329 vout2x89AB = vmulq_lane_f32(vout2x89AB, vget_low_f32(vinput_scale23), 1);
330 vout3x89AB = vmulq_lane_f32(vout3x89AB, vget_high_f32(vinput_scale23), 1);
331 vout2xCDEF = vmulq_lane_f32(vout2xCDEF, vget_low_f32(vinput_scale23), 1);
332 vout3xCDEF = vmulq_lane_f32(vout3xCDEF, vget_high_f32(vinput_scale23), 1);
333 const float32x4_t vinput_scale45 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[4].zero_point));
334 vout4x0123 = vmulq_lane_f32(vout4x0123, vget_low_f32(vinput_scale45), 1);
335 vout5x0123 = vmulq_lane_f32(vout5x0123, vget_high_f32(vinput_scale45), 1);
336 vout4x4567 = vmulq_lane_f32(vout4x4567, vget_low_f32(vinput_scale45), 1);
337 vout5x4567 = vmulq_lane_f32(vout5x4567, vget_high_f32(vinput_scale45), 1);
338 vout4x89AB = vmulq_lane_f32(vout4x89AB, vget_low_f32(vinput_scale45), 1);
339 vout5x89AB = vmulq_lane_f32(vout5x89AB, vget_high_f32(vinput_scale45), 1);
340 vout4xCDEF = vmulq_lane_f32(vout4xCDEF, vget_low_f32(vinput_scale45), 1);
341 vout5xCDEF = vmulq_lane_f32(vout5xCDEF, vget_high_f32(vinput_scale45), 1);
342
343
344 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
345 vout0x0123 = vaddq_f32(vbias0123, vout0x0123);
346 vout1x0123 = vaddq_f32(vbias0123, vout1x0123);
347 vout2x0123 = vaddq_f32(vbias0123, vout2x0123);
348 vout3x0123 = vaddq_f32(vbias0123, vout3x0123);
349 vout4x0123 = vaddq_f32(vbias0123, vout4x0123);
350 vout5x0123 = vaddq_f32(vbias0123, vout5x0123);
351 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
352 vout0x4567 = vaddq_f32(vbias4567, vout0x4567);
353 vout1x4567 = vaddq_f32(vbias4567, vout1x4567);
354 vout2x4567 = vaddq_f32(vbias4567, vout2x4567);
355 vout3x4567 = vaddq_f32(vbias4567, vout3x4567);
356 vout4x4567 = vaddq_f32(vbias4567, vout4x4567);
357 vout5x4567 = vaddq_f32(vbias4567, vout5x4567);
358 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
359 vout0x89AB = vaddq_f32(vbias89AB, vout0x89AB);
360 vout1x89AB = vaddq_f32(vbias89AB, vout1x89AB);
361 vout2x89AB = vaddq_f32(vbias89AB, vout2x89AB);
362 vout3x89AB = vaddq_f32(vbias89AB, vout3x89AB);
363 vout4x89AB = vaddq_f32(vbias89AB, vout4x89AB);
364 vout5x89AB = vaddq_f32(vbias89AB, vout5x89AB);
365 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
366 vout0xCDEF = vaddq_f32(vbiasCDEF, vout0xCDEF);
367 vout1xCDEF = vaddq_f32(vbiasCDEF, vout1xCDEF);
368 vout2xCDEF = vaddq_f32(vbiasCDEF, vout2xCDEF);
369 vout3xCDEF = vaddq_f32(vbiasCDEF, vout3xCDEF);
370 vout4xCDEF = vaddq_f32(vbiasCDEF, vout4xCDEF);
371 vout5xCDEF = vaddq_f32(vbiasCDEF, vout5xCDEF);
372
373 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
374 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
375 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
376 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
377 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
378 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
379 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
380 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
381 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
382 vout2x0123 = vmaxq_f32(vout2x0123, voutput_min);
383 vout2x4567 = vmaxq_f32(vout2x4567, voutput_min);
384 vout2x89AB = vmaxq_f32(vout2x89AB, voutput_min);
385 vout2xCDEF = vmaxq_f32(vout2xCDEF, voutput_min);
386 vout3x0123 = vmaxq_f32(vout3x0123, voutput_min);
387 vout3x4567 = vmaxq_f32(vout3x4567, voutput_min);
388 vout3x89AB = vmaxq_f32(vout3x89AB, voutput_min);
389 vout3xCDEF = vmaxq_f32(vout3xCDEF, voutput_min);
390 vout4x0123 = vmaxq_f32(vout4x0123, voutput_min);
391 vout4x4567 = vmaxq_f32(vout4x4567, voutput_min);
392 vout4x89AB = vmaxq_f32(vout4x89AB, voutput_min);
393 vout4xCDEF = vmaxq_f32(vout4xCDEF, voutput_min);
394 vout5x0123 = vmaxq_f32(vout5x0123, voutput_min);
395 vout5x4567 = vmaxq_f32(vout5x4567, voutput_min);
396 vout5x89AB = vmaxq_f32(vout5x89AB, voutput_min);
397 vout5xCDEF = vmaxq_f32(vout5xCDEF, voutput_min);
398
399 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
400 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
401 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
402 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
403 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
404 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
405 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
406 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
407 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
408 vout2x0123 = vminq_f32(vout2x0123, voutput_max);
409 vout2x4567 = vminq_f32(vout2x4567, voutput_max);
410 vout2x89AB = vminq_f32(vout2x89AB, voutput_max);
411 vout2xCDEF = vminq_f32(vout2xCDEF, voutput_max);
412 vout3x0123 = vminq_f32(vout3x0123, voutput_max);
413 vout3x4567 = vminq_f32(vout3x4567, voutput_max);
414 vout3x89AB = vminq_f32(vout3x89AB, voutput_max);
415 vout3xCDEF = vminq_f32(vout3xCDEF, voutput_max);
416 vout4x0123 = vminq_f32(vout4x0123, voutput_max);
417 vout4x4567 = vminq_f32(vout4x4567, voutput_max);
418 vout4x89AB = vminq_f32(vout4x89AB, voutput_max);
419 vout4xCDEF = vminq_f32(vout4xCDEF, voutput_max);
420 vout5x0123 = vminq_f32(vout5x0123, voutput_max);
421 vout5x4567 = vminq_f32(vout5x4567, voutput_max);
422 vout5x89AB = vminq_f32(vout5x89AB, voutput_max);
423 vout5xCDEF = vminq_f32(vout5xCDEF, voutput_max);
424
425 if XNN_LIKELY(nc >= 16) {
426 vst1q_f32(c0, vout0x0123);
427 vst1q_f32(c0 + 4, vout0x4567);
428 vst1q_f32(c0 + 8, vout0x89AB);
429 vst1q_f32(c0 + 12, vout0xCDEF);
430 vst1q_f32(c1, vout1x0123);
431 vst1q_f32(c1 + 4, vout1x4567);
432 vst1q_f32(c1 + 8, vout1x89AB);
433 vst1q_f32(c1 + 12, vout1xCDEF);
434 vst1q_f32(c2, vout2x0123);
435 vst1q_f32(c2 + 4, vout2x4567);
436 vst1q_f32(c2 + 8, vout2x89AB);
437 vst1q_f32(c2 + 12, vout2xCDEF);
438 vst1q_f32(c3, vout3x0123);
439 vst1q_f32(c3 + 4, vout3x4567);
440 vst1q_f32(c3 + 8, vout3x89AB);
441 vst1q_f32(c3 + 12, vout3xCDEF);
442 vst1q_f32(c4, vout4x0123);
443 vst1q_f32(c4 + 4, vout4x4567);
444 vst1q_f32(c4 + 8, vout4x89AB);
445 vst1q_f32(c4 + 12, vout4xCDEF);
446 vst1q_f32(c5, vout5x0123);
447 vst1q_f32(c5 + 4, vout5x4567);
448 vst1q_f32(c5 + 8, vout5x89AB);
449 vst1q_f32(c5 + 12, vout5xCDEF);
450
451 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
452 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
453 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
454 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
455 a4 = (const int8_t*) ((uintptr_t) a4 - kc);
456 a5 = (const int8_t*) ((uintptr_t) a5 - kc);
457
458 c0 = (float*) ((uintptr_t) c0 + cn_stride);
459 c1 = (float*) ((uintptr_t) c1 + cn_stride);
460 c2 = (float*) ((uintptr_t) c2 + cn_stride);
461 c3 = (float*) ((uintptr_t) c3 + cn_stride);
462 c4 = (float*) ((uintptr_t) c4 + cn_stride);
463 c5 = (float*) ((uintptr_t) c5 + cn_stride);
464
465 nc -= 16;
466 } else {
467 if (nc & 8) {
468 vst1q_f32(c0, vout0x0123); c0 += 4;
469 vout0x0123 = vout0x89AB;
470 vst1q_f32(c1, vout1x0123); c1 += 4;
471 vout1x0123 = vout1x89AB;
472 vst1q_f32(c2, vout2x0123); c2 += 4;
473 vout2x0123 = vout2x89AB;
474 vst1q_f32(c3, vout3x0123); c3 += 4;
475 vout3x0123 = vout3x89AB;
476 vst1q_f32(c4, vout4x0123); c4 += 4;
477 vout4x0123 = vout4x89AB;
478 vst1q_f32(c5, vout5x0123); c5 += 4;
479 vout5x0123 = vout5x89AB;
480 vst1q_f32(c0, vout0x4567); c0 += 4;
481 vout0x4567 = vout0xCDEF;
482 vst1q_f32(c1, vout1x4567); c1 += 4;
483 vout1x4567 = vout1xCDEF;
484 vst1q_f32(c2, vout2x4567); c2 += 4;
485 vout2x4567 = vout2xCDEF;
486 vst1q_f32(c3, vout3x4567); c3 += 4;
487 vout3x4567 = vout3xCDEF;
488 vst1q_f32(c4, vout4x4567); c4 += 4;
489 vout4x4567 = vout4xCDEF;
490 vst1q_f32(c5, vout5x4567); c5 += 4;
491 vout5x4567 = vout5xCDEF;
492 }
493 if (nc & 4) {
494 vst1q_f32(c0, vout0x0123); c0 += 4;
495 vout0x0123 = vout0x4567;
496 vst1q_f32(c1, vout1x0123); c1 += 4;
497 vout1x0123 = vout1x4567;
498 vst1q_f32(c2, vout2x0123); c2 += 4;
499 vout2x0123 = vout2x4567;
500 vst1q_f32(c3, vout3x0123); c3 += 4;
501 vout3x0123 = vout3x4567;
502 vst1q_f32(c4, vout4x0123); c4 += 4;
503 vout4x0123 = vout4x4567;
504 vst1q_f32(c5, vout5x0123); c5 += 4;
505 vout5x0123 = vout5x4567;
506 }
507 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
508 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
509 float32x2_t vout2x01 = vget_low_f32(vout2x0123);
510 float32x2_t vout3x01 = vget_low_f32(vout3x0123);
511 float32x2_t vout4x01 = vget_low_f32(vout4x0123);
512 float32x2_t vout5x01 = vget_low_f32(vout5x0123);
513 if (nc & 2) {
514 vst1_f32(c0, vout0x01); c0 += 2;
515 vst1_f32(c1, vout1x01); c1 += 2;
516 vst1_f32(c2, vout2x01); c2 += 2;
517 vst1_f32(c3, vout3x01); c3 += 2;
518 vst1_f32(c4, vout4x01); c4 += 2;
519 vst1_f32(c5, vout5x01); c5 += 2;
520 vout0x01 = vget_high_f32(vout0x0123);
521 vout1x01 = vget_high_f32(vout1x0123);
522 vout2x01 = vget_high_f32(vout2x0123);
523 vout3x01 = vget_high_f32(vout3x0123);
524 vout4x01 = vget_high_f32(vout4x0123);
525 vout5x01 = vget_high_f32(vout5x0123);
526 }
527 if (nc & 1) {
528 vst1_lane_f32(c0, vout0x01, 0);
529 vst1_lane_f32(c1, vout1x01, 0);
530 vst1_lane_f32(c2, vout2x01, 0);
531 vst1_lane_f32(c3, vout3x01, 0);
532 vst1_lane_f32(c4, vout4x01, 0);
533 vst1_lane_f32(c5, vout5x01, 0);
534 }
535 nc = 0;
536 }
537 } while (nc != 0);
538 }