Debian Codegraph @

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