Debian Codegraph @

src/qd8-f32-qb4w-gemm/gen/qd8-f32-qb4w-gemm-3x16c8-minmax-neoni8mm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/c8-neoni8mm.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2023 Google LLC
6 //
7 // This source code is licensed under the BSD-style license found in the
8 // LICENSE file in the root directory of this source tree.
9
10 #include <assert.h>
11
12 #include <arm_neon.h>
13
14 #include "xnnpack/gemm.h"
15 #include "xnnpack/math.h"
16
17
18 void xnn_qd8_f32_qb4w_gemm_minmax_ukernel_3x16c8__neoni8mm(
19 size_t mr,
20 size_t nc,
21 size_t kc,
22 const int8_t* restrict a,
23 size_t a_stride,
24 const void* restrict w,
25 float* restrict c,
26 size_t cm_stride,
27 size_t cn_stride,
28 const 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 <= 3);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(kc % sizeof(int8_t) == 0);
36 assert(a != NULL);
37 assert(w != NULL);
38 assert(c != NULL);
39
40 kc = round_up_po2(kc, 8 * sizeof(int8_t));
41 size_t bl = params->scalar.blocksize;
42 assert(bl <= kc);
43 assert(bl != 0);
44 assert(bl % 32 == 0);
45 const int8_t* a0 = a;
46 float* c0 = c;
47 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
48 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
49 if XNN_UNPREDICTABLE(mr < 2) {
50 a1 = a0;
51 c1 = c0;
52 }
53 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
54 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
55 if XNN_UNPREDICTABLE(mr <= 2) {
56 a2 = a1;
57 c2 = c1;
58 }
59 const int8x16_t vmask = vmovq_n_s8(INT8_C(0xF0));
60
61 // Loop over groups of 16 columns.
62 do {
63 // Initialize accumulators with scaled vksum. 16 scaled vksum values are loaded from the
64 // weight matrix, at the start of the group of 16 columns.
65 const float32x4_t vinput_zero_point01 = vcvtq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
66 const float32x4_t vksum0123 = vld1q_f32(w); w = (const float*) w + 4;
67 float32x4_t vout0x0123 = vmulq_lane_f32(vksum0123, vget_low_f32(vinput_zero_point01), 0);
68 float32x4_t vout1x0123 = vmulq_lane_f32(vksum0123, vget_high_f32(vinput_zero_point01), 0);
69 const float32x4_t vksum4567 = vld1q_f32(w); w = (const float*) w + 4;
70 float32x4_t vout0x4567 = vmulq_lane_f32(vksum4567, vget_low_f32(vinput_zero_point01), 0);
71 float32x4_t vout1x4567 = vmulq_lane_f32(vksum4567, vget_high_f32(vinput_zero_point01), 0);
72 const float32x4_t vksum89AB = vld1q_f32(w); w = (const float*) w + 4;
73 float32x4_t vout0x89AB = vmulq_lane_f32(vksum89AB, vget_low_f32(vinput_zero_point01), 0);
74 float32x4_t vout1x89AB = vmulq_lane_f32(vksum89AB, vget_high_f32(vinput_zero_point01), 0);
75 const float32x4_t vksumCDEF = vld1q_f32(w); w = (const float*) w + 4;
76 float32x4_t vout0xCDEF = vmulq_lane_f32(vksumCDEF, vget_low_f32(vinput_zero_point01), 0);
77 float32x4_t vout1xCDEF = vmulq_lane_f32(vksumCDEF, vget_high_f32(vinput_zero_point01), 0);
78 const float32x4_t vinput_zero_point23 = vcvtq_f32_s32(vld1q_dup_s32(&quantization_params[2].zero_point));
79 float32x4_t vout2x0123 = vmulq_f32(vksum0123, vinput_zero_point23);
80 float32x4_t vout2x4567 = vmulq_f32(vksum4567, vinput_zero_point23);
81 float32x4_t vout2x89AB = vmulq_f32(vksum89AB, vinput_zero_point23);
82 float32x4_t vout2xCDEF = vmulq_f32(vksumCDEF, vinput_zero_point23);
83
84
85 for (size_t kb=0; kb < kc; kb += bl) {
86 int32x4_t vacc01x01 = vdupq_n_s32(0);
87 int32x4_t vacc01x23 = vdupq_n_s32(0);
88 int32x4_t vacc01x45 = vdupq_n_s32(0);
89 int32x4_t vacc01x67 = vdupq_n_s32(0);
90 int32x4_t vacc01x89 = vdupq_n_s32(0);
91 int32x4_t vacc01xAB = vdupq_n_s32(0);
92 int32x4_t vacc01xCD = vdupq_n_s32(0);
93 int32x4_t vacc01xEF = vdupq_n_s32(0);
94 int32x4_t vacc23x01 = vdupq_n_s32(0);
95 int32x4_t vacc23x23 = vdupq_n_s32(0);
96 int32x4_t vacc23x45 = vdupq_n_s32(0);
97 int32x4_t vacc23x67 = vdupq_n_s32(0);
98 int32x4_t vacc23x89 = vdupq_n_s32(0);
99 int32x4_t vacc23xAB = vdupq_n_s32(0);
100 int32x4_t vacc23xCD = vdupq_n_s32(0);
101 int32x4_t vacc23xEF = vdupq_n_s32(0);
102
103 size_t k = bl;
104 // 2x partial unrolled loop to load 8 bytes at a time.
105
106 uint64x2x2_t va01x0123456789ABCDEF;
107 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
108 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
109 uint64x2x2_t va23x0123456789ABCDEF;
110 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
111 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
112
113 while (k >= 16 * sizeof(int8_t)) {
114 // Load a 3x16 block of activations.
115 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
116 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
117 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
118
119 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
120 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
121 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
122 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
123
124 // Load a 16x16 block of weights.
125 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
126 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
127 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
128 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
129 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
130 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
131 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
132 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
133 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
134 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
135 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
136 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
137 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
138 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
139 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
140 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
141 const int8x16_t vb01x89ABCDEF = vandq_s8(vb01x0123456789ABCDEF, vmask);
142 const int8x16_t vb23x89ABCDEF = vandq_s8(vb23x0123456789ABCDEF, vmask);
143 const int8x16_t vb45x89ABCDEF = vandq_s8(vb45x0123456789ABCDEF, vmask);
144 const int8x16_t vb67x89ABCDEF = vandq_s8(vb67x0123456789ABCDEF, vmask);
145 const int8x16_t vb89x89ABCDEF = vandq_s8(vb89x0123456789ABCDEF, vmask);
146 const int8x16_t vbABx89ABCDEF = vandq_s8(vbABx0123456789ABCDEF, vmask);
147 const int8x16_t vbCDx89ABCDEF = vandq_s8(vbCDx0123456789ABCDEF, vmask);
148 const int8x16_t vbEFx89ABCDEF = vandq_s8(vbEFx0123456789ABCDEF, vmask);
149
150 // Multiply-accumulate: 3x8 * 8x16 --> 3x16.
151 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
152 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
153 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
154 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
155 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
156 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
157 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
158 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
159 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
160 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
161 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
162 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
163 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
164 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
165 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
166 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
167 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
168 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
169 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
170 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
171 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
172 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
173 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
174 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
175 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
176 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
177 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
178 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
179 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
180 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
181 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
182 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
183
184 k -= 16 * sizeof(int8_t);
185 }
186 // Handle up to 8 final positions of `k`
187 if XNN_UNLIKELY(k != 0) {
188 // Load a 3x8 block of activations.
189 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
190 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
191 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
192
193 // Load a 16x16 block of weights.
194 const int8x16_t vb01x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vb23x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vb45x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vb67x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
198 const int8x16_t vb89x0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
199 const int8x16_t vbABx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
200 const int8x16_t vbCDx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
201 const int8x16_t vbEFx0123456789ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
202 const int8x16_t vb01x01234567 = vshlq_n_s8(vb01x0123456789ABCDEF, 4);
203 const int8x16_t vb23x01234567 = vshlq_n_s8(vb23x0123456789ABCDEF, 4);
204 const int8x16_t vb45x01234567 = vshlq_n_s8(vb45x0123456789ABCDEF, 4);
205 const int8x16_t vb67x01234567 = vshlq_n_s8(vb67x0123456789ABCDEF, 4);
206 const int8x16_t vb89x01234567 = vshlq_n_s8(vb89x0123456789ABCDEF, 4);
207 const int8x16_t vbABx01234567 = vshlq_n_s8(vbABx0123456789ABCDEF, 4);
208 const int8x16_t vbCDx01234567 = vshlq_n_s8(vbCDx0123456789ABCDEF, 4);
209 const int8x16_t vbEFx01234567 = vshlq_n_s8(vbEFx0123456789ABCDEF, 4);
210
211 // Multiply-accumulate: 3x4 * 4x16 --> 3x16.
212 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
213 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
214 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
215 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
216 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
217 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
218 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
219 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
220 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
221 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
222 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
223 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
224 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
225 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
226 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
227 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
228 }
229
230 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
231 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
232 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
233 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
234 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
235 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
236 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
237 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
238 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
239 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
240 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
241 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
242 const float32x4_t vfilter_output_scale0123 = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
243 const float32x4_t vfilter_output_scale4567 = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
244 const float32x4_t vfilter_output_scale89AB = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
245 const float32x4_t vfilter_output_scaleCDEF = vreinterpretq_f32_u32(vshll_n_u16(vld1_u16(w), 16)); w = (const uint16_t*) w + 4;
246 float32x4_t vf0x0123 = vcvtq_f32_s32(vacc0x0123);
247 vout0x0123 = vfmaq_f32(vout0x0123, vf0x0123, vfilter_output_scale0123);
248 float32x4_t vf0x4567 = vcvtq_f32_s32(vacc0x4567);
249 vout0x4567 = vfmaq_f32(vout0x4567, vf0x4567, vfilter_output_scale4567);
250 float32x4_t vf0x89AB = vcvtq_f32_s32(vacc0x89AB);
251 vout0x89AB = vfmaq_f32(vout0x89AB, vf0x89AB, vfilter_output_scale89AB);
252 float32x4_t vf0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
253 vout0xCDEF = vfmaq_f32(vout0xCDEF, vf0xCDEF, vfilter_output_scaleCDEF);
254 float32x4_t vf1x0123 = vcvtq_f32_s32(vacc1x0123);
255 vout1x0123 = vfmaq_f32(vout1x0123, vf1x0123, vfilter_output_scale0123);
256 float32x4_t vf1x4567 = vcvtq_f32_s32(vacc1x4567);
257 vout1x4567 = vfmaq_f32(vout1x4567, vf1x4567, vfilter_output_scale4567);
258 float32x4_t vf1x89AB = vcvtq_f32_s32(vacc1x89AB);
259 vout1x89AB = vfmaq_f32(vout1x89AB, vf1x89AB, vfilter_output_scale89AB);
260 float32x4_t vf1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
261 vout1xCDEF = vfmaq_f32(vout1xCDEF, vf1xCDEF, vfilter_output_scaleCDEF);
262 float32x4_t vf2x0123 = vcvtq_f32_s32(vacc2x0123);
263 vout2x0123 = vfmaq_f32(vout2x0123, vf2x0123, vfilter_output_scale0123);
264 float32x4_t vf2x4567 = vcvtq_f32_s32(vacc2x4567);
265 vout2x4567 = vfmaq_f32(vout2x4567, vf2x4567, vfilter_output_scale4567);
266 float32x4_t vf2x89AB = vcvtq_f32_s32(vacc2x89AB);
267 vout2x89AB = vfmaq_f32(vout2x89AB, vf2x89AB, vfilter_output_scale89AB);
268 float32x4_t vf2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
269 vout2xCDEF = vfmaq_f32(vout2xCDEF, vf2xCDEF, vfilter_output_scaleCDEF);
270 }
271
272 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
273 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
274 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
275 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
276 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
277 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
278 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
279 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
280 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
281 const float32x4_t vinput_scale2 = vld1q_dup_f32(&quantization_params[2].inv_scale);
282 vout2x0123 = vmulq_f32(vout2x0123, vinput_scale2);
283 vout2x4567 = vmulq_f32(vout2x4567, vinput_scale2);
284 vout2x89AB = vmulq_f32(vout2x89AB, vinput_scale2);
285 vout2xCDEF = vmulq_f32(vout2xCDEF, vinput_scale2);
286
287
288 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
289 vout0x0123 = vaddq_f32(vbias0123, vout0x0123);
290 vout1x0123 = vaddq_f32(vbias0123, vout1x0123);
291 vout2x0123 = vaddq_f32(vbias0123, vout2x0123);
292 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
293 vout0x4567 = vaddq_f32(vbias4567, vout0x4567);
294 vout1x4567 = vaddq_f32(vbias4567, vout1x4567);
295 vout2x4567 = vaddq_f32(vbias4567, vout2x4567);
296 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
297 vout0x89AB = vaddq_f32(vbias89AB, vout0x89AB);
298 vout1x89AB = vaddq_f32(vbias89AB, vout1x89AB);
299 vout2x89AB = vaddq_f32(vbias89AB, vout2x89AB);
300 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
301 vout0xCDEF = vaddq_f32(vbiasCDEF, vout0xCDEF);
302 vout1xCDEF = vaddq_f32(vbiasCDEF, vout1xCDEF);
303 vout2xCDEF = vaddq_f32(vbiasCDEF, vout2xCDEF);
304
305 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
306 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
307 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
308 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
309 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
310 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
311 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
312 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
313 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
314 vout2x0123 = vmaxq_f32(vout2x0123, voutput_min);
315 vout2x4567 = vmaxq_f32(vout2x4567, voutput_min);
316 vout2x89AB = vmaxq_f32(vout2x89AB, voutput_min);
317 vout2xCDEF = vmaxq_f32(vout2xCDEF, voutput_min);
318
319 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
320 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
321 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
322 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
323 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
324 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
325 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
326 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
327 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
328 vout2x0123 = vminq_f32(vout2x0123, voutput_max);
329 vout2x4567 = vminq_f32(vout2x4567, voutput_max);
330 vout2x89AB = vminq_f32(vout2x89AB, voutput_max);
331 vout2xCDEF = vminq_f32(vout2xCDEF, voutput_max);
332
333 if XNN_LIKELY(nc >= 16) {
334 vst1q_f32(c0, vout0x0123);
335 vst1q_f32(c0 + 4, vout0x4567);
336 vst1q_f32(c0 + 8, vout0x89AB);
337 vst1q_f32(c0 + 12, vout0xCDEF);
338 vst1q_f32(c1, vout1x0123);
339 vst1q_f32(c1 + 4, vout1x4567);
340 vst1q_f32(c1 + 8, vout1x89AB);
341 vst1q_f32(c1 + 12, vout1xCDEF);
342 vst1q_f32(c2, vout2x0123);
343 vst1q_f32(c2 + 4, vout2x4567);
344 vst1q_f32(c2 + 8, vout2x89AB);
345 vst1q_f32(c2 + 12, vout2xCDEF);
346
347 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
348 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
349 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
350
351 c0 = (float*) ((uintptr_t) c0 + cn_stride);
352 c1 = (float*) ((uintptr_t) c1 + cn_stride);
353 c2 = (float*) ((uintptr_t) c2 + cn_stride);
354
355 nc -= 16;
356 } else {
357 if (nc & 8) {
358 vst1q_f32(c0, vout0x0123); c0 += 4;
359 vout0x0123 = vout0x89AB;
360 vst1q_f32(c1, vout1x0123); c1 += 4;
361 vout1x0123 = vout1x89AB;
362 vst1q_f32(c2, vout2x0123); c2 += 4;
363 vout2x0123 = vout2x89AB;
364 vst1q_f32(c0, vout0x4567); c0 += 4;
365 vout0x4567 = vout0xCDEF;
366 vst1q_f32(c1, vout1x4567); c1 += 4;
367 vout1x4567 = vout1xCDEF;
368 vst1q_f32(c2, vout2x4567); c2 += 4;
369 vout2x4567 = vout2xCDEF;
370 }
371 if (nc & 4) {
372 vst1q_f32(c0, vout0x0123); c0 += 4;
373 vout0x0123 = vout0x4567;
374 vst1q_f32(c1, vout1x0123); c1 += 4;
375 vout1x0123 = vout1x4567;
376 vst1q_f32(c2, vout2x0123); c2 += 4;
377 vout2x0123 = vout2x4567;
378 }
379 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
380 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
381 float32x2_t vout2x01 = vget_low_f32(vout2x0123);
382 if (nc & 2) {
383 vst1_f32(c0, vout0x01); c0 += 2;
384 vst1_f32(c1, vout1x01); c1 += 2;
385 vst1_f32(c2, vout2x01); c2 += 2;
386 vout0x01 = vget_high_f32(vout0x0123);
387 vout1x01 = vget_high_f32(vout1x0123);
388 vout2x01 = vget_high_f32(vout2x0123);
389 }
390 if (nc & 1) {
391 vst1_lane_f32(c0, vout0x01, 0);
392 vst1_lane_f32(c1, vout1x01, 0);
393 vst1_lane_f32(c2, vout2x01, 0);
394 }
395 nc = 0;
396 }
397 } while (nc != 0);
398 }