未验证 提交 8d3672f0 编写于 作者: R Ruibiao Chen 提交者: GitHub

Remove ControlDepVar in GraphToBlock (#44591)

上级 1892a441
......@@ -446,6 +446,27 @@ std::vector<ir::Node *> TopologySortGraphByDescOrder(const Graph &graph) {
return ret;
}
void RemoveControlDepInputAndOuput(OpDesc *op_desc) {
auto remove_control_dep_var = [](VariableNameMap *var_name_map) {
for (auto &pair : *var_name_map) {
std::vector<std::string> &var_names = pair.second;
auto it = var_names.begin();
while (it != var_names.end()) {
if (it->find(ir::Node::kControlDepVarName) != std::string::npos) {
it = var_names.erase(it);
VLOG(6) << "Remove var " << *it;
} else {
++it;
}
}
}
};
remove_control_dep_var(op_desc->MutableInputs());
remove_control_dep_var(op_desc->MutableOutputs());
op_desc->Flush();
}
static OpDesc *ReplaceScaleLossGradOp(const Node &node, OpDesc *desc) {
desc->SetType("fill_constant");
desc->SetAttr(
......@@ -552,7 +573,9 @@ static void GraphToBlock(const Graph &graph,
std::vector<OpDesc> ops;
GetGraphOpDesc(nodes, &ops);
for (auto &op : ops) {
RemoveControlDepInputAndOuput(&op);
block->add_ops()->MergeFrom(*op.Proto());
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册