diff --git a/unsupported/Eigen/src/Tensor/Tensor.h b/unsupported/Eigen/src/Tensor/Tensor.h index 9dc95916c..f7aca0bc6 100644 --- a/unsupported/Eigen/src/Tensor/Tensor.h +++ b/unsupported/Eigen/src/Tensor/Tensor.h @@ -88,9 +88,9 @@ class Tensor : public TensorBase struct isOfNormalIndex { - static const bool is_array = internal::is_base_of, CustomIndices>::value; - static const bool is_int = NumTraits::IsInteger; - static const bool value = is_array | is_int; + static constexpr bool is_array = internal::is_base_of, CustomIndices>::value; + static constexpr bool is_int = NumTraits::IsInteger; + static constexpr bool value = is_array | is_int; }; public: diff --git a/unsupported/Eigen/src/Tensor/TensorBlock.h b/unsupported/Eigen/src/Tensor/TensorBlock.h index 00bec1326..7fd993cdb 100644 --- a/unsupported/Eigen/src/Tensor/TensorBlock.h +++ b/unsupported/Eigen/src/Tensor/TensorBlock.h @@ -333,7 +333,7 @@ class TensorBlockMapper { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE BlockDescriptor blockDescriptor(IndexType block_index) const { - static const bool isColMajor = Layout == static_cast(ColMajor); + static constexpr bool isColMajor = Layout == static_cast(ColMajor); IndexType offset = 0; DSizes dimensions; @@ -388,7 +388,7 @@ class TensorBlockMapper { return; } - static const bool isColMajor = Layout == static_cast(ColMajor); + static constexpr bool isColMajor = Layout == static_cast(ColMajor); // Block shape skewed towards inner dimension. if (shape_type == TensorBlockShapeType::kSkewedInnerDims) { @@ -710,7 +710,7 @@ class TensorMaterializedBlock { // // In this case we can construct a TensorBlock starting at // `data + desc.offset()`, with a `desc.dimensions()` block sizes. - static const bool is_col_major = Layout == ColMajor; + static constexpr bool is_col_major = Layout == ColMajor; // Find out how many inner dimensions have a matching size. int num_matching_inner_dims = 0; @@ -1389,8 +1389,8 @@ class TensorBlockAssignment { // Tensor block expression dimension should match destination dimensions. eigen_assert(dimensions_match(target.dims, eval.dimensions())); - static const int Layout = TensorBlockEvaluator::Layout; - static const bool is_col_major = Layout == ColMajor; + static constexpr int Layout = TensorBlockEvaluator::Layout; + static constexpr bool is_col_major = Layout == ColMajor; // Initialize output inner dimension size based on a layout. const IndexType output_size = NumDims == 0 ? 1 : target.dims.TotalSize(); diff --git a/unsupported/Eigen/src/Tensor/TensorBroadcasting.h b/unsupported/Eigen/src/Tensor/TensorBroadcasting.h index 799e513a7..f94d39b36 100644 --- a/unsupported/Eigen/src/Tensor/TensorBroadcasting.h +++ b/unsupported/Eigen/src/Tensor/TensorBroadcasting.h @@ -46,11 +46,11 @@ struct nested, 1, template struct is_input_scalar { - static const bool value = false; + static constexpr bool value = false; }; template <> struct is_input_scalar> { - static const bool value = true; + static constexpr bool value = true; }; template struct is_input_scalar> { diff --git a/unsupported/Eigen/src/Tensor/TensorContraction.h b/unsupported/Eigen/src/Tensor/TensorContraction.h index c3f9135f0..6d63ee1f4 100644 --- a/unsupported/Eigen/src/Tensor/TensorContraction.h +++ b/unsupported/Eigen/src/Tensor/TensorContraction.h @@ -228,7 +228,7 @@ struct TensorContractionKernel { // Default GEBP kernel does not support beta. EIGEN_ONLY_USED_FOR_DEBUG(beta); eigen_assert(beta == ResScalar(1)); - static const int kComputeStrideFromBlockDimensions = -1; + static constexpr int kComputeStrideFromBlockDimensions = -1; GebpKernel()(output_mapper, lhsBlock, rhsBlock, rows, depth, cols, alpha, /*strideA*/ kComputeStrideFromBlockDimensions, /*strideB*/ kComputeStrideFromBlockDimensions, diff --git a/unsupported/Eigen/src/Tensor/TensorContractionMapper.h b/unsupported/Eigen/src/Tensor/TensorContractionMapper.h index c491ee934..f11c08c2e 100644 --- a/unsupported/Eigen/src/Tensor/TensorContractionMapper.h +++ b/unsupported/Eigen/src/Tensor/TensorContractionMapper.h @@ -519,8 +519,8 @@ struct TensorContractionInputMapperTrait< TensorContractionInputMapper > { using XprType = Tensor_; - static const bool inner_dim_contiguous = inner_dim_contiguous_; - static const bool inner_dim_reordered = inner_dim_reordered_; + static constexpr bool inner_dim_contiguous = inner_dim_contiguous_; + static constexpr bool inner_dim_reordered = inner_dim_reordered_; }; } // end namespace internal diff --git a/unsupported/Eigen/src/Tensor/TensorCostModel.h b/unsupported/Eigen/src/Tensor/TensorCostModel.h index d17d356d4..6134151df 100644 --- a/unsupported/Eigen/src/Tensor/TensorCostModel.h +++ b/unsupported/Eigen/src/Tensor/TensorCostModel.h @@ -43,8 +43,8 @@ class TensorOpCost { return internal::functor_traits >::Cost; } - EIGEN_DEVICE_FUNC TensorOpCost() : bytes_loaded_(0), bytes_stored_(0), compute_cycles_(0) {} - EIGEN_DEVICE_FUNC TensorOpCost(double bytes_loaded, double bytes_stored, double compute_cycles) + constexpr EIGEN_DEVICE_FUNC TensorOpCost() : bytes_loaded_(0), bytes_stored_(0), compute_cycles_(0) {} + constexpr EIGEN_DEVICE_FUNC TensorOpCost(double bytes_loaded, double bytes_stored, double compute_cycles) : bytes_loaded_(bytes_loaded), bytes_stored_(bytes_stored), compute_cycles_(compute_cycles) {} EIGEN_DEVICE_FUNC TensorOpCost(double bytes_loaded, double bytes_stored, double compute_cycles, bool vectorized, @@ -57,11 +57,11 @@ class TensorOpCost { eigen_assert(compute_cycles >= 0 && (numext::isfinite)(compute_cycles)); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double bytes_loaded() const { return bytes_loaded_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double bytes_stored() const { return bytes_stored_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double compute_cycles() const { return compute_cycles_; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double total_cost(double load_cost, double store_cost, - double compute_cost) const { + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double bytes_loaded() const { return bytes_loaded_; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double bytes_stored() const { return bytes_stored_; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double compute_cycles() const { return compute_cycles_; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE double total_cost(double load_cost, double store_cost, + double compute_cost) const { return load_cost * bytes_loaded_ + store_cost * bytes_stored_ + compute_cost * compute_cycles_; } @@ -140,12 +140,12 @@ template class TensorCostModel { public: // Scaling from Eigen compute cost to device cycles. - static const int kDeviceCyclesPerComputeCycle = 1; + static constexpr int kDeviceCyclesPerComputeCycle = 1; // Costs in device cycles. - static const int kStartupCycles = 100000; - static const int kPerThreadCycles = 100000; - static const int kTaskSize = 40000; + static constexpr int kStartupCycles = 100000; + static constexpr int kPerThreadCycles = 100000; + static constexpr int kTaskSize = 40000; // Returns the number of threads in [1:max_threads] to use for // evaluating an expression with the given output size and cost per diff --git a/unsupported/Eigen/src/Tensor/TensorDimensionList.h b/unsupported/Eigen/src/Tensor/TensorDimensionList.h index 8f2e5af63..249d248c6 100644 --- a/unsupported/Eigen/src/Tensor/TensorDimensionList.h +++ b/unsupported/Eigen/src/Tensor/TensorDimensionList.h @@ -25,26 +25,22 @@ namespace Eigen { */ template struct DimensionList { - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const Index operator[](const Index i) const { return i; } + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const Index operator[](const Index i) const { return i; } }; namespace internal { template struct array_size > { - static const size_t value = Rank; + static constexpr size_t value = Rank; }; template struct array_size > { - static const size_t value = Rank; + static constexpr size_t value = Rank; }; template -const Index array_get(DimensionList&) { - return n; -} -template -const Index array_get(const DimensionList&) { +constexpr Index array_get(const DimensionList&) { return n; } diff --git a/unsupported/Eigen/src/Tensor/TensorDimensions.h b/unsupported/Eigen/src/Tensor/TensorDimensions.h index 8aca0f3d6..077f35f9a 100644 --- a/unsupported/Eigen/src/Tensor/TensorDimensions.h +++ b/unsupported/Eigen/src/Tensor/TensorDimensions.h @@ -20,14 +20,14 @@ namespace internal { template struct dget { - static const std::ptrdiff_t value = get::value; + static constexpr std::ptrdiff_t value = get::value; }; template struct fixed_size_tensor_index_linearization_helper { template - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(array const& indices, - const Dimensions& dimensions) { + constexpr EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(array const& indices, + const Dimensions& dimensions) { return array_get < RowMajor ? n - 1 : (NumIndices - n) > (indices) + dget < RowMajor ? n - 1 : (NumIndices - n), @@ -39,7 +39,7 @@ struct fixed_size_tensor_index_linearization_helper { template struct fixed_size_tensor_index_linearization_helper { template - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(array const&, const Dimensions&) { + constexpr EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(array const&, const Dimensions&) { return 0; } }; @@ -47,7 +47,7 @@ struct fixed_size_tensor_index_linearization_helper struct fixed_size_tensor_index_extraction_helper { template - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(const Index index, const Dimensions& dimensions) { + constexpr EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(const Index index, const Dimensions& dimensions) { const Index mult = (index == n - 1) ? 1 : 0; return array_get(dimensions) * mult + fixed_size_tensor_index_extraction_helper::run(index, dimensions); @@ -57,7 +57,7 @@ struct fixed_size_tensor_index_extraction_helper { template struct fixed_size_tensor_index_extraction_helper { template - EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(const Index, const Dimensions&) { + constexpr EIGEN_DEVICE_FUNC static EIGEN_STRONG_INLINE Index run(const Index, const Dimensions&) { return 0; } }; @@ -80,20 +80,22 @@ template struct Sizes { typedef internal::numeric_list Base; const Base t = Base(); - static const std::ptrdiff_t total_size = internal::arg_prod(Indices...); - static const ptrdiff_t count = Base::count; + static constexpr std::ptrdiff_t total_size = internal::arg_prod(Indices...); + static constexpr ptrdiff_t count = Base::count; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t rank() const { return Base::count; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t rank() const { return Base::count; } - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t TotalSize() { return internal::arg_prod(Indices...); } + static constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t TotalSize() { + return internal::arg_prod(Indices...); + } - EIGEN_DEVICE_FUNC Sizes() {} + constexpr EIGEN_DEVICE_FUNC Sizes() {} template - explicit EIGEN_DEVICE_FUNC Sizes(const array& /*indices*/) { + explicit constexpr EIGEN_DEVICE_FUNC Sizes(const array& /*indices*/) { // TODO: Add assertion. } template - EIGEN_DEVICE_FUNC Sizes(DenseIndex...) {} + constexpr EIGEN_DEVICE_FUNC Sizes(DenseIndex...) {} explicit EIGEN_DEVICE_FUNC Sizes(std::initializer_list /*l*/) { // TODO: Add assertion. } @@ -104,17 +106,19 @@ struct Sizes { return *this; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t operator[](const std::ptrdiff_t index) const { + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t operator[](const std::ptrdiff_t index) const { return internal::fixed_size_tensor_index_extraction_helper::run(index, t); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ptrdiff_t IndexOfColMajor(const array& indices) const { + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ptrdiff_t + IndexOfColMajor(const array& indices) const { return internal::fixed_size_tensor_index_linearization_helper::run( indices, t); } template - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ptrdiff_t IndexOfRowMajor(const array& indices) const { + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE ptrdiff_t + IndexOfRowMajor(const array& indices) const { return internal::fixed_size_tensor_index_linearization_helper::run( indices, t); } @@ -122,7 +126,7 @@ struct Sizes { namespace internal { template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes&) { +constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes&) { return Sizes::total_size; } } // namespace internal @@ -131,8 +135,8 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_prod(const Sizes struct tensor_index_linearization_helper { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index run(array const& indices, - array const& dimensions) { + static constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index run(array const& indices, + array const& dimensions) { return array_get < RowMajor ? n : (NumIndices - n - 1) > (indices) + array_get < RowMajor ? n @@ -144,8 +148,8 @@ struct tensor_index_linearization_helper { template struct tensor_index_linearization_helper { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index run(array const& indices, - array const&) { + static constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index run(array const& indices, + array const&) { return array_get < RowMajor ? 0 : NumIndices - 1 > (indices); } }; @@ -165,11 +169,11 @@ struct tensor_index_linearization_helper { template struct DSizes : array { typedef array Base; - static const int count = NumDims; + static constexpr int count = NumDims; - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const { return NumDims; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const { return NumDims; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DenseIndex TotalSize() const { + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DenseIndex TotalSize() const { return (NumDims == 0) ? 1 : internal::array_prod(*static_cast(this)); } @@ -281,22 +285,22 @@ namespace internal { template struct array_size > { - static const ptrdiff_t value = NumDims; + static constexpr ptrdiff_t value = NumDims; }; template struct array_size > { - static const ptrdiff_t value = NumDims; + static constexpr ptrdiff_t value = NumDims; }; template struct array_size > { - static const std::ptrdiff_t value = Sizes::count; + static constexpr std::ptrdiff_t value = Sizes::count; }; template struct array_size > { - static const std::ptrdiff_t value = Sizes::count; + static constexpr std::ptrdiff_t value = Sizes::count; }; template -EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes&) { +constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes&) { return get >::value; } template @@ -307,24 +311,24 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE std::ptrdiff_t array_get(const Sizes<>&) { template struct sizes_match_below_dim { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(Dims1&, Dims2&) { return false; } + static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(const Dims1&, const Dims2&) { return false; } }; template struct sizes_match_below_dim { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(Dims1& dims1, Dims2& dims2) { + static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(const Dims1& dims1, const Dims2& dims2) { return numext::equal_strict(array_get(dims1), array_get(dims2)) && sizes_match_below_dim::run(dims1, dims2); } }; template struct sizes_match_below_dim { - static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(Dims1&, Dims2&) { return true; } + static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool run(const Dims1&, const Dims2&) { return true; } }; } // end namespace internal template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool dimensions_match(Dims1 dims1, Dims2 dims2) { +EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool dimensions_match(const Dims1& dims1, const Dims2& dims2) { return internal::sizes_match_below_dim::value, internal::array_size::value>::run(dims1, dims2); } diff --git a/unsupported/Eigen/src/Tensor/TensorEvaluator.h b/unsupported/Eigen/src/Tensor/TensorEvaluator.h index 7a19d7af5..a09ce7abe 100644 --- a/unsupported/Eigen/src/Tensor/TensorEvaluator.h +++ b/unsupported/Eigen/src/Tensor/TensorEvaluator.h @@ -440,7 +440,7 @@ struct TensorEvaluator, Device> { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::TensorBlockResourceRequirements getResourceRequirements() const { - static const double functor_cost = internal::functor_traits::Cost; + static constexpr double functor_cost = internal::functor_traits::Cost; return m_argImpl.getResourceRequirements().addCostPerCoeff({0, 0, functor_cost / PacketSize}); } @@ -552,7 +552,7 @@ struct TensorEvaluator::Cost; + static constexpr double functor_cost = internal::functor_traits::Cost; return internal::TensorBlockResourceRequirements::merge(m_leftImpl.getResourceRequirements(), m_rightImpl.getResourceRequirements()) .addCostPerCoeff({0, 0, functor_cost / PacketSize}); diff --git a/unsupported/Eigen/src/Tensor/TensorFixedSize.h b/unsupported/Eigen/src/Tensor/TensorFixedSize.h index faa7af86d..40f20373e 100644 --- a/unsupported/Eigen/src/Tensor/TensorFixedSize.h +++ b/unsupported/Eigen/src/Tensor/TensorFixedSize.h @@ -60,10 +60,10 @@ class TensorFixedSize : public TensorBase m_storage; public: - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const { return NumIndices; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index rank() const { return NumIndices; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index dimension(std::size_t n) const { return m_storage.dimensions()[n]; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions dimensions() const { return m_storage.dimensions(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return m_storage.size(); } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Dimensions dimensions() const { return m_storage.dimensions(); } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index size() const { return m_storage.size(); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Scalar* data() { return m_storage.data(); } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar* data() const { return m_storage.data(); } diff --git a/unsupported/Eigen/src/Tensor/TensorForwardDeclarations.h b/unsupported/Eigen/src/Tensor/TensorForwardDeclarations.h index 49c20a4e2..29ea1da17 100644 --- a/unsupported/Eigen/src/Tensor/TensorForwardDeclarations.h +++ b/unsupported/Eigen/src/Tensor/TensorForwardDeclarations.h @@ -44,11 +44,11 @@ struct StorageMemory : MakePointer {}; namespace internal { template struct Pointer_type_promotion { - static const bool val = false; + static constexpr bool val = false; }; template struct Pointer_type_promotion { - static const bool val = true; + static constexpr bool val = true; }; template struct TypeConversion { @@ -173,12 +173,12 @@ namespace internal { template struct IsVectorizable { - static const bool value = TensorEvaluator::PacketAccess; + static constexpr bool value = TensorEvaluator::PacketAccess; }; template struct IsVectorizable { - static const bool value = + static constexpr bool value = TensorEvaluator::PacketAccess && TensorEvaluator::IsAligned; }; @@ -196,7 +196,7 @@ struct IsTileable { static constexpr bool BlockAccess = TensorEvaluator::BlockAccess && TensorEvaluator::PreferBlockAccess; - static const TiledEvaluation value = BlockAccess ? TiledEvaluation::On : TiledEvaluation::Off; + static constexpr TiledEvaluation value = BlockAccess ? TiledEvaluation::On : TiledEvaluation::Off; }; template ::value, diff --git a/unsupported/Eigen/src/Tensor/TensorGenerator.h b/unsupported/Eigen/src/Tensor/TensorGenerator.h index 2dac3379c..d1fd0b00d 100644 --- a/unsupported/Eigen/src/Tensor/TensorGenerator.h +++ b/unsupported/Eigen/src/Tensor/TensorGenerator.h @@ -160,7 +160,7 @@ struct TensorEvaluator, Device> { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorBlock block(TensorBlockDesc& desc, TensorBlockScratch& scratch, bool /*root_of_expr_ast*/ = false) const { - static const bool is_col_major = static_cast(Layout) == static_cast(ColMajor); + static constexpr bool is_col_major = static_cast(Layout) == static_cast(ColMajor); // Compute spatial coordinates for the first block element. array coords; @@ -187,9 +187,9 @@ struct TensorEvaluator, Device> { CoeffReturnType* block_buffer = block_storage.data(); - static const int packet_size = PacketType::size; + static constexpr int packet_size = PacketType::size; - static const int inner_dim = is_col_major ? 0 : NumDims - 1; + static constexpr int inner_dim = is_col_major ? 0 : NumDims - 1; const Index inner_dim_size = it[0].size; const Index inner_dim_vectorized = inner_dim_size - packet_size; diff --git a/unsupported/Eigen/src/Tensor/TensorIndexList.h b/unsupported/Eigen/src/Tensor/TensorIndexList.h index d244b50a5..c3480cb21 100644 --- a/unsupported/Eigen/src/Tensor/TensorIndexList.h +++ b/unsupported/Eigen/src/Tensor/TensorIndexList.h @@ -358,20 +358,20 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index array_prod(const IndexList struct array_size> { - static const size_t value = array_size>::value; + static constexpr size_t value = array_size>::value; }; template struct array_size> { - static const size_t value = array_size>::value; + static constexpr size_t value = array_size>::value; }; template struct array_size> { - static const size_t value = 1 + sizeof...(OtherTypes); + static constexpr size_t value = 1 + sizeof...(OtherTypes); }; template struct array_size> { - static const size_t value = 1 + sizeof...(OtherTypes); + static constexpr size_t value = 1 + sizeof...(OtherTypes); }; template diff --git a/unsupported/Eigen/src/Tensor/TensorMeta.h b/unsupported/Eigen/src/Tensor/TensorMeta.h index 8454070af..5762b8547 100644 --- a/unsupported/Eigen/src/Tensor/TensorMeta.h +++ b/unsupported/Eigen/src/Tensor/TensorMeta.h @@ -19,22 +19,22 @@ template struct Cond {}; template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T1& choose(Cond, const T1& first, const T2&) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T1& choose(Cond, const T1& first, const T2&) { return first; } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T2& choose(Cond, const T1&, const T2& second) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE const T2& choose(Cond, const T1&, const T2& second) { return second; } template struct max_n_1 { - static const size_t size = n; + static constexpr size_t size = n; }; template <> struct max_n_1<0> { - static const size_t size = 1; + static constexpr size_t size = 1; }; template @@ -55,7 +55,7 @@ typedef ulonglong2 Packet4h2; template <> struct PacketType { typedef Packet4h2 type; - static const int size = 8; + static constexpr int size = 8; enum { HasAdd = 1, HasSub = 1, @@ -132,7 +132,7 @@ static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE Index roundUp(Index x, Index y) { r template <> struct PacketType { typedef half type; - static const int size = 1; + static constexpr int size = 1; enum { HasAdd = 0, HasSub = 0, @@ -281,7 +281,7 @@ struct is_base_of { static yes check(D*, T); static no check(B*, int); - static const bool value = sizeof(check(Host(), int())) == sizeof(yes); + static constexpr bool value = sizeof(check(Host(), int())) == sizeof(yes); }; } // namespace internal diff --git a/unsupported/Eigen/src/Tensor/TensorPadding.h b/unsupported/Eigen/src/Tensor/TensorPadding.h index 815759688..fbcd781e5 100644 --- a/unsupported/Eigen/src/Tensor/TensorPadding.h +++ b/unsupported/Eigen/src/Tensor/TensorPadding.h @@ -223,7 +223,7 @@ struct TensorEvaluator, Device return TensorBlock(internal::TensorBlockKind::kView, NULL, desc.dimensions()); } - static const bool IsColMajor = Layout == static_cast(ColMajor); + static constexpr bool IsColMajor = Layout == static_cast(ColMajor); const int inner_dim_idx = IsColMajor ? 0 : NumDims - 1; Index offset = desc.offset(); diff --git a/unsupported/Eigen/src/Tensor/TensorReduction.h b/unsupported/Eigen/src/Tensor/TensorReduction.h index 25ba136de..36865354c 100644 --- a/unsupported/Eigen/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/src/Tensor/TensorReduction.h @@ -92,39 +92,39 @@ struct DimInitializer > { template struct are_inner_most_dims { - static const bool value = false; + static constexpr bool value = false; }; template struct preserve_inner_most_dims { - static const bool value = false; + static constexpr bool value = false; }; 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 = + static constexpr bool tmp1 = indices_statically_known_to_increase(); + static constexpr bool tmp2 = index_statically_eq(0, 0); + static constexpr bool tmp3 = index_statically_eq(array_size::value - 1, array_size::value - 1); - static const bool value = tmp1 & tmp2 & tmp3; + static constexpr 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 value = tmp1 & tmp2 & tmp3; + static constexpr bool tmp1 = indices_statically_known_to_increase(); + static constexpr bool tmp2 = index_statically_eq(0, NumTensorDims - array_size::value); + static constexpr bool tmp3 = index_statically_eq(array_size::value - 1, NumTensorDims - 1); + static constexpr 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 value = tmp1 & tmp2; + static constexpr bool tmp1 = indices_statically_known_to_increase(); + static constexpr bool tmp2 = index_statically_gt(0, 0); + static constexpr 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 value = tmp1 & tmp2; + static constexpr bool tmp1 = indices_statically_known_to_increase(); + static constexpr bool tmp2 = index_statically_lt(array_size::value - 1, NumTensorDims - 1); + static constexpr bool value = tmp1 & tmp2; }; template diff --git a/unsupported/Eigen/src/Tensor/TensorShuffling.h b/unsupported/Eigen/src/Tensor/TensorShuffling.h index 51f424e81..a9649e661 100644 --- a/unsupported/Eigen/src/Tensor/TensorShuffling.h +++ b/unsupported/Eigen/src/Tensor/TensorShuffling.h @@ -206,7 +206,7 @@ struct TensorEvaluator, Device> { } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE internal::TensorBlockResourceRequirements getResourceRequirements() const { - static const int inner_dim = Layout == static_cast(ColMajor) ? 0 : NumDims - 1; + static constexpr int inner_dim = Layout == static_cast(ColMajor) ? 0 : NumDims - 1; const size_t target_size = m_device.firstLevelCacheSize(); const bool inner_dim_shuffled = m_shuffle[inner_dim] != inner_dim; diff --git a/unsupported/Eigen/src/Tensor/TensorStorage.h b/unsupported/Eigen/src/Tensor/TensorStorage.h index 62686ce69..74a3882cd 100644 --- a/unsupported/Eigen/src/Tensor/TensorStorage.h +++ b/unsupported/Eigen/src/Tensor/TensorStorage.h @@ -52,9 +52,9 @@ class TensorStorage { EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T* data() { return m_data; } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const T* data() const { return m_data; } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const FixedDimensions dimensions() const { return FixedDimensions(); } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const FixedDimensions dimensions() const { return FixedDimensions(); } - EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DenseIndex size() const { return Size; } + constexpr EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE DenseIndex size() const { return Size; } }; // pure dynamic diff --git a/unsupported/Eigen/src/Tensor/TensorUInt128.h b/unsupported/Eigen/src/Tensor/TensorUInt128.h index 1ba582c67..00d7ec26e 100644 --- a/unsupported/Eigen/src/Tensor/TensorUInt128.h +++ b/unsupported/Eigen/src/Tensor/TensorUInt128.h @@ -18,10 +18,10 @@ namespace internal { template struct static_val { - static const uint64_t value = n; - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE operator uint64_t() const { return n; } + static constexpr uint64_t value = n; + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE operator uint64_t() const { return n; } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static_val() {} + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static_val() {} template EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE static_val(const T& v) { @@ -58,28 +58,28 @@ struct TensorUInt128 { eigen_assert(x >= 0); } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128(HIGH y, LOW x) : high(y), low(x) {} + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128(HIGH y, LOW x) : high(y), low(x) {} - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE operator LOW() const { return low; } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE LOW lower() const { return low; } - EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE HIGH upper() const { return high; } + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE operator LOW() const { return low; } + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE LOW lower() const { return low; } + constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE HIGH upper() const { return high; } }; template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator==(const TensorUInt128& lhs, - const TensorUInt128& rhs) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator==(const TensorUInt128& lhs, + const TensorUInt128& rhs) { return (lhs.high == rhs.high) && (lhs.low == rhs.low); } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator!=(const TensorUInt128& lhs, - const TensorUInt128& rhs) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator!=(const TensorUInt128& lhs, + const TensorUInt128& rhs) { return (lhs.high != rhs.high) || (lhs.low != rhs.low); } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator>=(const TensorUInt128& lhs, - const TensorUInt128& rhs) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator>=(const TensorUInt128& lhs, + const TensorUInt128& rhs) { if (lhs.high != rhs.high) { return lhs.high > rhs.high; } @@ -87,8 +87,8 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator>=(const TensorUInt128 -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128& lhs, - const TensorUInt128& rhs) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128& lhs, + const TensorUInt128& rhs) { if (lhs.high != rhs.high) { return lhs.high < rhs.high; } @@ -96,8 +96,8 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool operator<(const TensorUInt128 } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128 operator+(const TensorUInt128& lhs, - const TensorUInt128& rhs) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128 operator+( + const TensorUInt128& lhs, const TensorUInt128& rhs) { TensorUInt128 result(lhs.high + rhs.high, lhs.low + rhs.low); if (result.low < rhs.low) { result.high += 1; @@ -106,8 +106,8 @@ EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128 operator } template -EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128 operator-(const TensorUInt128& lhs, - const TensorUInt128& rhs) { +constexpr EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE TensorUInt128 operator-( + const TensorUInt128& lhs, const TensorUInt128& rhs) { TensorUInt128 result(lhs.high - rhs.high, lhs.low - rhs.low); if (result.low > lhs.low) { result.high -= 1;