mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-07-03 11:45:12 +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 int Options = Options_;
|
||||||
|
|
||||||
static const std::size_t NumIndices = NumIndices_;
|
static const std::size_t NumIndices = NumIndices_;
|
||||||
|
|
||||||
typedef DSizes<DenseIndex, NumIndices_> Dimensions;
|
typedef DSizes<DenseIndex, NumIndices_> Dimensions;
|
||||||
@ -232,11 +233,9 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other)
|
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;
|
typedef TensorAssignOp<Tensor, const Tensor> Assign;
|
||||||
Assign assign(*this, other);
|
Assign assign(*this, other);
|
||||||
|
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
|
||||||
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -244,11 +243,9 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
|||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE Tensor& operator=(const OtherDerived& other)
|
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;
|
typedef TensorAssignOp<Tensor, const OtherDerived> Assign;
|
||||||
Assign assign(*this, other);
|
Assign assign(*this, other);
|
||||||
|
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
|
||||||
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user