• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_qu8_f32_vcvt_ukernel__avx512skx_x16(size_t n,const uint8_t * x,float * y,const union xnn_qu8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS (1)])19 void xnn_qu8_f32_vcvt_ukernel__avx512skx_x16(
20     size_t n,
21     const uint8_t* x,
22     float* y,
23     const union xnn_qu8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS
24 {
25   assert(n != 0);
26   assert(n % sizeof(uint8_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 >= 16 * sizeof(uint8_t); n -= 16 * sizeof(uint8_t)) {
33     __m512i vx = _mm512_cvtepu8_epi32(_mm_loadu_si128((const __m128i*) x));
34     vx = _mm512_add_epi32(vx, vminus_zero_point);
35     x += 16;
36 
37     __m512 vy = _mm512_cvtepi32_ps(vx);
38     vy = _mm512_mul_ps(vy, vscale);
39 
40     _mm512_storeu_ps(y, vy);
41     y += 16;
42   }
43   if XNN_UNLIKELY(n != 0) {
44     assert(n >= 1 * sizeof(uint8_t));
45     assert(n <= 15 * sizeof(uint8_t));
46 
47     // Prepare mask for valid elements (depends on n).
48     const __mmask16 vmask = _cvtu32_mask16((uint16_t) ((uint32_t) (UINT32_C(1) << n) - UINT32_C(1)));
49 
50     __m512i vx = _mm512_cvtepu8_epi32(_mm_maskz_loadu_epi8(vmask, x));
51     vx = _mm512_add_epi32(vx, vminus_zero_point);
52 
53     __m512 vy = _mm512_cvtepi32_ps(vx);
54     vy = _mm512_mul_ps(vy, vscale);
55 
56     _mm512_mask_storeu_ps(y, vmask, vy);
57   }
58 }
59