mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-06-04 18:54:00 +08:00
Cleanup
This commit is contained in:
parent
81c928ba55
commit
970640519b
@ -165,8 +165,8 @@ struct tuple_cat_impl<NTuples, TupleImpl<N1, Args1...>, TupleImpl<N2, Args2...>,
|
|||||||
// then recursively calls again.
|
// then recursively calls again.
|
||||||
template<typename Tuple1, size_t... I1s, typename Tuple2, size_t... I2s, typename... MoreTuples>
|
template<typename Tuple1, size_t... I1s, typename Tuple2, size_t... I2s, typename... MoreTuples>
|
||||||
static EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
static EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
ReturnType run(Tuple1&& tuple1, index_sequence<I1s...>,
|
ReturnType run(Tuple1&& tuple1, std::index_sequence<I1s...>,
|
||||||
Tuple2&& tuple2, index_sequence<I2s...>,
|
Tuple2&& tuple2, std::index_sequence<I2s...>,
|
||||||
MoreTuples&&... tuples) {
|
MoreTuples&&... tuples) {
|
||||||
return tuple_cat_impl<NTuples-1, MergedTupleType, Tuples...>::run(
|
return tuple_cat_impl<NTuples-1, MergedTupleType, Tuples...>::run(
|
||||||
MergedTupleType(tuple_get_impl<I1s, Args1...>::run(std::forward<Tuple1>(tuple1))...,
|
MergedTupleType(tuple_get_impl<I1s, Args1...>::run(std::forward<Tuple1>(tuple1))...,
|
||||||
@ -178,8 +178,8 @@ struct tuple_cat_impl<NTuples, TupleImpl<N1, Args1...>, TupleImpl<N2, Args2...>,
|
|||||||
template<typename Tuple1, typename Tuple2, typename... MoreTuples>
|
template<typename Tuple1, typename Tuple2, typename... MoreTuples>
|
||||||
static EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
static EIGEN_CONSTEXPR EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
ReturnType run(Tuple1&& tuple1, Tuple2&& tuple2, MoreTuples&&... tuples) {
|
ReturnType run(Tuple1&& tuple1, Tuple2&& tuple2, MoreTuples&&... tuples) {
|
||||||
return run(std::forward<Tuple1>(tuple1), make_index_sequence<N1>{},
|
return run(std::forward<Tuple1>(tuple1), std::make_index_sequence<N1>{},
|
||||||
std::forward<Tuple2>(tuple2), make_index_sequence<N2>{},
|
std::forward<Tuple2>(tuple2), std::make_index_sequence<N2>{},
|
||||||
std::forward<MoreTuples>(tuples)...);
|
std::forward<MoreTuples>(tuples)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -681,16 +681,6 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does the compiler support result_of?
|
|
||||||
// result_of was deprecated in c++17 and removed in c++ 20
|
|
||||||
#ifndef EIGEN_HAS_STD_RESULT_OF
|
|
||||||
#if EIGEN_COMP_CXXVER < 17
|
|
||||||
#define EIGEN_HAS_STD_RESULT_OF 1
|
|
||||||
#else
|
|
||||||
#define EIGEN_HAS_STD_RESULT_OF 0
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Does the compiler support std::hash?
|
// Does the compiler support std::hash?
|
||||||
#ifndef EIGEN_HAS_STD_HASH
|
#ifndef EIGEN_HAS_STD_HASH
|
||||||
// The std::hash struct is defined in C++11 but is not labelled as a __device__
|
// The std::hash struct is defined in C++11 but is not labelled as a __device__
|
||||||
@ -710,28 +700,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Does the compiler fully support const expressions? (as in c++14)
|
|
||||||
#ifndef EIGEN_HAS_CONSTEXPR
|
|
||||||
#if defined(EIGEN_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_COMP_CLANG || EIGEN_COMP_NVCC >= 70500)
|
|
||||||
#define EIGEN_HAS_CONSTEXPR 1
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
#define EIGEN_HAS_CONSTEXPR 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_CONSTEXPR
|
|
||||||
#define EIGEN_HAS_CONSTEXPR 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // EIGEN_HAS_CONSTEXPR
|
|
||||||
|
|
||||||
#if EIGEN_HAS_CONSTEXPR
|
|
||||||
#define EIGEN_CONSTEXPR constexpr
|
#define EIGEN_CONSTEXPR constexpr
|
||||||
#else
|
|
||||||
#define EIGEN_CONSTEXPR
|
|
||||||
#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
|
||||||
@ -760,7 +729,7 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(EIGEN_CUDACC) && EIGEN_HAS_CONSTEXPR
|
#if defined(EIGEN_CUDACC)
|
||||||
// While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
|
// While available already with c++11, this is useful mostly starting with c++14 and relaxed constexpr rules
|
||||||
#if defined(__NVCC__)
|
#if defined(__NVCC__)
|
||||||
// nvcc considers constexpr functions as __host__ __device__ with the option --expt-relaxed-constexpr
|
// nvcc considers constexpr functions as __host__ __device__ with the option --expt-relaxed-constexpr
|
||||||
|
@ -244,16 +244,11 @@ EIGEN_CONSTEXPR auto index_list_size(T&& x) {
|
|||||||
* Convenient struct to get the result type of a nullary, unary, binary, or
|
* Convenient struct to get the result type of a nullary, unary, binary, or
|
||||||
* ternary functor.
|
* ternary functor.
|
||||||
*
|
*
|
||||||
* Pre C++11:
|
* Pre C++17:
|
||||||
* Supports both a Func::result_type member and templated
|
|
||||||
* Func::result<Func(ArgTypes...)>::type member.
|
|
||||||
*
|
|
||||||
* If none of these members is provided, then the type of the first
|
|
||||||
* argument is returned.
|
|
||||||
*
|
|
||||||
* Post C++11:
|
|
||||||
* This uses std::result_of. However, note the `type` member removes
|
* This uses std::result_of. However, note the `type` member removes
|
||||||
* const and converts references/pointers to their corresponding value type.
|
* const and converts references/pointers to their corresponding value type.
|
||||||
|
*
|
||||||
|
* Post C++17: Uses std::invoke_result
|
||||||
*/
|
*/
|
||||||
#if EIGEN_HAS_STD_INVOKE_RESULT
|
#if EIGEN_HAS_STD_INVOKE_RESULT
|
||||||
template<typename T> struct result_of;
|
template<typename T> struct result_of;
|
||||||
@ -263,119 +258,18 @@ struct result_of<F(ArgTypes...)> {
|
|||||||
typedef typename std::invoke_result<F, ArgTypes...>::type type1;
|
typedef typename std::invoke_result<F, ArgTypes...>::type type1;
|
||||||
typedef typename remove_all<type1>::type type;
|
typedef typename remove_all<type1>::type type;
|
||||||
};
|
};
|
||||||
#elif EIGEN_HAS_STD_RESULT_OF
|
|
||||||
template<typename T> struct result_of {
|
|
||||||
typedef typename std::result_of<T>::type type1;
|
|
||||||
typedef typename remove_all<type1>::type type;
|
|
||||||
};
|
|
||||||
#else
|
|
||||||
template<typename T> struct result_of { };
|
|
||||||
|
|
||||||
struct has_none {int a[1];};
|
|
||||||
struct has_std_result_type {int a[2];};
|
|
||||||
struct has_tr1_result {int a[3];};
|
|
||||||
|
|
||||||
template<typename Func, int SizeOf>
|
|
||||||
struct nullary_result_of_select {};
|
|
||||||
|
|
||||||
template<typename Func>
|
|
||||||
struct nullary_result_of_select<Func, sizeof(has_std_result_type)> {typedef typename Func::result_type type;};
|
|
||||||
|
|
||||||
template<typename Func>
|
|
||||||
struct nullary_result_of_select<Func, sizeof(has_tr1_result)> {typedef typename Func::template result<Func()>::type type;};
|
|
||||||
|
|
||||||
template<typename Func>
|
|
||||||
struct result_of<Func()> {
|
|
||||||
template<typename T>
|
|
||||||
static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
|
|
||||||
template<typename T>
|
|
||||||
static has_tr1_result testFunctor(T const *, typename T::template result<T()>::type const * = 0);
|
|
||||||
static has_none testFunctor(...);
|
|
||||||
|
|
||||||
// note that the following indirection is needed for gcc-3.3
|
|
||||||
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
|
|
||||||
typedef typename nullary_result_of_select<Func, FunctorType>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType, int SizeOf=sizeof(has_none)>
|
|
||||||
struct unary_result_of_select {typedef typename internal::remove_all<ArgType>::type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType>
|
|
||||||
struct unary_result_of_select<Func, ArgType, sizeof(has_std_result_type)> {typedef typename Func::result_type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType>
|
|
||||||
struct unary_result_of_select<Func, ArgType, sizeof(has_tr1_result)> {typedef typename Func::template result<Func(ArgType)>::type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType>
|
|
||||||
struct result_of<Func(ArgType)> {
|
|
||||||
template<typename T>
|
|
||||||
static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
|
|
||||||
template<typename T>
|
|
||||||
static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType)>::type const * = 0);
|
|
||||||
static has_none testFunctor(...);
|
|
||||||
|
|
||||||
// note that the following indirection is needed for gcc-3.3
|
|
||||||
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
|
|
||||||
typedef typename unary_result_of_select<Func, ArgType, FunctorType>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1, int SizeOf=sizeof(has_none)>
|
|
||||||
struct binary_result_of_select {typedef typename internal::remove_all<ArgType0>::type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1>
|
|
||||||
struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_std_result_type)>
|
|
||||||
{typedef typename Func::result_type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1>
|
|
||||||
struct binary_result_of_select<Func, ArgType0, ArgType1, sizeof(has_tr1_result)>
|
|
||||||
{typedef typename Func::template result<Func(ArgType0,ArgType1)>::type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1>
|
|
||||||
struct result_of<Func(ArgType0,ArgType1)> {
|
|
||||||
template<typename T>
|
|
||||||
static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
|
|
||||||
template<typename T>
|
|
||||||
static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1)>::type const * = 0);
|
|
||||||
static has_none testFunctor(...);
|
|
||||||
|
|
||||||
// note that the following indirection is needed for gcc-3.3
|
|
||||||
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
|
|
||||||
typedef typename binary_result_of_select<Func, ArgType0, ArgType1, FunctorType>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2, int SizeOf=sizeof(has_none)>
|
|
||||||
struct ternary_result_of_select {typedef typename internal::remove_all<ArgType0>::type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>
|
|
||||||
struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_std_result_type)>
|
|
||||||
{typedef typename Func::result_type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>
|
|
||||||
struct ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, sizeof(has_tr1_result)>
|
|
||||||
{typedef typename Func::template result<Func(ArgType0,ArgType1,ArgType2)>::type type;};
|
|
||||||
|
|
||||||
template<typename Func, typename ArgType0, typename ArgType1, typename ArgType2>
|
|
||||||
struct result_of<Func(ArgType0,ArgType1,ArgType2)> {
|
|
||||||
template<typename T>
|
|
||||||
static has_std_result_type testFunctor(T const *, typename T::result_type const * = 0);
|
|
||||||
template<typename T>
|
|
||||||
static has_tr1_result testFunctor(T const *, typename T::template result<T(ArgType0,ArgType1,ArgType2)>::type const * = 0);
|
|
||||||
static has_none testFunctor(...);
|
|
||||||
|
|
||||||
// note that the following indirection is needed for gcc-3.3
|
|
||||||
enum {FunctorType = sizeof(testFunctor(static_cast<Func*>(0)))};
|
|
||||||
typedef typename ternary_result_of_select<Func, ArgType0, ArgType1, ArgType2, FunctorType>::type type;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if EIGEN_HAS_STD_INVOKE_RESULT
|
|
||||||
template<typename F, typename... ArgTypes>
|
template<typename F, typename... ArgTypes>
|
||||||
struct invoke_result {
|
struct invoke_result {
|
||||||
typedef typename std::invoke_result<F, ArgTypes...>::type type1;
|
typedef typename std::invoke_result<F, ArgTypes...>::type type1;
|
||||||
typedef typename remove_all<type1>::type type;
|
typedef typename remove_all<type1>::type type;
|
||||||
};
|
};
|
||||||
#else
|
#else
|
||||||
|
template<typename T> struct result_of {
|
||||||
|
typedef typename std::result_of<T>::type type1;
|
||||||
|
typedef typename remove_all<type1>::type type;
|
||||||
|
};
|
||||||
|
|
||||||
template<typename F, typename... ArgTypes>
|
template<typename F, typename... ArgTypes>
|
||||||
struct invoke_result {
|
struct invoke_result {
|
||||||
typedef typename result_of<F(ArgTypes...)>::type type1;
|
typedef typename result_of<F(ArgTypes...)>::type type1;
|
||||||
@ -383,59 +277,15 @@ struct invoke_result {
|
|||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// C++14 integer/index_sequence.
|
|
||||||
#if defined(__cpp_lib_integer_sequence) && __cpp_lib_integer_sequence >= 201304L
|
|
||||||
|
|
||||||
using std::integer_sequence;
|
|
||||||
using std::make_integer_sequence;
|
|
||||||
|
|
||||||
using std::index_sequence;
|
|
||||||
using std::make_index_sequence;
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
template <typename T, T... Ints>
|
|
||||||
struct integer_sequence {
|
|
||||||
static EIGEN_CONSTEXPR size_t size() EIGEN_NOEXCEPT { return sizeof...(Ints); }
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, typename Sequence, T N>
|
|
||||||
struct append_integer;
|
|
||||||
|
|
||||||
template<typename T, T... Ints, T N>
|
|
||||||
struct append_integer<T, integer_sequence<T, Ints...>, N> {
|
|
||||||
using type = integer_sequence<T, Ints..., N>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T, size_t N>
|
|
||||||
struct generate_integer_sequence {
|
|
||||||
using type = typename append_integer<T, typename generate_integer_sequence<T, N-1>::type, N-1>::type;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<typename T>
|
|
||||||
struct generate_integer_sequence<T, 0> {
|
|
||||||
using type = integer_sequence<T>;
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T, size_t N>
|
|
||||||
using make_integer_sequence = typename generate_integer_sequence<T, N>::type;
|
|
||||||
|
|
||||||
template<size_t... Ints>
|
|
||||||
using index_sequence = integer_sequence<size_t, Ints...>;
|
|
||||||
|
|
||||||
template<size_t N>
|
|
||||||
using make_index_sequence = make_integer_sequence<size_t, N>;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Reduces a sequence of bools to true if all are true, false otherwise.
|
// Reduces a sequence of bools to true if all are true, false otherwise.
|
||||||
template<bool... values>
|
template<bool... values>
|
||||||
using reduce_all = std::is_same<integer_sequence<bool, values..., true>, integer_sequence<bool, true, values...> >;
|
using reduce_all = std::is_same<std::integer_sequence<bool, values..., true>,
|
||||||
|
std::integer_sequence<bool, true, values...> >;
|
||||||
|
|
||||||
// Reduces a sequence of bools to true if any are true, false if all false.
|
// Reduces a sequence of bools to true if any are true, false if all false.
|
||||||
template<bool... values>
|
template<bool... values>
|
||||||
using reduce_any = std::integral_constant<bool,
|
using reduce_any = std::integral_constant<bool,
|
||||||
!std::is_same<integer_sequence<bool, values..., false>, integer_sequence<bool, false, values...> >::value>;
|
!std::is_same<std::integer_sequence<bool, values..., false>, std::integer_sequence<bool, false, values...> >::value>;
|
||||||
|
|
||||||
struct meta_yes { char a[1]; };
|
struct meta_yes { char a[1]; };
|
||||||
struct meta_no { char a[2]; };
|
struct meta_no { char a[2]; };
|
||||||
|
@ -219,14 +219,8 @@ template <typename Device, typename T> class BenchmarkSuite {
|
|||||||
size_b[1] = m_;
|
size_b[1] = m_;
|
||||||
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
|
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
|
||||||
|
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
Eigen::IndexPairList<Eigen::type2indexpair<0, 0>,
|
Eigen::IndexPairList<Eigen::type2indexpair<0, 0>,
|
||||||
Eigen::type2indexpair<2, 1> > paddings;
|
Eigen::type2indexpair<2, 1> > paddings;
|
||||||
#else
|
|
||||||
Eigen::array<Eigen::IndexPair<TensorIndex>, 2> paddings;
|
|
||||||
paddings[0] = Eigen::IndexPair<TensorIndex>(0, 0);
|
|
||||||
paddings[1] = Eigen::IndexPair<TensorIndex>(2, 1);
|
|
||||||
#endif
|
|
||||||
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
||||||
for (int iter = 0; iter < 10; ++iter) {
|
for (int iter = 0; iter < 10; ++iter) {
|
||||||
B.device(device_) = A.pad(paddings);
|
B.device(device_) = A.pad(paddings);
|
||||||
@ -251,15 +245,7 @@ template <typename Device, typename T> class BenchmarkSuite {
|
|||||||
size_b[1] = k_/2;
|
size_b[1] = k_/2;
|
||||||
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
|
TensorMap<Tensor<T, 2>, Eigen::Aligned> B(b_, size_b);
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_INDEX_LIST
|
|
||||||
Eigen::array<TensorIndex, 2> strides;
|
|
||||||
strides[0] = 1;
|
|
||||||
strides[1] = 2;
|
|
||||||
#else
|
|
||||||
// Take advantage of cxx11 to give the compiler information it can use to
|
|
||||||
// optimize the code.
|
|
||||||
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<2> > strides;
|
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<2> > strides;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
||||||
for (int iter = 0; iter < 10; ++iter) {
|
for (int iter = 0; iter < 10; ++iter) {
|
||||||
@ -284,17 +270,8 @@ template <typename Device, typename T> class BenchmarkSuite {
|
|||||||
size_c[0] = m_;
|
size_c[0] = m_;
|
||||||
size_c[1] = n_;
|
size_c[1] = n_;
|
||||||
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, size_c);
|
TensorMap<Tensor<T, 2>, Eigen::Aligned> C(c_, size_c);
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_INDEX_LIST
|
|
||||||
Eigen::array<int, 2> broadcast;
|
|
||||||
broadcast[0] = 1;
|
|
||||||
broadcast[1] = n_;
|
|
||||||
#else
|
|
||||||
// Take advantage of cxx11 to give the compiler information it can use to
|
|
||||||
// optimize the code.
|
|
||||||
Eigen::IndexList<Eigen::type2index<1>, int> broadcast;
|
Eigen::IndexList<Eigen::type2index<1>, int> broadcast;
|
||||||
broadcast.set(1, n_);
|
broadcast.set(1, n_);
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
||||||
for (int iter = 0; iter < 10; ++iter) {
|
for (int iter = 0; iter < 10; ++iter) {
|
||||||
@ -385,15 +362,7 @@ for (int iter = 0; iter < 10; ++iter) {
|
|||||||
Eigen::array<TensorIndex, 1> output_size;
|
Eigen::array<TensorIndex, 1> output_size;
|
||||||
output_size[0] = n_;
|
output_size[0] = n_;
|
||||||
TensorMap<Tensor<T, 1, 0, TensorIndex>, Eigen::Aligned> C(c_, output_size);
|
TensorMap<Tensor<T, 1, 0, TensorIndex>, Eigen::Aligned> C(c_, output_size);
|
||||||
|
|
||||||
#ifndef EIGEN_HAS_INDEX_LIST
|
|
||||||
Eigen::array<TensorIndex, 1> sum_along_dim;
|
|
||||||
sum_along_dim[0] = 0;
|
|
||||||
#else
|
|
||||||
// Take advantage of cxx11 to give the compiler information it can use to
|
|
||||||
// optimize the code.
|
|
||||||
Eigen::IndexList<Eigen::type2index<0>> sum_along_dim;
|
Eigen::IndexList<Eigen::type2index<0>> sum_along_dim;
|
||||||
#endif
|
|
||||||
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
#ifdef EIGEN_USE_SYCL // warmup for sycl
|
||||||
for (int iter = 0; iter < 10; ++iter) {
|
for (int iter = 0; iter < 10; ++iter) {
|
||||||
C.device(device_) = B.sum(sum_along_dim);
|
C.device(device_) = B.sum(sum_along_dim);
|
||||||
|
@ -65,7 +65,6 @@ functions by defining EIGEN_HAS_C99_MATH=1.
|
|||||||
- \b EIGEN_HAS_C99_MATH - controls the usage of C99 math functions such as erf, erfc, lgamma, etc.
|
- \b EIGEN_HAS_C99_MATH - controls the usage of C99 math functions such as erf, erfc, lgamma, etc.
|
||||||
- \b EIGEN_HAS_CXX11_MATH - controls the implementation of some functions such as round, logp1, isinf, isnan, etc.
|
- \b EIGEN_HAS_CXX11_MATH - controls the implementation of some functions such as round, logp1, isinf, isnan, etc.
|
||||||
- \b EIGEN_HAS_STD_RESULT_OF - defines whether std::result_of is supported
|
- \b EIGEN_HAS_STD_RESULT_OF - defines whether std::result_of is supported
|
||||||
- \b EIGEN_HAS_CONSTEXPR - defines whether relaxed const expression are supported
|
|
||||||
- \b EIGEN_NO_IO - Disables any usage and support for `<iostreams>`.
|
- \b EIGEN_NO_IO - Disables any usage and support for `<iostreams>`.
|
||||||
|
|
||||||
\section TopicPreprocessorDirectivesAssertions Assertions
|
\section TopicPreprocessorDirectivesAssertions Assertions
|
||||||
|
@ -59,7 +59,7 @@ struct extract_output_indices_helper;
|
|||||||
* \tparam Ts the remaining types.
|
* \tparam Ts the remaining types.
|
||||||
*/
|
*/
|
||||||
template<size_t N, size_t Idx, size_t... OutputIndices, typename T1, typename... Ts>
|
template<size_t N, size_t Idx, size_t... OutputIndices, typename T1, typename... Ts>
|
||||||
struct extract_output_indices_helper<N, Idx, index_sequence<OutputIndices...>, T1, Ts...> {
|
struct extract_output_indices_helper<N, Idx, std::index_sequence<OutputIndices...>, T1, Ts...> {
|
||||||
using type = typename
|
using type = typename
|
||||||
extract_output_indices_helper<
|
extract_output_indices_helper<
|
||||||
N - 1, Idx + 1,
|
N - 1, Idx + 1,
|
||||||
@ -67,21 +67,21 @@ struct extract_output_indices_helper<N, Idx, index_sequence<OutputIndices...>, T
|
|||||||
// If is a non-const l-value reference, append index.
|
// If is a non-const l-value reference, append index.
|
||||||
std::is_lvalue_reference<T1>::value
|
std::is_lvalue_reference<T1>::value
|
||||||
&& !std::is_const<typename std::remove_reference<T1>::type>::value,
|
&& !std::is_const<typename std::remove_reference<T1>::type>::value,
|
||||||
index_sequence<OutputIndices..., Idx>,
|
std::index_sequence<OutputIndices..., Idx>,
|
||||||
index_sequence<OutputIndices...> >::type,
|
std::index_sequence<OutputIndices...> >::type,
|
||||||
Ts...>::type;
|
Ts...>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Base case.
|
// Base case.
|
||||||
template<size_t Idx, size_t... OutputIndices>
|
template<size_t Idx, size_t... OutputIndices>
|
||||||
struct extract_output_indices_helper<0, Idx, index_sequence<OutputIndices...> > {
|
struct extract_output_indices_helper<0, Idx, std::index_sequence<OutputIndices...> > {
|
||||||
using type = index_sequence<OutputIndices...>;
|
using type = std::index_sequence<OutputIndices...>;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extracts a set of indices into Types... that correspond to non-const
|
// Extracts a set of indices into Types... that correspond to non-const
|
||||||
// l-value references.
|
// l-value references.
|
||||||
template<typename... Types>
|
template<typename... Types>
|
||||||
using extract_output_indices = typename extract_output_indices_helper<sizeof...(Types), 0, index_sequence<>, Types...>::type;
|
using extract_output_indices = typename extract_output_indices_helper<sizeof...(Types), 0, std::index_sequence<>, Types...>::type;
|
||||||
|
|
||||||
// Helper struct for dealing with Generic functors that may return void.
|
// Helper struct for dealing with Generic functors that may return void.
|
||||||
struct void_helper {
|
struct void_helper {
|
||||||
@ -134,7 +134,7 @@ struct void_helper {
|
|||||||
// output_buffer_size is populated.
|
// output_buffer_size is populated.
|
||||||
template<typename Kernel, typename... Args, size_t... Indices, size_t... OutputIndices>
|
template<typename Kernel, typename... Args, size_t... Indices, size_t... OutputIndices>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
void run_serialized(index_sequence<Indices...>, index_sequence<OutputIndices...>,
|
void run_serialized(std::index_sequence<Indices...>, std::index_sequence<OutputIndices...>,
|
||||||
Kernel kernel, uint8_t* buffer, size_t capacity) {
|
Kernel kernel, uint8_t* buffer, size_t capacity) {
|
||||||
using test_detail::get;
|
using test_detail::get;
|
||||||
using test_detail::make_tuple;
|
using test_detail::make_tuple;
|
||||||
@ -175,7 +175,7 @@ void run_serialized(index_sequence<Indices...>, index_sequence<OutputIndices...>
|
|||||||
template<typename Kernel, typename... Args>
|
template<typename Kernel, typename... Args>
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE
|
||||||
void run_serialized(Kernel kernel, uint8_t* buffer, size_t capacity) {
|
void run_serialized(Kernel kernel, uint8_t* buffer, size_t capacity) {
|
||||||
run_serialized<Kernel, Args...> (make_index_sequence<sizeof...(Args)>{},
|
run_serialized<Kernel, Args...> (std::make_index_sequence<sizeof...(Args)>{},
|
||||||
extract_output_indices<Args...>{},
|
extract_output_indices<Args...>{},
|
||||||
kernel, buffer, capacity);
|
kernel, buffer, capacity);
|
||||||
}
|
}
|
||||||
@ -206,8 +206,8 @@ void run_serialized_on_gpu_meta_kernel(const Kernel kernel, uint8_t* buffer, siz
|
|||||||
// buffer is not large enough to hold the outputs.
|
// buffer is not large enough to hold the outputs.
|
||||||
template<typename Kernel, typename... Args, size_t... Indices, size_t... OutputIndices>
|
template<typename Kernel, typename... Args, size_t... Indices, size_t... OutputIndices>
|
||||||
auto run_serialized_on_gpu(size_t buffer_capacity_hint,
|
auto run_serialized_on_gpu(size_t buffer_capacity_hint,
|
||||||
index_sequence<Indices...>,
|
std::index_sequence<Indices...>,
|
||||||
index_sequence<OutputIndices...>,
|
std::index_sequence<OutputIndices...>,
|
||||||
Kernel kernel, Args&&... args) -> decltype(kernel(args...)) {
|
Kernel kernel, Args&&... args) -> decltype(kernel(args...)) {
|
||||||
// Compute the required serialization buffer capacity.
|
// Compute the required serialization buffer capacity.
|
||||||
// Round up input size to next power of two to give a little extra room
|
// Round up input size to next power of two to give a little extra room
|
||||||
@ -323,7 +323,7 @@ template<typename Kernel, typename... Args>
|
|||||||
auto run_on_gpu(Kernel kernel, Args&&... args) -> decltype(kernel(args...)){
|
auto run_on_gpu(Kernel kernel, Args&&... args) -> decltype(kernel(args...)){
|
||||||
return internal::run_serialized_on_gpu<Kernel, Args...>(
|
return internal::run_serialized_on_gpu<Kernel, Args...>(
|
||||||
/*buffer_capacity_hint=*/ 0,
|
/*buffer_capacity_hint=*/ 0,
|
||||||
internal::make_index_sequence<sizeof...(Args)>{},
|
std::make_index_sequence<sizeof...(Args)>{},
|
||||||
internal::extract_output_indices<Args...>{},
|
internal::extract_output_indices<Args...>{},
|
||||||
kernel, std::forward<Args>(args)...);
|
kernel, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
@ -347,7 +347,7 @@ auto run_on_gpu_with_hint(size_t buffer_capacity_hint,
|
|||||||
Kernel kernel, Args&&... args) -> decltype(kernel(args...)){
|
Kernel kernel, Args&&... args) -> decltype(kernel(args...)){
|
||||||
return internal::run_serialized_on_gpu<Kernel, Args...>(
|
return internal::run_serialized_on_gpu<Kernel, Args...>(
|
||||||
buffer_capacity_hint,
|
buffer_capacity_hint,
|
||||||
internal::make_index_sequence<sizeof...(Args)>{},
|
std::make_index_sequence<sizeof...(Args)>{},
|
||||||
internal::extract_output_indices<Args...>{},
|
internal::extract_output_indices<Args...>{},
|
||||||
kernel, std::forward<Args>(args)...);
|
kernel, std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
|
@ -388,7 +388,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
|||||||
// Nothing to do: rank 0 tensors have fixed size
|
// Nothing to do: rank 0 tensors have fixed size
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_INDEX_LIST
|
|
||||||
template <typename FirstType, typename... OtherTypes>
|
template <typename FirstType, typename... OtherTypes>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
void resize(const Eigen::IndexList<FirstType, OtherTypes...>& dimensions) {
|
void resize(const Eigen::IndexList<FirstType, OtherTypes...>& dimensions) {
|
||||||
@ -398,7 +397,6 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_, IndexTyp
|
|||||||
}
|
}
|
||||||
resize(dims);
|
resize(dims);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
/** Custom Dimension */
|
/** Custom Dimension */
|
||||||
template<typename CustomDimension,
|
template<typename CustomDimension,
|
||||||
|
@ -45,8 +45,6 @@ template<DenseIndex n, typename Index, std::size_t Rank> const Index array_get(c
|
|||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#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) {
|
||||||
@ -138,99 +136,6 @@ struct index_statically_lt_impl<const DimensionList<Index, Rank> > {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#else
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_known_statically_impl<DimensionList<Index, Rank> > {
|
|
||||||
EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_known_statically_impl<const DimensionList<Index, Rank> > {
|
|
||||||
EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run(const DenseIndex) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct all_indices_known_statically_impl<DimensionList<Index, Rank> > {
|
|
||||||
EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct all_indices_known_statically_impl<const DimensionList<Index, Rank> > {
|
|
||||||
EIGEN_DEVICE_FUNC static EIGEN_ALWAYS_INLINE bool run() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct indices_statically_known_to_increase_impl<DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct indices_statically_known_to_increase_impl<const DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_eq_impl<DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_eq_impl<const DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_ne_impl<DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_ne_impl<const DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_gt_impl<DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_gt_impl<const DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_lt_impl<DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
template <typename Index, std::size_t Rank>
|
|
||||||
struct index_statically_lt_impl<const DimensionList<Index, Rank> > {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const DenseIndex, const DenseIndex) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
|
@ -297,7 +297,6 @@ struct DSizes : array<DenseIndex, NumDims> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_INDEX_LIST
|
|
||||||
template <typename FirstType, typename... OtherTypes>
|
template <typename FirstType, typename... OtherTypes>
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
explicit DSizes(const Eigen::IndexList<FirstType, OtherTypes...>& dimensions) {
|
explicit DSizes(const Eigen::IndexList<FirstType, OtherTypes...>& dimensions) {
|
||||||
@ -305,7 +304,6 @@ struct DSizes : array<DenseIndex, NumDims> {
|
|||||||
(*this)[i] = dimensions[i];
|
(*this)[i] = dimensions[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef EIGEN_EMULATE_CXX11_META_H
|
#ifndef EIGEN_EMULATE_CXX11_META_H
|
||||||
template <typename std::ptrdiff_t... Indices>
|
template <typename std::ptrdiff_t... Indices>
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
|
|
||||||
#include "./InternalHeaderCheck.h"
|
#include "./InternalHeaderCheck.h"
|
||||||
|
|
||||||
#if EIGEN_HAS_CONSTEXPR
|
|
||||||
|
|
||||||
#define EIGEN_HAS_INDEX_LIST
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
|
|
||||||
/** \internal
|
/** \internal
|
||||||
@ -609,81 +605,6 @@ struct index_pair_second_statically_eq_impl<const IndexPairList<FirstType, Other
|
|||||||
} // end namespace internal
|
} // end namespace internal
|
||||||
} // end namespace Eigen
|
} // end namespace Eigen
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
namespace Eigen {
|
|
||||||
namespace internal {
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct index_known_statically_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(const Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct all_indices_known_statically_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct indices_statically_known_to_increase_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct index_statically_eq_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct index_statically_ne_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct index_statically_gt_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct index_statically_lt_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Tx>
|
|
||||||
struct index_pair_first_statically_eq_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename Tx>
|
|
||||||
struct index_pair_second_statically_eq_impl {
|
|
||||||
static EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool run(Index, Index) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace internal
|
|
||||||
} // end namespace Eigen
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
namespace Eigen {
|
namespace Eigen {
|
||||||
namespace internal {
|
namespace internal {
|
||||||
|
@ -109,13 +109,9 @@ struct TensorEvaluator<const TensorReshapingOp<NewDimensions, ArgType>, Device>
|
|||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static const ReshapingKind kind =
|
static const ReshapingKind kind =
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
(NumOutputDims == 2 && internal::index_statically_eq<NewDimensions>(/*index=*/0, /*value=*/1)) ? OneByN
|
(NumOutputDims == 2 && internal::index_statically_eq<NewDimensions>(/*index=*/0, /*value=*/1)) ? OneByN
|
||||||
: (NumOutputDims == 2 && internal::index_statically_eq<NewDimensions>(/*index=*/1, /*value=*/1)) ? NByOne
|
: (NumOutputDims == 2 && internal::index_statically_eq<NewDimensions>(/*index=*/1, /*value=*/1)) ? NByOne
|
||||||
: Runtime;
|
: Runtime;
|
||||||
#else
|
|
||||||
Runtime;
|
|
||||||
#endif
|
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -512,35 +512,20 @@ struct TensorEvaluator<const TensorPaddingOp<PaddingDimensions, ArgType>, Device
|
|||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool isPaddingAtIndexForDim(
|
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool isPaddingAtIndexForDim(
|
||||||
Index index, int dim_index) const {
|
Index index, int dim_index) const {
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
return (!internal::index_pair_first_statically_eq<PaddingDimensions>(dim_index, 0) &&
|
return (!internal::index_pair_first_statically_eq<PaddingDimensions>(dim_index, 0) &&
|
||||||
index < m_padding[dim_index].first) ||
|
index < m_padding[dim_index].first) ||
|
||||||
(!internal::index_pair_second_statically_eq<PaddingDimensions>(dim_index, 0) &&
|
(!internal::index_pair_second_statically_eq<PaddingDimensions>(dim_index, 0) &&
|
||||||
index >= m_dimensions[dim_index] - m_padding[dim_index].second);
|
index >= m_dimensions[dim_index] - m_padding[dim_index].second);
|
||||||
#else
|
|
||||||
return (index < m_padding[dim_index].first) ||
|
|
||||||
(index >= m_dimensions[dim_index] - m_padding[dim_index].second);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool isLeftPaddingCompileTimeZero(
|
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool isLeftPaddingCompileTimeZero(
|
||||||
int dim_index) const {
|
int dim_index) const {
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
return internal::index_pair_first_statically_eq<PaddingDimensions>(dim_index, 0);
|
return internal::index_pair_first_statically_eq<PaddingDimensions>(dim_index, 0);
|
||||||
#else
|
|
||||||
EIGEN_UNUSED_VARIABLE(dim_index);
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool isRightPaddingCompileTimeZero(
|
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE bool isRightPaddingCompileTimeZero(
|
||||||
int dim_index) const {
|
int dim_index) const {
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
return internal::index_pair_second_statically_eq<PaddingDimensions>(dim_index, 0);
|
return internal::index_pair_second_statically_eq<PaddingDimensions>(dim_index, 0);
|
||||||
#else
|
|
||||||
EIGEN_UNUSED_VARIABLE(dim_index);
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,7 +108,6 @@ struct preserve_inner_most_dims {
|
|||||||
static const bool value = false;
|
static const bool value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
#if EIGEN_HAS_CONSTEXPR
|
|
||||||
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>();
|
||||||
@ -137,7 +136,6 @@ struct preserve_inner_most_dims<ReducedDims, NumTensorDims, RowMajor>{
|
|||||||
static const bool tmp2 = index_statically_lt<ReducedDims>(array_size<ReducedDims>::value - 1, NumTensorDims - 1);
|
static const bool tmp2 = index_statically_lt<ReducedDims>(array_size<ReducedDims>::value - 1, NumTensorDims - 1);
|
||||||
static const bool value = tmp1 & tmp2;
|
static const bool value = tmp1 & tmp2;
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
template <int DimIndex, typename Self, typename Op>
|
template <int DimIndex, typename Self, typename Op>
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t
|
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t
|
||||||
#define EIGEN_USE_SYCL
|
#define EIGEN_USE_SYCL
|
||||||
#define EIGEN_HAS_CONSTEXPR 1
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
@ -116,15 +116,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();
|
||||||
|
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
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
|
|
||||||
Eigen::array<int, 3> broadcasts;
|
|
||||||
broadcasts[0] = 2;
|
|
||||||
broadcasts[1] = 3;
|
|
||||||
broadcasts[2] = 4;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Tensor<float, 3, DataLayout> broadcast;
|
Tensor<float, 3, DataLayout> broadcast;
|
||||||
broadcast = tensor.broadcast(broadcasts);
|
broadcast = tensor.broadcast(broadcasts);
|
||||||
|
|
||||||
|
@ -11,8 +11,6 @@
|
|||||||
|
|
||||||
#include <Eigen/CXX11/Tensor>
|
#include <Eigen/CXX11/Tensor>
|
||||||
|
|
||||||
#ifdef EIGEN_HAS_INDEX_LIST
|
|
||||||
|
|
||||||
static void test_static_index_list()
|
static void test_static_index_list()
|
||||||
{
|
{
|
||||||
Tensor<float, 4> tensor(2,3,5,7);
|
Tensor<float, 4> tensor(2,3,5,7);
|
||||||
@ -370,16 +368,12 @@ static void test_dim_check()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EIGEN_DECLARE_TEST(cxx11_tensor_index_list)
|
EIGEN_DECLARE_TEST(cxx11_tensor_index_list)
|
||||||
{
|
{
|
||||||
#ifdef EIGEN_HAS_INDEX_LIST
|
|
||||||
CALL_SUBTEST(test_static_index_list());
|
CALL_SUBTEST(test_static_index_list());
|
||||||
CALL_SUBTEST(test_type2index_list());
|
CALL_SUBTEST(test_type2index_list());
|
||||||
CALL_SUBTEST(test_type2indexpair_list());
|
CALL_SUBTEST(test_type2indexpair_list());
|
||||||
CALL_SUBTEST(test_dynamic_index_list());
|
CALL_SUBTEST(test_dynamic_index_list());
|
||||||
CALL_SUBTEST(test_mixed_index_list());
|
CALL_SUBTEST(test_mixed_index_list());
|
||||||
CALL_SUBTEST(test_dim_check());
|
CALL_SUBTEST(test_dim_check());
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,6 @@ static void test_simple_reshape()
|
|||||||
|
|
||||||
template <typename>
|
template <typename>
|
||||||
static void test_static_reshape() {
|
static void test_static_reshape() {
|
||||||
#if defined(EIGEN_HAS_INDEX_LIST)
|
|
||||||
using Eigen::type2index;
|
using Eigen::type2index;
|
||||||
|
|
||||||
Tensor<float, 5> tensor(2, 3, 1, 7, 1);
|
Tensor<float, 5> tensor(2, 3, 1, 7, 1);
|
||||||
@ -60,7 +59,6 @@ static void test_static_reshape() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename>
|
template <typename>
|
||||||
|
@ -370,13 +370,7 @@ static void test_static_dims() {
|
|||||||
Tensor<float, 2, DataLayout> out(72, 97);
|
Tensor<float, 2, DataLayout> out(72, 97);
|
||||||
in.setRandom();
|
in.setRandom();
|
||||||
|
|
||||||
#if !EIGEN_HAS_CONSTEXPR
|
|
||||||
array<int, 2> reduction_axis;
|
|
||||||
reduction_axis[0] = 1;
|
|
||||||
reduction_axis[1] = 3;
|
|
||||||
#else
|
|
||||||
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<3> > reduction_axis;
|
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<3> > reduction_axis;
|
||||||
#endif
|
|
||||||
|
|
||||||
out = in.maximum(reduction_axis);
|
out = in.maximum(reduction_axis);
|
||||||
|
|
||||||
@ -400,14 +394,8 @@ static void test_innermost_last_dims() {
|
|||||||
in.setRandom();
|
in.setRandom();
|
||||||
|
|
||||||
// Reduce on the innermost dimensions.
|
// Reduce on the innermost dimensions.
|
||||||
#if !EIGEN_HAS_CONSTEXPR
|
|
||||||
array<int, 2> reduction_axis;
|
|
||||||
reduction_axis[0] = 0;
|
|
||||||
reduction_axis[1] = 1;
|
|
||||||
#else
|
|
||||||
// This triggers the use of packets for ColMajor.
|
// This triggers the use of packets for ColMajor.
|
||||||
Eigen::IndexList<Eigen::type2index<0>, Eigen::type2index<1> > reduction_axis;
|
Eigen::IndexList<Eigen::type2index<0>, Eigen::type2index<1> > reduction_axis;
|
||||||
#endif
|
|
||||||
|
|
||||||
out = in.maximum(reduction_axis);
|
out = in.maximum(reduction_axis);
|
||||||
|
|
||||||
@ -431,14 +419,8 @@ static void test_innermost_first_dims() {
|
|||||||
in.setRandom();
|
in.setRandom();
|
||||||
|
|
||||||
// Reduce on the innermost dimensions.
|
// Reduce on the innermost dimensions.
|
||||||
#if !EIGEN_HAS_CONSTEXPR
|
|
||||||
array<int, 2> reduction_axis;
|
|
||||||
reduction_axis[0] = 2;
|
|
||||||
reduction_axis[1] = 3;
|
|
||||||
#else
|
|
||||||
// This triggers the use of packets for RowMajor.
|
// This triggers the use of packets for RowMajor.
|
||||||
Eigen::IndexList<Eigen::type2index<2>, Eigen::type2index<3>> reduction_axis;
|
Eigen::IndexList<Eigen::type2index<2>, Eigen::type2index<3>> reduction_axis;
|
||||||
#endif
|
|
||||||
|
|
||||||
out = in.maximum(reduction_axis);
|
out = in.maximum(reduction_axis);
|
||||||
|
|
||||||
@ -462,14 +444,8 @@ static void test_reduce_middle_dims() {
|
|||||||
in.setRandom();
|
in.setRandom();
|
||||||
|
|
||||||
// Reduce on the innermost dimensions.
|
// Reduce on the innermost dimensions.
|
||||||
#if !EIGEN_HAS_CONSTEXPR
|
|
||||||
array<int, 2> reduction_axis;
|
|
||||||
reduction_axis[0] = 1;
|
|
||||||
reduction_axis[1] = 2;
|
|
||||||
#else
|
|
||||||
// This triggers the use of packets for RowMajor.
|
// This triggers the use of packets for RowMajor.
|
||||||
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<2>> reduction_axis;
|
Eigen::IndexList<Eigen::type2index<1>, Eigen::type2index<2>> reduction_axis;
|
||||||
#endif
|
|
||||||
|
|
||||||
out = in.maximum(reduction_axis);
|
out = in.maximum(reduction_axis);
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t
|
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE int64_t
|
||||||
#define EIGEN_USE_SYCL
|
#define EIGEN_USE_SYCL
|
||||||
#define EIGEN_HAS_CONSTEXPR 1
|
|
||||||
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user