Debian Codegraph @

src/qs8-qc8w-igemm/gen/qs8-qc8w-igemm-4x16c8-minmax-fp32-neoni8mm.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-igemm/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/igemm.h"
15 #include "xnnpack/intrinsics-polyfill.h"
16 #include "xnnpack/math.h"
17
18
19 void xnn_qs8_qc8w_igemm_minmax_fp32_ukernel_4x16c8__neoni8mm(
20 size_t mr,
21 size_t nc,
22 size_t kc,
23 size_t ks,
24 const int8_t** restrict a,
25 const void* restrict w,
26 int8_t* restrict c,
27 size_t cm_stride,
28 size_t cn_stride,
29 size_t a_offset,
30 const int8_t* zero,
31 const union xnn_qs8_qc8w_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
32 {
33 assert(mr != 0);
34 assert(mr <= 4);
35 assert(nc != 0);
36 assert(kc != 0);
37 assert(ks != 0);
38 assert(ks % (4 * sizeof(void*)) == 0);
39 assert(a_offset % sizeof(int8_t) == 0);
40 assert(a != NULL);
41 assert(w != NULL);
42 assert(c != NULL);
43
44 kc = round_up_po2(kc, 8 * sizeof(int8_t));
45 int8_t* c0 = c;
46 int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
47 if XNN_UNPREDICTABLE(mr < 2) {
48 c1 = c0;
49 }
50 int8_t* c2 = (int8_t*) ((uintptr_t) c1 + cm_stride);
51 if XNN_UNPREDICTABLE(mr <= 2) {
52 c2 = c1;
53 }
54 int8_t* c3 = (int8_t*) ((uintptr_t) c2 + cm_stride);
55 if XNN_UNPREDICTABLE(mr != 4) {
56 c3 = c2;
57 }
58
59 do {
60 const uint64x2x2_t vbias01x0123 = vld2q_dup_u64(w); w = (const int32_t*) w + 4;
61 const uint64x2x2_t vbias01x4567 = vld2q_dup_u64(w); w = (const int32_t*) w + 4;
62 const uint64x2x2_t vbias01x89AB = vld2q_dup_u64(w); w = (const int32_t*) w + 4;
63 const uint64x2x2_t vbias01xCDEF = vld2q_dup_u64(w); w = (const int32_t*) w + 4;
64 int32x4_t vacc01x01 = vreinterpretq_s32_u64(vbias01x0123.val[0]);
65 int32x4_t vacc01x23 = vreinterpretq_s32_u64(vbias01x0123.val[1]);
66 int32x4_t vacc01x45 = vreinterpretq_s32_u64(vbias01x4567.val[0]);
67 int32x4_t vacc01x67 = vreinterpretq_s32_u64(vbias01x4567.val[1]);
68 int32x4_t vacc01x89 = vreinterpretq_s32_u64(vbias01x89AB.val[0]);
69 int32x4_t vacc01xAB = vreinterpretq_s32_u64(vbias01x89AB.val[1]);
70 int32x4_t vacc01xCD = vreinterpretq_s32_u64(vbias01xCDEF.val[0]);
71 int32x4_t vacc01xEF = vreinterpretq_s32_u64(vbias01xCDEF.val[1]);
72 int32x4_t vacc23x01 = vreinterpretq_s32_u64(vbias01x0123.val[0]);
73 int32x4_t vacc23x23 = vreinterpretq_s32_u64(vbias01x0123.val[1]);
74 int32x4_t vacc23x45 = vreinterpretq_s32_u64(vbias01x4567.val[0]);
75 int32x4_t vacc23x67 = vreinterpretq_s32_u64(vbias01x4567.val[1]);
76 int32x4_t vacc23x89 = vreinterpretq_s32_u64(vbias01x89AB.val[0]);
77 int32x4_t vacc23xAB = vreinterpretq_s32_u64(vbias01x89AB.val[1]);
78 int32x4_t vacc23xCD = vreinterpretq_s32_u64(vbias01xCDEF.val[0]);
79 int32x4_t vacc23xEF = vreinterpretq_s32_u64(vbias01xCDEF.val[1]);
80
81 size_t p = ks;
82 do {
83 const int8_t* restrict a0 = a[0];
84 if XNN_UNPREDICTABLE(a0 != zero) {
85 a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
86 }
87 const int8_t* restrict a1 = a[1];
88 if XNN_UNPREDICTABLE(a1 != zero) {
89 a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
90 }
91 const int8_t* restrict a2 = a[2];
92 if XNN_UNPREDICTABLE(a2 != zero) {
93 a2 = (const int8_t*) ((uintptr_t) a2 + a_offset);
94 }
95 const int8_t* restrict a3 = a[3];
96 if XNN_UNPREDICTABLE(a3 != zero) {
97 a3 = (const int8_t*) ((uintptr_t) a3 + a_offset);
98 }
99 a += 4;
100
101 uint64x2x2_t va01x0123456789ABCDEF;
102 va01x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
103 va01x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
104 uint64x2x2_t va23x0123456789ABCDEF;
105 va23x0123456789ABCDEF.val[0] = vdupq_n_u64(0);
106 va23x0123456789ABCDEF.val[1] = vdupq_n_u64(0);
107
108 // Inner accumulation loop along the 16 columns.
109 size_t k = kc;
110 // 2x partial unrolled loop to load 8 bytes at a time.
111 while (k >= 16 * sizeof(int8_t)) {
112 // Load a 4x16 block of activations.
113 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a0, va01x0123456789ABCDEF, 0); a0 += 16;
114 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a2, va23x0123456789ABCDEF, 0); a2 += 16;
115 va01x0123456789ABCDEF = vld2q_lane_u64((const void*) a1, va01x0123456789ABCDEF, 1); a1 += 16;
116 va23x0123456789ABCDEF = vld2q_lane_u64((const void*) a3, va23x0123456789ABCDEF, 1); a3 += 16;
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: 4x16 * 16x16 --> 4x16.
137 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb01x01234567);
138 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb23x01234567);
139 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb45x01234567);
140 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb67x01234567);
141 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vb89x01234567);
142 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vbABx01234567);
143 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vbCDx01234567);
144 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[0]), vbEFx01234567);
145 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb01x01234567);
146 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb23x01234567);
147 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb45x01234567);
148 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb67x01234567);
149 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vb89x01234567);
150 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vbABx01234567);
151 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vbCDx01234567);
152 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[0]), vbEFx01234567);
153 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
154 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
155 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
156 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
157 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vb89x89ABCDEF);
158 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vbABx89ABCDEF);
159 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vbCDx89ABCDEF);
160 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x0123456789ABCDEF.val[1]), vbEFx89ABCDEF);
161 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb01x89ABCDEF);
162 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb23x89ABCDEF);
163 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb45x89ABCDEF);
164 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb67x89ABCDEF);
165 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vb89x89ABCDEF);
166 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vbABx89ABCDEF);
167 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), vbCDx89ABCDEF);
168 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x0123456789ABCDEF.val[1]), 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 4x8 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 va23x01234567 = vld1q_lane_u64((const void*) a3, va23x01234567, 1); a3 += 8;
179
180 // Load a 16x16 block of weights.
181 const int8x16_t vb01x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
182 const int8x16_t vb23x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
183 const int8x16_t vb45x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
184 const int8x16_t vb67x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
185 const int8x16_t vb89x01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
186 const int8x16_t vbABx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
187 const int8x16_t vbCDx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
188 const int8x16_t vbEFx01234567 = vld1q_s8(w); w = (const int8_t*) w + 16;
189
190 // Multiply-accumulate: 4x4 * 4x16 --> 4x16.
191 vacc01x01 = vmmlaq_s32(vacc01x01, vreinterpretq_s8_u64(va01x01234567), vb01x01234567);
192 vacc01x23 = vmmlaq_s32(vacc01x23, vreinterpretq_s8_u64(va01x01234567), vb23x01234567);
193 vacc01x45 = vmmlaq_s32(vacc01x45, vreinterpretq_s8_u64(va01x01234567), vb45x01234567);
194 vacc01x67 = vmmlaq_s32(vacc01x67, vreinterpretq_s8_u64(va01x01234567), vb67x01234567);
195 vacc01x89 = vmmlaq_s32(vacc01x89, vreinterpretq_s8_u64(va01x01234567), vb89x01234567);
196 vacc01xAB = vmmlaq_s32(vacc01xAB, vreinterpretq_s8_u64(va01x01234567), vbABx01234567);
197 vacc01xCD = vmmlaq_s32(vacc01xCD, vreinterpretq_s8_u64(va01x01234567), vbCDx01234567);
198 vacc01xEF = vmmlaq_s32(vacc01xEF, vreinterpretq_s8_u64(va01x01234567), vbEFx01234567);
199 vacc23x01 = vmmlaq_s32(vacc23x01, vreinterpretq_s8_u64(va23x01234567), vb01x01234567);
200 vacc23x23 = vmmlaq_s32(vacc23x23, vreinterpretq_s8_u64(va23x01234567), vb23x01234567);
201 vacc23x45 = vmmlaq_s32(vacc23x45, vreinterpretq_s8_u64(va23x01234567), vb45x01234567);
202 vacc23x67 = vmmlaq_s32(vacc23x67, vreinterpretq_s8_u64(va23x01234567), vb67x01234567);
203 vacc23x89 = vmmlaq_s32(vacc23x89, vreinterpretq_s8_u64(va23x01234567), vb89x01234567);
204 vacc23xAB = vmmlaq_s32(vacc23xAB, vreinterpretq_s8_u64(va23x01234567), vbABx01234567);
205 vacc23xCD = vmmlaq_s32(vacc23xCD, vreinterpretq_s8_u64(va23x01234567), vbCDx01234567);
206 vacc23xEF = vmmlaq_s32(vacc23xEF, vreinterpretq_s8_u64(va23x01234567), vbEFx01234567);
207 }
208
209 p -= 4 * sizeof(void*);
210 } while (p != 0);
211
212 int32x4_t vacc0x0123 = vcombine_s32(vget_low_s32(vacc01x01), vget_low_s32(vacc01x23));
213 int32x4_t vacc1x0123 = vcombine_s32(vget_high_s32(vacc01x01), vget_high_s32(vacc01x23));
214 int32x4_t vacc0x4567 = vcombine_s32(vget_low_s32(vacc01x45), vget_low_s32(vacc01x67));
215 int32x4_t vacc1x4567 = vcombine_s32(vget_high_s32(vacc01x45), vget_high_s32(vacc01x67));
216 int32x4_t vacc0x89AB = vcombine_s32(vget_low_s32(vacc01x89), vget_low_s32(vacc01xAB));
217 int32x4_t vacc1x89AB = vcombine_s32(vget_high_s32(vacc01x89), vget_high_s32(vacc01xAB));
218 int32x4_t vacc0xCDEF = vcombine_s32(vget_low_s32(vacc01xCD), vget_low_s32(vacc01xEF));
219 int32x4_t vacc1xCDEF = vcombine_s32(vget_high_s32(vacc01xCD), vget_high_s32(vacc01xEF));
220 int32x4_t vacc2x0123 = vcombine_s32(vget_low_s32(vacc23x01), vget_low_s32(vacc23x23));
221 int32x4_t vacc3x0123 = vcombine_s32(vget_high_s32(vacc23x01), vget_high_s32(vacc23x23));
222 int32x4_t vacc2x4567 = vcombine_s32(vget_low_s32(vacc23x45), vget_low_s32(vacc23x67));
223 int32x4_t vacc3x4567 = vcombine_s32(vget_high_s32(vacc23x45), vget_high_s32(vacc23x67));
224 int32x4_t vacc2x89AB = vcombine_s32(vget_low_s32(vacc23x89), vget_low_s32(vacc23xAB));
225 int32x4_t vacc3x89AB = vcombine_s32(vget_high_s32(vacc23x89), vget_high_s32(vacc23xAB));
226 int32x4_t vacc2xCDEF = vcombine_s32(vget_low_s32(vacc23xCD), vget_low_s32(vacc23xEF));
227 int32x4_t vacc3xCDEF = vcombine_s32(vget_high_s32(vacc23xCD), vget_high_s32(vacc23xEF));
228
229 float32x4_t vfpacc0x0123 = vcvtq_f32_s32(vacc0x0123);
230 float32x4_t vfpacc0x4567 = vcvtq_f32_s32(vacc0x4567);
231 float32x4_t vfpacc0x89AB = vcvtq_f32_s32(vacc0x89AB);
232 float32x4_t vfpacc0xCDEF = vcvtq_f32_s32(vacc0xCDEF);
233 float32x4_t vfpacc1x0123 = vcvtq_f32_s32(vacc1x0123);
234 float32x4_t vfpacc1x4567 = vcvtq_f32_s32(vacc1x4567);
235 float32x4_t vfpacc1x89AB = vcvtq_f32_s32(vacc1x89AB);
236 float32x4_t vfpacc1xCDEF = vcvtq_f32_s32(vacc1xCDEF);
237 float32x4_t vfpacc2x0123 = vcvtq_f32_s32(vacc2x0123);
238 float32x4_t vfpacc2x4567 = vcvtq_f32_s32(vacc2x4567);
239 float32x4_t vfpacc2x89AB = vcvtq_f32_s32(vacc2x89AB);
240 float32x4_t vfpacc2xCDEF = vcvtq_f32_s32(vacc2xCDEF);
241 float32x4_t vfpacc3x0123 = vcvtq_f32_s32(vacc3x0123);
242 float32x4_t vfpacc3x4567 = vcvtq_f32_s32(vacc3x4567);
243 float32x4_t vfpacc3x89AB = vcvtq_f32_s32(vacc3x89AB);
244 float32x4_t vfpacc3xCDEF = vcvtq_f32_s32(vacc3xCDEF);
245
246 const float32x4_t vscale0123 = vld1q_f32((const float*) w); w = (const float*) w + 4;
247 vfpacc0x0123 = vmulq_f32(vfpacc0x0123, vscale0123);
248 vfpacc1x0123 = vmulq_f32(vfpacc1x0123, vscale0123);
249 vfpacc2x0123 = vmulq_f32(vfpacc2x0123, vscale0123);
250 vfpacc3x0123 = vmulq_f32(vfpacc3x0123, vscale0123);
251 const float32x4_t vscale4567 = vld1q_f32((const float*) w); w = (const float*) w + 4;
252 vfpacc0x4567 = vmulq_f32(vfpacc0x4567, vscale4567);
253 vfpacc1x4567 = vmulq_f32(vfpacc1x4567, vscale4567);
254 vfpacc2x4567 = vmulq_f32(vfpacc2x4567, vscale4567);
255 vfpacc3x4567 = vmulq_f32(vfpacc3x4567, vscale4567);
256 const float32x4_t vscale89AB = vld1q_f32((const float*) w); w = (const float*) w + 4;
257 vfpacc0x89AB = vmulq_f32(vfpacc0x89AB, vscale89AB);
258 vfpacc1x89AB = vmulq_f32(vfpacc1x89AB, vscale89AB);
259 vfpacc2x89AB = vmulq_f32(vfpacc2x89AB, vscale89AB);
260 vfpacc3x89AB = vmulq_f32(vfpacc3x89AB, vscale89AB);
261 const float32x4_t vscaleCDEF = vld1q_f32((const float*) w); w = (const float*) w + 4;
262 vfpacc0xCDEF = vmulq_f32(vfpacc0xCDEF, vscaleCDEF);
263 vfpacc1xCDEF = vmulq_f32(vfpacc1xCDEF, vscaleCDEF);
264 vfpacc2xCDEF = vmulq_f32(vfpacc2xCDEF, vscaleCDEF);
265 vfpacc3xCDEF = vmulq_f32(vfpacc3xCDEF, vscaleCDEF);
266
267 vacc0x0123 = vcvtnq_s32_f32(vfpacc0x0123);
268 vacc0x4567 = vcvtnq_s32_f32(vfpacc0x4567);
269 vacc0x89AB = vcvtnq_s32_f32(vfpacc0x89AB);
270 vacc0xCDEF = vcvtnq_s32_f32(vfpacc0xCDEF);
271 vacc1x0123 = vcvtnq_s32_f32(vfpacc1x0123);
272 vacc1x4567 = vcvtnq_s32_f32(vfpacc1x4567);
273 vacc1x89AB = vcvtnq_s32_f32(vfpacc1x89AB);
274 vacc1xCDEF = vcvtnq_s32_f32(vfpacc1xCDEF);
275 vacc2x0123 = vcvtnq_s32_f32(vfpacc2x0123);
276 vacc2x4567 = vcvtnq_s32_f32(vfpacc2x4567);
277 vacc2x89AB = vcvtnq_s32_f32(vfpacc2x89AB);
278 vacc2xCDEF = vcvtnq_s32_f32(vfpacc2xCDEF);
279 vacc3x0123 = vcvtnq_s32_f32(vfpacc3x0123);
280 vacc3x4567 = vcvtnq_s32_f32(vfpacc3x4567);
281 vacc3x89AB = vcvtnq_s32_f32(vfpacc3x89AB);
282 vacc3xCDEF = vcvtnq_s32_f32(vfpacc3xCDEF);
283
284 const int16x8_t voutput_zero_point = vld1q_dup_s16(&params->fp32_neonv8.output_zero_point);
285 #if XNN_ARCH_ARM64
286 const int16x8_t vacc0x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567), voutput_zero_point);
287 const int16x8_t vacc0x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc0x89AB), vacc0xCDEF), voutput_zero_point);
288 const int16x8_t vacc1x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567), voutput_zero_point);
289 const int16x8_t vacc1x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc1x89AB), vacc1xCDEF), voutput_zero_point);
290 const int16x8_t vacc2x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc2x0123), vacc2x4567), voutput_zero_point);
291 const int16x8_t vacc2x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc2x89AB), vacc2xCDEF), voutput_zero_point);
292 const int16x8_t vacc3x01234567 = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc3x0123), vacc3x4567), voutput_zero_point);
293 const int16x8_t vacc3x89ABCDEF = vqaddq_s16(vqmovn_high_s32(vqmovn_s32(vacc3x89AB), vacc3xCDEF), voutput_zero_point);
294
295 int8x16_t vout0x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc0x89ABCDEF);
296 int8x16_t vout1x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc1x01234567), vacc1x89ABCDEF);
297 int8x16_t vout2x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc2x01234567), vacc2x89ABCDEF);
298 int8x16_t vout3x0123456789ABCDEF = vqmovn_high_s16(vqmovn_s16(vacc3x01234567), vacc3x89ABCDEF);
299 #else
300 const int16x8_t vacc0x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567)), voutput_zero_point);
301 const int16x8_t vacc0x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc0x89AB), vqmovn_s32(vacc0xCDEF)), voutput_zero_point);
302 const int16x8_t vacc1x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567)), voutput_zero_point);
303 const int16x8_t vacc1x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc1x89AB), vqmovn_s32(vacc1xCDEF)), voutput_zero_point);
304 const int16x8_t vacc2x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc2x0123), vqmovn_s32(vacc2x4567)), voutput_zero_point);
305 const int16x8_t vacc2x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc2x89AB), vqmovn_s32(vacc2xCDEF)), voutput_zero_point);
306 const int16x8_t vacc3x01234567 = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc3x0123), vqmovn_s32(vacc3x4567)), voutput_zero_point);
307 const int16x8_t vacc3x89ABCDEF = vqaddq_s16(vcombine_s16(vqmovn_s32(vacc3x89AB), vqmovn_s32(vacc3xCDEF)), voutput_zero_point);
308
309 int8x16_t vout0x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc0x89ABCDEF));
310 int8x16_t vout1x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc1x01234567), vqmovn_s16(vacc1x89ABCDEF));
311 int8x16_t vout2x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc2x01234567), vqmovn_s16(vacc2x89ABCDEF));
312 int8x16_t vout3x0123456789ABCDEF = vcombine_s8(vqmovn_s16(vacc3x01234567), vqmovn_s16(vacc3x89ABCDEF));
313 #endif
314 const int8x16_t voutput_min = vld1q_dup_s8(&params->fp32_neonv8.output_min);
315 const int8x16_t voutput_max = vld1q_dup_s8(&params->fp32_neonv8.output_max);
316
317 vout3x0123456789ABCDEF = vmaxq_s8(vout3x0123456789ABCDEF, voutput_min);
318 vout2x0123456789ABCDEF = vmaxq_s8(vout2x0123456789ABCDEF, voutput_min);
319 vout1x0123456789ABCDEF = vmaxq_s8(vout1x0123456789ABCDEF, voutput_min);
320 vout0x0123456789ABCDEF = vmaxq_s8(vout0x0123456789ABCDEF, voutput_min);
321
322 vout3x0123456789ABCDEF = vminq_s8(vout3x0123456789ABCDEF, voutput_max);
323 vout2x0123456789ABCDEF = vminq_s8(vout2x0123456789ABCDEF, voutput_max);
324 vout1x0123456789ABCDEF = vminq_s8(vout1x0123456789ABCDEF, voutput_max);
325 vout0x0123456789ABCDEF = vminq_s8(vout0x0123456789ABCDEF, voutput_max);
326
327 if (nc >= 16) {
328 vst1q_s8(c3, vout3x0123456789ABCDEF);
329 vst1q_s8(c2, vout2x0123456789ABCDEF);
330 vst1q_s8(c1, vout1x0123456789ABCDEF);
331 vst1q_s8(c0, vout0x0123456789ABCDEF);
332
333 c3 = (int8_t*) ((uintptr_t) c3 + cn_stride);
334 c2 = (int8_t*) ((uintptr_t) c2 + cn_stride);
335 c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
336 c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
337
338 a = (const int8_t**restrict) ((uintptr_t) a - ks);
339
340 nc -= 16;
341 } else {
342 int8x16_t vout2x01234567_3x01234567 = vcombine_s8(vget_low_s8(vout2x0123456789ABCDEF), vget_low_s8(vout3x0123456789ABCDEF));
343 int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vget_low_s8(vout0x0123456789ABCDEF), vget_low_s8(vout1x0123456789ABCDEF));
344 if (nc & 8) {
345 vst1_s8(c3, vget_high_s8(vout2x01234567_3x01234567)); c3 += 8;
346 vst1_s8(c2, vget_low_s8(vout2x01234567_3x01234567)); c2 += 8;
347 vst1_s8(c1, vget_high_s8(vout0x01234567_1x01234567)); c1 += 8;
348 vst1_s8(c0, vget_low_s8(vout0x01234567_1x01234567)); c0 += 8;
349 vout2x01234567_3x01234567 = vcombine_s8(vget_high_s8(vout2x0123456789ABCDEF), vget_high_s8(vout3x0123456789ABCDEF));
350 vout0x01234567_1x01234567 = vcombine_s8(vget_high_s8(vout0x0123456789ABCDEF), vget_high_s8(vout1x0123456789ABCDEF));
351 }
352 if (nc & 4) {
353 vst1q_lane_u32((void*) c3, vreinterpretq_u32_s8(vout2x01234567_3x01234567), 2); c3 += 4;
354 vst1q_lane_u32((void*) c2, vreinterpretq_u32_s8(vout2x01234567_3x01234567), 0); c2 += 4;
355 vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
356 vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
357 vout2x01234567_3x01234567 = vextq_s8(vout2x01234567_3x01234567, vout2x01234567_3x01234567, 4);
358 vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
359 }
360 if (nc & 2) {
361 vst1q_lane_u16((void*) c3, vreinterpretq_u16_s8(vout2x01234567_3x01234567), 4); c3 += 2;
362 vst1q_lane_u16((void*) c2, vreinterpretq_u16_s8(vout2x01234567_3x01234567), 0); c2 += 2;
363 vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
364 vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
365 vout2x01234567_3x01234567 = vextq_s8(vout2x01234567_3x01234567, vout2x01234567_3x01234567, 2);
366 vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
367 }
368 if (nc & 1) {
369 vst1q_lane_s8(c3, vout2x01234567_3x01234567, 8);
370 vst1q_lane_s8(c2, vout2x01234567_3x01234567, 0);
371 vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
372 vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
373 }
374
375 nc = 0;
376 }
377 } while (nc != 0);
378 }