Please, help us to better know about our user community by answering the following short survey: https://forms.gle/wpyrxWi18ox9Z5ae9
Eigen  3.4.0
AVX512/TypeCasting.h
1 // This file is part of Eigen, a lightweight C++ template library
2 // for linear algebra.
3 //
4 // Copyright (C) 2019 Rasmus Munk Larsen <rmlarsen@google.com>
5 //
6 // This Source Code Form is subject to the terms of the Mozilla
7 // Public License v. 2.0. If a copy of the MPL was not distributed
8 // with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 
10 #ifndef EIGEN_TYPE_CASTING_AVX512_H
11 #define EIGEN_TYPE_CASTING_AVX512_H
12 
13 namespace Eigen {
14 
15 namespace internal {
16 
17 template<> EIGEN_STRONG_INLINE Packet16i pcast<Packet16f, Packet16i>(const Packet16f& a) {
18  return _mm512_cvttps_epi32(a);
19 }
20 
21 template<> EIGEN_STRONG_INLINE Packet16f pcast<Packet16i, Packet16f>(const Packet16i& a) {
22  return _mm512_cvtepi32_ps(a);
23 }
24 
25 template<> EIGEN_STRONG_INLINE Packet16i preinterpret<Packet16i, Packet16f>(const Packet16f& a) {
26  return _mm512_castps_si512(a);
27 }
28 
29 template<> EIGEN_STRONG_INLINE Packet16f preinterpret<Packet16f, Packet16i>(const Packet16i& a) {
30  return _mm512_castsi512_ps(a);
31 }
32 
33 template <>
34 struct type_casting_traits<half, float> {
35  enum {
36  VectorizedCast = 1,
37  SrcCoeffRatio = 1,
38  TgtCoeffRatio = 1
39  };
40 };
41 
42 template<> EIGEN_STRONG_INLINE Packet16f pcast<Packet16h, Packet16f>(const Packet16h& a) {
43  return half2float(a);
44 }
45 
46 template <>
47 struct type_casting_traits<float, half> {
48  enum {
49  VectorizedCast = 1,
50  SrcCoeffRatio = 1,
51  TgtCoeffRatio = 1
52  };
53 };
54 
55 template<> EIGEN_STRONG_INLINE Packet16h pcast<Packet16f, Packet16h>(const Packet16f& a) {
56  return float2half(a);
57 }
58 
59 template <>
60 struct type_casting_traits<bfloat16, float> {
61  enum {
62  VectorizedCast = 1,
63  SrcCoeffRatio = 1,
64  TgtCoeffRatio = 1
65  };
66 };
67 
68 template<> EIGEN_STRONG_INLINE Packet16f pcast<Packet16bf, Packet16f>(const Packet16bf& a) {
69  return Bf16ToF32(a);
70 }
71 
72 template <>
73 struct type_casting_traits<float, bfloat16> {
74  enum {
75  VectorizedCast = 1,
76  SrcCoeffRatio = 1,
77  TgtCoeffRatio = 1
78  };
79 };
80 
81 template<> EIGEN_STRONG_INLINE Packet16bf pcast<Packet16f, Packet16bf>(const Packet16f& a) {
82  return F32ToBf16(a);
83 }
84 
85 } // end namespace internal
86 
87 } // end namespace Eigen
88 
89 #endif // EIGEN_TYPE_CASTING_AVX512_H
Namespace containing all symbols from the Eigen library.
Definition: Core:141
Definition: Eigen_Colamd.h:50