Skip to content

Commit

Permalink
Fix hang when input is duplicated (#10709)
Browse files Browse the repository at this point in the history
  • Loading branch information
reyoung authored and Yang Yang(Tony) committed May 16, 2018
1 parent d73f2bd commit 14248a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions paddle/fluid/framework/details/op_handle_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,14 @@ class OpHandleBase {

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

size_t NoDupInputSize() const {
std::unordered_set<VarHandleBase *> res;
for (auto *var : inputs_) {
res.emplace(var);
}
return res.size();
}

const std::vector<VarHandleBase *> &Outputs() const { return outputs_; }

protected:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ void ThreadedSSAGraphExecutor::InsertFetchOps(
void ThreadedSSAGraphExecutor::InsertPendingOp(
std::unordered_map<OpHandleBase *, size_t> *pending_ops,
OpHandleBase *op_instance) const {
pending_ops->insert({op_instance, op_instance->Inputs().size()});
pending_ops->insert({op_instance, op_instance->NoDupInputSize()});
}

void ThreadedSSAGraphExecutor::InsertPendingVar(
Expand Down

0 comments on commit 14248a6

Please sign in to comment.