Debian Codegraph @

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