diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index 426025150..9540c0330 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -353,9 +353,10 @@ // Does the compiler support const expressions? #ifdef __CUDACC__ +#define EIGEN_HAS_CONSTEXPR 1 // Const expressions are not supported regardless of what host compiler is used #elif (defined(__cplusplus) && __cplusplus >= 201402L) || \ - EIGEN_GNUC_AT_LEAST(4,9) + EIGEN_GNUC_AT_LEAST(4,8) #define EIGEN_HAS_CONSTEXPR 1 #endif diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h b/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h index c7af02b11..dc64959e1 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorBroadcasting.h @@ -156,11 +156,11 @@ struct TensorEvaluator, Device> Index inputIndex = 0; for (int i = NumDims - 1; i > 0; --i) { const Index idx = index / m_outputStrides[i]; - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx < m_impl.dimensions()[i]); inputIndex += idx * m_inputStrides[i]; } else { - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx % m_impl.dimensions()[i] == 0); } else { inputIndex += (idx % m_impl.dimensions()[i]) * m_inputStrides[i]; @@ -168,11 +168,11 @@ struct TensorEvaluator, Device> } index -= idx * m_outputStrides[i]; } - if (internal::index_statically_eq()(0, 1)) { + if (internal::index_statically_eq(0, 1)) { eigen_assert(index < m_impl.dimensions()[0]); inputIndex += index; } else { - if (internal::index_statically_eq()(0, 1)) { + if (internal::index_statically_eq(0, 1)) { eigen_assert(index % m_impl.dimensions()[0] == 0); } else { inputIndex += (index % m_impl.dimensions()[0]); @@ -186,11 +186,11 @@ struct TensorEvaluator, Device> Index inputIndex = 0; for (int i = 0; i < NumDims - 1; ++i) { const Index idx = index / m_outputStrides[i]; - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx < m_impl.dimensions()[i]); inputIndex += idx * m_inputStrides[i]; } else { - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx % m_impl.dimensions()[i] == 0); } else { inputIndex += (idx % m_impl.dimensions()[i]) * m_inputStrides[i]; @@ -198,11 +198,11 @@ struct TensorEvaluator, Device> } index -= idx * m_outputStrides[i]; } - if (internal::index_statically_eq()(NumDims-1, 1)) { + if (internal::index_statically_eq(NumDims-1, 1)) { eigen_assert(index < m_impl.dimensions()[NumDims-1]); inputIndex += index; } else { - if (internal::index_statically_eq()(NumDims-1, 1)) { + if (internal::index_statically_eq(NumDims-1, 1)) { eigen_assert(index % m_impl.dimensions()[NumDims-1] == 0); } else { inputIndex += (index % m_impl.dimensions()[NumDims-1]); @@ -235,11 +235,11 @@ struct TensorEvaluator, Device> Index inputIndex = 0; for (int i = NumDims - 1; i > 0; --i) { const Index idx = index / m_outputStrides[i]; - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx < m_impl.dimensions()[i]); inputIndex += idx * m_inputStrides[i]; } else { - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx % m_impl.dimensions()[i] == 0); } else { inputIndex += (idx % m_impl.dimensions()[i]) * m_inputStrides[i]; @@ -248,11 +248,11 @@ struct TensorEvaluator, Device> index -= idx * m_outputStrides[i]; } Index innermostLoc; - if (internal::index_statically_eq()(0, 1)) { + if (internal::index_statically_eq(0, 1)) { eigen_assert(index < m_impl.dimensions()[0]); innermostLoc = index; } else { - if (internal::index_statically_eq()(0, 1)) { + if (internal::index_statically_eq(0, 1)) { eigen_assert(index % m_impl.dimensions()[0] == 0); innermostLoc = 0; } else { @@ -288,11 +288,11 @@ struct TensorEvaluator, Device> Index inputIndex = 0; for (int i = 0; i < NumDims - 1; ++i) { const Index idx = index / m_outputStrides[i]; - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx < m_impl.dimensions()[i]); inputIndex += idx * m_inputStrides[i]; } else { - if (internal::index_statically_eq()(i, 1)) { + if (internal::index_statically_eq(i, 1)) { eigen_assert(idx % m_impl.dimensions()[i] == 0); } else { inputIndex += (idx % m_impl.dimensions()[i]) * m_inputStrides[i]; @@ -301,11 +301,11 @@ struct TensorEvaluator, Device> index -= idx * m_outputStrides[i]; } Index innermostLoc; - if (internal::index_statically_eq()(NumDims-1, 1)) { + if (internal::index_statically_eq(NumDims-1, 1)) { eigen_assert(index < m_impl.dimensions()[NumDims-1]); innermostLoc = index; } else { - if (internal::index_statically_eq()(NumDims-1, 1)) { + if (internal::index_statically_eq(NumDims-1, 1)) { eigen_assert(index % m_impl.dimensions()[NumDims-1] == 0); innermostLoc = 0; } else { diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h index da7782188..206808245 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorDimensionList.h @@ -85,53 +85,53 @@ struct indices_statically_known_to_increase_impl -struct index_statically_eq > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_eq_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i == value; } }; template -struct index_statically_eq > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_eq_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i == value; } }; template -struct index_statically_ne > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_ne_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i != value; } }; template -struct index_statically_ne > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_ne_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i != value; } }; template -struct index_statically_gt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_gt_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i > value; } }; template -struct index_statically_gt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_gt_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i > value; } }; template -struct index_statically_lt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_lt_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i < value; } }; template -struct index_statically_lt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_lt_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return i < value; } }; @@ -177,53 +177,53 @@ struct indices_statically_known_to_increase_impl -struct index_statically_eq > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_eq_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_eq > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_eq_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_ne > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_ne_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() (const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_ne > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_ne_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_gt > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_gt_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() (const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_gt > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_gt_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_lt > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_lt_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() (const DenseIndex, const DenseIndex) const { return false; } }; template -struct index_statically_lt > { - EIGEN_ALWAYS_INLINE bool operator() (const DenseIndex, const DenseIndex) const { +struct index_statically_lt_impl > { + static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) const { return false; } }; diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h b/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h index 69d21d3c1..472fad0da 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorIndexList.h @@ -363,98 +363,124 @@ static constexpr bool indices_statically_known_to_increase() { template -struct index_statically_eq { - constexpr bool operator() (DenseIndex, DenseIndex) const { +struct index_statically_eq_impl { + static constexpr bool run(DenseIndex, DenseIndex) { return false; } }; template -struct index_statically_eq > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_eq_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) == value); } }; template -struct index_statically_eq > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_eq_impl > { +static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) == value); } }; template -struct index_statically_ne { - constexpr bool operator() (DenseIndex, DenseIndex) const { - return false; +static constexpr bool index_statically_eq(DenseIndex i, DenseIndex value) { + return index_statically_eq_impl::run(i, value); +} + + +template +struct index_statically_ne_impl { + static constexpr bool run(DenseIndex, DenseIndex) { + return false; } }; template -struct index_statically_ne > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_ne_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) != value); } }; template -struct index_statically_ne > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_ne_impl > { +static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) != value); } }; +template +static constexpr bool index_statically_ne(DenseIndex i, DenseIndex value) { + return index_statically_ne_impl::run(i, value); +} + + template -struct index_statically_gt { - constexpr bool operator() (DenseIndex, DenseIndex) const { - return false; +struct index_statically_gt_impl { + static constexpr bool run(DenseIndex, DenseIndex) { + return false; } }; template -struct index_statically_gt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_gt_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) > value); } }; template -struct index_statically_gt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_gt_impl > { +static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) > value); } }; template -struct index_statically_lt { - constexpr bool operator() (DenseIndex, DenseIndex) const { - return false; +static constexpr bool index_statically_gt(DenseIndex i, DenseIndex value) { + return index_statically_gt_impl::run(i, value); +} + + + + +template +struct index_statically_lt_impl { + static constexpr bool run(DenseIndex, DenseIndex) { + return false; } }; template -struct index_statically_lt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_lt_impl > { + static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) < value); } }; template -struct index_statically_lt > { - constexpr bool operator() (const DenseIndex i, const DenseIndex value) const { +struct index_statically_lt_impl > { +static constexpr bool run(const DenseIndex i, const DenseIndex value) { return IndexList().value_known_statically(i) & (IndexList().get(i) < value); } }; +template +static constexpr bool index_statically_lt(DenseIndex i, DenseIndex value) { + return index_statically_lt_impl::run(i, value); +} + + } // end namespace internal } // end namespace Eigen @@ -484,32 +510,24 @@ static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_known_to_in } template -struct index_statically_eq { - EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool operator() (DenseIndex, DenseIndex) const{ - return false; - } -}; +static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_eq(DenseIndex, DenseIndex) { + return false; +} template -struct index_statically_ne { - EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool operator() (DenseIndex, DenseIndex) const{ - return false; - } -}; +static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_ne(DenseIndex, DenseIndex) { + return false; +} template -struct index_statically_gt { - EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool operator() (DenseIndex, DenseIndex) const{ - return false; - } -}; +static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_gt(DenseIndex, DenseIndex) { + return false; +} template -struct index_statically_lt { - EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool operator() (DenseIndex, DenseIndex) const{ - return false; - } -}; +static EIGEN_ALWAYS_INLINE EIGEN_DEVICE_FUNC bool indices_statically_lt(DenseIndex, DenseIndex) { + return false; +} } // end namespace internal } // end namespace Eigen diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 4d3e25d87..bd15295b8 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -89,29 +89,29 @@ struct preserve_inner_most_dims { template struct are_inner_most_dims{ static const bool tmp1 = indices_statically_known_to_increase(); - static const bool tmp2 = index_statically_eq()(0, 0); - static const bool tmp3 = index_statically_eq()(array_size::value-1, array_size::value-1); + static const bool tmp2 = index_statically_eq(0, 0); + static const bool tmp3 = index_statically_eq(array_size::value-1, array_size::value-1); static const bool value = tmp1 & tmp2 & tmp3; }; template struct are_inner_most_dims{ static const bool tmp1 = indices_statically_known_to_increase(); - static const bool tmp2 = index_statically_eq()(0, NumTensorDims - array_size::value); - static const bool tmp3 = index_statically_eq()(array_size::value - 1, NumTensorDims - 1); + static const bool tmp2 = index_statically_eq(0, NumTensorDims - array_size::value); + static const bool tmp3 = index_statically_eq(array_size::value - 1, NumTensorDims - 1); static const bool value = tmp1 & tmp2 & tmp3; }; template struct preserve_inner_most_dims{ static const bool tmp1 = indices_statically_known_to_increase(); - static const bool tmp2 = index_statically_gt()(0, 0); + static const bool tmp2 = index_statically_gt(0, 0); static const bool value = tmp1 & tmp2; }; template struct preserve_inner_most_dims{ static const bool tmp1 = indices_statically_known_to_increase(); - static const bool tmp2 = index_statically_lt()(array_size::value - 1, NumTensorDims - 1); + static const bool tmp2 = index_statically_lt(array_size::value - 1, NumTensorDims - 1); static const bool value = tmp1 & tmp2; }; #endif