mirror of
https://gitlab.com/libeigen/eigen.git
synced 2025-04-30 07:44:10 +08:00
Added missing tensor copy constructors. As a result it is now possible to declare and initialize a tensor on the same line, as in:
Tensor<bla> T = A + B; or Tensor<bla> T(A.reshape(new_shape));
This commit is contained in:
parent
b24fe22b1a
commit
f50548e86a
@ -75,7 +75,7 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
IsAligned = bool(EIGEN_ALIGN) & !(Options_&DontAlign),
|
IsAligned = bool(EIGEN_ALIGN) & !(Options_&DontAlign),
|
||||||
PacketAccess = true,
|
PacketAccess = (internal::packet_traits<Scalar>::size > 1),
|
||||||
};
|
};
|
||||||
|
|
||||||
static const int Options = Options_;
|
static const int Options = Options_;
|
||||||
@ -224,12 +224,31 @@ class Tensor : public TensorBase<Tensor<Scalar_, NumIndices_, Options_> >
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
inline Tensor(const array<Index, NumIndices>& dimensions)
|
inline explicit Tensor(const array<Index, NumIndices>& dimensions)
|
||||||
: m_storage(internal::array_prod(dimensions), dimensions)
|
: m_storage(internal::array_prod(dimensions), dimensions)
|
||||||
{
|
{
|
||||||
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
|
EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Tensor(const TensorBase<OtherDerived, ReadOnlyAccessors>& other)
|
||||||
|
{
|
||||||
|
typedef TensorAssignOp<Tensor, const OtherDerived> Assign;
|
||||||
|
Assign assign(*this, other.derived());
|
||||||
|
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
|
||||||
|
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||||
|
}
|
||||||
|
template<typename OtherDerived>
|
||||||
|
EIGEN_DEVICE_FUNC
|
||||||
|
EIGEN_STRONG_INLINE Tensor(const TensorBase<OtherDerived, WriteAccessors>& other)
|
||||||
|
{
|
||||||
|
typedef TensorAssignOp<Tensor, const OtherDerived> Assign;
|
||||||
|
Assign assign(*this, other.derived());
|
||||||
|
resize(TensorEvaluator<const Assign, DefaultDevice>(assign, DefaultDevice()).dimensions());
|
||||||
|
internal::TensorExecutor<const Assign, DefaultDevice>::run(assign, DefaultDevice());
|
||||||
|
}
|
||||||
|
|
||||||
EIGEN_DEVICE_FUNC
|
EIGEN_DEVICE_FUNC
|
||||||
EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other)
|
EIGEN_STRONG_INLINE Tensor& operator=(const Tensor& other)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user