Debian Codegraph @

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