mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -13,9 +13,9 @@
|
||||
|
||||
#include <Eigen/CXX11/Tensor>
|
||||
|
||||
using Eigen::Tensor;
|
||||
using Eigen::RowMajor;
|
||||
using Eigen::ColMajor;
|
||||
using Eigen::RowMajor;
|
||||
using Eigen::Tensor;
|
||||
using Eigen::internal::TiledEvaluation;
|
||||
|
||||
// A set of tests to verify that different TensorExecutor strategies yields the
|
||||
@@ -26,21 +26,18 @@ using Eigen::internal::TiledEvaluation;
|
||||
template <typename Dst, typename Expr>
|
||||
static void DefaultAssign(Dst& dst, Expr expr) {
|
||||
using Assign = Eigen::TensorAssignOp<Dst, const Expr>;
|
||||
using Executor =
|
||||
Eigen::internal::TensorExecutor<const Assign, DefaultDevice,
|
||||
/*Vectorizable=*/false,
|
||||
/*Tiling=*/TiledEvaluation::Off>;
|
||||
using Executor = Eigen::internal::TensorExecutor<const Assign, DefaultDevice,
|
||||
/*Vectorizable=*/false,
|
||||
/*Tiling=*/TiledEvaluation::Off>;
|
||||
|
||||
Executor::run(Assign(dst, expr), DefaultDevice());
|
||||
}
|
||||
|
||||
// Assignment with specified device and tiling strategy.
|
||||
template <bool Vectorizable, TiledEvaluation Tiling, typename Device,
|
||||
typename Dst, typename Expr>
|
||||
template <bool Vectorizable, TiledEvaluation Tiling, typename Device, typename Dst, typename Expr>
|
||||
static void DeviceAssign(Device& d, Dst& dst, Expr expr) {
|
||||
using Assign = Eigen::TensorAssignOp<Dst, const Expr>;
|
||||
using Executor = Eigen::internal::TensorExecutor<const Assign, Device,
|
||||
Vectorizable, Tiling>;
|
||||
using Executor = Eigen::internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
}
|
||||
@@ -54,10 +51,8 @@ static array<Index, NumDims> RandomDims(int min_dim = 1, int max_dim = 20) {
|
||||
return dims;
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_unary_expr(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_unary_expr(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
// Pick a large enough tensor size to bypass small tensor block evaluation
|
||||
@@ -71,8 +66,7 @@ static void test_execute_unary_expr(Device d)
|
||||
const auto expr = src.square();
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -82,10 +76,8 @@ static void test_execute_unary_expr(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_binary_expr(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_binary_expr(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
// Pick a large enough tensor size to bypass small tensor block evaluation
|
||||
@@ -102,8 +94,7 @@ static void test_execute_binary_expr(Device d)
|
||||
const auto expr = lhs + rhs;
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -113,10 +104,8 @@ static void test_execute_binary_expr(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_broadcasting(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_broadcasting(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
auto dims = RandomDims<NumDims>(1, 10);
|
||||
@@ -135,8 +124,7 @@ static void test_execute_broadcasting(Device d)
|
||||
Tensor<T, NumDims, Options, Index> dst(golden.dimensions());
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -145,33 +133,30 @@ static void test_execute_broadcasting(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_chipping_rvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_chipping_rvalue(Device d) {
|
||||
auto dims = RandomDims<NumDims>(1, 10);
|
||||
Tensor<T, NumDims, Layout, Index> src(dims);
|
||||
src.setRandom();
|
||||
|
||||
#define TEST_CHIPPING(CHIP_DIM) \
|
||||
if (NumDims > (CHIP_DIM)) { \
|
||||
const auto offset = internal::random<Index>(0, dims[(CHIP_DIM)] - 1); \
|
||||
const auto expr = src.template chip<(CHIP_DIM)>(offset); \
|
||||
\
|
||||
Tensor<T, NumDims - 1, Layout, Index> golden; \
|
||||
golden = expr; \
|
||||
\
|
||||
Tensor<T, NumDims - 1, Layout, Index> dst(golden.dimensions()); \
|
||||
\
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>; \
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, \
|
||||
Vectorizable, Tiling>; \
|
||||
\
|
||||
Executor::run(Assign(dst, expr), d); \
|
||||
\
|
||||
for (Index i = 0; i < dst.dimensions().TotalSize(); ++i) { \
|
||||
VERIFY_IS_EQUAL(dst.coeff(i), golden.coeff(i)); \
|
||||
} \
|
||||
#define TEST_CHIPPING(CHIP_DIM) \
|
||||
if (NumDims > (CHIP_DIM)) { \
|
||||
const auto offset = internal::random<Index>(0, dims[(CHIP_DIM)] - 1); \
|
||||
const auto expr = src.template chip<(CHIP_DIM)>(offset); \
|
||||
\
|
||||
Tensor<T, NumDims - 1, Layout, Index> golden; \
|
||||
golden = expr; \
|
||||
\
|
||||
Tensor<T, NumDims - 1, Layout, Index> dst(golden.dimensions()); \
|
||||
\
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>; \
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>; \
|
||||
\
|
||||
Executor::run(Assign(dst, expr), d); \
|
||||
\
|
||||
for (Index i = 0; i < dst.dimensions().TotalSize(); ++i) { \
|
||||
VERIFY_IS_EQUAL(dst.coeff(i), golden.coeff(i)); \
|
||||
} \
|
||||
}
|
||||
|
||||
TEST_CHIPPING(0)
|
||||
@@ -184,46 +169,43 @@ static void test_execute_chipping_rvalue(Device d)
|
||||
#undef TEST_CHIPPING
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_chipping_lvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_chipping_lvalue(Device d) {
|
||||
auto dims = RandomDims<NumDims>(1, 10);
|
||||
|
||||
#define TEST_CHIPPING(CHIP_DIM) \
|
||||
if (NumDims > (CHIP_DIM)) { \
|
||||
/* Generate random data that we'll assign to the chipped tensor dim. */ \
|
||||
array<Index, NumDims - 1> src_dims; \
|
||||
for (int i = 0; i < NumDims - 1; ++i) { \
|
||||
int dim = i < (CHIP_DIM) ? i : i + 1; \
|
||||
src_dims[i] = dims[dim]; \
|
||||
} \
|
||||
\
|
||||
Tensor<T, NumDims - 1, Layout, Index> src(src_dims); \
|
||||
src.setRandom(); \
|
||||
\
|
||||
const auto offset = internal::random<Index>(0, dims[(CHIP_DIM)] - 1); \
|
||||
\
|
||||
Tensor<T, NumDims, Layout, Index> random(dims); \
|
||||
random.setZero(); \
|
||||
\
|
||||
Tensor<T, NumDims, Layout, Index> golden(dims); \
|
||||
golden = random; \
|
||||
golden.template chip<(CHIP_DIM)>(offset) = src; \
|
||||
\
|
||||
Tensor<T, NumDims, Layout, Index> dst(dims); \
|
||||
dst = random; \
|
||||
auto expr = dst.template chip<(CHIP_DIM)>(offset); \
|
||||
\
|
||||
using Assign = TensorAssignOp<decltype(expr), const decltype(src)>; \
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, \
|
||||
Vectorizable, Tiling>; \
|
||||
\
|
||||
Executor::run(Assign(expr, src), d); \
|
||||
\
|
||||
for (Index i = 0; i < dst.dimensions().TotalSize(); ++i) { \
|
||||
VERIFY_IS_EQUAL(dst.coeff(i), golden.coeff(i)); \
|
||||
} \
|
||||
#define TEST_CHIPPING(CHIP_DIM) \
|
||||
if (NumDims > (CHIP_DIM)) { \
|
||||
/* Generate random data that we'll assign to the chipped tensor dim. */ \
|
||||
array<Index, NumDims - 1> src_dims; \
|
||||
for (int i = 0; i < NumDims - 1; ++i) { \
|
||||
int dim = i < (CHIP_DIM) ? i : i + 1; \
|
||||
src_dims[i] = dims[dim]; \
|
||||
} \
|
||||
\
|
||||
Tensor<T, NumDims - 1, Layout, Index> src(src_dims); \
|
||||
src.setRandom(); \
|
||||
\
|
||||
const auto offset = internal::random<Index>(0, dims[(CHIP_DIM)] - 1); \
|
||||
\
|
||||
Tensor<T, NumDims, Layout, Index> random(dims); \
|
||||
random.setZero(); \
|
||||
\
|
||||
Tensor<T, NumDims, Layout, Index> golden(dims); \
|
||||
golden = random; \
|
||||
golden.template chip<(CHIP_DIM)>(offset) = src; \
|
||||
\
|
||||
Tensor<T, NumDims, Layout, Index> dst(dims); \
|
||||
dst = random; \
|
||||
auto expr = dst.template chip<(CHIP_DIM)>(offset); \
|
||||
\
|
||||
using Assign = TensorAssignOp<decltype(expr), const decltype(src)>; \
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>; \
|
||||
\
|
||||
Executor::run(Assign(expr, src), d); \
|
||||
\
|
||||
for (Index i = 0; i < dst.dimensions().TotalSize(); ++i) { \
|
||||
VERIFY_IS_EQUAL(dst.coeff(i), golden.coeff(i)); \
|
||||
} \
|
||||
}
|
||||
|
||||
TEST_CHIPPING(0)
|
||||
@@ -236,10 +218,8 @@ static void test_execute_chipping_lvalue(Device d)
|
||||
#undef TEST_CHIPPING
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_shuffle_rvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_shuffle_rvalue(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
auto dims = RandomDims<NumDims>(1, 10);
|
||||
@@ -274,10 +254,8 @@ static void test_execute_shuffle_rvalue(Device d)
|
||||
} while (std::next_permutation(&shuffle[0], &shuffle[0] + NumDims));
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_shuffle_lvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_shuffle_lvalue(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
auto dims = RandomDims<NumDims>(5, 10);
|
||||
@@ -310,10 +288,8 @@ static void test_execute_shuffle_lvalue(Device d)
|
||||
} while (std::next_permutation(&shuffle[0], &shuffle[0] + NumDims));
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_reshape(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_reshape(Device d) {
|
||||
static_assert(NumDims >= 2, "NumDims must be greater or equal than 2");
|
||||
|
||||
static constexpr int ReshapedDims = NumDims - 1;
|
||||
@@ -340,8 +316,7 @@ static void test_execute_reshape(Device d)
|
||||
auto expr = src.reshape(reshaped_dims);
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -350,10 +325,8 @@ static void test_execute_reshape(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_slice_rvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_slice_rvalue(Device d) {
|
||||
static_assert(NumDims >= 2, "NumDims must be greater or equal than 2");
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
@@ -371,8 +344,7 @@ static void test_execute_slice_rvalue(Device d)
|
||||
slice_size[i] = numext::mini(slice_size[i], dims[i] - slice_start[i]);
|
||||
}
|
||||
|
||||
Tensor<T, NumDims, Options, Index> golden =
|
||||
src.slice(slice_start, slice_size);
|
||||
Tensor<T, NumDims, Options, Index> golden = src.slice(slice_start, slice_size);
|
||||
|
||||
// Now reshape using configured tensor executor.
|
||||
Tensor<T, NumDims, Options, Index> dst(golden.dimensions());
|
||||
@@ -380,8 +352,7 @@ static void test_execute_slice_rvalue(Device d)
|
||||
auto expr = src.slice(slice_start, slice_size);
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -390,10 +361,8 @@ static void test_execute_slice_rvalue(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_slice_lvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_slice_lvalue(Device d) {
|
||||
static_assert(NumDims >= 2, "NumDims must be greater or equal than 2");
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
@@ -423,8 +392,7 @@ static void test_execute_slice_lvalue(Device d)
|
||||
auto expr = dst.slice(slice_start, slice_size);
|
||||
|
||||
using Assign = TensorAssignOp<decltype(expr), const decltype(slice)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(expr, slice), d);
|
||||
|
||||
@@ -433,10 +401,8 @@ static void test_execute_slice_lvalue(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_broadcasting_of_forced_eval(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_broadcasting_of_forced_eval(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
auto dims = RandomDims<NumDims>(1, 10);
|
||||
@@ -455,8 +421,7 @@ static void test_execute_broadcasting_of_forced_eval(Device d)
|
||||
Tensor<T, NumDims, Options, Index> dst(golden.dimensions());
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -465,10 +430,9 @@ static void test_execute_broadcasting_of_forced_eval(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T, int NumDims>
|
||||
template <typename T, int NumDims>
|
||||
struct DummyGenerator {
|
||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE
|
||||
T operator()(const array <Index, NumDims>& dims) const {
|
||||
EIGEN_DEVICE_FUNC EIGEN_ALWAYS_INLINE T operator()(const array<Index, NumDims>& dims) const {
|
||||
T result = static_cast<T>(0);
|
||||
for (int i = 0; i < NumDims; ++i) {
|
||||
result += static_cast<T>((i + 1) * dims[i]);
|
||||
@@ -477,10 +441,8 @@ struct DummyGenerator {
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_generator_op(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_generator_op(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
auto dims = RandomDims<NumDims>(20, 30);
|
||||
@@ -498,8 +460,7 @@ static void test_execute_generator_op(Device d)
|
||||
Tensor<T, NumDims, Options, Index> dst(golden.dimensions());
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -508,14 +469,12 @@ static void test_execute_generator_op(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_reverse_rvalue(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_execute_reverse_rvalue(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
auto dims = RandomDims<NumDims>(1, numext::pow(1000000.0, 1.0 / NumDims));
|
||||
Tensor <T, NumDims, Options, Index> src(dims);
|
||||
Tensor<T, NumDims, Options, Index> src(dims);
|
||||
src.setRandom();
|
||||
|
||||
// Reverse half of the dimensions.
|
||||
@@ -526,15 +485,14 @@ static void test_execute_reverse_rvalue(Device d)
|
||||
|
||||
// We assume that reversing on a default device is tested and correct, so
|
||||
// we can rely on it to verify correctness of tensor executor and tiling.
|
||||
Tensor <T, NumDims, Options, Index> golden;
|
||||
Tensor<T, NumDims, Options, Index> golden;
|
||||
golden = expr;
|
||||
|
||||
// Now do the reversing using configured tensor executor.
|
||||
Tensor <T, NumDims, Options, Index> dst(golden.dimensions());
|
||||
Tensor<T, NumDims, Options, Index> dst(golden.dimensions());
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using Executor =
|
||||
internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorExecutor<const Assign, Device, Vectorizable, Tiling>;
|
||||
|
||||
Executor::run(Assign(dst, expr), d);
|
||||
|
||||
@@ -543,10 +501,8 @@ static void test_execute_reverse_rvalue(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_async_execute_unary_expr(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_async_execute_unary_expr(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
// Pick a large enough tensor size to bypass small tensor block evaluation
|
||||
@@ -564,8 +520,7 @@ static void test_async_execute_unary_expr(Device d)
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using DoneCallback = decltype(on_done);
|
||||
using Executor = internal::TensorAsyncExecutor<const Assign, Device, DoneCallback,
|
||||
Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorAsyncExecutor<const Assign, Device, DoneCallback, Vectorizable, Tiling>;
|
||||
|
||||
Executor::runAsync(Assign(dst, expr), d, on_done);
|
||||
done.Wait();
|
||||
@@ -576,10 +531,8 @@ static void test_async_execute_unary_expr(Device d)
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable,
|
||||
TiledEvaluation Tiling, int Layout>
|
||||
static void test_async_execute_binary_expr(Device d)
|
||||
{
|
||||
template <typename T, int NumDims, typename Device, bool Vectorizable, TiledEvaluation Tiling, int Layout>
|
||||
static void test_async_execute_binary_expr(Device d) {
|
||||
static constexpr int Options = 0 | Layout;
|
||||
|
||||
// Pick a large enough tensor size to bypass small tensor block evaluation
|
||||
@@ -600,8 +553,7 @@ static void test_async_execute_binary_expr(Device d)
|
||||
|
||||
using Assign = TensorAssignOp<decltype(dst), const decltype(expr)>;
|
||||
using DoneCallback = decltype(on_done);
|
||||
using Executor = internal::TensorAsyncExecutor<const Assign, Device, DoneCallback,
|
||||
Vectorizable, Tiling>;
|
||||
using Executor = internal::TensorAsyncExecutor<const Assign, Device, DoneCallback, Vectorizable, Tiling>;
|
||||
|
||||
Executor::runAsync(Assign(dst, expr), d, on_done);
|
||||
done.Wait();
|
||||
@@ -615,39 +567,50 @@ static void test_async_execute_binary_expr(Device d)
|
||||
#ifndef EIGEN_DONT_VECTORIZE
|
||||
#define EIGEN_DONT_VECTORIZE 0
|
||||
#endif
|
||||
#define VECTORIZABLE(T, VAL) !EIGEN_DONT_VECTORIZE && Eigen::internal::packet_traits<T>::Vectorizable && VAL
|
||||
#define VECTORIZABLE(T, VAL) !EIGEN_DONT_VECTORIZE&& Eigen::internal::packet_traits<T>::Vectorizable&& VAL
|
||||
|
||||
#define CALL_SUBTEST_PART(PART) \
|
||||
CALL_SUBTEST_##PART
|
||||
#define CALL_SUBTEST_PART(PART) CALL_SUBTEST_##PART
|
||||
|
||||
#define CALL_SUBTEST_COMBINATIONS(PART, NAME, T, NUM_DIMS) \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::Off, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::On, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::On, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::Off, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::On, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::On, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, RowMajor>(tp_device)))
|
||||
#define CALL_SUBTEST_COMBINATIONS(PART, NAME, T, NUM_DIMS) \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::Off, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::On, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::On, ColMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::Off, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, DefaultDevice, false, TiledEvaluation::On, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, DefaultDevice, VECTORIZABLE(T, true), TiledEvaluation::On, RowMajor>(default_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, RowMajor>(tp_device)))
|
||||
|
||||
// NOTE: Currently only ThreadPoolDevice supports async expression evaluation.
|
||||
#define CALL_ASYNC_SUBTEST_COMBINATIONS(PART, NAME, T, NUM_DIMS) \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, RowMajor>(tp_device)))
|
||||
#define CALL_ASYNC_SUBTEST_COMBINATIONS(PART, NAME, T, NUM_DIMS) \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, ColMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART)((NAME<T, NUM_DIMS, ThreadPoolDevice, false, TiledEvaluation::On, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::Off, RowMajor>(tp_device))); \
|
||||
CALL_SUBTEST_PART(PART) \
|
||||
((NAME<T, NUM_DIMS, ThreadPoolDevice, VECTORIZABLE(T, true), TiledEvaluation::On, RowMajor>(tp_device)))
|
||||
|
||||
EIGEN_DECLARE_TEST(cxx11_tensor_executor) {
|
||||
Eigen::DefaultDevice default_device;
|
||||
|
||||
Reference in New Issue
Block a user