1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-igemm/c2-neon-mull-dup.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2021 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
xnn_qc8_igemm_minmax_fp32_ukernel_2x8c2__neon_mlal_ld2r(size_t mr,size_t nc,size_t kc,size_t ks,const int8_t ** restrict a,const void * restrict w,int8_t * restrict c,size_t cm_stride,size_t cn_stride,size_t a_offset,const int8_t * zero,const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qc8_igemm_minmax_fp32_ukernel_2x8c2__neon_mlal_ld2r(
18 size_t mr,
19 size_t nc,
20 size_t kc,
21 size_t ks,
22 const int8_t** restrict a,
23 const void* restrict w,
24 int8_t* restrict c,
25 size_t cm_stride,
26 size_t cn_stride,
27 size_t a_offset,
28 const int8_t* zero,
29 const union xnn_qc8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
30 {
31 assert(mr != 0);
32 assert(mr <= 2);
33 assert(nc != 0);
34 assert(kc != 0);
35 assert(ks != 0);
36 assert(ks % (2 * sizeof(void*)) == 0);
37 assert(a_offset % sizeof(int8_t) == 0);
38 assert(a != NULL);
39 assert(w != NULL);
40 assert(c != NULL);
41
42 kc = round_up_po2(kc, 2 * sizeof(int8_t));
43 int8_t* c0 = c;
44 int8_t* c1 = (int8_t*) ((uintptr_t) c0 + cm_stride);
45 if XNN_UNPREDICTABLE(mr != 2) {
46 c1 = c0;
47 }
48
49 do {
50 int32x4_t vacc0x0123 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
51 int32x4_t vacc0x4567 = vld1q_s32(w); w = (const void*) ((uintptr_t) w + 4 * sizeof(int32_t));
52 int32x4_t vacc1x0123 = vacc0x0123;
53 int32x4_t vacc1x4567 = vacc0x4567;
54
55 size_t p = ks;
56 do {
57 const int8_t* restrict a0 = a[0];
58 if XNN_UNPREDICTABLE(a0 != zero) {
59 a0 = (const int8_t*) ((uintptr_t) a0 + a_offset);
60 }
61 const int8_t* restrict a1 = a[1];
62 if XNN_UNPREDICTABLE(a1 != zero) {
63 a1 = (const int8_t*) ((uintptr_t) a1 + a_offset);
64 }
65 a += 2;
66
67 size_t k = kc;
68
69 while (k >= 16 * sizeof(int8_t)) {
70 const int16x4x2_t va00x0 = vld2_dup_s16((const void*)a0);
71 const int16x4x2_t va01x0 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
72 const int16x4x2_t va00x1 = vld2_dup_s16((const void*)a0);
73 const int16x4x2_t va01x1 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
74 const int16x4x2_t va10x0 = vld2_dup_s16((const void*)a1);
75 const int16x4x2_t va11x0 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
76 const int16x4x2_t va10x1 = vld2_dup_s16((const void*)a1);
77 const int16x4x2_t va11x1 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
78
79 const int8x8_t vb0123c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
80 const int8x8_t vb4567c0x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
81 const int8x8_t vb0123c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
82 const int8x8_t vb4567c1x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
83 const int8x8_t vb0123c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
84 const int8x8_t vb4567c2x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
85 const int8x8_t vb0123c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
86 const int8x8_t vb4567c3x0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
87
88 const int8x8_t va0c0x0 = vreinterpret_s8_s16(va00x0.val[0]);
89 const int8x8_t va0c0x1 = vreinterpret_s8_s16(va00x1.val[0]);
90 const int8x8_t va1c0x0 = vreinterpret_s8_s16(va10x0.val[0]);
91 const int8x8_t va1c0x1 = vreinterpret_s8_s16(va10x1.val[0]);
92
93 int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0x0, va0c0x0);
94 int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0x0, va1c0x0);
95 const int8x8_t vb0123c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
96 vprod0x0123c0 = vmlal_s8(vprod0x0123c0, vb0123c0x1, va0c0x1);
97 vprod1x0123c0 = vmlal_s8(vprod1x0123c0, vb0123c0x1, va1c0x1);
98 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
99 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
100 int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0x0, va0c0x0);
101 int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0x0, va1c0x0);
102 const int8x8_t vb4567c0x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
103 vprod0x4567c0 = vmlal_s8(vprod0x4567c0, vb4567c0x1, va0c0x1);
104 vprod1x4567c0 = vmlal_s8(vprod1x4567c0, vb4567c0x1, va1c0x1);
105 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
106 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
107 const int8x8_t va0c1x0 = vreinterpret_s8_s16(va00x0.val[1]);
108 const int8x8_t va0c1x1 = vreinterpret_s8_s16(va00x1.val[1]);
109 const int8x8_t va1c1x0 = vreinterpret_s8_s16(va10x0.val[1]);
110 const int8x8_t va1c1x1 = vreinterpret_s8_s16(va10x1.val[1]);
111
112 int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1x0, va0c1x0);
113 int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1x0, va1c1x0);
114 const int8x8_t vb0123c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
115 vprod0x0123c1 = vmlal_s8(vprod0x0123c1, vb0123c1x1, va0c1x1);
116 vprod1x0123c1 = vmlal_s8(vprod1x0123c1, vb0123c1x1, va1c1x1);
117 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
118 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
119 int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1x0, va0c1x0);
120 int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1x0, va1c1x0);
121 const int8x8_t vb4567c1x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
122 vprod0x4567c1 = vmlal_s8(vprod0x4567c1, vb4567c1x1, va0c1x1);
123 vprod1x4567c1 = vmlal_s8(vprod1x4567c1, vb4567c1x1, va1c1x1);
124 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
125 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
126 const int8x8_t va0c2x0 = vreinterpret_s8_s16(va01x0.val[0]);
127 const int8x8_t va0c2x1 = vreinterpret_s8_s16(va01x1.val[0]);
128 const int8x8_t va1c2x0 = vreinterpret_s8_s16(va11x0.val[0]);
129 const int8x8_t va1c2x1 = vreinterpret_s8_s16(va11x1.val[0]);
130
131 int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2x0, va0c2x0);
132 int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2x0, va1c2x0);
133 const int8x8_t vb0123c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
134 vprod0x0123c2 = vmlal_s8(vprod0x0123c2, vb0123c2x1, va0c2x1);
135 vprod1x0123c2 = vmlal_s8(vprod1x0123c2, vb0123c2x1, va1c2x1);
136 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
137 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
138 int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2x0, va0c2x0);
139 int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2x0, va1c2x0);
140 const int8x8_t vb4567c2x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
141 vprod0x4567c2 = vmlal_s8(vprod0x4567c2, vb4567c2x1, va0c2x1);
142 vprod1x4567c2 = vmlal_s8(vprod1x4567c2, vb4567c2x1, va1c2x1);
143 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
144 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
145 const int8x8_t va0c3x0 = vreinterpret_s8_s16(va01x0.val[1]);
146 const int8x8_t va0c3x1 = vreinterpret_s8_s16(va01x1.val[1]);
147 const int8x8_t va1c3x0 = vreinterpret_s8_s16(va11x0.val[1]);
148 const int8x8_t va1c3x1 = vreinterpret_s8_s16(va11x1.val[1]);
149
150 int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3x0, va0c3x0);
151 int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3x0, va1c3x0);
152 const int8x8_t vb0123c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
153 vprod0x0123c3 = vmlal_s8(vprod0x0123c3, vb0123c3x1, va0c3x1);
154 vprod1x0123c3 = vmlal_s8(vprod1x0123c3, vb0123c3x1, va1c3x1);
155 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
156 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
157 int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3x0, va0c3x0);
158 int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3x0, va1c3x0);
159 const int8x8_t vb4567c3x1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
160 vprod0x4567c3 = vmlal_s8(vprod0x4567c3, vb4567c3x1, va0c3x1);
161 vprod1x4567c3 = vmlal_s8(vprod1x4567c3, vb4567c3x1, va1c3x1);
162 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
163 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
164
165 k -= 16 * sizeof(int8_t);
166 }
167
168 if (k >= 8 * sizeof(int8_t)) {
169 const int16x4x2_t va00 = vld2_dup_s16((const void*)a0);
170 const int16x4x2_t va01 = vld2_dup_s16((const void*)(a0 + 4)); a0 += 8;
171 const int16x4x2_t va10 = vld2_dup_s16((const void*)a1);
172 const int16x4x2_t va11 = vld2_dup_s16((const void*)(a1 + 4)); a1 += 8;
173
174 const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
175 const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
176 const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
177 const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
178 const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
179 const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
180 const int8x8_t vb0123c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
181 const int8x8_t vb4567c3 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
182
183 const int8x8_t va0c0 = vreinterpret_s8_s16(va00.val[0]);
184 const int8x8_t va1c0 = vreinterpret_s8_s16(va10.val[0]);
185
186 const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
187 const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
188 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
189 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
190 const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
191 const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
192 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
193 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
194 const int8x8_t va0c1 = vreinterpret_s8_s16(va00.val[1]);
195 const int8x8_t va1c1 = vreinterpret_s8_s16(va10.val[1]);
196
197 const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
198 const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
199 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
200 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
201 const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
202 const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
203 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
204 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
205 const int8x8_t va0c2 = vreinterpret_s8_s16(va01.val[0]);
206 const int8x8_t va1c2 = vreinterpret_s8_s16(va11.val[0]);
207
208 const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
209 const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
210 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
211 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
212 const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
213 const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
214 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
215 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
216 const int8x8_t va0c3 = vreinterpret_s8_s16(va01.val[1]);
217 const int8x8_t va1c3 = vreinterpret_s8_s16(va11.val[1]);
218
219 const int16x8_t vprod0x0123c3 = vmull_s8(vb0123c3, va0c3);
220 const int16x8_t vprod1x0123c3 = vmull_s8(vb0123c3, va1c3);
221 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c3);
222 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c3);
223 const int16x8_t vprod0x4567c3 = vmull_s8(vb4567c3, va0c3);
224 const int16x8_t vprod1x4567c3 = vmull_s8(vb4567c3, va1c3);
225 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c3);
226 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c3);
227
228 k -= 8 * sizeof(int8_t);
229 }
230
231 if XNN_UNLIKELY(k != 0) {
232 const int8x8_t va0 = vld1_s8(a0); a0 = (const int8_t*) ((uintptr_t) a0 + k);
233 const int8x8_t va1 = vld1_s8(a1); a1 = (const int8_t*) ((uintptr_t) a1 + k);
234
235 const int8x8_t vb0123c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
236 const int8x8_t vb4567c0 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
237
238 const int8x8_t va0c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 0));
239 const int16x8_t vprod0x0123c0 = vmull_s8(vb0123c0, va0c0);
240 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c0);
241 const int16x8_t vprod0x4567c0 = vmull_s8(vb4567c0, va0c0);
242 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c0);
243 const int8x8_t va1c0 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 0));
244 const int16x8_t vprod1x0123c0 = vmull_s8(vb0123c0, va1c0);
245 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c0);
246 const int16x8_t vprod1x4567c0 = vmull_s8(vb4567c0, va1c0);
247 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c0);
248
249 if (k > 2 * sizeof(int8_t)) {
250 const int8x8_t vb0123c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
251 const int8x8_t vb4567c1 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
252
253 const int8x8_t va0c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 1));
254 const int16x8_t vprod0x0123c1 = vmull_s8(vb0123c1, va0c1);
255 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c1);
256 const int16x8_t vprod0x4567c1 = vmull_s8(vb4567c1, va0c1);
257 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c1);
258 const int8x8_t va1c1 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 1));
259 const int16x8_t vprod1x0123c1 = vmull_s8(vb0123c1, va1c1);
260 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c1);
261 const int16x8_t vprod1x4567c1 = vmull_s8(vb4567c1, va1c1);
262 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c1);
263
264 if (k > 4 * sizeof(int8_t)) {
265 const int8x8_t vb0123c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
266 const int8x8_t vb4567c2 = vld1_s8(w); w = (const void*) ((uintptr_t) w + 8 * sizeof(int8_t));
267
268 const int8x8_t va0c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va0), 2));
269 const int16x8_t vprod0x0123c2 = vmull_s8(vb0123c2, va0c2);
270 vacc0x0123 = vpadalq_s16(vacc0x0123, vprod0x0123c2);
271 const int16x8_t vprod0x4567c2 = vmull_s8(vb4567c2, va0c2);
272 vacc0x4567 = vpadalq_s16(vacc0x4567, vprod0x4567c2);
273 const int8x8_t va1c2 = vreinterpret_s8_s16(vdup_lane_s16(vreinterpret_s16_s8(va1), 2));
274 const int16x8_t vprod1x0123c2 = vmull_s8(vb0123c2, va1c2);
275 vacc1x0123 = vpadalq_s16(vacc1x0123, vprod1x0123c2);
276 const int16x8_t vprod1x4567c2 = vmull_s8(vb4567c2, va1c2);
277 vacc1x4567 = vpadalq_s16(vacc1x4567, vprod1x4567c2);
278 }
279 }
280 }
281 p -= 2 * sizeof(void*);
282 } while (p != 0);
283
284 float32x4_t vfpacc0x0123 = vcvtq_f32_s32(vacc0x0123);
285 float32x4_t vfpacc0x4567 = vcvtq_f32_s32(vacc0x4567);
286 float32x4_t vfpacc1x0123 = vcvtq_f32_s32(vacc1x0123);
287 float32x4_t vfpacc1x4567 = vcvtq_f32_s32(vacc1x4567);
288
289 const float32x4_t vscale0123 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
290 vfpacc0x0123 = vmulq_f32(vfpacc0x0123, vscale0123);
291 vfpacc1x0123 = vmulq_f32(vfpacc1x0123, vscale0123);
292 const float32x4_t vscale4567 = vld1q_f32((const float*) w); w = (const void*) ((const float*) w + 4);
293 vfpacc0x4567 = vmulq_f32(vfpacc0x4567, vscale4567);
294 vfpacc1x4567 = vmulq_f32(vfpacc1x4567, vscale4567);
295
296 const float32x4_t vmagic_bias = vld1q_dup_f32(¶ms->fp32_neon.magic_bias);
297 vacc0x0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0x0123, vmagic_bias));
298 vacc0x4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc0x4567, vmagic_bias));
299 vacc1x0123 = vreinterpretq_s32_f32(vaddq_f32(vfpacc1x0123, vmagic_bias));
300 vacc1x4567 = vreinterpretq_s32_f32(vaddq_f32(vfpacc1x4567, vmagic_bias));
301
302 const int32x4_t vmagic_bias_less_output_zero_point = vld1q_dup_s32(¶ms->fp32_neon.magic_bias_less_output_zero_point);
303 vacc0x0123 = vqsubq_s32(vacc0x0123, vmagic_bias_less_output_zero_point);
304 vacc0x4567 = vqsubq_s32(vacc0x4567, vmagic_bias_less_output_zero_point);
305 vacc1x0123 = vqsubq_s32(vacc1x0123, vmagic_bias_less_output_zero_point);
306 vacc1x4567 = vqsubq_s32(vacc1x4567, vmagic_bias_less_output_zero_point);
307
308 #if XNN_ARCH_ARM64
309 int16x8_t vacc0x01234567 = vqmovn_high_s32(vqmovn_s32(vacc0x0123), vacc0x4567);
310 int16x8_t vacc1x01234567 = vqmovn_high_s32(vqmovn_s32(vacc1x0123), vacc1x4567);
311
312
313 int8x16_t vout0x01234567_1x01234567 = vqmovn_high_s16(vqmovn_s16(vacc0x01234567), vacc1x01234567);
314 #else
315 int16x8_t vacc0x01234567 = vcombine_s16(vqmovn_s32(vacc0x0123), vqmovn_s32(vacc0x4567));
316 int16x8_t vacc1x01234567 = vcombine_s16(vqmovn_s32(vacc1x0123), vqmovn_s32(vacc1x4567));
317
318
319 int8x16_t vout0x01234567_1x01234567 = vcombine_s8(vqmovn_s16(vacc0x01234567), vqmovn_s16(vacc1x01234567));
320 #endif
321
322 const int8x16_t voutput_min = vld1q_dup_s8(¶ms->fp32_neon.output_min);
323 vout0x01234567_1x01234567 = vmaxq_s8(vout0x01234567_1x01234567, voutput_min);
324
325 const int8x16_t voutput_max = vld1q_dup_s8(¶ms->fp32_neon.output_max);
326 vout0x01234567_1x01234567 = vminq_s8(vout0x01234567_1x01234567, voutput_max);
327
328 if (nc >= 8) {
329 vst1_s8(c1 + 0, vget_high_s8(vout0x01234567_1x01234567));
330 vst1_s8(c0 + 0, vget_low_s8(vout0x01234567_1x01234567));
331
332 c1 = (int8_t*) ((uintptr_t) c1 + cn_stride);
333 c0 = (int8_t*) ((uintptr_t) c0 + cn_stride);
334
335 a = (const int8_t**restrict) ((uintptr_t) a - ks);
336
337 nc -= 8;
338 } else {
339 if (nc & 4) {
340 vst1q_lane_u32((void*) c1, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 2); c1 += 4;
341 vst1q_lane_u32((void*) c0, vreinterpretq_u32_s8(vout0x01234567_1x01234567), 0); c0 += 4;
342 vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 4);
343 }
344 if (nc & 2) {
345 vst1q_lane_u16((void*) c1, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 4); c1 += 2;
346 vst1q_lane_u16((void*) c0, vreinterpretq_u16_s8(vout0x01234567_1x01234567), 0); c0 += 2;
347 vout0x01234567_1x01234567 = vextq_s8(vout0x01234567_1x01234567, vout0x01234567_1x01234567, 2);
348 }
349 if (nc & 1) {
350 vst1q_lane_s8(c1, vout0x01234567_1x01234567, 8);
351 vst1q_lane_s8(c0, vout0x01234567_1x01234567, 0);
352 }
353
354 nc = 0;
355 }
356 } while (nc != 0);
357 }
358