mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-29 15:24:51 +08:00
The tensor assignment code now resizes the destination tensor as needed.
This commit is contained in:
parent
2116e261fb
commit
647622281e
@ -79,6 +79,7 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
||||
};
|
||||
|
||||
static const int Options = Options_;
|
||||
|
||||
static const std::size_t NumIndices = NumIndices_;
|
||||
|
||||
typedef DSizes<DenseIndex, NumIndices_> Dimensions;
|
||||
@ -232,11 +233,9 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
||||
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<Tensor, const Tensor> Assign;
|
||||
Assign assign(*this, other);
|
||||
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
|
||||
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||
return *this;
|
||||
}
|
||||
@ -244,11 +243,9 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
||||
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<Tensor, const OtherDerived> Assign;
|
||||
Assign assign(*this, other);
|
||||
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
|
||||
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||
return *this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user