diff options
author | Teng Lu <teng.lu@intel.com> | 2020-06-20 19:16:24 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-06-20 19:16:24 +0000 |
commit | 386d809bde475c65b7940f290efe80e6a05878c4 (patch) | |
tree | c38e161a53393d15be0ddb02a7a4e22dec738484 /Eigen/src/Core/arch/AVX512/TypeCasting.h | |
parent | 6b9c92fe7eff0dedb031cec38004c9c3667f3057 (diff) |
Support BFloat16 in Eigen
Diffstat (limited to 'Eigen/src/Core/arch/AVX512/TypeCasting.h')
-rw-r--r-- | Eigen/src/Core/arch/AVX512/TypeCasting.h | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Eigen/src/Core/arch/AVX512/TypeCasting.h b/Eigen/src/Core/arch/AVX512/TypeCasting.h index a82176941..e643b18a7 100644 --- a/Eigen/src/Core/arch/AVX512/TypeCasting.h +++ b/Eigen/src/Core/arch/AVX512/TypeCasting.h @@ -40,6 +40,32 @@ template<> EIGEN_STRONG_INLINE Packet16h pcast<Packet16f, Packet16h>(const Packe return float2half(a); } +template <> +struct type_casting_traits<bfloat16, float> { + enum { + VectorizedCast = 1, + SrcCoeffRatio = 1, + TgtCoeffRatio = 1 + }; +}; + +template<> EIGEN_STRONG_INLINE Packet16f pcast<Packet16bf, Packet16f>(const Packet16bf& a) { + return Bf16ToF32(a); +} + +template <> +struct type_casting_traits<float, bfloat16> { + enum { + VectorizedCast = 1, + SrcCoeffRatio = 1, + TgtCoeffRatio = 1 + }; +}; + +template<> EIGEN_STRONG_INLINE Packet16bf pcast<Packet16f, Packet16bf>(const Packet16f& a) { + return F32ToBf16(a); +} + } // end namespace internal } // end namespace Eigen |