diff options
author | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-10-13 21:48:31 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-10-13 21:48:31 +0000 |
commit | c6953f799b01d36f4236b64f351cc1446e0abe17 (patch) | |
tree | 9abcded97c6effc010d08787c5b43ef7bb043b54 /Eigen/src/Core/functors | |
parent | 807e51528d220c0efed870f0505dea81a5776085 (diff) |
Add packet generic ops `predux_fmin`, `predux_fmin_nan`, `predux_fmax`, and `predux_fmax_nan` that implement reductions with `PropagateNaN`, and `PropagateNumbers` semantics. Add (slow) generic implementations for most reductions.
Diffstat (limited to 'Eigen/src/Core/functors')
-rw-r--r-- | Eigen/src/Core/functors/BinaryFunctors.h | 42 |
1 files changed, 10 insertions, 32 deletions
diff --git a/Eigen/src/Core/functors/BinaryFunctors.h b/Eigen/src/Core/functors/BinaryFunctors.h index 55650bb8d..f3509c4b9 100644 --- a/Eigen/src/Core/functors/BinaryFunctors.h +++ b/Eigen/src/Core/functors/BinaryFunctors.h @@ -140,29 +140,18 @@ struct scalar_min_op : binary_op_base<LhsScalar,RhsScalar> typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_min_op>::ReturnType result_type; EIGEN_EMPTY_STRUCT_CTOR(scalar_min_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const LhsScalar& a, const RhsScalar& b) const { - if (NaNPropagation == PropagateFast) { - return numext::mini(a, b); - } else if (NaNPropagation == PropagateNumbers) { - return internal::pfmin(a,b); - } else if (NaNPropagation == PropagateNaN) { - return internal::pfmin_nan(a,b); - } + return internal::pmin<NaNPropagation>(a, b); } template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a, const Packet& b) const { - if (NaNPropagation == PropagateFast) { - return internal::pmin(a,b); - } else if (NaNPropagation == PropagateNumbers) { - return internal::pfmin(a,b); - } else if (NaNPropagation == PropagateNaN) { - return internal::pfmin_nan(a,b); - } + return internal::pmin<NaNPropagation>(a,b); } - // TODO(rmlarsen): Handle all NaN propagation semantics reductions. template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type predux(const Packet& a) const - { return internal::predux_min(a); } + { + return internal::predux_min<NaNPropagation>(a); + } }; template<typename LhsScalar,typename RhsScalar, int NaNPropagation> @@ -184,29 +173,18 @@ struct scalar_max_op : binary_op_base<LhsScalar,RhsScalar> typedef typename ScalarBinaryOpTraits<LhsScalar,RhsScalar,scalar_max_op>::ReturnType result_type; EIGEN_EMPTY_STRUCT_CTOR(scalar_max_op) EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type operator() (const LhsScalar& a, const RhsScalar& b) const { - if (NaNPropagation == PropagateFast) { - return numext::maxi(a, b); - } else if (NaNPropagation == PropagateNumbers) { - return internal::pfmax(a,b); - } else if (NaNPropagation == PropagateNaN) { - return internal::pfmax_nan(a,b); - } + return internal::pmax<NaNPropagation>(a,b); } template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet packetOp(const Packet& a, const Packet& b) const { - if (NaNPropagation == PropagateFast) { - return internal::pmax(a,b); - } else if (NaNPropagation == PropagateNumbers) { - return internal::pfmax(a,b); - } else if (NaNPropagation == PropagateNaN) { - return internal::pfmax_nan(a,b); - } + return internal::pmax<NaNPropagation>(a,b); } - // TODO(rmlarsen): Handle all NaN propagation semantics reductions. template<typename Packet> EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE result_type predux(const Packet& a) const - { return internal::predux_max(a); } + { + return internal::predux_max<NaNPropagation>(a); + } }; template<typename LhsScalar,typename RhsScalar, int NaNPropagation> |