Browse Source

optimize duplicate value node

tags/v1.6.0
lanzhineng 4 years ago
parent
commit
6bcc9cf9bd
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      mindspore/ccsrc/transform/express_ir/mindir_exporter.cc

+ 7
- 2
mindspore/ccsrc/transform/express_ir/mindir_exporter.cc View File

@@ -554,11 +554,9 @@ bool IrExportBuilder::BuildCNode(const CNodePtr &node, mind_ir::GraphProto *cons
}

// Need to build input node before dealing with cnode
std::vector<AnfNodePtr> op_inputs;
std::vector<string> input_names;
for (size_t i = 1; i < inputs_size; i++) {
auto input = node->input(i);
op_inputs.push_back(input);
std::string node_name = BuildInputNode(input, graph_proto);
if (node_name.empty()) {
MS_LOG(ERROR) << "Build input node for " << input->DebugString() << " failed.";
@@ -612,6 +610,12 @@ bool IrExportBuilder::BuildCNode(const CNodePtr &node, mind_ir::GraphProto *cons
}

std::string IrExportBuilder::BuildInputNode(const AnfNodePtr &node, mind_ir::GraphProto *const graph_proto) {
// Return the NodeName that the node has been processed.
auto iter = node_index_map_.find(node);
if (iter != node_index_map_.end()) {
return iter->second;
}

std::string node_name = GetUniqueNodeName(node);
// FuncGraph will be added to functions and the input name is the function name.
if (IsValueNode<FuncGraph>(node)) {
@@ -620,6 +624,7 @@ std::string IrExportBuilder::BuildInputNode(const AnfNodePtr &node, mind_ir::Gra
return fg->ToString();
}
if (node->isa<ValueNode>()) {
nodeName_.insert(node_name);
// When node input is a ValueNode, need to create a Constant Node
mind_ir::NodeProto *node_proto = graph_proto->add_node();
node_proto->set_name(node_name);


Loading…
Cancel
Save