diff options
author | David Tellenbach <david.tellenbach@me.com> | 2020-11-19 18:49:09 +0100 |
---|---|---|
committer | David Tellenbach <david.tellenbach@me.com> | 2020-11-19 18:49:09 +0100 |
commit | 6c9c3f9a1a4d17c6eaa8008d13bde3a5fe23e04a (patch) | |
tree | de32c7d7aaa338bba3b31c438c963d2e9c2ed210 /Eigen/src/Core/arch/Default | |
parent | a8fdcae55d1f002966fc9b963597a404f30baa09 (diff) |
Remove explicit casts from Eigen::half and Eigen::bfloat16 to bool
Both, Eigen::half and Eigen::Bfloat16 are implicitly convertible to
float and can hence be converted to bool via the conversion chain
Eigen::{half,bfloat16} -> float -> bool
We thus remove the explicit cast operator to bool.
Diffstat (limited to 'Eigen/src/Core/arch/Default')
-rw-r--r-- | Eigen/src/Core/arch/Default/BFloat16.h | 8 | ||||
-rw-r--r-- | Eigen/src/Core/arch/Default/Half.h | 9 |
2 files changed, 0 insertions, 17 deletions
diff --git a/Eigen/src/Core/arch/Default/BFloat16.h b/Eigen/src/Core/arch/Default/BFloat16.h index 6f81fe382..351f451a3 100644 --- a/Eigen/src/Core/arch/Default/BFloat16.h +++ b/Eigen/src/Core/arch/Default/BFloat16.h @@ -82,14 +82,6 @@ struct bfloat16 : public bfloat16_impl::bfloat16_base { EIGEN_DEVICE_FUNC operator float() const { // NOLINT: Allow implicit conversion to float, because it is lossless. return bfloat16_impl::bfloat16_to_float(*this); } - -#if EIGEN_HAS_CXX11 - EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(bool) const { - // +0.0 and -0.0 become false, everything else becomes true. - return (value & 0x7fff) != 0; - } -#endif - }; } // namespace Eigen diff --git a/Eigen/src/Core/arch/Default/Half.h b/Eigen/src/Core/arch/Default/Half.h index 91d3bc51b..4dde91365 100644 --- a/Eigen/src/Core/arch/Default/Half.h +++ b/Eigen/src/Core/arch/Default/Half.h @@ -162,15 +162,6 @@ struct half : public half_impl::half_base { EIGEN_DEVICE_FUNC operator float() const { // NOLINT: Allow implicit conversion to float, because it is lossless. return half_impl::half_to_float(*this); } - - EIGEN_DEVICE_FUNC EIGEN_EXPLICIT_CAST(bool) const { - // +0.0 and -0.0 become false, everything else becomes true. - #if defined(EIGEN_HAS_ARM64_FP16_SCALAR_ARITHMETIC) - return (numext::bit_cast<numext::uint16_t>(x) & 0x7fff) != 0; - #else - return (x & 0x7fff) != 0; - #endif - } }; } // end namespace Eigen |