xref: /aosp_15_r20/external/XNNPACK/src/math/cvt-f16-f32-f16c.c (revision 4bdc94577ba0e567308109d787f7fec7b531ce36)
1 // Copyright 2021 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5 
6 #include <assert.h>
7 #include <stddef.h>
8 #include <stdint.h>
9 
10 #include <immintrin.h>
11 
12 #include <xnnpack/math-stubs.h>
13 
14 
xnn_math_f16_f32_cvt__f16c(size_t n,const void * input,float * output)15 void xnn_math_f16_f32_cvt__f16c(
16     size_t n,
17     const void* input,
18     float* output)
19 {
20   assert(n % (8 * sizeof(float)) == 0);
21 
22   const uint16_t* i = (const uint16_t*) input;
23   for (; n != 0; n -= 8 * sizeof(float)) {
24     const __m128i vx = _mm_loadu_si128((const __m128i*) i);
25     i += 8;
26 
27     const __m256 vy = _mm256_cvtph_ps(vx);
28 
29     _mm256_storeu_ps(output, vy);
30     output += 8;
31   }
32 }
33