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