Debian Codegraph @

src/qd8-f32-qc8w-gemm/gen/qd8-f32-qc8w-gemm-4x16c8-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_qc8w_gemm_minmax_ukernel_4x16c8__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 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 <= 4);
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 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
62 // Loop over groups of 16 columns.
63 do {
64 // Initialize accumulators with bias. 16 bias values are loaded from the
65 // weight matrix, at the start of the group of 16 columns.
66 const int32x4_t vinput_zero_point01 = vld1q_s32(&quantization_params[0].zero_point);
67 const int32x4_t vksum0123 = vld1q_s32(w); w = (const int32_t*) w + 4;
68 const int32x4_t vksumzp0x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point01), 0);
69 const int32x4_t vksumzp1x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point01), 0);
70 const int32x4_t vksum4567 = vld1q_s32(w); w = (const int32_t*) w + 4;
71 const int32x4_t vksumzp0x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point01), 0);
72 const int32x4_t vksumzp1x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point01), 0);
73 const int32x4_t vksum89AB = vld1q_s32(w); w = (const int32_t*) w + 4;
74 const int32x4_t vksumzp0x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point01), 0);
75 const int32x4_t vksumzp1x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point01), 0);
76 const int32x4_t vksumCDEF = vld1q_s32(w); w = (const int32_t*) w + 4;
77 const int32x4_t vksumzp0xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point01), 0);
78 const int32x4_t vksumzp1xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point01), 0);
79 const int32x4_t vinput_zero_point23 = vld1q_s32(&quantization_params[2].zero_point);
80 const int32x4_t vksumzp2x0123 = vmulq_lane_s32(vksum0123, vget_low_s32(vinput_zero_point23), 0);
81 const int32x4_t vksumzp3x0123 = vmulq_lane_s32(vksum0123, vget_high_s32(vinput_zero_point23), 0);
82 const int32x4_t vksumzp2x4567 = vmulq_lane_s32(vksum4567, vget_low_s32(vinput_zero_point23), 0);
83 const int32x4_t vksumzp3x4567 = vmulq_lane_s32(vksum4567, vget_high_s32(vinput_zero_point23), 0);
84 const int32x4_t vksumzp2x89AB = vmulq_lane_s32(vksum89AB, vget_low_s32(vinput_zero_point23), 0);
85 const int32x4_t vksumzp3x89AB = vmulq_lane_s32(vksum89AB, vget_high_s32(vinput_zero_point23), 0);
86 const int32x4_t vksumzp2xCDEF = vmulq_lane_s32(vksumCDEF, vget_low_s32(vinput_zero_point23), 0);
87 const int32x4_t vksumzp3xCDEF = vmulq_lane_s32(vksumCDEF, vget_high_s32(vinput_zero_point23), 0);
88
89 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
90 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x0123), vreinterpretq_u64_s32(vksumzp1x0123)));
91 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
92 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x4567), vreinterpretq_u64_s32(vksumzp1x4567)));
93 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
94 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0x89AB), vreinterpretq_u64_s32(vksumzp1x89AB)));
95 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
96 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp0xCDEF), vreinterpretq_u64_s32(vksumzp1xCDEF)));
97 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
98 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x0123), vreinterpretq_u64_s32(vksumzp3x0123)));
99 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
100 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x4567), vreinterpretq_u64_s32(vksumzp3x4567)));
101 int32x4_t vacc23x89 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
102 int32x4_t vacc23xAB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2x89AB), vreinterpretq_u64_s32(vksumzp3x89AB)));
103 int32x4_t vacc23xCD = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
104 int32x4_t vacc23xEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vksumzp2xCDEF), vreinterpretq_u64_s32(vksumzp3xCDEF)));
105
106 // Inner accumulation loop along the 16 columns.
107 size_t k = kc;
108 // 2x partial unrolled loop to load 8 bytes at a time.
109
110 uint64x2x2_t va01x0123456789ABCDEF;
111 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
112 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
113 uint64x2x2_t va23x0123456789ABCDEF;
114 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
115 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
116
117 while (k >= 16 * sizeof(int8_t)) {
118 // Load a 4x16 block of activations.
119 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
120 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
121 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
122 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
123
124 const int8x16_t va01x01234567 = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]);
125 const int8x16_t va01x89ABCDEF = vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]);
126 const int8x16_t va23x01234567 = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]);
127 const int8x16_t va23x89ABCDEF = vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]);
128
129 // Load a 16x16 block of weights.
130 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
131 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
132 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
133 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
134 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
135 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
136 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
137 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
138 const int8x16_t vb01x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
139 const int8x16_t vb23x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
140 const int8x16_t vb45x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
141 const int8x16_t vb67x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
142 const int8x16_t vb89x89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
143 const int8x16_t vbABx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
144 const int8x16_t vbCDx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
145 const int8x16_t vbEFx89ABCDEF = vld1q_s8(w); w = (const int8_t*) w + 16;
146
147 // Multiply-accumulate: 4x8 * 8x16 --> 4x16.
148 vacc01x01 = vmmlaq_s32(vacc01x01, va01x01234567, vb01x01234567);
149 vacc01x23 = vmmlaq_s32(vacc01x23, va01x01234567, vb23x01234567);
150 vacc01x45 = vmmlaq_s32(vacc01x45, va01x01234567, vb45x01234567);
151 vacc01x67 = vmmlaq_s32(vacc01x67, va01x01234567, vb67x01234567);
152 vacc01x89 = vmmlaq_s32(vacc01x89, va01x01234567, vb89x01234567);
153 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x01234567, vbABx01234567);
154 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x01234567, vbCDx01234567);
155 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x01234567, vbEFx01234567);
156 vacc23x01 = vmmlaq_s32(vacc23x01, va23x01234567, vb01x01234567);
157 vacc23x23 = vmmlaq_s32(vacc23x23, va23x01234567, vb23x01234567);
158 vacc23x45 = vmmlaq_s32(vacc23x45, va23x01234567, vb45x01234567);
159 vacc23x67 = vmmlaq_s32(vacc23x67, va23x01234567, vb67x01234567);
160 vacc23x89 = vmmlaq_s32(vacc23x89, va23x01234567, vb89x01234567);
161 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x01234567, vbABx01234567);
162 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x01234567, vbCDx01234567);
163 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x01234567, vbEFx01234567);
164 vacc01x01 = vmmlaq_s32(vacc01x01, va01x89ABCDEF, vb01x89ABCDEF);
165 vacc01x23 = vmmlaq_s32(vacc01x23, va01x89ABCDEF, vb23x89ABCDEF);
166 vacc01x45 = vmmlaq_s32(vacc01x45, va01x89ABCDEF, vb45x89ABCDEF);
167 vacc01x67 = vmmlaq_s32(vacc01x67, va01x89ABCDEF, vb67x89ABCDEF);
168 vacc01x89 = vmmlaq_s32(vacc01x89, va01x89ABCDEF, vb89x89ABCDEF);
169 vacc01xAB = vmmlaq_s32(vacc01xAB, va01x89ABCDEF, vbABx89ABCDEF);
170 vacc01xCD = vmmlaq_s32(vacc01xCD, va01x89ABCDEF, vbCDx89ABCDEF);
171 vacc01xEF = vmmlaq_s32(vacc01xEF, va01x89ABCDEF, vbEFx89ABCDEF);
172 vacc23x01 = vmmlaq_s32(vacc23x01, va23x89ABCDEF, vb01x89ABCDEF);
173 vacc23x23 = vmmlaq_s32(vacc23x23, va23x89ABCDEF, vb23x89ABCDEF);
174 vacc23x45 = vmmlaq_s32(vacc23x45, va23x89ABCDEF, vb45x89ABCDEF);
175 vacc23x67 = vmmlaq_s32(vacc23x67, va23x89ABCDEF, vb67x89ABCDEF);
176 vacc23x89 = vmmlaq_s32(vacc23x89, va23x89ABCDEF, vb89x89ABCDEF);
177 vacc23xAB = vmmlaq_s32(vacc23xAB, va23x89ABCDEF, vbABx89ABCDEF);
178 vacc23xCD = vmmlaq_s32(vacc23xCD, va23x89ABCDEF, vbCDx89ABCDEF);
179 vacc23xEF = vmmlaq_s32(vacc23xEF, va23x89ABCDEF, vbEFx89ABCDEF);
180
181 k -= 16 * sizeof(int8_t);
182 }
183 // Handle up to 8 final positions of `k`
184 if XNN_UNLIKELY(k != 0) {
185 // Load a 4x8 block of activations.
186 uint64x2_t va01x01234567 = vld1q_dup_u64((const void*) a0); a0 += 8;
187 uint64x2_t va23x01234567 = vld1q_dup_u64((const void*) a2); a2 += 8;
188 va01x01234567 = vld1q_lane_u64((const void*) a1, va01x01234567, 1); a1 += 8;
189 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
190
191 // Load a 16x16 block of weights.
192 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
193 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
194 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
195 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
196 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
197 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
198 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
199 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
200
201 // Multiply-accumulate: 4x4 * 4x16 --> 4x16.
202 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
203 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
204 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
205 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
206 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
207 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
208 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
209 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
210 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
211 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
212 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
213 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
214 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
215 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
216 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
217 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
218 }
219
220 int32x4_t vacc0x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
221 int32x4_t vacc1x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x01), vreinterpretq_u64_s32(vacc01x23)));
222 int32x4_t vacc0x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
223 int32x4_t vacc1x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x45), vreinterpretq_u64_s32(vacc01x67)));
224 int32x4_t vacc0x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
225 int32x4_t vacc1x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01x89), vreinterpretq_u64_s32(vacc01xAB)));
226 int32x4_t vacc0xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
227 int32x4_t vacc1xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc01xCD), vreinterpretq_u64_s32(vacc01xEF)));
228 int32x4_t vacc2x0123 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
229 int32x4_t vacc3x0123 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x01), vreinterpretq_u64_s32(vacc23x23)));
230 int32x4_t vacc2x4567 = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
231 int32x4_t vacc3x4567 = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x45), vreinterpretq_u64_s32(vacc23x67)));
232 int32x4_t vacc2x89AB = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
233 int32x4_t vacc3x89AB = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23x89), vreinterpretq_u64_s32(vacc23xAB)));
234 int32x4_t vacc2xCDEF = vreinterpretq_s32_u64(vtrn1q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
235 int32x4_t vacc3xCDEF = vreinterpretq_s32_u64(vtrn2q_u64(vreinterpretq_u64_s32(vacc23xCD), vreinterpretq_u64_s32(vacc23xEF)));
236 float32x4_t vout0x0123 = vcvtq_f32_s32(vacc0x0123);
237 float32x4_t vout0x4567 = vcvtq_f32_s32(vacc0x4567);
238 float32x4_t vout0x89AB = vcvtq_f32_s32(vacc0x89AB);
239 float32x4_t vout0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
240 float32x4_t vout1x0123 = vcvtq_f32_s32(vacc1x0123);
241 float32x4_t vout1x4567 = vcvtq_f32_s32(vacc1x4567);
242 float32x4_t vout1x89AB = vcvtq_f32_s32(vacc1x89AB);
243 float32x4_t vout1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
244 float32x4_t vout2x0123 = vcvtq_f32_s32(vacc2x0123);
245 float32x4_t vout2x4567 = vcvtq_f32_s32(vacc2x4567);
246 float32x4_t vout2x89AB = vcvtq_f32_s32(vacc2x89AB);
247 float32x4_t vout2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
248 float32x4_t vout3x0123 = vcvtq_f32_s32(vacc3x0123);
249 float32x4_t vout3x4567 = vcvtq_f32_s32(vacc3x4567);
250 float32x4_t vout3x89AB = vcvtq_f32_s32(vacc3x89AB);
251 float32x4_t vout3xCDEF = vcvtq_f32_s32(vacc3xCDEF);
252
253 const float32x4_t vinput_scale01 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[0].zero_point));
254 vout0x0123 = vmulq_lane_f32(vout0x0123, vget_low_f32(vinput_scale01), 1);
255 vout1x0123 = vmulq_lane_f32(vout1x0123, vget_high_f32(vinput_scale01), 1);
256 vout0x4567 = vmulq_lane_f32(vout0x4567, vget_low_f32(vinput_scale01), 1);
257 vout1x4567 = vmulq_lane_f32(vout1x4567, vget_high_f32(vinput_scale01), 1);
258 vout0x89AB = vmulq_lane_f32(vout0x89AB, vget_low_f32(vinput_scale01), 1);
259 vout1x89AB = vmulq_lane_f32(vout1x89AB, vget_high_f32(vinput_scale01), 1);
260 vout0xCDEF = vmulq_lane_f32(vout0xCDEF, vget_low_f32(vinput_scale01), 1);
261 vout1xCDEF = vmulq_lane_f32(vout1xCDEF, vget_high_f32(vinput_scale01), 1);
262 const float32x4_t vinput_scale23 = vreinterpretq_f32_s32(vld1q_s32(&quantization_params[2].zero_point));
263 vout2x0123 = vmulq_lane_f32(vout2x0123, vget_low_f32(vinput_scale23), 1);
264 vout3x0123 = vmulq_lane_f32(vout3x0123, vget_high_f32(vinput_scale23), 1);
265 vout2x4567 = vmulq_lane_f32(vout2x4567, vget_low_f32(vinput_scale23), 1);
266 vout3x4567 = vmulq_lane_f32(vout3x4567, vget_high_f32(vinput_scale23), 1);
267 vout2x89AB = vmulq_lane_f32(vout2x89AB, vget_low_f32(vinput_scale23), 1);
268 vout3x89AB = vmulq_lane_f32(vout3x89AB, vget_high_f32(vinput_scale23), 1);
269 vout2xCDEF = vmulq_lane_f32(vout2xCDEF, vget_low_f32(vinput_scale23), 1);
270 vout3xCDEF = vmulq_lane_f32(vout3xCDEF, vget_high_f32(vinput_scale23), 1);
271
272 const float32x4_t vfilter_output_scale0123 = vld1q_f32(w); w = (const float*) w + 4;
273 const float32x4_t vfilter_output_scale4567 = vld1q_f32(w); w = (const float*) w + 4;
274 const float32x4_t vfilter_output_scale89AB = vld1q_f32(w); w = (const float*) w + 4;
275 const float32x4_t vfilter_output_scaleCDEF = vld1q_f32(w); w = (const float*) w + 4;
276
277 const float32x4_t vbias0123 = vld1q_f32(w); w = (const float*) w + 4;
278 vout0x0123 = vfmaq_f32(vbias0123, vout0x0123, vfilter_output_scale0123);
279 vout1x0123 = vfmaq_f32(vbias0123, vout1x0123, vfilter_output_scale0123);
280 vout2x0123 = vfmaq_f32(vbias0123, vout2x0123, vfilter_output_scale0123);
281 vout3x0123 = vfmaq_f32(vbias0123, vout3x0123, vfilter_output_scale0123);
282 const float32x4_t vbias4567 = vld1q_f32(w); w = (const float*) w + 4;
283 vout0x4567 = vfmaq_f32(vbias4567, vout0x4567, vfilter_output_scale4567);
284 vout1x4567 = vfmaq_f32(vbias4567, vout1x4567, vfilter_output_scale4567);
285 vout2x4567 = vfmaq_f32(vbias4567, vout2x4567, vfilter_output_scale4567);
286 vout3x4567 = vfmaq_f32(vbias4567, vout3x4567, vfilter_output_scale4567);
287 const float32x4_t vbias89AB = vld1q_f32(w); w = (const float*) w + 4;
288 vout0x89AB = vfmaq_f32(vbias89AB, vout0x89AB, vfilter_output_scale89AB);
289 vout1x89AB = vfmaq_f32(vbias89AB, vout1x89AB, vfilter_output_scale89AB);
290 vout2x89AB = vfmaq_f32(vbias89AB, vout2x89AB, vfilter_output_scale89AB);
291 vout3x89AB = vfmaq_f32(vbias89AB, vout3x89AB, vfilter_output_scale89AB);
292 const float32x4_t vbiasCDEF = vld1q_f32(w); w = (const float*) w + 4;
293 vout0xCDEF = vfmaq_f32(vbiasCDEF, vout0xCDEF, vfilter_output_scaleCDEF);
294 vout1xCDEF = vfmaq_f32(vbiasCDEF, vout1xCDEF, vfilter_output_scaleCDEF);
295 vout2xCDEF = vfmaq_f32(vbiasCDEF, vout2xCDEF, vfilter_output_scaleCDEF);
296 vout3xCDEF = vfmaq_f32(vbiasCDEF, vout3xCDEF, vfilter_output_scaleCDEF);
297
298 const float32x4_t voutput_min = vld1q_dup_f32(&params->scalar.min);
299 vout0x0123 = vmaxq_f32(vout0x0123, voutput_min);
300 vout0x4567 = vmaxq_f32(vout0x4567, voutput_min);
301 vout0x89AB = vmaxq_f32(vout0x89AB, voutput_min);
302 vout0xCDEF = vmaxq_f32(vout0xCDEF, voutput_min);
303 vout1x0123 = vmaxq_f32(vout1x0123, voutput_min);
304 vout1x4567 = vmaxq_f32(vout1x4567, voutput_min);
305 vout1x89AB = vmaxq_f32(vout1x89AB, voutput_min);
306 vout1xCDEF = vmaxq_f32(vout1xCDEF, voutput_min);
307 vout2x0123 = vmaxq_f32(vout2x0123, voutput_min);
308 vout2x4567 = vmaxq_f32(vout2x4567, voutput_min);
309 vout2x89AB = vmaxq_f32(vout2x89AB, voutput_min);
310 vout2xCDEF = vmaxq_f32(vout2xCDEF, voutput_min);
311 vout3x0123 = vmaxq_f32(vout3x0123, voutput_min);
312 vout3x4567 = vmaxq_f32(vout3x4567, voutput_min);
313 vout3x89AB = vmaxq_f32(vout3x89AB, voutput_min);
314 vout3xCDEF = vmaxq_f32(vout3xCDEF, voutput_min);
315
316 const float32x4_t voutput_max = vld1q_dup_f32(&params->scalar.max);
317 vout0x0123 = vminq_f32(vout0x0123, voutput_max);
318 vout0x4567 = vminq_f32(vout0x4567, voutput_max);
319 vout0x89AB = vminq_f32(vout0x89AB, voutput_max);
320 vout0xCDEF = vminq_f32(vout0xCDEF, voutput_max);
321 vout1x0123 = vminq_f32(vout1x0123, voutput_max);
322 vout1x4567 = vminq_f32(vout1x4567, voutput_max);
323 vout1x89AB = vminq_f32(vout1x89AB, voutput_max);
324 vout1xCDEF = vminq_f32(vout1xCDEF, voutput_max);
325 vout2x0123 = vminq_f32(vout2x0123, voutput_max);
326 vout2x4567 = vminq_f32(vout2x4567, voutput_max);
327 vout2x89AB = vminq_f32(vout2x89AB, voutput_max);
328 vout2xCDEF = vminq_f32(vout2xCDEF, voutput_max);
329 vout3x0123 = vminq_f32(vout3x0123, voutput_max);
330 vout3x4567 = vminq_f32(vout3x4567, voutput_max);
331 vout3x89AB = vminq_f32(vout3x89AB, voutput_max);
332 vout3xCDEF = vminq_f32(vout3xCDEF, voutput_max);
333
334 if XNN_LIKELY(nc >= 16) {
335 vst1q_f32(c0, vout0x0123);
336 vst1q_f32(c0 + 4, vout0x4567);
337 vst1q_f32(c0 + 8, vout0x89AB);
338 vst1q_f32(c0 + 12, vout0xCDEF);
339 vst1q_f32(c1, vout1x0123);
340 vst1q_f32(c1 + 4, vout1x4567);
341 vst1q_f32(c1 + 8, vout1x89AB);
342 vst1q_f32(c1 + 12, vout1xCDEF);
343 vst1q_f32(c2, vout2x0123);
344 vst1q_f32(c2 + 4, vout2x4567);
345 vst1q_f32(c2 + 8, vout2x89AB);
346 vst1q_f32(c2 + 12, vout2xCDEF);
347 vst1q_f32(c3, vout3x0123);
348 vst1q_f32(c3 + 4, vout3x4567);
349 vst1q_f32(c3 + 8, vout3x89AB);
350 vst1q_f32(c3 + 12, vout3xCDEF);
351
352 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
353 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
354 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
355 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
356
357 c0 = (float*) ((uintptr_t) c0 + cn_stride);
358 c1 = (float*) ((uintptr_t) c1 + cn_stride);
359 c2 = (float*) ((uintptr_t) c2 + cn_stride);
360 c3 = (float*) ((uintptr_t) c3 + cn_stride);
361
362 nc -= 16;
363 } else {
364 if (nc & 8) {
365 vst1q_f32(c0, vout0x0123); c0 += 4;
366 vout0x0123 = vout0x89AB;
367 vst1q_f32(c1, vout1x0123); c1 += 4;
368 vout1x0123 = vout1x89AB;
369 vst1q_f32(c2, vout2x0123); c2 += 4;
370 vout2x0123 = vout2x89AB;
371 vst1q_f32(c3, vout3x0123); c3 += 4;
372 vout3x0123 = vout3x89AB;
373 vst1q_f32(c0, vout0x4567); c0 += 4;
374 vout0x4567 = vout0xCDEF;
375 vst1q_f32(c1, vout1x4567); c1 += 4;
376 vout1x4567 = vout1xCDEF;
377 vst1q_f32(c2, vout2x4567); c2 += 4;
378 vout2x4567 = vout2xCDEF;
379 vst1q_f32(c3, vout3x4567); c3 += 4;
380 vout3x4567 = vout3xCDEF;
381 }
382 if (nc & 4) {
383 vst1q_f32(c0, vout0x0123); c0 += 4;
384 vout0x0123 = vout0x4567;
385 vst1q_f32(c1, vout1x0123); c1 += 4;
386 vout1x0123 = vout1x4567;
387 vst1q_f32(c2, vout2x0123); c2 += 4;
388 vout2x0123 = vout2x4567;
389 vst1q_f32(c3, vout3x0123); c3 += 4;
390 vout3x0123 = vout3x4567;
391 }
392 float32x2_t vout0x01 = vget_low_f32(vout0x0123);
393 float32x2_t vout1x01 = vget_low_f32(vout1x0123);
394 float32x2_t vout2x01 = vget_low_f32(vout2x0123);
395 float32x2_t vout3x01 = vget_low_f32(vout3x0123);
396 if (nc & 2) {
397 vst1_f32(c0, vout0x01); c0 += 2;
398 vst1_f32(c1, vout1x01); c1 += 2;
399 vst1_f32(c2, vout2x01); c2 += 2;
400 vst1_f32(c3, vout3x01); c3 += 2;
401 vout0x01 = vget_high_f32(vout0x0123);
402 vout1x01 = vget_high_f32(vout1x0123);
403 vout2x01 = vget_high_f32(vout2x0123);
404 vout3x01 = vget_high_f32(vout3x0123);
405 }
406 if (nc & 1) {
407 vst1_lane_f32(c0, vout0x01, 0);
408 vst1_lane_f32(c1, vout1x01, 0);
409 vst1_lane_f32(c2, vout2x01, 0);
410 vst1_lane_f32(c3, vout3x01, 0);
411 }
412 nc = 0;
413 }
414 } while (nc != 0);
415 }