Browse Source

!181 parser one to many add original name

Merge pull request !181 from yangyongqiang/master
r1.1.1
储星 Gitee 4 years ago
parent
commit
a879159cd9
2 changed files with 29 additions and 6 deletions
  1. +25
    -4
      parser/common/parser_utils.cc
  2. +4
    -2
      parser/onnx/onnx_parser.cc

+ 25
- 4
parser/common/parser_utils.cc View File

@@ -26,6 +26,29 @@
#include "register/op_registry.h" #include "register/op_registry.h"


namespace ge { namespace ge {
namespace {
Status HandleNewOp(const NodePtr &node, const ComputeGraphPtr &compute_graph, const NodePtr &new_node) {
GE_CHECK_NOTNULL(node);
GE_CHECK_NOTNULL(new_node);
if (new_node->SetOwnerComputeGraph(compute_graph) != GRAPH_SUCCESS) {
GELOGE(FAILED, "Set owner graph for node:%s failed.", new_node->GetName().c_str());
return FAILED;
}
auto op_desc = new_node->GetOpDesc();
static std::atomic_long new_node_index(0);
auto new_name = "PartitionedCall_" + new_node->GetName() + "_" + to_string(new_node_index++);
op_desc->SetName(new_name);
bool ret = ge::AttrUtils::SetListStr(op_desc,
ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES,
std::move(std::vector<std::string>{node->GetName()}));
if (!ret) {
GELOGW("Set %s to %s fail.", ge::ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES.c_str(), op_desc->GetName().c_str());
}
GELOGD("Handle new op[%s] for node[%s] success.", new_node->GetName().c_str(), node->GetName().c_str());
return SUCCESS;
}
}

Status ParserUtils::ExpandOneToManyGraph(Graph &graph) { Status ParserUtils::ExpandOneToManyGraph(Graph &graph) {
GELOGD("Begin run ParserUtils::ExpandOneToManyGraph."); GELOGD("Begin run ParserUtils::ExpandOneToManyGraph.");
ComputeGraphPtr compute_graph = GraphUtils::GetComputeGraph(graph); ComputeGraphPtr compute_graph = GraphUtils::GetComputeGraph(graph);
@@ -66,14 +89,12 @@ Status ParserUtils::ExpandNodeToSubgraph(const Graph &subgraph, const NodePtr &n
GE_CHECK_NOTNULL(compute_graph); GE_CHECK_NOTNULL(compute_graph);


// add subgraph node to graph. // add subgraph node to graph.
std::unordered_map<std::string, NodePtr> all_new_nodes;
std::vector<NodePtr> input_nodes; std::vector<NodePtr> input_nodes;
for (const auto &n : sub_compute_graph->GetDirectNode()) { for (const auto &n : sub_compute_graph->GetDirectNode()) {
auto new_node = compute_graph->AddNode(n); auto new_node = compute_graph->AddNode(n);
GE_CHECK_NOTNULL(new_node); GE_CHECK_NOTNULL(new_node);
all_new_nodes[new_node->GetName()] = new_node;
if (new_node->SetOwnerComputeGraph(compute_graph) != GRAPH_SUCCESS) {
GELOGE(FAILED, "Set owner graph for node:%s failed.", new_node->GetName().c_str());
if (HandleNewOp(node, compute_graph, new_node) != SUCCESS) {
GELOGE(FAILED, "Handle new op[%s] for node[%s] failed.", new_node->GetName().c_str(), node->GetName().c_str());
return FAILED; return FAILED;
} }




+ 4
- 2
parser/onnx/onnx_parser.cc View File

@@ -255,9 +255,11 @@ Status OnnxModelParser::SetOperatorInputs() {
for (auto in_iter = inputs_map_.begin(); in_iter != inputs_map_.end(); in_iter++) { for (auto in_iter = inputs_map_.begin(); in_iter != inputs_map_.end(); in_iter++) {
auto out_iter = outputs_map_.find(in_iter->first); auto out_iter = outputs_map_.find(in_iter->first);
if (out_iter == outputs_map_.end()) { if (out_iter == outputs_map_.end()) {
GELOGE(INTERNAL_ERROR, "Unknown input: %s:%d in node: %s", in_iter->first.c_str(), in_iter->second[0].second,
GELOGW("Unknown input: %s:%d for node: %s, which maybe option input.",
in_iter->first.c_str(),
in_iter->second[0].second,
in_iter->second[0].first.c_str()); in_iter->second[0].first.c_str());
return INTERNAL_ERROR;
continue;
} }


std::vector<std::pair<std::string, int>> &input_node_indexs = in_iter->second; std::vector<std::pair<std::string, int>> &input_node_indexs = in_iter->second;


Loading…
Cancel
Save