Debian Codegraph @

src/f16-f32-vcvt/gen/f16-f32-vcvt-f16c-u8.c

raw
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_u8(
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 >= 8 * sizeof(uint16_t); batch -= 8 * sizeof(uint16_t)) {
31 const __m256 vacc = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i));
32 i += 8;
33
34 _mm256_storeu_ps(output, vacc);
35 output += 8;
36 }
37 if XNN_UNLIKELY(batch != 0) {
38 assert(batch >= 1 * sizeof(uint16_t));
39 assert(batch <= 7 * sizeof(uint16_t));
40 const __m256 vacc = _mm256_cvtph_ps(_mm_loadu_si128((const __m128i*) i));
41
42 __m128 vacc_lo = _mm256_castps256_ps128(vacc);
43 if (batch & (4 * sizeof(uint16_t))) {
44 _mm_storeu_ps(output, vacc_lo);
45 vacc_lo = _mm256_extractf128_ps(vacc, 1);
46 output += 4;
47 }
48 if (batch & (2 * sizeof(uint16_t))) {
49 _mm_storel_pi((__m64*) output, vacc_lo);
50 vacc_lo = _mm_movehl_ps(vacc_lo, vacc_lo);
51 output += 2;
52 }
53 if (batch & (1 * sizeof(uint16_t))) {
54 _mm_store_ss(output, vacc_lo);
55 }
56 }
57 }