aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/arch/AVX/TypeCasting.h
diff options
context:
space:
mode:
authorGravatar Sheng Yang <yang.sheng@intel.com>2020-07-14 01:34:03 +0000
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2020-07-14 01:34:03 +0000
commit56b3e3f3f8ca9972ca390c8296fde363bdab271c (patch)
tree5d06bf0995ed07dd232e346369e71f70561b5d9c /Eigen/src/Core/arch/AVX/TypeCasting.h
parent4ab32e2de2511746e2108563a43cbbeb1922fbf2 (diff)
AVX path for BF16
Diffstat (limited to 'Eigen/src/Core/arch/AVX/TypeCasting.h')
-rw-r--r--Eigen/src/Core/arch/AVX/TypeCasting.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/Eigen/src/Core/arch/AVX/TypeCasting.h b/Eigen/src/Core/arch/AVX/TypeCasting.h
index 181043588..c669a7f60 100644
--- a/Eigen/src/Core/arch/AVX/TypeCasting.h
+++ b/Eigen/src/Core/arch/AVX/TypeCasting.h
@@ -76,12 +76,38 @@ struct type_casting_traits<float, Eigen::half> {
};
};
+template <>
+struct type_casting_traits<bfloat16, float> {
+ enum {
+ VectorizedCast = 1,
+ SrcCoeffRatio = 1,
+ TgtCoeffRatio = 1
+ };
+};
+
+template<> EIGEN_STRONG_INLINE Packet8f pcast<Packet8bf, Packet8f>(const Packet8bf& a) {
+ return Bf16ToF32(a);
+}
+
+template <>
+struct type_casting_traits<float, bfloat16> {
+ enum {
+ VectorizedCast = 1,
+ SrcCoeffRatio = 1,
+ TgtCoeffRatio = 1
+ };
+};
+
#endif // EIGEN_VECTORIZE_AVX512
template<> EIGEN_STRONG_INLINE Packet8h pcast<Packet8f, Packet8h>(const Packet8f& a) {
return float2half(a);
}
+template<> EIGEN_STRONG_INLINE Packet8bf pcast<Packet8f, Packet8bf>(const Packet8f& a) {
+ return F32ToBf16(a);
+}
+
} // end namespace internal
} // end namespace Eigen