mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-01-30 17:40:05 +08:00
Make EIGEN_HAS_CONSTEXPR user configurable
This commit is contained in:
parent
c3410804cd
commit
ccaace03c9
@ -393,6 +393,8 @@
|
||||
#endif
|
||||
|
||||
// Does the compiler fully support const expressions? (as in c++14)
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
|
||||
#ifdef __CUDACC__
|
||||
// Const expressions are supported provided that c++11 is enabled and we're using either clang or nvcc 7.5 or above
|
||||
#if EIGEN_MAX_CPP_VER>=14 && (__cplusplus > 199711L && defined(__CUDACC_VER__) && (EIGEN_COMP_CLANG || __CUDACC_VER__ >= 70500))
|
||||
@ -403,6 +405,12 @@
|
||||
#define EIGEN_HAS_CONSTEXPR 1
|
||||
#endif
|
||||
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
#define EIGEN_HAS_CONSTEXPR 0
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// Does the compiler support C++11 math?
|
||||
// Let's be conservative and enable the default C++11 implementation only if we are sure it exists
|
||||
#ifndef EIGEN_HAS_CXX11_MATH
|
||||
|
@ -44,7 +44,7 @@ template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(c
|
||||
}
|
||||
|
||||
|
||||
#if defined(EIGEN_HAS_CONSTEXPR)
|
||||
#if EIGEN_HAS_CONSTEXPR
|
||||
template <typename Index, std::size_t Rank>
|
||||
struct index_known_statically_impl<DimensionList<Index, Rank> > {
|
||||
EIGEN_DEVICE_FUNC static constexpr bool run(const DenseIndex) {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#ifndef EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
|
||||
#define EIGEN_CXX11_TENSOR_TENSOR_INDEX_LIST_H
|
||||
|
||||
#if defined(EIGEN_HAS_CONSTEXPR) && EIGEN_HAS_VARIADIC_TEMPLATES
|
||||
#if EIGEN_HAS_CONSTEXPR && EIGEN_HAS_VARIADIC_TEMPLATES
|
||||
|
||||
#define EIGEN_HAS_INDEX_LIST
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
typename internal::enable_if< ( __condition__ ) , int >::type = 0
|
||||
|
||||
|
||||
#if defined(EIGEN_HAS_CONSTEXPR)
|
||||
#if EIGEN_HAS_CONSTEXPR
|
||||
#define EIGEN_CONSTEXPR constexpr
|
||||
#else
|
||||
#define EIGEN_CONSTEXPR
|
||||
|
@ -87,7 +87,7 @@ struct preserve_inner_most_dims {
|
||||
static const bool value = false;
|
||||
};
|
||||
|
||||
#if defined(EIGEN_HAS_CONSTEXPR) && EIGEN_HAS_VARIADIC_TEMPLATES
|
||||
#if EIGEN_HAS_CONSTEXPR && EIGEN_HAS_VARIADIC_TEMPLATES
|
||||
template <typename ReducedDims, int NumTensorDims>
|
||||
struct are_inner_most_dims<ReducedDims, NumTensorDims, ColMajor>{
|
||||
static const bool tmp1 = indices_statically_known_to_increase<ReducedDims>();
|
||||
|
@ -115,7 +115,7 @@ static void test_static_broadcasting()
|
||||
Tensor<float, 3, DataLayout> tensor(8,3,5);
|
||||
tensor.setRandom();
|
||||
|
||||
#ifdef EIGEN_HAS_CONSTEXPR
|
||||
#if EIGEN_HAS_CONSTEXPR
|
||||
Eigen::IndexList<Eigen::type2index<2>, Eigen::type2index<3>, Eigen::type2index<4>> broadcasts;
|
||||
#else
|
||||
Eigen::array<int, 3> broadcasts;
|
||||
|
@ -341,7 +341,7 @@ static void test_static_dims() {
|
||||
Tensor<float, 2, DataLayout> out(72, 97);
|
||||
in.setRandom();
|
||||
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
#if !EIGEN_HAS_CONSTEXPR
|
||||
array<int, 2> reduction_axis;
|
||||
reduction_axis[0] = 1;
|
||||
reduction_axis[1] = 3;
|
||||
@ -371,7 +371,7 @@ static void test_innermost_last_dims() {
|
||||
in.setRandom();
|
||||
|
||||
// Reduce on the innermost dimensions.
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
#if !EIGEN_HAS_CONSTEXPR
|
||||
array<int, 2> reduction_axis;
|
||||
reduction_axis[0] = 0;
|
||||
reduction_axis[1] = 1;
|
||||
@ -402,7 +402,7 @@ static void test_innermost_first_dims() {
|
||||
in.setRandom();
|
||||
|
||||
// Reduce on the innermost dimensions.
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
#if !EIGEN_HAS_CONSTEXPR
|
||||
array<int, 2> reduction_axis;
|
||||
reduction_axis[0] = 2;
|
||||
reduction_axis[1] = 3;
|
||||
@ -433,7 +433,7 @@ static void test_reduce_middle_dims() {
|
||||
in.setRandom();
|
||||
|
||||
// Reduce on the innermost dimensions.
|
||||
#ifndef EIGEN_HAS_CONSTEXPR
|
||||
#if !EIGEN_HAS_CONSTEXPR
|
||||
array<int, 2> reduction_axis;
|
||||
reduction_axis[0] = 1;
|
||||
reduction_axis[1] = 2;
|
||||
|
Loading…
Reference in New Issue
Block a user