aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2016-09-02 13:41:36 -0700
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2016-09-02 13:41:36 -0700
commit13e93ca8b726a42bd8fcac24387cbb2507cc948e (patch)
treea2a222395b6a8ecd0a3d714fee3f04de4af2b903 /unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
parentef54723dbe80787f743f6bfa4d11c090486ec01a (diff)
Fix CUDA build broken by changes to min and max reduction.
Diffstat (limited to 'unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h')
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h38
1 files changed, 28 insertions, 10 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h b/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
index f73178b30..3f623afa4 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorFunctors.h
@@ -188,6 +188,32 @@ struct reducer_traits<MeanReducer<T>, Device> {
};
+template <typename T, bool IsMax = true, bool IsInteger = true>
+struct MinMaxBottomValue {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE static T bottom_value() {
+ return Eigen::NumTraits<T>::lowest();
+ }
+};
+template <typename T>
+struct MinMaxBottomValue<T, true, false> {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE static T bottom_value() {
+ return -Eigen::NumTraits<T>::infinity();
+ }
+};
+template <typename T>
+struct MinMaxBottomValue<T, false, true> {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE static T bottom_value() {
+ return Eigen::NumTraits<T>::highest();
+ }
+};
+template <typename T>
+struct MinMaxBottomValue<T, false, false> {
+ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE static T bottom_value() {
+ return Eigen::NumTraits<T>::infinity();
+ }
+};
+
+
template <typename T> struct MaxReducer
{
static const bool PacketAccess = packet_traits<T>::HasMax;
@@ -201,11 +227,7 @@ template <typename T> struct MaxReducer
(*accum) = pmax<Packet>(*accum, p);
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T initialize() const {
- if (Eigen::NumTraits<T>::IsInteger) {
- return Eigen::NumTraits<T>::lowest();
- } else {
- return -Eigen::NumTraits<T>::infinity();
- }
+ return MinMaxBottomValue<T, true, Eigen::NumTraits<T>::IsInteger>::bottom_value();
}
template <typename Packet>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet initializePacket() const {
@@ -246,11 +268,7 @@ template <typename T> struct MinReducer
(*accum) = pmin<Packet>(*accum, p);
}
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T initialize() const {
- if (Eigen::NumTraits<T>::IsInteger) {
- return Eigen::NumTraits<T>::highest();
- } else {
- return Eigen::NumTraits<T>::infinity();
- }
+ return MinMaxBottomValue<T, false, Eigen::NumTraits<T>::IsInteger>::bottom_value();
}
template <typename Packet>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet initializePacket() const {