未验证 提交 65ffc3f5 编写于 作者: W Wilber 提交者: GitHub

fix error when share buffer but modify the dtype (#48666)

上级 796499fd
......@@ -68,7 +68,7 @@ void NaiveExecutor::Run() {
// According to reuse table, we share the out tensor's holder.
if (reuse_cache_.count(op.get())) {
for (auto &it : reuse_cache_[op.get()]) {
it.first->ShareBufferWith(*cluster_buffer_[it.second]);
it.first->ShareBufferWith(*cluster_buffer_[it.second], true);
}
}
......
......@@ -62,7 +62,7 @@ void clear() {
meta_.offset = 0;
}
void ShareBufferWith(const DenseTensor& tensor);
void ShareBufferWith(const DenseTensor& tensor, bool only_buffer=false);
void ShareDataTypeWith(const DenseTensor& tensor) {
meta_.dtype = tensor.meta().dtype;
......
......@@ -172,10 +172,12 @@ inline T* DenseTensor::mutable_data(const Place& place, size_t requested_size) {
requested_size));
}
void DenseTensor::ShareBufferWith(const DenseTensor& tensor) {
void DenseTensor::ShareBufferWith(const DenseTensor& tensor, bool only_buffer) {
holder_ = tensor.holder_;
meta_.offset = tensor.meta().offset;
meta_.dtype = tensor.dtype();
if (!only_buffer) {
meta_.offset = tensor.meta().offset;
meta_.dtype = tensor.dtype();
}
}
#define LEGACY_DATA_MEMBER_FUNC_INSTANTIATION(dtype) \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册