Browse Source

modified: ge/graph/passes/folding_pass.cc

modified:   ge/graph/passes/unused_const_pass.cc
pull/568/head
zhaoxinxin 4 years ago
parent
commit
08b220cf8d
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

@@ -238,6 +238,14 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
node->GetName().c_str(), index); node->GetName().c_str(), index);
return INTERNAL_ERROR; 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_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, {node->GetName()});
} else {
(void)AttrUtils::SetListStr(const_desc, 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(), 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); node->GetName().c_str(), node->GetType().c_str(), index);
// add new const to re-pass node // 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."); GELOGD("op type is unused const.");
return IsolateAndDeleteNode(node, {-1}); 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; return SUCCESS;
} }
} // namespace ge } // namespace ge

Loading…
Cancel
Save