From 647622281e5409e617854d35450afc0cd3a4dd49 Mon Sep 17 00:00:00 2001 From: Benoit Steiner Date: Thu, 31 Jul 2014 17:39:04 -0700 Subject: The tensor assignment code now resizes the destination tensor as needed. --- unsupported/Eigen/CXX11/src/Tensor/Tensor.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'unsupported/Eigen/CXX11/src/Tensor/Tensor.h') diff --git a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h index 547bb74d1..fdbe8df4c 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/Tensor.h +++ b/unsupported/Eigen/CXX11/src/Tensor/Tensor.h @@ -79,6 +79,7 @@ class Tensor : public TensorBase > }; static const int Options = Options_; + static const std::size_t NumIndices = NumIndices_; typedef DSizes Dimensions; @@ -232,11 +233,9 @@ class Tensor : public TensorBase > EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other) { - // FIXME: we need to resize the tensor to fix the dimensions of the other. - // Unfortunately this isn't possible yet when the rhs is an expression. - // resize(other.dimensions()); typedef TensorAssignOp Assign; Assign assign(*this, other); + resize(TensorEvaluator(assign, DefaultDevice()).dimensions()); internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } @@ -244,11 +243,9 @@ class Tensor : public TensorBase > EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Tensor& operator=(const OtherDerived& other) { - // FIXME: we need to resize the tensor to fix the dimensions of the other. - // Unfortunately this isn't possible yet when the rhs is an expression. - // resize(other.dimensions()); typedef TensorAssignOp Assign; Assign assign(*this, other); + resize(TensorEvaluator(assign, DefaultDevice()).dimensions()); internal::TensorExecutor::run(assign, DefaultDevice()); return *this; } -- cgit v1.2.3