aboutsummaryrefslogtreecommitdiffhomepage
path: root/unsupported
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-09-02 14:11:20 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2016-09-02 14:11:20 -0700
commitadf864fec07a7cec7a36f6f77020c872e966fc81 (patch)
treed5ecba6f401a1bb9f97ce38095428c417d087aaa /unsupported
parent5a6be66cef95b47e46a2d11bcafc7078e8afb3fd (diff)
parent13e93ca8b726a42bd8fcac24387cbb2507cc948e (diff)
Merged in rmlarsen/eigen (pull request PR-222)
Fix CUDA build broken by changes to min and max reduction.
Diffstat (limited to 'unsupported')
-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 {