未验证 提交 4e564e48 编写于 作者: F fengjiayi 提交者: GitHub

make WriteToArrayOp supporting empty tensor input (#6030)

上级 a38c1512
...@@ -37,9 +37,15 @@ class WriteToArrayOp : public ArrayOp { ...@@ -37,9 +37,15 @@ class WriteToArrayOp : public ArrayOp {
<< " to " << offset + 1; << " to " << offset + 1;
out->resize(offset + 1); out->resize(offset + 1);
} }
auto *out_tensor = &out->at(offset); if (x_tensor.memory_size() > 0) {
CopyFrom(x_tensor, dev_ctx.GetPlace(), dev_ctx, out_tensor); auto *out_tensor = &out->at(offset);
out_tensor->set_lod(x_tensor.lod()); CopyFrom(x_tensor, dev_ctx.GetPlace(), dev_ctx, out_tensor);
out_tensor->set_lod(x_tensor.lod());
} else {
VLOG(10) << "WARNING: The input tensor 'x_tensor' holds no memory, so "
"nothing has been written to output array["
<< offset << "].";
}
} }
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册