Skip to content

Commit 14248a6

Browse files
reyoungYang Yang(Tony)
authored andcommitted
Fix hang when input is duplicated (#10709)
1 parent d73f2bd commit 14248a6

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

paddle/fluid/framework/details/op_handle_base.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ class OpHandleBase {
7070

7171
const std::vector<VarHandleBase *> &Inputs() const { return inputs_; }
7272

73+
size_t NoDupInputSize() const {
74+
std::unordered_set<VarHandleBase *> res;
75+
for (auto *var : inputs_) {
76+
res.emplace(var);
77+
}
78+
return res.size();
79+
}
80+
7381
const std::vector<VarHandleBase *> &Outputs() const { return outputs_; }
7482

7583
protected:

paddle/fluid/framework/details/threaded_ssa_graph_executor.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ void ThreadedSSAGraphExecutor::InsertFetchOps(
174174
void ThreadedSSAGraphExecutor::InsertPendingOp(
175175
std::unordered_map<OpHandleBase *, size_t> *pending_ops,
176176
OpHandleBase *op_instance) const {
177-
pending_ops->insert({op_instance, op_instance->Inputs().size()});
177+
pending_ops->insert({op_instance, op_instance->NoDupInputSize()});
178178
}
179179

180180
void ThreadedSSAGraphExecutor::InsertPendingVar(

0 commit comments

Comments
 (0)