提交 68d91cd5 编写于 作者: S sneaxiy

add copy ctor

test=develop
上级 e02f67ef
......@@ -60,6 +60,8 @@ class DDim {
DDim() : rank_(1) { dim_[0] = 0; }
DDim(const DDim& ddim) { this->CopyFrom(ddim); }
DDim(const int* d, int n) : rank_(n) {
dynamic_dim_assign(d, dim_.GetMutable(), n);
}
......@@ -138,6 +140,12 @@ class DDim {
return *reinterpret_cast<const Dim<D>*>(p);
}
inline void CopyFrom(const DDim& ddim) {
rank_ = ddim.rank_;
PADDLE_VISIT_DDIM(rank_,
(void)(UnsafeCast<kRank>() = ddim.UnsafeCast<kRank>()));
}
friend DDim slice_ddim(const DDim& dim, int begin, int end);
friend DDim stride(const DDim& ddim);
friend DDim stride_numel(const DDim& ddim);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册