| 1 |
// Auto-generated file. Do not edit! |
| 2 |
// Template: src/f16-f32-vcvt/f16c.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/vcvt.h" |
| 16 |
|
| 17 |
|
| 18 |
void xnn_f16_f32_vcvt_ukernel__f16c_u16( |
| 19 |
size_t batch, |
| 20 |
const xnn_float16* input, |
| 21 |
float* output, |
| 22 |
const void* params) XNN_OOB_READS |
| 23 |
{ |
| 24 |
assert(batch != 0); |
| 25 |
assert(batch % sizeof(uint16_t) == 0); |
| 26 |
assert(input != NULL); |
| 27 |
assert(output != NULL); |
| 28 |
|
| 29 |
const uint16_t* i = (const uint16_t*) input; |
| 30 |
for (; batch >= 16 * sizeof(uint16_t); batch -= 16 * sizeof(uint16_t)) { |
| 31 |
const __m256 vacc0 = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i)); |
| 32 |
const __m256 vacc1 = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) (i + 8))); |
| 33 |
i += 16; |
| 34 |
|
| 35 |
_mm256_storeu_ps(output, vacc0); |
| 36 |
_mm256_storeu_ps(output + 8, vacc1); |
| 37 |
output += 16; |
| 38 |
} |
| 39 |
for (; batch >= 8 * sizeof(uint16_t); batch -= 8 * sizeof(uint16_t)) { |
| 40 |
const __m256 vacc = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i)); |
| 41 |
i += 8; |
| 42 |
|
| 43 |
_mm256_storeu_ps(output, vacc); |
| 44 |
output += 8; |
| 45 |
} |
| 46 |
if XNN_UNLIKELY(batch != 0) { |
| 47 |
assert(batch >= 1 * sizeof(uint16_t)); |
| 48 |
assert(batch <= 7 * sizeof(uint16_t)); |
| 49 |
const __m256 vacc = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i)); |
| 50 |
|
| 51 |
__m128 vacc_lo = _mm256_castps256_ps128(vacc); |
| 52 |
if (batch & (4 * sizeof(uint16_t))) { |
| 53 |
_mm_storeu_ps(output, vacc_lo); |
| 54 |
vacc_lo = _mm256_extractf128_ps(vacc, 1); |
| 55 |
output += 4; |
| 56 |
} |
| 57 |
if (batch & (2 * sizeof(uint16_t))) { |
| 58 |
_mm_storel_pi((__m64*) output, vacc_lo); |
| 59 |
vacc_lo = _mm_movehl_ps(vacc_lo, vacc_lo); |
| 60 |
output += 2; |
| 61 |
} |
| 62 |
if (batch & (1 * sizeof(uint16_t))) { |
| 63 |
_mm_store_ss(output, vacc_lo); |
| 64 |
} |
| 65 |
} |
| 66 |
} |