提交 2c025181 编写于 作者: H hjchen2

update

上级 7d17f2ef
......@@ -67,6 +67,15 @@ class Tensor : public TensorBase {
/*! The internal of two tensors share the same memory block. */
inline Tensor &ShareDataWith(const Tensor &src) {
src.check_memory_size();
if (holder_.get() != src.holder_.get()) {
*this = src;
}
return *this;
}
/*! The internal of two tensors share the same memory block. */
inline Tensor &ShareHolderWith(const Tensor &src) {
src.check_memory_size();
if (holder_.get() != src.holder_.get()) {
holder_ = src.holder_;
......
......@@ -131,7 +131,7 @@ void MemoryOptPass::operator()(const framework::ProgramDesc *program,
DLOG << node->name;
auto *var = scope->Var(node->name);
auto *tensor = var->template GetMutable<framework::LoDTensor>();
tensor->ShareDataWith(*reuse_tensor);
tensor->ShareHolderWith(*reuse_tensor);
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册