Fix test basic stuff

- Guard fundamental types that are not available pre C++11
- Separate subsequent angle brackets >> by spaces
- Allow casting of Eigen::half and Eigen::bfloat16 to complex types
This commit is contained in:
David Tellenbach
2020-07-09 17:24:00 +00:00
committed by Rasmus Munk Larsen
parent 8889a2c1c6
commit ee4715ff48
3 changed files with 95 additions and 34 deletions

View File

@@ -27,6 +27,20 @@ namespace Eigen {
struct bfloat16;
// explicit conversion operators are no available before C++11 so we first cast
// bfloat16 to RealScalar rather than to std::complex<RealScalar> directly
#if !EIGEN_HAS_CXX11
namespace internal {
template <typename RealScalar>
struct cast_impl<bfloat16, std::complex<RealScalar> > {
EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const bfloat16 &x)
{
return static_cast<std::complex<RealScalar> >(static_cast<RealScalar>(x));
}
};
} // namespace internal
#endif // EIGEN_HAS_CXX11
namespace bfloat16_impl {
// Make our own __bfloat16_raw definition.

View File

@@ -36,7 +36,7 @@
#ifndef EIGEN_HALF_H
#define EIGEN_HALF_H
#if __cplusplus > 199711L
#if EIGEN_HAS_CXX11
#define EIGEN_EXPLICIT_CAST(tgt_type) explicit operator tgt_type()
#else
#define EIGEN_EXPLICIT_CAST(tgt_type) operator tgt_type()
@@ -48,6 +48,20 @@ namespace Eigen {
struct half;
// explicit conversion operators are no available before C++11 so we first cast
// half to RealScalar rather than to std::complex<RealScalar> directly
#if !EIGEN_HAS_CXX11
namespace internal {
template <typename RealScalar>
struct cast_impl<half, std::complex<RealScalar> > {
EIGEN_DEVICE_FUNC static inline std::complex<RealScalar> run(const half &x)
{
return static_cast<std::complex<RealScalar> >(static_cast<RealScalar>(x));
}
};
} // namespace internal
#endif // EIGEN_HAS_CXX11
namespace half_impl {
#if !defined(EIGEN_HAS_GPU_FP16)
@@ -737,7 +751,6 @@ EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC Eigen::half __ldg(const Eigen::half* ptr)
}
#endif
#if defined(EIGEN_GPU_COMPILE_PHASE)
namespace Eigen {
namespace numext {