未验证 提交 067d3aa0 编写于 作者: R Ruibiao Chen 提交者: GitHub

Remove IsDependency function in dependency_builder (#45658)

上级 1f2c38a0
......@@ -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<int, std::set<int>>& downstream_map) {
std::queue<int> 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<int, std::set<int>>& 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);
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册