未验证 提交 ba486c5e 编写于 作者: C Chen Weihang 提交者: GitHub

Remove useless lod copy in DenseTensor::ShareDataWith (#42395)

* remove useless lod copy

* fix test failed

* revert meta change

* revert tensor change
上级 eca6638c
......@@ -371,12 +371,20 @@ dnnl::memory::format_tag DenseTensor::format() const {
}
#endif
// NOTE: For historical reasons, this interface has a special behavior,
// sharing other tensor members except lod
DenseTensor& DenseTensor::ShareDataWith(const DenseTensor& src) {
src.check_memory_size();
// Preserve LoD
auto lod = meta_.lod;
*this = src;
meta_.lod = lod;
holder_ = src.holder_;
meta_.is_scalar = src.meta_.is_scalar;
meta_.dims = src.meta_.dims;
meta_.dtype = src.meta_.dtype;
meta_.layout = src.meta_.layout;
meta_.offset = src.meta_.offset;
#ifdef PADDLE_WITH_MKLDNN
format_ = src.format_;
mem_desc_ = src.mem_desc_;
#endif
return *this;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册