aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Eugene Zhulenev <ezhulenev@google.com>2018-08-09 09:44:07 -0700
committerGravatar Eugene Zhulenev <ezhulenev@google.com>2018-08-09 09:44:07 -0700
commitcfaedb38cd662def3b5684a20965b3bc1b0d6a3f (patch)
tree82dc639a1f91a2eebd9d1afb777945dd8830ff70
parent1c8b9e10a791cb43b4f730dcb5d7889099cc1c68 (diff)
Fix bug in a test + compilation errors
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h6
-rw-r--r--unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h8
-rw-r--r--unsupported/test/cxx11_tensor_executor.cpp2
-rw-r--r--unsupported/test/cxx11_tensor_shuffling.cpp8
4 files changed, 13 insertions, 11 deletions
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
index f11241f83..4bc18bd97 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorExecutor.h
@@ -115,6 +115,7 @@ class TensorExecutor<Expression, DefaultDevice, Vectorizable,
const DefaultDevice& device = DefaultDevice()) {
typedef TensorBlock<ScalarNoConst, StorageIndex, NumDims, Evaluator::Layout>
TensorBlock;
+ typedef typename TensorBlock::Dimensions TensorBlockDimensions;
typedef TensorBlockMapper<ScalarNoConst, StorageIndex, NumDims,
Evaluator::Layout>
TensorBlockMapper;
@@ -141,8 +142,9 @@ class TensorExecutor<Expression, DefaultDevice, Vectorizable,
evaluator.getResourceRequirements(&resources);
MergeResourceRequirements(resources, &block_shape, &block_total_size);
- TensorBlockMapper block_mapper(evaluator.dimensions(), block_shape,
- block_total_size);
+ TensorBlockMapper block_mapper(
+ TensorBlockDimensions(evaluator.dimensions()), block_shape,
+ block_total_size);
block_total_size = block_mapper.block_dims_total_size();
Scalar* data = static_cast<Scalar*>(
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
index d5b0c1237..b25c1eabc 100644
--- a/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
+++ b/unsupported/Eigen/CXX11/src/Tensor/TensorMorphing.h
@@ -520,6 +520,7 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
typedef internal::TensorBlock<ScalarNoConst, Index, NumDims, Layout>
TensorBlock;
+ typedef typename TensorBlock::Dimensions TensorBlockDimensions;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
: m_impl(op.expression(), device), m_device(device), m_dimensions(op.sizes()), m_offsets(op.startIndices())
@@ -687,7 +688,7 @@ struct TensorEvaluator<const TensorSlicingOp<StartIndices, Sizes, ArgType>, Devi
TensorBlock input_block(srcCoeff(output_block->first_coeff_index()),
output_block->block_sizes(),
output_block->block_strides(),
- Dimensions(m_inputStrides),
+ TensorBlockDimensions(m_inputStrides),
output_block->data());
m_impl.block(&input_block);
}
@@ -796,6 +797,7 @@ struct TensorEvaluator<TensorSlicingOp<StartIndices, Sizes, ArgType>, Device>
typedef internal::TensorBlock<ScalarNoConst, Index, NumDims, Layout>
TensorBlock;
+ typedef typename TensorBlock::Dimensions TensorBlockDimensions;
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE TensorEvaluator(const XprType& op, const Device& device)
: Base(op, device)
@@ -862,13 +864,11 @@ struct TensorEvaluator<TensorSlicingOp<StartIndices, Sizes, ArgType>, Device>
const TensorBlock& block) {
this->m_impl.writeBlock(TensorBlock(
this->srcCoeff(block.first_coeff_index()), block.block_sizes(),
- block.block_strides(), Dimensions(this->m_inputStrides),
+ block.block_strides(), TensorBlockDimensions(this->m_inputStrides),
const_cast<ScalarNoConst*>(block.data())));
}
};
-
-
namespace internal {
template<typename StartIndices, typename StopIndices, typename Strides, typename XprType>
struct traits<TensorStridingSlicingOp<StartIndices, StopIndices, Strides, XprType> > : public traits<XprType>
diff --git a/unsupported/test/cxx11_tensor_executor.cpp b/unsupported/test/cxx11_tensor_executor.cpp
index 448f47f1d..d16ae4d11 100644
--- a/unsupported/test/cxx11_tensor_executor.cpp
+++ b/unsupported/test/cxx11_tensor_executor.cpp
@@ -317,7 +317,7 @@ static void test_execute_reshape(Device d)
DSizes<Index, ReshapedDims> reshaped_dims;
reshaped_dims[shuffle[0]] = dims[0] * dims[1];
- for (int i = 2; i < NumDims; ++i) reshaped_dims[shuffle[i]] = dims[i];
+ for (int i = 1; i < ReshapedDims; ++i) reshaped_dims[shuffle[i]] = dims[i + 1];
Tensor<T, ReshapedDims, Options, Index> golden = src.reshape(reshaped_dims);
diff --git a/unsupported/test/cxx11_tensor_shuffling.cpp b/unsupported/test/cxx11_tensor_shuffling.cpp
index ab19b6e6b..467df39c7 100644
--- a/unsupported/test/cxx11_tensor_shuffling.cpp
+++ b/unsupported/test/cxx11_tensor_shuffling.cpp
@@ -83,10 +83,10 @@ static void test_expr_shuffling()
Tensor<float, 4, DataLayout> result(5,7,3,2);
- array<int, 4> src_slice_dim{{2,3,1,7}};
- array<int, 4> src_slice_start{{0,0,0,0}};
- array<int, 4> dst_slice_dim{{1,7,3,2}};
- array<int, 4> dst_slice_start{{0,0,0,0}};
+ array<ptrdiff_t, 4> src_slice_dim{{2,3,1,7}};
+ array<ptrdiff_t, 4> src_slice_start{{0,0,0,0}};
+ array<ptrdiff_t, 4> dst_slice_dim{{1,7,3,2}};
+ array<ptrdiff_t, 4> dst_slice_start{{0,0,0,0}};
for (int i = 0; i < 5; ++i) {
result.slice(dst_slice_start, dst_slice_dim) =