1 // Auto-generated file. Do not edit!
2 // Template: src/qs8-f32-vcvt/avx512skx.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 <immintrin.h>
13
14 #include <xnnpack/common.h>
15 #include <xnnpack/intrinsics-polyfill.h>
16 #include <xnnpack/vcvt.h>
17
18
xnn_qs8_f32_vcvt_ukernel__avx512skx_x48(size_t n,const int8_t * x,float * y,const union xnn_qs8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS (1)])19 void xnn_qs8_f32_vcvt_ukernel__avx512skx_x48(
20 size_t n,
21 const int8_t* x,
22 float* y,
23 const union xnn_qs8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24 {
25 assert(n != 0);
26 assert(n % sizeof(int8_t) == 0);
27 assert(x != NULL);
28 assert(y != NULL);
29
30 const __m512i vminus_zero_point = _mm512_load_si512(params->avx512.minus_zero_point);
31 const __m512 vscale = _mm512_load_ps(params->avx512.scale);
32 for (; n >= 48 * sizeof(int8_t); n -= 48 * sizeof(int8_t)) {
33 __m512i vx0123456789ABCDEF = _mm512_cvtepi8_epi32(_mm_loadu_si128((const __m128i*) x));
34 __m512i vxGHIJKLMNOPQRSTUV = _mm512_cvtepi8_epi32(_mm_loadu_si128((const __m128i*) (x + 16)));
35 __m512i vxWXYZ = _mm512_cvtepi8_epi32(_mm_loadu_si128((const __m128i*) (x + 32)));
36 x += 48;
37
38 vx0123456789ABCDEF = _mm512_add_epi32(vx0123456789ABCDEF, vminus_zero_point);
39 vxGHIJKLMNOPQRSTUV = _mm512_add_epi32(vxGHIJKLMNOPQRSTUV, vminus_zero_point);
40 vxWXYZ = _mm512_add_epi32(vxWXYZ, vminus_zero_point);
41
42 __m512 vy0123456789ABCDEF = _mm512_cvtepi32_ps(vx0123456789ABCDEF);
43 __m512 vyGHIJKLMNOPQRSTUV = _mm512_cvtepi32_ps(vxGHIJKLMNOPQRSTUV);
44 __m512 vyWXYZ = _mm512_cvtepi32_ps(vxWXYZ);
45
46 vy0123456789ABCDEF = _mm512_mul_ps(vy0123456789ABCDEF, vscale);
47 vyGHIJKLMNOPQRSTUV = _mm512_mul_ps(vyGHIJKLMNOPQRSTUV, vscale);
48 vyWXYZ = _mm512_mul_ps(vyWXYZ, vscale);
49
50 _mm512_storeu_ps(y, vy0123456789ABCDEF);
51 _mm512_storeu_ps(y + 16, vyGHIJKLMNOPQRSTUV);
52 _mm512_storeu_ps(y + 32, vyWXYZ);
53 y += 48;
54 }
55 for (; n >= 16 * sizeof(int8_t); n -= 16 * sizeof(int8_t)) {
56 __m512i vx = _mm512_cvtepi8_epi32(_mm_loadu_si128((const __m128i*) x));
57 vx = _mm512_add_epi32(vx, vminus_zero_point);
58 x += 16;
59
60 __m512 vy = _mm512_cvtepi32_ps(vx);
61 vy = _mm512_mul_ps(vy, vscale);
62
63 _mm512_storeu_ps(y, vy);
64 y += 16;
65 }
66 if XNN_UNLIKELY(n != 0) {
67 assert(n >= 1 * sizeof(int8_t));
68 assert(n <= 15 * sizeof(int8_t));
69
70 // Prepare mask for valid elements (depends on n).
71 const __mmask16 vmask = _cvtu32_mask16((uint16_t) ((uint32_t) (UINT32_C(1) << n) - UINT32_C(1)));
72
73 __m512i vx = _mm512_cvtepi8_epi32(_mm_maskz_loadu_epi8(vmask, x));
74 vx = _mm512_add_epi32(vx, vminus_zero_point);
75
76 __m512 vy = _mm512_cvtepi32_ps(vx);
77 vy = _mm512_mul_ps(vy, vscale);
78
79 _mm512_mask_storeu_ps(y, vmask, vy);
80 }
81 }
82