| 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 |
|
| 19 |
void xnn_qu8_f32_vcvt_ukernel__avx512skx_u48( |
| 20 |
size_t batch, |
| 21 |
const uint8_t* input, |
| 22 |
float* output, |
| 23 |
const struct xnn_qu8_f32_cvt_params params[restrict XNN_MIN_ELEMENTS(1)]) XNN_OOB_READS |
| 24 |
{ |
| 25 |
assert(batch != 0); |
| 26 |
assert(batch % sizeof(uint8_t) == 0); |
| 27 |
assert(input != NULL); |
| 28 |
assert(output != NULL); |
| 29 |
|
| 30 |
const __m512i vzero_point = _mm512_set1_epi32(params->scalar.zero_point); |
| 31 |
const __m512 vscale = _mm512_set1_ps(params->scalar.scale); |
| 32 |
XNN_FORCE_REALIZATION(vzero_point); |
| 33 |
XNN_FORCE_REALIZATION(vscale); |
| 34 |
for (; batch >= 48 * sizeof(uint8_t); batch -= 48 * sizeof(uint8_t)) { |
| 35 |
__m512i vx0123456789ABCDEF = _mm512_cvtepu8_epi32(_mm_loadu_si128((const __m128i*) input)); |
| 36 |
__m512i vxGHIJKLMNOPQRSTUV = _mm512_cvtepu8_epi32(_mm_loadu_si128((const __m128i*) (input + 16))); |
| 37 |
__m512i vxWXYZ = _mm512_cvtepu8_epi32(_mm_loadu_si128((const __m128i*) (input + 32))); |
| 38 |
input += 48; |
| 39 |
|
| 40 |
vx0123456789ABCDEF = _mm512_sub_epi32(vx0123456789ABCDEF, vzero_point); |
| 41 |
vxGHIJKLMNOPQRSTUV = _mm512_sub_epi32(vxGHIJKLMNOPQRSTUV, vzero_point); |
| 42 |
vxWXYZ = _mm512_sub_epi32(vxWXYZ, vzero_point); |
| 43 |
|
| 44 |
__m512 vy0123456789ABCDEF = _mm512_cvtepi32_ps(vx0123456789ABCDEF); |
| 45 |
__m512 vyGHIJKLMNOPQRSTUV = _mm512_cvtepi32_ps(vxGHIJKLMNOPQRSTUV); |
| 46 |
__m512 vyWXYZ = _mm512_cvtepi32_ps(vxWXYZ); |
| 47 |
|
| 48 |
vy0123456789ABCDEF = _mm512_mul_ps(vy0123456789ABCDEF, vscale); |
| 49 |
vyGHIJKLMNOPQRSTUV = _mm512_mul_ps(vyGHIJKLMNOPQRSTUV, vscale); |
| 50 |
vyWXYZ = _mm512_mul_ps(vyWXYZ, vscale); |
| 51 |
|
| 52 |
_mm512_storeu_ps(output, vy0123456789ABCDEF); |
| 53 |
_mm512_storeu_ps(output + 16, vyGHIJKLMNOPQRSTUV); |
| 54 |
_mm512_storeu_ps(output + 32, vyWXYZ); |
| 55 |
output += 48; |
| 56 |
} |
| 57 |
for (; batch >= 16 * sizeof(uint8_t); batch -= 16 * sizeof(uint8_t)) { |
| 58 |
__m512i vx = _mm512_cvtepu8_epi32(_mm_loadu_si128((const __m128i*) input)); |
| 59 |
vx = _mm512_sub_epi32(vx, vzero_point); |
| 60 |
input += 16; |
| 61 |
|
| 62 |
__m512 vy = _mm512_cvtepi32_ps(vx); |
| 63 |
vy = _mm512_mul_ps(vy, vscale); |
| 64 |
|
| 65 |
_mm512_storeu_ps(output, vy); |
| 66 |
output += 16; |
| 67 |
} |
| 68 |
if XNN_UNLIKELY(batch != 0) { |
| 69 |
assert(batch >= 1 * sizeof(uint8_t)); |
| 70 |
assert(batch <= 15 * sizeof(uint8_t)); |
| 71 |
|
| 72 |
// Prepare mask for valid elements (depends on batch). |
| 73 |
const __mmask16 vmask = _cvtu32_mask16((uint32_t) ((UINT32_C(1) << batch) - UINT32_C(1))); |
| 74 |
|
| 75 |
__m512i vx = _mm512_cvtepu8_epi32(_mm_maskz_loadu_epi8(vmask, input)); |
| 76 |
vx = _mm512_sub_epi32(vx, vzero_point); |
| 77 |
|
| 78 |
__m512 vy = _mm512_cvtepi32_ps(vx); |
| 79 |
vy = _mm512_mul_ps(vy, vscale); |
| 80 |
|
| 81 |
_mm512_mask_storeu_ps(output, vmask, vy); |
| 82 |
} |
| 83 |
} |