Debian Codegraph @

src/qd8-f32-qc8w-gemm/gen/qd8-f32-qc8w-gemm-7x8c4-minmax-avxvnni-u4-acc4.c

raw
1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-gemm/MRx8c4-avxvnni.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 #include <stdint.h>
12
13 #include <immintrin.h>
14
15 #include "xnnpack/common.h"
16 #include "xnnpack/gemm.h"
17 #include "xnnpack/intrinsics-polyfill.h"
18 #include "xnnpack/math.h"
19 #include "xnnpack/unaligned.h"
20 #include "xnnpack/prefetch.h"
21
22
23 void xnn_qd8_f32_qc8w_gemm_minmax_ukernel_7x8c4__avxvnni_u4_acc4(
24 size_t mr,
25 size_t nc,
26 size_t kc,
27 const int8_t* restrict a,
28 size_t a_stride,
29 const void* restrict w,
30 float* restrict c,
31 size_t cm_stride,
32 size_t cn_stride,
33 const union xnn_f32_minmax_params params[restrict XNN_MIN_ELEMENTS(1)],
34 const struct xnn_qd8_quantization_params quantization_params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
35 {
36 assert(mr != 0);
37 assert(mr <= 7);
38 assert(nc != 0);
39 assert(kc != 0);
40 assert(kc % sizeof(int8_t) == 0);
41 assert(a != NULL);
42 assert(w != NULL);
43 assert(c != NULL);
44
45 kc = round_up_po2(kc, 4 * sizeof(int8_t));
46 const int8_t* a0 = a;
47 float* c0 = c;
48 const int8_t* a1 = (const int8_t*) ((uintptr_t) a0 + a_stride);
49 float* c1 = (float*) ((uintptr_t) c0 + cm_stride);
50 if XNN_UNPREDICTABLE(mr < 2) {
51 a1 = a0;
52 c1 = c0;
53 }
54 const int8_t* a2 = (const int8_t*) ((uintptr_t) a1 + a_stride);
55 float* c2 = (float*) ((uintptr_t) c1 + cm_stride);
56 if XNN_UNPREDICTABLE(mr <= 2) {
57 a2 = a1;
58 c2 = c1;
59 }
60 const int8_t* a3 = (const int8_t*) ((uintptr_t) a2 + a_stride);
61 float* c3 = (float*) ((uintptr_t) c2 + cm_stride);
62 if XNN_UNPREDICTABLE(mr < 4) {
63 a3 = a2;
64 c3 = c2;
65 }
66 const int8_t* a4 = (const int8_t*) ((uintptr_t) a3 + a_stride);
67 float* c4 = (float*) ((uintptr_t) c3 + cm_stride);
68 if XNN_UNPREDICTABLE(mr <= 4) {
69 a4 = a3;
70 c4 = c3;
71 }
72 const int8_t* a5 = (const int8_t*) ((uintptr_t) a4 + a_stride);
73 float* c5 = (float*) ((uintptr_t) c4 + cm_stride);
74 if XNN_UNPREDICTABLE(mr < 6) {
75 a5 = a4;
76 c5 = c4;
77 }
78 const int8_t* a6 = (const int8_t*) ((uintptr_t) a5 + a_stride);
79 float* c6 = (float*) ((uintptr_t) c5 + cm_stride);
80 if XNN_UNPREDICTABLE(mr <= 6) {
81 a6 = a5;
82 c6 = c5;
83 }
84
85 const __m256i vsign_mask =_mm256_set1_epi8(0x80);
86 XNN_FORCE_REALIZATION(vsign_mask);
87 const __m256i vinput_zero_point0 = _mm256_set1_epi32((int) quantization_params[0].zero_point + 128);
88 const __m256i vinput_zero_point1 = _mm256_set1_epi32((int) quantization_params[1].zero_point + 128);
89 const __m256i vinput_zero_point2 = _mm256_set1_epi32((int) quantization_params[2].zero_point + 128);
90 const __m256i vinput_zero_point3 = _mm256_set1_epi32((int) quantization_params[3].zero_point + 128);
91 const __m256i vinput_zero_point4 = _mm256_set1_epi32((int) quantization_params[4].zero_point + 128);
92 const __m256i vinput_zero_point5 = _mm256_set1_epi32((int) quantization_params[5].zero_point + 128);
93 const __m256i vinput_zero_point6 = _mm256_set1_epi32((int) quantization_params[6].zero_point + 128);
94 const __m256 voutput_min = _mm256_set1_ps(params->scalar.min);
95 const __m256 voutput_max = _mm256_set1_ps(params->scalar.max);
96 // XNN_FORCE_REALIZATION(voutput_min);
97 // XNN_FORCE_REALIZATION(voutput_max);
98 do {
99 const __m256i vksum01234567 = _mm256_load_si256(w);
100 __m256i vacc0x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point0);
101 __m256i vacc0x1x01234567 = _mm256_setzero_si256();
102 __m256i vacc0x2x01234567 = _mm256_setzero_si256();
103 __m256i vacc0x3x01234567 = _mm256_setzero_si256();
104 __m256i vacc1x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point1);
105 __m256i vacc1x1x01234567 = _mm256_setzero_si256();
106 __m256i vacc1x2x01234567 = _mm256_setzero_si256();
107 __m256i vacc1x3x01234567 = _mm256_setzero_si256();
108 __m256i vacc2x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point2);
109 __m256i vacc2x1x01234567 = _mm256_setzero_si256();
110 __m256i vacc2x2x01234567 = _mm256_setzero_si256();
111 __m256i vacc2x3x01234567 = _mm256_setzero_si256();
112 __m256i vacc3x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point3);
113 __m256i vacc3x1x01234567 = _mm256_setzero_si256();
114 __m256i vacc3x2x01234567 = _mm256_setzero_si256();
115 __m256i vacc3x3x01234567 = _mm256_setzero_si256();
116 __m256i vacc4x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point4);
117 __m256i vacc4x1x01234567 = _mm256_setzero_si256();
118 __m256i vacc4x2x01234567 = _mm256_setzero_si256();
119 __m256i vacc4x3x01234567 = _mm256_setzero_si256();
120 __m256i vacc5x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point5);
121 __m256i vacc5x1x01234567 = _mm256_setzero_si256();
122 __m256i vacc5x2x01234567 = _mm256_setzero_si256();
123 __m256i vacc5x3x01234567 = _mm256_setzero_si256();
124 __m256i vacc6x0x01234567 = _mm256_mullo_epi32(vksum01234567, vinput_zero_point6);
125 __m256i vacc6x1x01234567 = _mm256_setzero_si256();
126 __m256i vacc6x2x01234567 = _mm256_setzero_si256();
127 __m256i vacc6x3x01234567 = _mm256_setzero_si256();
128 w = (const int32_t*) w + 8;
129
130 size_t k = kc;
131 while (k >= 16 * sizeof(int8_t)) {
132 __m256i va0x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a0 + 0));
133 __m256i va0x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a0 + 4));
134 __m256i va0x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a0 + 8));
135 __m256i va0x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a0 + 12));
136 a0 += 16;
137 __m256i va1x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a1 + 0));
138 __m256i va1x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a1 + 4));
139 __m256i va1x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a1 + 8));
140 __m256i va1x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a1 + 12));
141 a1 += 16;
142 __m256i va2x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a2 + 0));
143 __m256i va2x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a2 + 4));
144 __m256i va2x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a2 + 8));
145 __m256i va2x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a2 + 12));
146 a2 += 16;
147 __m256i va3x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a3 + 0));
148 __m256i va3x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a3 + 4));
149 __m256i va3x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a3 + 8));
150 __m256i va3x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a3 + 12));
151 a3 += 16;
152 __m256i va4x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a4 + 0));
153 __m256i va4x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a4 + 4));
154 __m256i va4x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a4 + 8));
155 __m256i va4x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a4 + 12));
156 a4 += 16;
157 __m256i va5x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a5 + 0));
158 __m256i va5x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a5 + 4));
159 __m256i va5x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a5 + 8));
160 __m256i va5x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a5 + 12));
161 a5 += 16;
162 __m256i va6x0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a6 + 0));
163 __m256i va6x1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a6 + 4));
164 __m256i va6x2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a6 + 8));
165 __m256i va6x3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a6 + 12));
166 a6 += 16;
167
168 va0x0x0123 = _mm256_xor_si256(va0x0x0123, vsign_mask);
169 va0x1x0123 = _mm256_xor_si256(va0x1x0123, vsign_mask);
170 va0x2x0123 = _mm256_xor_si256(va0x2x0123, vsign_mask);
171 va0x3x0123 = _mm256_xor_si256(va0x3x0123, vsign_mask);
172 va1x0x0123 = _mm256_xor_si256(va1x0x0123, vsign_mask);
173 va1x1x0123 = _mm256_xor_si256(va1x1x0123, vsign_mask);
174 va1x2x0123 = _mm256_xor_si256(va1x2x0123, vsign_mask);
175 va1x3x0123 = _mm256_xor_si256(va1x3x0123, vsign_mask);
176 va2x0x0123 = _mm256_xor_si256(va2x0x0123, vsign_mask);
177 va2x1x0123 = _mm256_xor_si256(va2x1x0123, vsign_mask);
178 va2x2x0123 = _mm256_xor_si256(va2x2x0123, vsign_mask);
179 va2x3x0123 = _mm256_xor_si256(va2x3x0123, vsign_mask);
180 va3x0x0123 = _mm256_xor_si256(va3x0x0123, vsign_mask);
181 va3x1x0123 = _mm256_xor_si256(va3x1x0123, vsign_mask);
182 va3x2x0123 = _mm256_xor_si256(va3x2x0123, vsign_mask);
183 va3x3x0123 = _mm256_xor_si256(va3x3x0123, vsign_mask);
184 va4x0x0123 = _mm256_xor_si256(va4x0x0123, vsign_mask);
185 va4x1x0123 = _mm256_xor_si256(va4x1x0123, vsign_mask);
186 va4x2x0123 = _mm256_xor_si256(va4x2x0123, vsign_mask);
187 va4x3x0123 = _mm256_xor_si256(va4x3x0123, vsign_mask);
188 va5x0x0123 = _mm256_xor_si256(va5x0x0123, vsign_mask);
189 va5x1x0123 = _mm256_xor_si256(va5x1x0123, vsign_mask);
190 va5x2x0123 = _mm256_xor_si256(va5x2x0123, vsign_mask);
191 va5x3x0123 = _mm256_xor_si256(va5x3x0123, vsign_mask);
192 va6x0x0123 = _mm256_xor_si256(va6x0x0123, vsign_mask);
193 va6x1x0123 = _mm256_xor_si256(va6x1x0123, vsign_mask);
194 va6x2x0123 = _mm256_xor_si256(va6x2x0123, vsign_mask);
195 va6x3x0123 = _mm256_xor_si256(va6x3x0123, vsign_mask);
196
197 const __m256i vb0x01234567 = _mm256_load_si256((const __m256i*) ((const int8_t*) w + 0));
198 const __m256i vb1x01234567 = _mm256_load_si256((const __m256i*) ((const int8_t*) w + 32));
199 const __m256i vb2x01234567 = _mm256_load_si256((const __m256i*) ((const int8_t*) w + 64));
200 const __m256i vb3x01234567 = _mm256_load_si256((const __m256i*) ((const int8_t*) w + 96));
201 w = (const int8_t*) w + 128;
202
203 vacc0x0x01234567 = _mm256_dpbusd_avx_epi32(vacc0x0x01234567, va0x0x0123, vb0x01234567);
204 vacc0x1x01234567 = _mm256_dpbusd_avx_epi32(vacc0x1x01234567, va0x1x0123, vb1x01234567);
205 vacc0x2x01234567 = _mm256_dpbusd_avx_epi32(vacc0x2x01234567, va0x2x0123, vb2x01234567);
206 vacc0x3x01234567 = _mm256_dpbusd_avx_epi32(vacc0x3x01234567, va0x3x0123, vb3x01234567);
207 vacc1x0x01234567 = _mm256_dpbusd_avx_epi32(vacc1x0x01234567, va1x0x0123, vb0x01234567);
208 vacc1x1x01234567 = _mm256_dpbusd_avx_epi32(vacc1x1x01234567, va1x1x0123, vb1x01234567);
209 vacc1x2x01234567 = _mm256_dpbusd_avx_epi32(vacc1x2x01234567, va1x2x0123, vb2x01234567);
210 vacc1x3x01234567 = _mm256_dpbusd_avx_epi32(vacc1x3x01234567, va1x3x0123, vb3x01234567);
211 vacc2x0x01234567 = _mm256_dpbusd_avx_epi32(vacc2x0x01234567, va2x0x0123, vb0x01234567);
212 vacc2x1x01234567 = _mm256_dpbusd_avx_epi32(vacc2x1x01234567, va2x1x0123, vb1x01234567);
213 vacc2x2x01234567 = _mm256_dpbusd_avx_epi32(vacc2x2x01234567, va2x2x0123, vb2x01234567);
214 vacc2x3x01234567 = _mm256_dpbusd_avx_epi32(vacc2x3x01234567, va2x3x0123, vb3x01234567);
215 vacc3x0x01234567 = _mm256_dpbusd_avx_epi32(vacc3x0x01234567, va3x0x0123, vb0x01234567);
216 vacc3x1x01234567 = _mm256_dpbusd_avx_epi32(vacc3x1x01234567, va3x1x0123, vb1x01234567);
217 vacc3x2x01234567 = _mm256_dpbusd_avx_epi32(vacc3x2x01234567, va3x2x0123, vb2x01234567);
218 vacc3x3x01234567 = _mm256_dpbusd_avx_epi32(vacc3x3x01234567, va3x3x0123, vb3x01234567);
219 vacc4x0x01234567 = _mm256_dpbusd_avx_epi32(vacc4x0x01234567, va4x0x0123, vb0x01234567);
220 vacc4x1x01234567 = _mm256_dpbusd_avx_epi32(vacc4x1x01234567, va4x1x0123, vb1x01234567);
221 vacc4x2x01234567 = _mm256_dpbusd_avx_epi32(vacc4x2x01234567, va4x2x0123, vb2x01234567);
222 vacc4x3x01234567 = _mm256_dpbusd_avx_epi32(vacc4x3x01234567, va4x3x0123, vb3x01234567);
223 vacc5x0x01234567 = _mm256_dpbusd_avx_epi32(vacc5x0x01234567, va5x0x0123, vb0x01234567);
224 vacc5x1x01234567 = _mm256_dpbusd_avx_epi32(vacc5x1x01234567, va5x1x0123, vb1x01234567);
225 vacc5x2x01234567 = _mm256_dpbusd_avx_epi32(vacc5x2x01234567, va5x2x0123, vb2x01234567);
226 vacc5x3x01234567 = _mm256_dpbusd_avx_epi32(vacc5x3x01234567, va5x3x0123, vb3x01234567);
227 vacc6x0x01234567 = _mm256_dpbusd_avx_epi32(vacc6x0x01234567, va6x0x0123, vb0x01234567);
228 vacc6x1x01234567 = _mm256_dpbusd_avx_epi32(vacc6x1x01234567, va6x1x0123, vb1x01234567);
229 vacc6x2x01234567 = _mm256_dpbusd_avx_epi32(vacc6x2x01234567, va6x2x0123, vb2x01234567);
230 vacc6x3x01234567 = _mm256_dpbusd_avx_epi32(vacc6x3x01234567, va6x3x0123, vb3x01234567);
231
232 k -= 16 * sizeof(int8_t);
233 }
234 vacc0x0x01234567 = _mm256_add_epi32(vacc0x0x01234567, vacc0x1x01234567);
235 vacc1x0x01234567 = _mm256_add_epi32(vacc1x0x01234567, vacc1x1x01234567);
236 vacc2x0x01234567 = _mm256_add_epi32(vacc2x0x01234567, vacc2x1x01234567);
237 vacc3x0x01234567 = _mm256_add_epi32(vacc3x0x01234567, vacc3x1x01234567);
238 vacc4x0x01234567 = _mm256_add_epi32(vacc4x0x01234567, vacc4x1x01234567);
239 vacc5x0x01234567 = _mm256_add_epi32(vacc5x0x01234567, vacc5x1x01234567);
240 vacc6x0x01234567 = _mm256_add_epi32(vacc6x0x01234567, vacc6x1x01234567);
241 vacc0x2x01234567 = _mm256_add_epi32(vacc0x2x01234567, vacc0x3x01234567);
242 vacc1x2x01234567 = _mm256_add_epi32(vacc1x2x01234567, vacc1x3x01234567);
243 vacc2x2x01234567 = _mm256_add_epi32(vacc2x2x01234567, vacc2x3x01234567);
244 vacc3x2x01234567 = _mm256_add_epi32(vacc3x2x01234567, vacc3x3x01234567);
245 vacc4x2x01234567 = _mm256_add_epi32(vacc4x2x01234567, vacc4x3x01234567);
246 vacc5x2x01234567 = _mm256_add_epi32(vacc5x2x01234567, vacc5x3x01234567);
247 vacc6x2x01234567 = _mm256_add_epi32(vacc6x2x01234567, vacc6x3x01234567);
248 vacc0x0x01234567 = _mm256_add_epi32(vacc0x0x01234567, vacc0x2x01234567);
249 vacc1x0x01234567 = _mm256_add_epi32(vacc1x0x01234567, vacc1x2x01234567);
250 vacc2x0x01234567 = _mm256_add_epi32(vacc2x0x01234567, vacc2x2x01234567);
251 vacc3x0x01234567 = _mm256_add_epi32(vacc3x0x01234567, vacc3x2x01234567);
252 vacc4x0x01234567 = _mm256_add_epi32(vacc4x0x01234567, vacc4x2x01234567);
253 vacc5x0x01234567 = _mm256_add_epi32(vacc5x0x01234567, vacc5x2x01234567);
254 vacc6x0x01234567 = _mm256_add_epi32(vacc6x0x01234567, vacc6x2x01234567);
255 while (k != 0) {
256 __m256i va0x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a0));
257 a0 += 4;
258 __m256i va1x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a1));
259 a1 += 4;
260 __m256i va2x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a2));
261 a2 += 4;
262 __m256i va3x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a3));
263 a3 += 4;
264 __m256i va4x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a4));
265 a4 += 4;
266 __m256i va5x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a5));
267 a5 += 4;
268 __m256i va6x0123 = _mm256_set1_epi32((int) unaligned_load_u32(a6));
269 a6 += 4;
270
271 va0x0123 = _mm256_xor_si256(va0x0123, vsign_mask);
272 va1x0123 = _mm256_xor_si256(va1x0123, vsign_mask);
273 va2x0123 = _mm256_xor_si256(va2x0123, vsign_mask);
274 va3x0123 = _mm256_xor_si256(va3x0123, vsign_mask);
275 va4x0123 = _mm256_xor_si256(va4x0123, vsign_mask);
276 va5x0123 = _mm256_xor_si256(va5x0123, vsign_mask);
277 va6x0123 = _mm256_xor_si256(va6x0123, vsign_mask);
278
279 const __m256i vb01234567 = _mm256_load_si256(w);
280
281 vacc0x0x01234567 = _mm256_dpbusd_avx_epi32(vacc0x0x01234567, va0x0123, vb01234567);
282 vacc1x0x01234567 = _mm256_dpbusd_avx_epi32(vacc1x0x01234567, va1x0123, vb01234567);
283 vacc2x0x01234567 = _mm256_dpbusd_avx_epi32(vacc2x0x01234567, va2x0123, vb01234567);
284 vacc3x0x01234567 = _mm256_dpbusd_avx_epi32(vacc3x0x01234567, va3x0123, vb01234567);
285 vacc4x0x01234567 = _mm256_dpbusd_avx_epi32(vacc4x0x01234567, va4x0123, vb01234567);
286 vacc5x0x01234567 = _mm256_dpbusd_avx_epi32(vacc5x0x01234567, va5x0123, vb01234567);
287 vacc6x0x01234567 = _mm256_dpbusd_avx_epi32(vacc6x0x01234567, va6x0123, vb01234567);
288
289 w = (const int8_t*) w + 32;
290 k -= 4 * sizeof(int8_t);
291 }
292
293 __m256 vout0x01234567 = _mm256_cvtepi32_ps(vacc0x0x01234567);
294 __m256 vout1x01234567 = _mm256_cvtepi32_ps(vacc1x0x01234567);
295 __m256 vout2x01234567 = _mm256_cvtepi32_ps(vacc2x0x01234567);
296 __m256 vout3x01234567 = _mm256_cvtepi32_ps(vacc3x0x01234567);
297 __m256 vout4x01234567 = _mm256_cvtepi32_ps(vacc4x0x01234567);
298 __m256 vout5x01234567 = _mm256_cvtepi32_ps(vacc5x0x01234567);
299 __m256 vout6x01234567 = _mm256_cvtepi32_ps(vacc6x0x01234567);
300
301 vout0x01234567 = _mm256_mul_ps(vout0x01234567, _mm256_set1_ps(quantization_params[0].inv_scale));
302 vout1x01234567 = _mm256_mul_ps(vout1x01234567, _mm256_set1_ps(quantization_params[1].inv_scale));
303 vout2x01234567 = _mm256_mul_ps(vout2x01234567, _mm256_set1_ps(quantization_params[2].inv_scale));
304 vout3x01234567 = _mm256_mul_ps(vout3x01234567, _mm256_set1_ps(quantization_params[3].inv_scale));
305 vout4x01234567 = _mm256_mul_ps(vout4x01234567, _mm256_set1_ps(quantization_params[4].inv_scale));
306 vout5x01234567 = _mm256_mul_ps(vout5x01234567, _mm256_set1_ps(quantization_params[5].inv_scale));
307 vout6x01234567 = _mm256_mul_ps(vout6x01234567, _mm256_set1_ps(quantization_params[6].inv_scale));
308
309 const __m256 vfilter_output_scale01234567 = _mm256_load_ps((const float*) w);
310 const __m256 vbias01234567 = _mm256_load_ps((const float*) w + 8);
311 w = (const float*) w + 16;
312
313 vout0x01234567 = _mm256_fmadd_ps(vout0x01234567, vfilter_output_scale01234567, vbias01234567);
314 vout1x01234567 = _mm256_fmadd_ps(vout1x01234567, vfilter_output_scale01234567, vbias01234567);
315 vout2x01234567 = _mm256_fmadd_ps(vout2x01234567, vfilter_output_scale01234567, vbias01234567);
316 vout3x01234567 = _mm256_fmadd_ps(vout3x01234567, vfilter_output_scale01234567, vbias01234567);
317 vout4x01234567 = _mm256_fmadd_ps(vout4x01234567, vfilter_output_scale01234567, vbias01234567);
318 vout5x01234567 = _mm256_fmadd_ps(vout5x01234567, vfilter_output_scale01234567, vbias01234567);
319 vout6x01234567 = _mm256_fmadd_ps(vout6x01234567, vfilter_output_scale01234567, vbias01234567);
320
321 vout0x01234567 = _mm256_max_ps(vout0x01234567, voutput_min);
322 vout1x01234567 = _mm256_max_ps(vout1x01234567, voutput_min);
323 vout2x01234567 = _mm256_max_ps(vout2x01234567, voutput_min);
324 vout3x01234567 = _mm256_max_ps(vout3x01234567, voutput_min);
325 vout4x01234567 = _mm256_max_ps(vout4x01234567, voutput_min);
326 vout5x01234567 = _mm256_max_ps(vout5x01234567, voutput_min);
327 vout6x01234567 = _mm256_max_ps(vout6x01234567, voutput_min);
328
329 vout0x01234567 = _mm256_min_ps(vout0x01234567, voutput_max);
330 vout1x01234567 = _mm256_min_ps(vout1x01234567, voutput_max);
331 vout2x01234567 = _mm256_min_ps(vout2x01234567, voutput_max);
332 vout3x01234567 = _mm256_min_ps(vout3x01234567, voutput_max);
333 vout4x01234567 = _mm256_min_ps(vout4x01234567, voutput_max);
334 vout5x01234567 = _mm256_min_ps(vout5x01234567, voutput_max);
335 vout6x01234567 = _mm256_min_ps(vout6x01234567, voutput_max);
336
337 if XNN_LIKELY(nc >= 8) {
338 _mm256_storeu_ps(c0, vout0x01234567);
339 a0 = (const int8_t*) ((uintptr_t) a0 - kc);
340 c0 = (float*) ((uintptr_t) c0 + cn_stride);
341 _mm256_storeu_ps(c1, vout1x01234567);
342 a1 = (const int8_t*) ((uintptr_t) a1 - kc);
343 c1 = (float*) ((uintptr_t) c1 + cn_stride);
344 _mm256_storeu_ps(c2, vout2x01234567);
345 a2 = (const int8_t*) ((uintptr_t) a2 - kc);
346 c2 = (float*) ((uintptr_t) c2 + cn_stride);
347 _mm256_storeu_ps(c3, vout3x01234567);
348 a3 = (const int8_t*) ((uintptr_t) a3 - kc);
349 c3 = (float*) ((uintptr_t) c3 + cn_stride);
350 _mm256_storeu_ps(c4, vout4x01234567);
351 a4 = (const int8_t*) ((uintptr_t) a4 - kc);
352 c4 = (float*) ((uintptr_t) c4 + cn_stride);
353 _mm256_storeu_ps(c5, vout5x01234567);
354 a5 = (const int8_t*) ((uintptr_t) a5 - kc);
355 c5 = (float*) ((uintptr_t) c5 + cn_stride);
356 _mm256_storeu_ps(c6, vout6x01234567);
357 a6 = (const int8_t*) ((uintptr_t) a6 - kc);
358 c6 = (float*) ((uintptr_t) c6 + cn_stride);
359 nc -= 8;
360 } else {
361 __m128 vout0x0123 = _mm256_castps256_ps128(vout0x01234567);
362 __m128 vout1x0123 = _mm256_castps256_ps128(vout1x01234567);
363 __m128 vout2x0123 = _mm256_castps256_ps128(vout2x01234567);
364 __m128 vout3x0123 = _mm256_castps256_ps128(vout3x01234567);
365 __m128 vout4x0123 = _mm256_castps256_ps128(vout4x01234567);
366 __m128 vout5x0123 = _mm256_castps256_ps128(vout5x01234567);
367 __m128 vout6x0123 = _mm256_castps256_ps128(vout6x01234567);
368 if (nc & 4) {
369 _mm_storeu_ps(c0, vout0x0123);
370 c0 += 4;
371 _mm_storeu_ps(c1, vout1x0123);
372 c1 += 4;
373 _mm_storeu_ps(c2, vout2x0123);
374 c2 += 4;
375 _mm_storeu_ps(c3, vout3x0123);
376 c3 += 4;
377 _mm_storeu_ps(c4, vout4x0123);
378 c4 += 4;
379 _mm_storeu_ps(c5, vout5x0123);
380 c5 += 4;
381 _mm_storeu_ps(c6, vout6x0123);
382 c6 += 4;
383 vout0x0123 = _mm256_extractf128_ps(vout0x01234567, 1);
384 vout1x0123 = _mm256_extractf128_ps(vout1x01234567, 1);
385 vout2x0123 = _mm256_extractf128_ps(vout2x01234567, 1);
386 vout3x0123 = _mm256_extractf128_ps(vout3x01234567, 1);
387 vout4x0123 = _mm256_extractf128_ps(vout4x01234567, 1);
388 vout5x0123 = _mm256_extractf128_ps(vout5x01234567, 1);
389 vout6x0123 = _mm256_extractf128_ps(vout6x01234567, 1);
390 }
391 if (nc & 2) {
392 _mm_storel_pi((__m64*) c0, vout0x0123);
393 c0 += 2;
394 _mm_storel_pi((__m64*) c1, vout1x0123);
395 c1 += 2;
396 _mm_storel_pi((__m64*) c2, vout2x0123);
397 c2 += 2;
398 _mm_storel_pi((__m64*) c3, vout3x0123);
399 c3 += 2;
400 _mm_storel_pi((__m64*) c4, vout4x0123);
401 c4 += 2;
402 _mm_storel_pi((__m64*) c5, vout5x0123);
403 c5 += 2;
404 _mm_storel_pi((__m64*) c6, vout6x0123);
405 c6 += 2;
406 vout0x0123 = _mm_movehl_ps(vout0x0123, vout0x0123);
407 vout1x0123 = _mm_movehl_ps(vout1x0123, vout1x0123);
408 vout2x0123 = _mm_movehl_ps(vout2x0123, vout2x0123);
409 vout3x0123 = _mm_movehl_ps(vout3x0123, vout3x0123);
410 vout4x0123 = _mm_movehl_ps(vout4x0123, vout4x0123);
411 vout5x0123 = _mm_movehl_ps(vout5x0123, vout5x0123);
412 vout6x0123 = _mm_movehl_ps(vout6x0123, vout6x0123);
413 }
414 if (nc & 1) {
415 _mm_store_ss(c0, vout0x0123);
416 _mm_store_ss(c1, vout1x0123);
417 _mm_store_ss(c2, vout2x0123);
418 _mm_store_ss(c3, vout3x0123);
419 _mm_store_ss(c4, vout4x0123);
420 _mm_store_ss(c5, vout5x0123);
421 _mm_store_ss(c6, vout6x0123);
422 }
423 nc = 0;
424 }
425 } while (nc != 0);
426 }