From 067d3aa08886507dd3acc8aa26117f31ee59532e Mon Sep 17 00:00:00 2001 From: Ruibiao Chen Date: Fri, 2 Sep 2022 14:30:14 +0800 Subject: [PATCH] Remove IsDependency function in dependency_builder (#45658) --- .../interpreter/dependency_builder.cc | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/paddle/fluid/framework/new_executor/interpreter/dependency_builder.cc b/paddle/fluid/framework/new_executor/interpreter/dependency_builder.cc index 7f4b52123fb..f12fc719d49 100644 --- a/paddle/fluid/framework/new_executor/interpreter/dependency_builder.cc +++ b/paddle/fluid/framework/new_executor/interpreter/dependency_builder.cc @@ -53,33 +53,6 @@ bool IsCommunicationOp(const std::string& op_name) { return false; } -// check whether exists prior_op -> ... -> posterior_op to avoid building loops -bool IsDependency(int prior_op_idx, - int posterior_op_idx, - const std::map>& downstream_map) { - std::queue q; - q.push(prior_op_idx); - - while (!q.empty()) { - int op_idx = q.front(); - q.pop(); - - auto it = downstream_map.find(op_idx); - if (it != downstream_map.end()) { - for (int downstream_op_idx : it->second) { - if (downstream_op_idx == posterior_op_idx) { - return true; - } - - // no need for double enqueue checking since DAG is assumed - q.push(downstream_op_idx); - } - } - } - - return false; -} - const std::string StringizeDownstreamMap( const std::map>& downstream_map) { std::ostringstream oss; @@ -324,8 +297,9 @@ void DependencyBuilder::AddDependencyForReadOp() { for (size_t read_op_idx : read_ops) { for (size_t downstream_op_idx : startup_ops) { if (read_op_idx != downstream_op_idx && - !IsDependency(downstream_op_idx, read_op_idx, op_downstream_map_)) + !op_happens_before_[downstream_op_idx][read_op_idx]) { AddDownstreamOp(read_op_idx, downstream_op_idx); + } } } } -- GitLab