Debian Codegraph @

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