Browse Source

Pre Merge pull request !568 from zhaoxinxin/development

pull/568/MERGE
zhaoxinxin Gitee 4 years ago
parent
commit
a91b8e0baa
2 changed files with 13 additions and 0 deletions
  1. +8
    -0
      ge/graph/passes/folding_pass.cc
  2. +5
    -0
      ge/graph/passes/unused_const_pass.cc

+ 8
- 0
ge/graph/passes/folding_pass.cc View File

@@ -241,6 +241,14 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
node->GetName().c_str(), index);
return INTERNAL_ERROR;
}

vector<string> curr_origin_op_names;
(void)AttrUtils::GetListStr(node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, curr_origin_op_names);
if (curr_origin_op_names.empty()) {
(void)AttrUtils::SetListStr(const_node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, {node->GetName()});
} else {
(void)AttrUtils::SetListStr(const_node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, curr_origin_op_names);
}
GELOGI("add const_node:%s, replace node %s, type %s, index %zu.", const_node->GetName().c_str(),
node->GetName().c_str(), node->GetType().c_str(), index);
// add new const to re-pass node


+ 5
- 0
ge/graph/passes/unused_const_pass.cc View File

@@ -40,6 +40,11 @@ Status UnusedConstPass::Run(NodePtr &node) {
GELOGD("op type is unused const.");
return IsolateAndDeleteNode(node, {-1});
}
// remove those const which only has control-in and control-out
if ((op_type == CONSTANT || op_type == CONSTANTOP) && (node->GetOutDataNodesSize() == 0)) {
GELOGD("Remove unused const %s.", node->GetName().c_str());
return IsolateAndDeleteNode(node, {-1});
}
return SUCCESS;
}
} // namespace ge

Loading…
Cancel
Save