未验证 提交 118213d4 编写于 作者: W wanghuancoder 提交者: GitHub

fix 2 bug of eager (#54046)

上级 1ebac643
......@@ -141,6 +141,7 @@ std::vector<paddle::Tensor> RunBackward(
std::deque<GradNodeBase*> orig_queue;
std::unordered_map<GradNodeBase*, std::unique_ptr<GradTensorHolder>>
node_input_buffers_dict;
std::unordered_set<GradNodeBase*> visited;
for (size_t i = 0; i < tensors.size(); i++) {
const paddle::Tensor& tensor = tensors[i];
......@@ -215,6 +216,10 @@ std::vector<paddle::Tensor> RunBackward(
}
// Prepare queue, potential startup_nodes
if (visited.count(grad_node)) {
continue;
}
visited.insert(grad_node);
queue.push_back(grad_node);
}
......
......@@ -163,7 +163,7 @@ GradNodePyLayer::operator()(
{paddle::pybind::UnSafeGetTensorFromPyObject(obj)});
} else if (obj == Py_None) {
VLOG(4) << "Got None for Tensor with pos: " << i;
grad_out.push_back({});
grad_out.push_back({paddle::Tensor()});
} else {
PADDLE_THROW(phi::errors::InvalidArgument(
"We can only support Tensor or None for backward output, "
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册