1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-dwconv/unipass-wasmsimd-mul16.c.in
3 // Generator: tools/xngen
4 //
5 // Copyright 2020 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 <wasm_simd128.h>
13
14 #include <xnnpack/dwconv.h>
15
16
xnn_qs8_dwconv_minmax_fp32_ukernel_up8x25__wasmsimd_mul16(size_t channels,size_t output_width,const int8_t ** input,const void * weights,int8_t * output,size_t input_stride,size_t output_increment,size_t input_offset,const int8_t * zero,const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS (1)])17 void xnn_qs8_dwconv_minmax_fp32_ukernel_up8x25__wasmsimd_mul16(
18 size_t channels,
19 size_t output_width,
20 const int8_t** input,
21 const void* weights,
22 int8_t* output,
23 size_t input_stride,
24 size_t output_increment,
25 size_t input_offset,
26 const int8_t* zero,
27 const union xnn_qs8_conv_minmax_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
28 {
29 assert(channels != 0);
30 assert(output_width != 0);
31
32 do {
33 const int8_t* i0 = input[0];
34 assert(i0 != NULL);
35 if XNN_UNPREDICTABLE(i0 != zero) {
36 i0 = (const int8_t*) ((uintptr_t) i0 + input_offset);
37 }
38 const int8_t* i1 = input[1];
39 assert(i1 != NULL);
40 if XNN_UNPREDICTABLE(i1 != zero) {
41 i1 = (const int8_t*) ((uintptr_t) i1 + input_offset);
42 }
43 const int8_t* i2 = input[2];
44 assert(i2 != NULL);
45 if XNN_UNPREDICTABLE(i2 != zero) {
46 i2 = (const int8_t*) ((uintptr_t) i2 + input_offset);
47 }
48 const int8_t* i3 = input[3];
49 assert(i3 != NULL);
50 if XNN_UNPREDICTABLE(i3 != zero) {
51 i3 = (const int8_t*) ((uintptr_t) i3 + input_offset);
52 }
53 const int8_t* i4 = input[4];
54 assert(i4 != NULL);
55 if XNN_UNPREDICTABLE(i4 != zero) {
56 i4 = (const int8_t*) ((uintptr_t) i4 + input_offset);
57 }
58 const int8_t* i5 = input[5];
59 assert(i5 != NULL);
60 if XNN_UNPREDICTABLE(i5 != zero) {
61 i5 = (const int8_t*) ((uintptr_t) i5 + input_offset);
62 }
63 const int8_t* i6 = input[6];
64 assert(i6 != NULL);
65 if XNN_UNPREDICTABLE(i6 != zero) {
66 i6 = (const int8_t*) ((uintptr_t) i6 + input_offset);
67 }
68 const int8_t* i7 = input[7];
69 assert(i7 != NULL);
70 if XNN_UNPREDICTABLE(i7 != zero) {
71 i7 = (const int8_t*) ((uintptr_t) i7 + input_offset);
72 }
73 const int8_t* i8 = input[8];
74 assert(i8 != NULL);
75 if XNN_UNPREDICTABLE(i8 != zero) {
76 i8 = (const int8_t*) ((uintptr_t) i8 + input_offset);
77 }
78 const int8_t* i9 = input[9];
79 assert(i9 != NULL);
80 if XNN_UNPREDICTABLE(i9 != zero) {
81 i9 = (const int8_t*) ((uintptr_t) i9 + input_offset);
82 }
83 const int8_t* i10 = input[10];
84 assert(i10 != NULL);
85 if XNN_UNPREDICTABLE(i10 != zero) {
86 i10 = (const int8_t*) ((uintptr_t) i10 + input_offset);
87 }
88 const int8_t* i11 = input[11];
89 assert(i11 != NULL);
90 if XNN_UNPREDICTABLE(i11 != zero) {
91 i11 = (const int8_t*) ((uintptr_t) i11 + input_offset);
92 }
93 const int8_t* i12 = input[12];
94 assert(i12 != NULL);
95 if XNN_UNPREDICTABLE(i12 != zero) {
96 i12 = (const int8_t*) ((uintptr_t) i12 + input_offset);
97 }
98 const int8_t* i13 = input[13];
99 assert(i13 != NULL);
100 if XNN_UNPREDICTABLE(i13 != zero) {
101 i13 = (const int8_t*) ((uintptr_t) i13 + input_offset);
102 }
103 const int8_t* i14 = input[14];
104 assert(i14 != NULL);
105 if XNN_UNPREDICTABLE(i14 != zero) {
106 i14 = (const int8_t*) ((uintptr_t) i14 + input_offset);
107 }
108 const int8_t* i15 = input[15];
109 assert(i15 != NULL);
110 if XNN_UNPREDICTABLE(i15 != zero) {
111 i15 = (const int8_t*) ((uintptr_t) i15 + input_offset);
112 }
113 const int8_t* i16 = input[16];
114 assert(i16 != NULL);
115 if XNN_UNPREDICTABLE(i16 != zero) {
116 i16 = (const int8_t*) ((uintptr_t) i16 + input_offset);
117 }
118 const int8_t* i17 = input[17];
119 assert(i17 != NULL);
120 if XNN_UNPREDICTABLE(i17 != zero) {
121 i17 = (const int8_t*) ((uintptr_t) i17 + input_offset);
122 }
123 const int8_t* i18 = input[18];
124 assert(i18 != NULL);
125 if XNN_UNPREDICTABLE(i18 != zero) {
126 i18 = (const int8_t*) ((uintptr_t) i18 + input_offset);
127 }
128 const int8_t* i19 = input[19];
129 assert(i19 != NULL);
130 if XNN_UNPREDICTABLE(i19 != zero) {
131 i19 = (const int8_t*) ((uintptr_t) i19 + input_offset);
132 }
133 const int8_t* i20 = input[20];
134 assert(i20 != NULL);
135 if XNN_UNPREDICTABLE(i20 != zero) {
136 i20 = (const int8_t*) ((uintptr_t) i20 + input_offset);
137 }
138 const int8_t* i21 = input[21];
139 assert(i21 != NULL);
140 if XNN_UNPREDICTABLE(i21 != zero) {
141 i21 = (const int8_t*) ((uintptr_t) i21 + input_offset);
142 }
143 const int8_t* i22 = input[22];
144 assert(i22 != NULL);
145 if XNN_UNPREDICTABLE(i22 != zero) {
146 i22 = (const int8_t*) ((uintptr_t) i22 + input_offset);
147 }
148 const int8_t* i23 = input[23];
149 assert(i23 != NULL);
150 if XNN_UNPREDICTABLE(i23 != zero) {
151 i23 = (const int8_t*) ((uintptr_t) i23 + input_offset);
152 }
153 const int8_t* i24 = input[24];
154 assert(i24 != NULL);
155 if XNN_UNPREDICTABLE(i24 != zero) {
156 i24 = (const int8_t*) ((uintptr_t) i24 + input_offset);
157 }
158 input = (const int8_t**) ((uintptr_t) input + input_stride);
159
160 size_t c = channels;
161 const void* w = weights;
162 for (; c >= 8; c -= 8) {
163 v128_t vacc0123 = wasm_v128_load(w);
164 v128_t vacc4567 = wasm_v128_load((const void*) ((uintptr_t) w + 4 * sizeof(int32_t)));
165
166
167 const v128_t vi0x01234567 = wasm_i16x8_load8x8(i0);
168 const v128_t vk0x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 0 * sizeof(int8_t)));
169 i0 += 8;
170
171 v128_t vprod01234567 = wasm_i16x8_mul(vi0x01234567, vk0x01234567);
172
173 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
174 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
175
176 const v128_t vi1x01234567 = wasm_i16x8_load8x8(i1);
177 const v128_t vk1x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 8 * sizeof(int8_t)));
178 i1 += 8;
179
180 vprod01234567 = wasm_i16x8_mul(vi1x01234567, vk1x01234567);
181
182 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
183 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
184
185 const v128_t vi2x01234567 = wasm_i16x8_load8x8(i2);
186 const v128_t vk2x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 16 * sizeof(int8_t)));
187 i2 += 8;
188
189 vprod01234567 = wasm_i16x8_mul(vi2x01234567, vk2x01234567);
190
191 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
192 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
193
194 const v128_t vi3x01234567 = wasm_i16x8_load8x8(i3);
195 const v128_t vk3x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 24 * sizeof(int8_t)));
196 i3 += 8;
197
198 vprod01234567 = wasm_i16x8_mul(vi3x01234567, vk3x01234567);
199
200 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
201 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
202
203 const v128_t vi4x01234567 = wasm_i16x8_load8x8(i4);
204 const v128_t vk4x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 32 * sizeof(int8_t)));
205 i4 += 8;
206
207 vprod01234567 = wasm_i16x8_mul(vi4x01234567, vk4x01234567);
208
209 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
210 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
211
212 const v128_t vi5x01234567 = wasm_i16x8_load8x8(i5);
213 const v128_t vk5x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 40 * sizeof(int8_t)));
214 i5 += 8;
215
216 vprod01234567 = wasm_i16x8_mul(vi5x01234567, vk5x01234567);
217
218 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
219 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
220
221 const v128_t vi6x01234567 = wasm_i16x8_load8x8(i6);
222 const v128_t vk6x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 48 * sizeof(int8_t)));
223 i6 += 8;
224
225 vprod01234567 = wasm_i16x8_mul(vi6x01234567, vk6x01234567);
226
227 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
228 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
229
230 const v128_t vi7x01234567 = wasm_i16x8_load8x8(i7);
231 const v128_t vk7x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 56 * sizeof(int8_t)));
232 i7 += 8;
233
234 vprod01234567 = wasm_i16x8_mul(vi7x01234567, vk7x01234567);
235
236 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
237 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
238
239 const v128_t vi8x01234567 = wasm_i16x8_load8x8(i8);
240 const v128_t vk8x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 64 * sizeof(int8_t)));
241 i8 += 8;
242
243 vprod01234567 = wasm_i16x8_mul(vi8x01234567, vk8x01234567);
244
245 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
246 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
247
248 const v128_t vi9x01234567 = wasm_i16x8_load8x8(i9);
249 const v128_t vk9x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 72 * sizeof(int8_t)));
250 i9 += 8;
251
252 vprod01234567 = wasm_i16x8_mul(vi9x01234567, vk9x01234567);
253
254 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
255 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
256
257 const v128_t vi10x01234567 = wasm_i16x8_load8x8(i10);
258 const v128_t vk10x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 80 * sizeof(int8_t)));
259 i10 += 8;
260
261 vprod01234567 = wasm_i16x8_mul(vi10x01234567, vk10x01234567);
262
263 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
264 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
265
266 const v128_t vi11x01234567 = wasm_i16x8_load8x8(i11);
267 const v128_t vk11x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 88 * sizeof(int8_t)));
268 i11 += 8;
269
270 vprod01234567 = wasm_i16x8_mul(vi11x01234567, vk11x01234567);
271
272 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
273 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
274
275 const v128_t vi12x01234567 = wasm_i16x8_load8x8(i12);
276 const v128_t vk12x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 96 * sizeof(int8_t)));
277 i12 += 8;
278
279 vprod01234567 = wasm_i16x8_mul(vi12x01234567, vk12x01234567);
280
281 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
282 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
283
284 const v128_t vi13x01234567 = wasm_i16x8_load8x8(i13);
285 const v128_t vk13x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 104 * sizeof(int8_t)));
286 i13 += 8;
287
288 vprod01234567 = wasm_i16x8_mul(vi13x01234567, vk13x01234567);
289
290 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
291 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
292
293 const v128_t vi14x01234567 = wasm_i16x8_load8x8(i14);
294 const v128_t vk14x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 112 * sizeof(int8_t)));
295 i14 += 8;
296
297 vprod01234567 = wasm_i16x8_mul(vi14x01234567, vk14x01234567);
298
299 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
300 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
301
302 const v128_t vi15x01234567 = wasm_i16x8_load8x8(i15);
303 const v128_t vk15x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 120 * sizeof(int8_t)));
304 i15 += 8;
305
306 vprod01234567 = wasm_i16x8_mul(vi15x01234567, vk15x01234567);
307
308 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
309 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
310
311 const v128_t vi16x01234567 = wasm_i16x8_load8x8(i16);
312 const v128_t vk16x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 128 * sizeof(int8_t)));
313 i16 += 8;
314
315 vprod01234567 = wasm_i16x8_mul(vi16x01234567, vk16x01234567);
316
317 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
318 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
319
320 const v128_t vi17x01234567 = wasm_i16x8_load8x8(i17);
321 const v128_t vk17x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 136 * sizeof(int8_t)));
322 i17 += 8;
323
324 vprod01234567 = wasm_i16x8_mul(vi17x01234567, vk17x01234567);
325
326 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
327 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
328
329 const v128_t vi18x01234567 = wasm_i16x8_load8x8(i18);
330 const v128_t vk18x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 144 * sizeof(int8_t)));
331 i18 += 8;
332
333 vprod01234567 = wasm_i16x8_mul(vi18x01234567, vk18x01234567);
334
335 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
336 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
337
338 const v128_t vi19x01234567 = wasm_i16x8_load8x8(i19);
339 const v128_t vk19x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 152 * sizeof(int8_t)));
340 i19 += 8;
341
342 vprod01234567 = wasm_i16x8_mul(vi19x01234567, vk19x01234567);
343
344 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
345 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
346
347 const v128_t vi20x01234567 = wasm_i16x8_load8x8(i20);
348 const v128_t vk20x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 160 * sizeof(int8_t)));
349 i20 += 8;
350
351 vprod01234567 = wasm_i16x8_mul(vi20x01234567, vk20x01234567);
352
353 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
354 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
355
356 const v128_t vi21x01234567 = wasm_i16x8_load8x8(i21);
357 const v128_t vk21x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 168 * sizeof(int8_t)));
358 i21 += 8;
359
360 vprod01234567 = wasm_i16x8_mul(vi21x01234567, vk21x01234567);
361
362 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
363 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
364
365 const v128_t vi22x01234567 = wasm_i16x8_load8x8(i22);
366 const v128_t vk22x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 176 * sizeof(int8_t)));
367 i22 += 8;
368
369 vprod01234567 = wasm_i16x8_mul(vi22x01234567, vk22x01234567);
370
371 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
372 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
373
374 const v128_t vi23x01234567 = wasm_i16x8_load8x8(i23);
375 const v128_t vk23x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 184 * sizeof(int8_t)));
376 i23 += 8;
377
378 vprod01234567 = wasm_i16x8_mul(vi23x01234567, vk23x01234567);
379
380 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
381 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
382
383 const v128_t vi24x01234567 = wasm_i16x8_load8x8(i24);
384 const v128_t vk24x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 192 * sizeof(int8_t)));
385 i24 += 8;
386
387 vprod01234567 = wasm_i16x8_mul(vi24x01234567, vk24x01234567);
388
389 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
390 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
391
392
393 w = (const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 200 * sizeof(int8_t));
394
395 vacc0123 = wasm_f32x4_convert_i32x4(vacc0123);
396 vacc4567 = wasm_f32x4_convert_i32x4(vacc4567);
397
398 const v128_t vscale = wasm_v128_load64_splat(params->fp32_wasmsimd.scale);
399 vacc0123 = wasm_f32x4_mul(vacc0123, vscale);
400 vacc4567 = wasm_f32x4_mul(vacc4567, vscale);
401
402 const v128_t vmagic_bias = wasm_v128_load64_splat(params->fp32_wasmsimd.magic_bias);
403 vacc0123 = wasm_f32x4_add(vacc0123, vmagic_bias);
404 vacc4567 = wasm_f32x4_add(vacc4567, vmagic_bias);
405
406 const v128_t vmagic_min = wasm_v128_load64_splat(params->fp32_wasmsimd.magic_min);
407 vacc0123 = wasm_i32x4_max(vacc0123, vmagic_min);
408 vacc4567 = wasm_i32x4_max(vacc4567, vmagic_min);
409
410 const v128_t vmagic_bias_less_output_zero_point = wasm_v128_load64_splat(params->fp32_wasmsimd.magic_bias_less_output_zero_point);
411 vacc0123 = wasm_i32x4_sub(vacc0123, vmagic_bias_less_output_zero_point);
412 vacc4567 = wasm_i32x4_sub(vacc4567, vmagic_bias_less_output_zero_point);
413
414 v128_t vout01234567 = wasm_i16x8_narrow_i32x4(vacc0123, vacc4567);
415
416 v128_t vout0123456701234567 = wasm_i8x16_narrow_i16x8(vout01234567, vout01234567);
417
418 const v128_t voutput_max = wasm_v128_load64_splat(params->fp32_wasmsimd.output_max);
419 vout0123456701234567 = wasm_i8x16_min(vout0123456701234567, voutput_max);
420
421 *((double*) output) = wasm_f64x2_extract_lane(vout0123456701234567, 0);
422 output += 8;
423 }
424 if XNN_UNLIKELY(c != 0) {
425 {
426 v128_t vacc0123 = wasm_v128_load(w);
427 v128_t vacc4567 = wasm_v128_load((const void*) ((uintptr_t) w + 4 * sizeof(int32_t)));
428
429
430 const v128_t vi0x01234567 = wasm_i16x8_load8x8(i0);
431 const v128_t vk0x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 0 * sizeof(int8_t)));
432
433 v128_t vprod01234567 = wasm_i16x8_mul(vi0x01234567, vk0x01234567);
434
435 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
436 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
437
438 const v128_t vi1x01234567 = wasm_i16x8_load8x8(i1);
439 const v128_t vk1x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 8 * sizeof(int8_t)));
440
441 vprod01234567 = wasm_i16x8_mul(vi1x01234567, vk1x01234567);
442
443 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
444 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
445
446 const v128_t vi2x01234567 = wasm_i16x8_load8x8(i2);
447 const v128_t vk2x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 16 * sizeof(int8_t)));
448
449 vprod01234567 = wasm_i16x8_mul(vi2x01234567, vk2x01234567);
450
451 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
452 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
453
454 const v128_t vi3x01234567 = wasm_i16x8_load8x8(i3);
455 const v128_t vk3x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 24 * sizeof(int8_t)));
456
457 vprod01234567 = wasm_i16x8_mul(vi3x01234567, vk3x01234567);
458
459 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
460 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
461
462 const v128_t vi4x01234567 = wasm_i16x8_load8x8(i4);
463 const v128_t vk4x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 32 * sizeof(int8_t)));
464
465 vprod01234567 = wasm_i16x8_mul(vi4x01234567, vk4x01234567);
466
467 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
468 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
469
470 const v128_t vi5x01234567 = wasm_i16x8_load8x8(i5);
471 const v128_t vk5x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 40 * sizeof(int8_t)));
472
473 vprod01234567 = wasm_i16x8_mul(vi5x01234567, vk5x01234567);
474
475 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
476 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
477
478 const v128_t vi6x01234567 = wasm_i16x8_load8x8(i6);
479 const v128_t vk6x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 48 * sizeof(int8_t)));
480
481 vprod01234567 = wasm_i16x8_mul(vi6x01234567, vk6x01234567);
482
483 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
484 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
485
486 const v128_t vi7x01234567 = wasm_i16x8_load8x8(i7);
487 const v128_t vk7x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 56 * sizeof(int8_t)));
488
489 vprod01234567 = wasm_i16x8_mul(vi7x01234567, vk7x01234567);
490
491 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
492 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
493
494 const v128_t vi8x01234567 = wasm_i16x8_load8x8(i8);
495 const v128_t vk8x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 64 * sizeof(int8_t)));
496
497 vprod01234567 = wasm_i16x8_mul(vi8x01234567, vk8x01234567);
498
499 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
500 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
501
502 const v128_t vi9x01234567 = wasm_i16x8_load8x8(i9);
503 const v128_t vk9x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 72 * sizeof(int8_t)));
504
505 vprod01234567 = wasm_i16x8_mul(vi9x01234567, vk9x01234567);
506
507 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
508 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
509
510 const v128_t vi10x01234567 = wasm_i16x8_load8x8(i10);
511 const v128_t vk10x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 80 * sizeof(int8_t)));
512
513 vprod01234567 = wasm_i16x8_mul(vi10x01234567, vk10x01234567);
514
515 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
516 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
517
518 const v128_t vi11x01234567 = wasm_i16x8_load8x8(i11);
519 const v128_t vk11x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 88 * sizeof(int8_t)));
520
521 vprod01234567 = wasm_i16x8_mul(vi11x01234567, vk11x01234567);
522
523 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
524 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
525
526 const v128_t vi12x01234567 = wasm_i16x8_load8x8(i12);
527 const v128_t vk12x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 96 * sizeof(int8_t)));
528
529 vprod01234567 = wasm_i16x8_mul(vi12x01234567, vk12x01234567);
530
531 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
532 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
533
534 const v128_t vi13x01234567 = wasm_i16x8_load8x8(i13);
535 const v128_t vk13x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 104 * sizeof(int8_t)));
536
537 vprod01234567 = wasm_i16x8_mul(vi13x01234567, vk13x01234567);
538
539 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
540 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
541
542 const v128_t vi14x01234567 = wasm_i16x8_load8x8(i14);
543 const v128_t vk14x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 112 * sizeof(int8_t)));
544
545 vprod01234567 = wasm_i16x8_mul(vi14x01234567, vk14x01234567);
546
547 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
548 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
549
550 const v128_t vi15x01234567 = wasm_i16x8_load8x8(i15);
551 const v128_t vk15x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 120 * sizeof(int8_t)));
552
553 vprod01234567 = wasm_i16x8_mul(vi15x01234567, vk15x01234567);
554
555 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
556 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
557
558 const v128_t vi16x01234567 = wasm_i16x8_load8x8(i16);
559 const v128_t vk16x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 128 * sizeof(int8_t)));
560
561 vprod01234567 = wasm_i16x8_mul(vi16x01234567, vk16x01234567);
562
563 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
564 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
565
566 const v128_t vi17x01234567 = wasm_i16x8_load8x8(i17);
567 const v128_t vk17x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 136 * sizeof(int8_t)));
568
569 vprod01234567 = wasm_i16x8_mul(vi17x01234567, vk17x01234567);
570
571 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
572 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
573
574 const v128_t vi18x01234567 = wasm_i16x8_load8x8(i18);
575 const v128_t vk18x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 144 * sizeof(int8_t)));
576
577 vprod01234567 = wasm_i16x8_mul(vi18x01234567, vk18x01234567);
578
579 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
580 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
581
582 const v128_t vi19x01234567 = wasm_i16x8_load8x8(i19);
583 const v128_t vk19x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 152 * sizeof(int8_t)));
584
585 vprod01234567 = wasm_i16x8_mul(vi19x01234567, vk19x01234567);
586
587 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
588 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
589
590 const v128_t vi20x01234567 = wasm_i16x8_load8x8(i20);
591 const v128_t vk20x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 160 * sizeof(int8_t)));
592
593 vprod01234567 = wasm_i16x8_mul(vi20x01234567, vk20x01234567);
594
595 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
596 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
597
598 const v128_t vi21x01234567 = wasm_i16x8_load8x8(i21);
599 const v128_t vk21x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 168 * sizeof(int8_t)));
600
601 vprod01234567 = wasm_i16x8_mul(vi21x01234567, vk21x01234567);
602
603 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
604 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
605
606 const v128_t vi22x01234567 = wasm_i16x8_load8x8(i22);
607 const v128_t vk22x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 176 * sizeof(int8_t)));
608
609 vprod01234567 = wasm_i16x8_mul(vi22x01234567, vk22x01234567);
610
611 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
612 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
613
614 const v128_t vi23x01234567 = wasm_i16x8_load8x8(i23);
615 const v128_t vk23x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 184 * sizeof(int8_t)));
616
617 vprod01234567 = wasm_i16x8_mul(vi23x01234567, vk23x01234567);
618
619 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
620 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
621
622 const v128_t vi24x01234567 = wasm_i16x8_load8x8(i24);
623 const v128_t vk24x01234567 = wasm_i16x8_load8x8((const void*) ((uintptr_t) w + 8 * sizeof(int32_t) + 192 * sizeof(int8_t)));
624
625 vprod01234567 = wasm_i16x8_mul(vi24x01234567, vk24x01234567);
626
627 vacc0123 = wasm_i32x4_add(vacc0123, wasm_i32x4_extend_low_i16x8(vprod01234567));
628 vacc4567 = wasm_i32x4_add(vacc4567, wasm_i32x4_extend_high_i16x8(vprod01234567));
629
630
631
632 vacc0123 = wasm_f32x4_convert_i32x4(vacc0123);
633 vacc4567 = wasm_f32x4_convert_i32x4(vacc4567);
634
635 const v128_t vscale = wasm_v128_load64_splat(params->fp32_wasmsimd.scale);
636 vacc0123 = wasm_f32x4_mul(vacc0123, vscale);
637 vacc4567 = wasm_f32x4_mul(vacc4567, vscale);
638
639 const v128_t vmagic_bias = wasm_v128_load64_splat(params->fp32_wasmsimd.magic_bias);
640 vacc0123 = wasm_f32x4_add(vacc0123, vmagic_bias);
641 vacc4567 = wasm_f32x4_add(vacc4567, vmagic_bias);
642
643 const v128_t vmagic_min = wasm_v128_load64_splat(params->fp32_wasmsimd.magic_min);
644 vacc0123 = wasm_i32x4_max(vacc0123, vmagic_min);
645 vacc4567 = wasm_i32x4_max(vacc4567, vmagic_min);
646
647 const v128_t vmagic_bias_less_output_zero_point = wasm_v128_load64_splat(params->fp32_wasmsimd.magic_bias_less_output_zero_point);
648 vacc0123 = wasm_i32x4_sub(vacc0123, vmagic_bias_less_output_zero_point);
649 vacc4567 = wasm_i32x4_sub(vacc4567, vmagic_bias_less_output_zero_point);
650
651 v128_t vout01234567 = wasm_i16x8_narrow_i32x4(vacc0123, vacc4567);
652 v128_t vout0123456701234567 = wasm_i8x16_narrow_i16x8(vout01234567, vout01234567);
653
654 const v128_t voutput_max = wasm_v128_load64_splat(params->fp32_wasmsimd.output_max);
655 vout0123456701234567 = wasm_i8x16_min(vout0123456701234567, voutput_max);
656
657
658 if (c & 4) {
659 *((float*) output) = wasm_f32x4_extract_lane(vout0123456701234567, 0);
660 vout0123456701234567 = wasm_u64x2_shr(vout0123456701234567, 32);
661 output += 4;
662 }
663 uint32_t vout0123 = wasm_i32x4_extract_lane(vout0123456701234567, 0);
664 if (c & 2) {
665 *((uint16_t*) output) = (uint16_t) vout0123;
666 vout0123 >>= 16;
667 output += 2;
668 }
669 if (c & 1) {
670 *output = (int8_t) vout0123;
671 output += 1;
672 }
673 }
674 }
675
676 output = (int8_t*) ((uintptr_t) output + output_increment);
677 } while (--output_width != 0);
678 }
679