Browse Source

add error msg

pull/1475/head
wangxiaotian22 4 years ago
parent
commit
e0fe73e825
14 changed files with 360 additions and 17 deletions
  1. +3
    -0
      ge/graph/passes/pass_utils.cc
  2. +104
    -0
      ge/graph/passes/same_transdata_breadth_fusion_pass.cc
  3. +5
    -1
      ge/graph/passes/save_pass.cc
  4. +25
    -0
      ge/graph/passes/set_input_output_offset_pass.cc
  5. +2
    -0
      ge/graph/passes/snapshot_pass.cc
  6. +3
    -0
      ge/graph/passes/stop_gradient_pass.cc
  7. +22
    -0
      ge/graph/passes/subexpression_migration_pass.cc
  8. +17
    -0
      ge/graph/passes/subgraph_const_migration_pass.cc
  9. +21
    -0
      ge/graph/passes/subgraph_pass.cc
  10. +20
    -0
      ge/graph/passes/switch_data_edges_bypass.cc
  11. +13
    -0
      ge/graph/passes/switch_dead_branch_elimination.cc
  12. +12
    -0
      ge/graph/passes/switch_logic_remove_pass.cc
  13. +112
    -16
      ge/graph/passes/switch_to_stream_switch_pass.cc
  14. +1
    -0
      ge/graph/passes/transop_breadth_fusion_pass.cc

+ 3
- 0
ge/graph/passes/pass_utils.cc View File

@@ -334,6 +334,9 @@ Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) {
auto father_node = out_data_anchor->GetOwnerNode();
// link father_node's in control nodes to node
if (GraphUtils::CopyInCtrlEdges(father_node, node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed",
father_node->GetName().c_str(), father_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
return SUCCESS;


+ 104
- 0
ge/graph/passes/same_transdata_breadth_fusion_pass.cc View File

@@ -71,6 +71,7 @@ OpDescPtr SameTransdataBreadthFusionPass::GetCastOp(const GeTensorDesc &in_desc,
auto cast_op = ge::OpDescUtils::GetOpDescFromOperator(node_op);
node_op.BreakConnect();
if (cast_op == nullptr) {
REPORT_INNER_ERROR("E19999", "Create Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST);
GELOGE(INTERNAL_ERROR, "new fusion cast op failed!");
return nullptr;
}
@@ -96,6 +97,8 @@ OpDescPtr SameTransdataBreadthFusionPass::GetCastOp(const GeTensorDesc &in_desc,
}
}
if (!AttrUtils::SetInt(cast_op, CAST_ATTR_DST_TYPE, static_cast<int64_t>(out_desc.GetDataType()))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set dst_type attr failed");
return nullptr;
}
@@ -204,6 +207,12 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
GELOGI("remove edge.src:%s, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::RemoveEdge(out_anchor, transdata_peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
out_anchor->GetOwnerNode()->GetName().c_str(),
out_anchor->GetOwnerNode()->GetType().c_str(), out_anchor->GetIdx(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
return GRAPH_FAILED;
@@ -211,6 +220,12 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
GELOGI("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(pre_out_anchor, transdata_peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
@@ -231,6 +246,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
GELOGD("remove edge.src:%s, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::RemoveEdge(out_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
out_anchor->GetOwnerNode()->GetName().c_str(),
out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
return GRAPH_FAILED;
@@ -240,6 +260,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(pre_out_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
@@ -249,6 +274,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
GELOGD("add edge.src node:%s, dst node:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_peer_out_control_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
transdata_peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
@@ -290,6 +320,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors
GELOGD("remove edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::RemoveEdge(out_control_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
out_control_anchor->GetOwnerNode()->GetName().c_str(),
out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove transdata control edge failed!");
return GRAPH_FAILED;
}
@@ -298,6 +333,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(pre_out_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_FAILED;
}
@@ -305,6 +345,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors
GELOGD("add edge.src:%s, dst:%s", transdata_peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_peer_out_control_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
transdata_peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_FAILED;
}
@@ -329,6 +374,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
GELOGD("remove edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::RemoveEdge(out_control_anchor, transdata_peer_in_data_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
out_control_anchor->GetOwnerNode()->GetName().c_str(),
out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove transdata control edge failed!");
return GRAPH_FAILED;
}
@@ -337,6 +387,12 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(pre_out_anchor, transdata_peer_in_data_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_data_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_FAILED;
}
@@ -344,6 +400,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
GELOGD("add edge.src:%s, dst:%s", transdata_peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_peer_out_control_anchor, transdata_peer_in_data_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
transdata_peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_FAILED;
}
@@ -460,6 +521,12 @@ graphStatus SameTransdataBreadthFusionPass::RelinkRemainTransdata(const ComputeG

GELOGI("add edge.out node %s, in node %s", head_node->GetName().c_str(), transdata_node_keep->GetName().c_str());
if (GraphUtils::AddEdge(head_node_anchor, transdata_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
head_node_anchor->GetOwnerNode()->GetName().c_str(),
head_node_anchor->GetOwnerNode()->GetType().c_str(), head_node_anchor->GetIdx(),
transdata_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge failed!out node %s, in node %s", head_node->GetName().c_str(),
transdata_node_keep->GetName().c_str());
return GRAPH_FAILED;
@@ -545,6 +612,12 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
GELOGI("add edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_out_anchor, head_node_peer_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
transdata_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_out_anchor->GetOwnerNode()->GetType().c_str(), transdata_out_anchor->GetIdx(),
head_node_peer_anchor->GetOwnerNode()->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetType().c_str(),
head_node_peer_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetName().c_str());
return GRAPH_FAILED;
@@ -562,6 +635,8 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
auto input_desc = in_op_desc->GetInputDesc(in_data_anchor->GetIdx());
CopyTensorDesc(transdata_output_desc, input_desc);
if (in_op_desc->UpdateInputDesc(in_data_anchor->GetIdx(), input_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update input:%d desc in op:%s(%s) failed", in_data_anchor->GetIdx(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(FAILED, "UpdateInputDesc fail.");
return FAILED;
}
@@ -569,6 +644,8 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
auto output_desc = in_op_desc->GetOutputDesc(output_idx);
CopyTensorDesc(transdata_output_desc, output_desc);
GE_IF_BOOL_EXEC(in_op_desc->UpdateOutputDesc(output_idx, output_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Update output:%d desc in op:%s(%s) failed", output_idx,
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(GRAPH_FAILED, "update input desc failed");
return GRAPH_FAILED);
// relink control edge
@@ -610,6 +687,13 @@ graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata(
GELOGI("remove edge.src:%s, dst:%s", transdata_peer_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_remove_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::RemoveEdge(transdata_peer_out_anchor, transdata_remove_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
transdata_peer_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_out_anchor->GetIdx(),
transdata_remove_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_remove_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_remove_in_anchor->GetIdx());
return GRAPH_FAILED;
}

@@ -642,6 +726,9 @@ graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata(
}

if (graph->RemoveNode(transdata_node_remove) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed",
transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(),
graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "remove node %s failed!", transdata_node_remove->GetName().c_str());
return GRAPH_FAILED;
}
@@ -660,6 +747,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkInControlEdge(const NodePtr &n
GELOGD("remove edge.src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_src->GetName().c_str());
if (GraphUtils::RemoveEdge(peer_out_control_anchor, node_src->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_src->GetName().c_str(), node_src->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove edge faliled!src:%s, dst:%s",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), node_src->GetName().c_str());
return GRAPH_FAILED;
@@ -667,6 +758,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkInControlEdge(const NodePtr &n
GELOGD("add edge.src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_dst->GetName().c_str());
if (GraphUtils::AddEdge(peer_out_control_anchor, node_dst->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_dst->GetName().c_str(), node_dst->GetType().c_str());
GELOGE(GRAPH_FAILED, "add edge failed!src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_dst->GetName().c_str());
return GRAPH_FAILED;
@@ -713,10 +808,16 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g

auto cast_node = graph->AddNode(cast_op_desc);
if (cast_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str(), graph->GetName().c_str());
return GRAPH_FAILED;
}
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(), cast_node->GetName().c_str());
if (GraphUtils::AddEdge(pre_out_anchor, cast_node->GetInDataAnchor(0)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(),
cast_node->GetName().c_str(), cast_node->GetType().c_str());
return GRAPH_FAILED;
}
if (i == 0) {
@@ -724,6 +825,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
}

if (!AttrUtils::SetBool(cast_op_desc, ATTR_NEED_COMPILE, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str());
GELOGE(FAILED, "SetExtAttr fail.");
return FAILED;
}
@@ -738,6 +841,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat
std::vector<std::pair<OutDataAnchorPtr, InDataAnchorPtr>> &nodes_list) {
graphStatus ret = GRAPH_SUCCESS;
if (out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid");
GELOGE(GRAPH_FAILED, "out data anchor is null!This should not happen!");
return GRAPH_FAILED;
}


+ 5
- 1
ge/graph/passes/save_pass.cc View File

@@ -47,7 +47,9 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) {
out_index.emplace_back(out_anchor->GetIdx());
ge::OpDescPtr op_desc = peer_node->GetOpDesc();
GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave),
GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); return INTERNAL_ERROR);
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kVarAttrVarIsSave,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); return INTERNAL_ERROR);
}
}
}
@@ -65,6 +67,8 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) {
for (auto &node_ptr : del_nodes) {
auto ret = graph->RemoveNode(node_ptr);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed",
node_ptr->GetName().c_str(), node_ptr->GetType().c_str(), graph->GetName().c_str());
GELOGE(ret, "GraphUtils::RemoveNodeWithoutRelink failed.");
return ret;
}


+ 25
- 0
ge/graph/passes/set_input_output_offset_pass.cc View File

@@ -54,6 +54,8 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vector<int64
std::vector<int64_t> input_offset_of_node;
input_offset_of_node = op_desc->GetInputOffset();
if (input_offset_of_node.size() < i) {
REPORT_INNER_ERROR("E19999", "Input offsets size:%zu of node:%s(%s) < index:%zu, check invalid",
input_offset_of_node.size(), op_desc->GetName().c_str(), op_desc->GetType().c_str(), i);
GELOGE(PARAM_INVALID, "not get input_offset of %zu", i);
return PARAM_INVALID;
}
@@ -77,10 +79,15 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vector<int64
int64_t relative_offset = input_offset - out_offset;
zero_copy_relative_offset.emplace_back(relative_offset);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(data_op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_BASIC_OFFSET.c_str(),
data_op_desc->GetName().c_str(), data_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED);
GE_CHK_BOOL_EXEC(
ge::AttrUtils::SetListInt(data_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
data_op_desc->GetName().c_str(), data_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED);
}
@@ -115,10 +122,15 @@ Status SetInputOutputOffsetPass::SetInputOffsetForHcom(const ge::NodePtr &node,
zero_copy_basic_offset.emplace_back(output_offset);
zero_copy_relative_offset.emplace_back(relative_offset);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(in_op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_BASIC_OFFSET.c_str(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED);
GE_CHK_BOOL_EXEC(
ge::AttrUtils::SetListInt(in_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED);
}
@@ -159,6 +171,9 @@ Status SetInputOutputOffsetPass::SetOutputOffsetForConcat(const NodePtr &node) {
output_offset_of_concat = op_desc->GetOutputOffset();
// phony_concat has one output
GE_IF_BOOL_EXEC(output_offset_of_concat.size() != 1,
REPORT_INNER_ERROR("E19999", "Output offsets size:%zu of node:%s(%s) not equal to 1, check invalid",
output_offset_of_concat.size(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "%s should has one output.", node->GetName().c_str());
return PARAM_INVALID);
NodePtr net_output = node->GetOutDataNodes().at(0);
@@ -186,9 +201,14 @@ Status SetInputOutputOffsetPass::SetOutputOffsetForConcat(const NodePtr &node) {
zero_copy_relative_offset.emplace_back(relative_offset);
}
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_BASIC_OFFSET.c_str(),
out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED);
return SUCCESS;
@@ -232,9 +252,14 @@ Status SetInputOutputOffsetPass::SetOutputOffsetForHcom(const NodePtr &node, con
}

GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_BASIC_OFFSET.c_str(),
out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED);
return SUCCESS;


+ 2
- 0
ge/graph/passes/snapshot_pass.cc View File

@@ -29,6 +29,8 @@ Status SnapshotPass::Run(NodePtr &node) {
string type;
Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(status_ret, "SnapshotPass get original type failed.");
return status_ret;
}


+ 3
- 0
ge/graph/passes/stop_gradient_pass.cc View File

@@ -20,12 +20,15 @@
namespace ge {
Status StopGradientPass::Run(NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
return FAILED;
}
string type;
Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(status_ret, "StopGradientPass get original type failed.");
return status_ret;
}


+ 22
- 0
ge/graph/passes/subexpression_migration_pass.cc View File

@@ -144,6 +144,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap
for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str());
GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH;
}
@@ -156,6 +158,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap

uint32_t parent_index = 0;
if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str());
return FAILED;
}
@@ -229,6 +233,7 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
const auto &data_nodes = it->second;
auto data_it = data_nodes.find(node_idx);
if (data_it == data_nodes.end()) {
REPORT_INNER_ERROR("E19999", "Find node in data_nodes by index:%u failed", node_idx);
GELOGE(FAILED, "Data: %s not fount, index: %u", base_node->GetName().c_str(), node_idx);
return false;
}
@@ -238,12 +243,15 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
const auto &in_anchors = out_anchor->GetPeerInDataAnchors();
const auto &in_anchor = in_anchors.at(anchor_idx);
if (in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)",
node_idx, kDataOutIndex, work_data->GetName().c_str(), work_data->GetType().c_str());
GELOGE(FAILED, "Data anchor size: %u, anchor size: %zu", anchor_idx, in_anchors.size());
return false;
}

const auto &work_node = in_anchor->GetOwnerNode();
if (work_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner node of anchor is nullptr, check invalid");
GELOGE(FAILED, "Data: %s not found, index: %u", base_node->GetName().c_str(), node_idx);
return false;
}
@@ -338,17 +346,22 @@ Status SubexpressionMigrationPass::AppendParallelNode(map<ComputeGraphPtr, map<u
OpDescBuilder op_builder(data_name, DATA);
const OpDescPtr op_desc = op_builder.AddInput("x").AddOutput("y").Build();
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA);
GELOGE(OUT_OF_MEMORY, "Create multi-batch case desc failed");
return OUT_OF_MEMORY;
}

uint32_t data_index = item.second - kCaseInputBase;
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED;
}

if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, item.second)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED;
}
@@ -392,12 +405,14 @@ Status SubexpressionMigrationPass::DetachParallelNode(const map<uint32_t, NodePt
for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) {
auto it_idx = outputs.find(i);
if (it_idx == outputs.end()) {
REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i);
return FAILED;
}

auto it_data = graph_datas.find(it_idx->second);
if (it_data == graph_datas.end()) {
REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i);
return FAILED;
}
@@ -444,6 +459,7 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra
for (uint32_t i = 0; i < attach->GetAllInDataAnchorsSize(); ++i) {
auto it_idx = inputs.find(i);
if (it_idx == inputs.end()) {
REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", attach->GetName().c_str(), i);
GELOGE(FAILED, "Node: %s parent index %u not found", attach->GetName().c_str(), i);
return FAILED;
}
@@ -505,6 +521,7 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
uint32_t anchor_idx, const map<uint32_t, uint32_t> &inputs,
const map<uint32_t, uint32_t> &outputs) {
if (inputs.empty()) {
REPORT_INNER_ERROR("E19999", "Param inputs is empty, check invalid");
GELOGE(FAILED, "Graph: %s, inputs is empty", graph->GetName().c_str());
return FAILED;
}
@@ -516,6 +533,8 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
const auto &subnodes = groups.second;
auto it = subnodes.find(base_index);
if (it == subnodes.end()) {
REPORT_INNER_ERROR("E19999", "Index:%u data node not found in graph:%s, check invalid",
base_index, subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Data: %u node not found", subgraph->GetName().c_str(), base_index);
return FAILED;
}
@@ -525,12 +544,15 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
const auto &in_anchors = out_anchor->GetPeerInDataAnchors();
const auto &in_anchor = in_anchors.at(anchor_idx);
if (in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)",
anchor_idx, kDataOutIndex, base_data->GetName().c_str(), base_data->GetType().c_str());
GELOGE(FAILED, "Data anchor index: %u, anchor size: %zu", anchor_idx, in_anchors.size());
return FAILED;
}

move_node = in_anchor->GetOwnerNode();
if (move_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner node of anchor is nullptr, check invalid");
GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), base_index);
return FAILED;
}


+ 17
- 0
ge/graph/passes/subgraph_const_migration_pass.cc View File

@@ -141,6 +141,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str());
GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH;
}
@@ -152,6 +154,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
if (node->GetType() == DATA) {
uint32_t parent_index = kInvalidParent;
if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}

@@ -326,17 +330,22 @@ Status SubgraphConstMigrationPass::AppendParallelNode(const NodePtr &func_node,
OpDescBuilder op_builder(data_name, DATA);
const auto op_desc = op_builder.AddInput("x").AddOutput("y").Build();
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA);
GELOGE(OUT_OF_MEMORY, "Create multi-batch subgraph data desc failed");
return OUT_OF_MEMORY;
}

uint32_t data_index = parent_index - kCaseInputBase;
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED;
}

if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED;
}
@@ -460,6 +469,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
const map<ComputeGraphPtr, map<uint32_t, NodePtr>> &all_data_nodes,
const string &node_key, uint32_t parent_index) {
if (node_key.empty() || parent_index == kInvalidParent) {
REPORT_INNER_ERROR("E19999", "Param node_key is empty or param parent_index is 0x%X, check invalid",
kInvalidParent);
GELOGE(FAILED, "Graph: %s, node key: %s, parent index: %u invalid",
graph->GetName().c_str(), node_key.c_str(), parent_index);
return FAILED;
@@ -470,6 +481,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
const auto &subgraph = item.first;
const auto it_const = item.second.find(node_key);
if (it_const == item.second.end()) {
REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
return FAILED;
}
@@ -477,11 +490,15 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph

const auto it_nodes = all_data_nodes.find(subgraph);
if (it_nodes == all_data_nodes.end()) {
REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
return FAILED;
}
const auto it_data = it_nodes->second.find(parent_index);
if (it_data == it_nodes->second.end()) {
REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
return FAILED;
}


+ 21
- 0
ge/graph/passes/subgraph_pass.cc View File

@@ -94,6 +94,8 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP

uint32_t parent_index = 0;
if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Get attr PARENT_NODE_INDEX failed, node:%s.", node->GetName().c_str());
return FAILED;
}
@@ -208,6 +210,8 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
// index of body_subgraph is 1
ComputeGraphPtr while_body = NodeUtils::GetSubgraph(*node, 1);
if (while_body == nullptr) {
REPORT_INNER_ERROR("E19999", "While_body of node:%s(%s) is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "while_body of %s is NULL.", node->GetName().c_str());
return FAILED;
}
@@ -242,12 +246,16 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
if (output_node == nullptr) {
output_node = n;
} else {
REPORT_INNER_ERROR("E19999", "While_body graph:%s exists multi NetOutput nodes, check invalid",
while_body->GetName().c_str());
GELOGE(FAILED, "while_body %s exists multi NetOutput nodes.", while_body->GetName().c_str());
return FAILED;
}
}
}
if (output_node == nullptr) {
REPORT_INNER_ERROR("E19999", "While_body graph:%s has no output, check invalid",
while_body->GetName().c_str());
GELOGE(FAILED, "while_body %s has no output.", while_body->GetName().c_str());
return FAILED;
}
@@ -462,6 +470,10 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat
(void)AttrUtils::SetBool(op_desc, ATTR_NO_NEED_CONSTANT_FOLDING, false);
(void)AttrUtils::SetBool(op_desc, ATTR_NAME_CANNOT_BE_DELETED, true);
if (GraphUtils::InsertNodeAfter(out_anchor, in_anchors, graph->AddNode(op_desc)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Insert Cast node %s(%s) after %s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(),
out_anchor->GetOwnerNode()->GetName().c_str(),
out_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(FAILED, "Insert IDENTITY node %s after %s failed.", name.c_str(), in_node->GetName().c_str());
return FAILED;
}
@@ -481,6 +493,9 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat
Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::vector<InDataAnchorPtr> &dsts,
const NodePtr &insert_node, uint32_t input_index, uint32_t output_index) {
if (GraphUtils::AddEdge(src, insert_node->GetInDataAnchor(input_index)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed",
src->GetOwnerNode()->GetName().c_str(), src->GetOwnerNode()->GetType().c_str(), src->GetIdx(),
insert_node->GetName().c_str(), insert_node->GetType().c_str(), input_index);
GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.",
src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index);
return FAILED;
@@ -490,6 +505,12 @@ Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::v
dst->GetOwnerNode()->GetName().c_str());
if ((GraphUtils::RemoveEdge(src, dst) != GRAPH_SUCCESS) ||
(GraphUtils::AddEdge(insert_node->GetOutDataAnchor(output_index), dst) != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) or "
"Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed",
src->GetOwnerNode()->GetName().c_str(), src->GetOwnerNode()->GetType().c_str(), src->GetIdx(),
dst->GetOwnerNode()->GetName().c_str(), dst->GetOwnerNode()->GetType().c_str(), dst->GetIdx(),
insert_node->GetName().c_str(), insert_node->GetType().c_str(), output_index,
dst->GetOwnerNode()->GetName().c_str(), dst->GetOwnerNode()->GetType().c_str(), dst->GetIdx());
GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.",
src->GetOwnerNode()->GetName().c_str(), src->GetIdx(),
dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx(),


+ 20
- 0
ge/graph/passes/switch_data_edges_bypass.cc View File

@@ -50,6 +50,8 @@ bool IsSwitchInWhileLoop(const NodePtr &node) {
std::vector<std::pair<NodePtr, InDataAnchorPtr>> GetOutDataNodesByIndex(const NodePtr &node, int index) {
auto out_anchor = node->GetOutDataAnchor(index);
if (out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d out data anchor, check invalid",
node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(PARAM_INVALID, "Failed to get out data nodes of index %d from node %s, the anchor does not exists", index,
node->GetName().c_str());
return {};
@@ -84,18 +86,23 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {

auto node_desc = node->GetOpDesc();
if (node_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to add identity after node %s index %d, the op desc is null",
node->GetName().c_str(), index);
return nullptr;
}
auto tensor = node_desc->GetOutputDescPtr(index);
if (tensor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d output tensor, check invalid",
node_desc->GetName().c_str(), node_desc->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Failed to find the tensor by index %d from node %s, can not add the identity node", index,
node->GetName().c_str());
return nullptr;
}
auto anchor = node->GetOutDataAnchor(index);
if (anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d out data anchor, check invalid",
node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d, the out anchor does not exists",
node->GetName().c_str(), index);
return nullptr;
@@ -104,6 +111,7 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {
auto identity_opdesc =
MakeShared<OpDesc>("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY);
if (identity_opdesc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index);
return nullptr;
}
@@ -111,6 +119,9 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {
auto ret2 = identity_opdesc->AddOutputDesc("y", *tensor);
auto identity = node->GetOwnerComputeGraph()->AddNode(identity_opdesc);
if (ret1 != GRAPH_SUCCESS || ret2 != GRAPH_SUCCESS || identity == nullptr) {
REPORT_CALL_ERROR("E19999", "Add input ouput desc to op:%s(%s) failed or add it to graph:%s failed",
identity_opdesc->GetName().c_str(), identity_opdesc->GetType().c_str(),
node->GetOwnerComputeGraph()->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index);
return nullptr;
}
@@ -124,18 +135,23 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) {

auto node_desc = node->GetOpDesc();
if (node_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, null op desc", node->GetName().c_str(),
index);
return nullptr;
}
auto tensor = node_desc->GetInputDescPtr(index);
if (tensor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d input tensor, check invalid",
node_desc->GetName().c_str(), node_desc->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Failed to find the tensor by index %d from node %s, can not add the memcpy node", index,
node->GetName().c_str());
return nullptr;
}
auto anchor = node->GetInDataAnchor(index);
if (anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d in data anchor, check invalid",
node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, the in anchor does not exists",
node->GetName().c_str(), index);
return nullptr;
@@ -143,6 +159,7 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) {

auto memcpy_opdesc = MakeShared<OpDesc>("SwitchDataEdgesByPass_Memcpy_" + std::to_string(counter), MEMCPYASYNC);
if (memcpy_opdesc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Failed to add memcpy before node %s index %d", node->GetName().c_str(), index);
return nullptr;
}
@@ -150,6 +167,9 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) {
auto ret2 = memcpy_opdesc->AddOutputDesc(*tensor);
auto memcpy_node = node->GetOwnerComputeGraph()->AddNode(memcpy_opdesc);
if (ret1 != GRAPH_SUCCESS || ret2 != GRAPH_SUCCESS || memcpy_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add input ouput desc to op:%s(%s) failed or add it to graph:%s failed",
memcpy_opdesc->GetName().c_str(), memcpy_opdesc->GetType().c_str(),
node->GetOwnerComputeGraph()->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Failed to add memcpy before node %s index %d", node->GetName().c_str(), index);
return nullptr;
}


+ 13
- 0
ge/graph/passes/switch_dead_branch_elimination.cc View File

@@ -31,6 +31,7 @@ const int kDefaultInputIndex = -1;

bool ParsePred(const ConstGeTensorPtr &tensor) {
if (tensor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param tensor is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
return false;
}
@@ -65,6 +66,8 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA
OutDataAnchorPtr &inactive_out_data_anchor) {
auto tensors = OpDescUtils::MutableWeights(pred_node);
if (tensors.empty()) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no weight, check invalid",
pred_node->GetName().c_str(), pred_node->GetType().c_str());
return false;
}

@@ -72,6 +75,7 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA
int inactive_output_index = pred_value ? 0 : 1;

if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
return false;
}
@@ -91,6 +95,7 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA
Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pred_node,
const OutDataAnchorPtr &active_out_data_anchor) {
if (node == nullptr || active_out_data_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node or active_out_data_anchor is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
return FAILED;
}
@@ -102,6 +107,9 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre

// link pred's in control nodes to switch
if (GraphUtils::CopyInCtrlEdges(pred_node, node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed",
pred_node->GetName().c_str(), pred_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
// Remove link between pred and switch
@@ -114,6 +122,8 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre
std::vector<int> switch_io_map = {kDefaultInputIndex, kDefaultInputIndex};
size_t out_index = static_cast<size_t>(active_out_data_anchor->GetIdx());
if (out_index >= switch_io_map.size()) {
REPORT_INNER_ERROR("E19999", "Out index:%zu of node:%s(%s) >= %zu, check invalid", out_index,
node->GetName().c_str(), node->GetType().c_str(), switch_io_map.size());
GELOGE(FAILED, "[%s] out index check failed, out_index:%zu.", node->GetName().c_str(), out_index);
return FAILED;
}
@@ -123,6 +133,7 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre

Status SwitchDeadBranchElimination::Run(NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Param [node] must not be null.");
return PARAM_INVALID;
}
@@ -168,6 +179,8 @@ Status SwitchDeadBranchElimination::Run(NodePtr &node) {
std::vector<NodePtr> end_nodes;
Status ret = PassUtils::RemoveInactiveBranchToMerge(inactive_out_data_anchor, del_nodes, end_nodes);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove inactive branch from node:%s(%s) to merge failed",
node->GetName().c_str(), node->GetType().c_str());
return ret;
}



+ 12
- 0
ge/graph/passes/switch_logic_remove_pass.cc View File

@@ -45,11 +45,15 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index)
GE_CHECK_NOTNULL(switch_node);
auto pred_in_anchor = switch_node->GetInDataAnchor(kSwitchPredIndex);
if (pred_in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d in data anchor, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex);
GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, no pred anchor", switch_node->GetName().c_str());
return INTERNAL_ERROR;
}
auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor();
if (pred_node_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d in data anchor, its peer anchor is nullptr, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex);
GELOGE(INTERNAL_ERROR,
"Failed to get pred node for switch %s, node peer out anchor",
switch_node->GetName().c_str());
@@ -57,6 +61,8 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index)
}
auto pred_node = pred_node_anchor->GetOwnerNode();
if (pred_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d in data anchor, its peer node is nullptr, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex);
GELOGE(INTERNAL_ERROR,
"Failed to get pred node for switch %s, null node",
switch_node->GetName().c_str());
@@ -89,11 +95,15 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) {
}
for (auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
if (in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d out data anchor, its peer anchors has nullptr, "
"check invalid", node->GetName().c_str(), node->GetType().c_str(), i);
GELOGE(INTERNAL_ERROR, "The in-anchor from out anchor %d node %s is null", i, node->GetName().c_str());
return INTERNAL_ERROR;
}
auto dst_node = in_anchor->GetOwnerNode();
if (dst_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d out data anchor, its peer nodes has nullptr, "
"check invalid", node->GetName().c_str(), node->GetType().c_str(), i);
GELOGE(INTERNAL_ERROR, "The peer node from out anchor %d node %s is null", i, node->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -143,6 +153,8 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt
std::vector<NodePtr> end_nodes;
auto ret = PassUtils::RemoveInactiveBranchToMerge(out_anchor, deleted_nodes, end_nodes);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove inactive branch from node:%s(%s) to merge failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str());
return ret;
}



+ 112
- 16
ge/graph/passes/switch_to_stream_switch_pass.cc View File

@@ -33,8 +33,14 @@ Status SwitchToStreamSwitchPass::Run(ComputeGraphPtr graph) {
GE_CHK_STATUS_RET(CombineSwitchNode(graph), "Combine StreamSwitch nodes failed.");

for (const auto &node : bypass_nodes_) {
GE_CHK_BOOL_EXEC(graph->IsolateNode(node) == GRAPH_SUCCESS, return FAILED, "Isolate node failed.");
GE_CHK_BOOL_EXEC(GraphUtils::RemoveNodeWithoutRelink(graph, node) == GRAPH_SUCCESS, return FAILED,
GE_CHK_BOOL_EXEC(graph->IsolateNode(node) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED, "Isolate node failed.");
GE_CHK_BOOL_EXEC(GraphUtils::RemoveNodeWithoutRelink(graph, node) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED,
"Remove switch node failed.");
}

@@ -159,7 +165,11 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc();
GE_CHECK_NOTNULL(cond_desc);
DataType cond_data_type = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx()).GetDataType();
GE_CHK_BOOL_EXEC(cond_data_type == DT_BOOL, return FAILED,
GE_CHK_BOOL_EXEC(cond_data_type == DT_BOOL,
REPORT_INNER_ERROR("E19999", "Pred_input of Switch node:%s(%s) only support DT_BOOL data_type, "
"but %s exactly", switch_node->GetName().c_str(), switch_node->GetType().c_str(),
TypeUtils::DataTypeToSerialString(cond_data_type).c_str());
return FAILED,
"pred_input of Switch only support DT_BOOL data_type, but %s exactly.",
TypeUtils::DataTypeToSerialString(cond_data_type).c_str());

@@ -176,6 +186,8 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
stream_switch = CreateStreamSwitchNode(graph, switch_node, true_branch_flag ? "_t" : "_f", peer_cond_anchor);
GE_CHK_BOOL_EXEC(stream_switch != nullptr, return FAILED, "Create stream_switch node failed.");
if (SetSwitchTrueBranchFlag(stream_switch, true_branch_flag) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set switch true branch flag from node:%s(%s) failed",
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "SetSwitchTrueBranchFlag for node %s failed.", stream_switch->GetName().c_str());
return FAILED;
}
@@ -204,6 +216,8 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
MoveCtrlEdges(switch_node, stream_switch);
switch_node_map_[stream_switch] = out_node_list;
if (SetOriginalNodeName(stream_switch, switch_node->GetName()) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set original node name:%s to node:%s(%s) failed", switch_node->GetName().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "SetOriginalNodeName for node %s failed.", stream_switch->GetName().c_str());
return FAILED;
}
@@ -230,6 +244,10 @@ Status SwitchToStreamSwitchPass::BypassSwitchNode(const NodePtr &switch_node, Ou
GE_CHECK_NOTNULL(peer_out_anchor);
// Remove Switch data input.
if (GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed",
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx(),
switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx);
GELOGE(FAILED, "Remove data edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
switch_node->GetName().c_str());
return FAILED;
@@ -284,8 +302,13 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
const std::string &suffix,
const OutDataAnchorPtr &peer_cond_anchor) {
OpDescPtr switch_op_desc = switch_node->GetOpDesc();
GE_CHK_BOOL_EXEC(switch_op_desc != nullptr, return nullptr, "OpDesc of Switch node is invalid.");
GE_CHK_BOOL_EXEC(switch_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
return nullptr, "OpDesc of Switch node is invalid.");
GE_IF_BOOL_EXEC(switch_op_desc->GetInputsSize() != SWITCH_INPUT_NUM, {
REPORT_INNER_ERROR("E19999", "Input desc size:%zu of node:%s(%s) not equal to %u, check invalid",
switch_op_desc->GetInputsSize(),
switch_op_desc->GetName().c_str(), switch_op_desc->GetType().c_str(), SWITCH_INPUT_NUM);
GELOGE(FAILED, "Switch input param invalid, input_size=%lu, should be %u.", switch_op_desc->GetInputsSize(),
SWITCH_INPUT_NUM);
return nullptr;
@@ -295,6 +318,7 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
GELOGI("Create StreamSwitch, name=%s.", node_name.c_str());
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, STREAMSWITCH);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamSwitch:%s.", node_name.c_str());
return nullptr;
}
@@ -316,6 +340,9 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &

if (!AttrUtils::SetInt(op_desc, ATTR_NAME_SWITCH_DATA_TYPE, RT_SWITCH_INT32) ||
!AttrUtils::SetInt(op_desc, ATTR_NAME_STREAM_SWITCH_COND, (int64_t)RT_EQUAL)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s or Attr:%s to op:%s(%s) failed",
ATTR_NAME_SWITCH_DATA_TYPE.c_str(), ATTR_NAME_STREAM_SWITCH_COND.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set int failed");
return nullptr;
}
@@ -323,13 +350,22 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
// Already checked, first input is Variable will passed, second is condition will checked.
GeTensorDesc cond_input_desc = switch_op_desc->GetInputDesc(SWITCH_PRED_INPUT);
GeTensorDesc input_desc(GeShape(cond_input_desc.GetShape().GetDims()), cond_input_desc.GetFormat(), DT_INT32);
GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(input_desc) == GRAPH_SUCCESS, return nullptr,
GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(input_desc) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"Create StreamSwitch node: add input desc failed.");
GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(input_desc) == GRAPH_SUCCESS, return nullptr,
GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(input_desc) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr,
"Create StreamSwitch node: add input desc failed.");

NodePtr stream_switch = graph->AddNode(op_desc);
GE_CHK_BOOL_EXEC(stream_switch != nullptr, return nullptr, "Insert StreamSwitch node failed.");
GE_CHK_BOOL_EXEC(stream_switch != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr, "Insert StreamSwitch node failed.");
GE_CHK_STATUS(GraphUtils::AddEdge(peer_cond_anchor, stream_switch->GetInDataAnchor(0)),
"StreamSwitch node add cond edge failed.");

@@ -361,6 +397,8 @@ Status SwitchToStreamSwitchPass::MarkBranches(const OutDataAnchorPtr &peer_cond_
it->second[switch_group_id] = switch_list;
} else {
GE_IF_BOOL_EXEC(switch_group_it->second.size() != SWITCH_OUTPUT_NUM, {
REPORT_INNER_ERROR("E19999", "switch group size:%zu not equal to %u, group_id:%ld, check invalid",
switch_group_it->second.size(), SWITCH_OUTPUT_NUM, switch_group_id);
GELOGE(INTERNAL_ERROR, "Check size failed, node: %s", stream_switch->GetName().c_str());
return FAILED;
});
@@ -443,6 +481,8 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph)
GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()),
"StreamActive add ctl edge failed.");
if (SetActiveLabelList(active_node, { cast_node->GetName() }) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(FAILED, "Set active_label_list attr for node %s failed.", active_node->GetName().c_str());
return FAILED;
}
@@ -456,7 +496,13 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph)
// select first stream_switch
NodePtr stream_switch = switch_list.front();
// set stream_label
GE_CHK_STATUS_RET(SetStreamLabel(stream_switch, cast_node->GetName()), "Set stream label failed.");
if (SetStreamLabel(stream_switch, cast_node->GetName()) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
cast_node->GetName().c_str(), stream_switch->GetName().c_str(),
stream_switch->GetType().c_str());
GELOGE(FAILED, "Set stream label failed.");
return FAILED;
}
OpDescPtr switch_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc);
switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f")));
@@ -497,18 +543,27 @@ NodePtr SwitchToStreamSwitchPass::CreateActiveNode(const ComputeGraphPtr &graph,
GELOGI("Create StreamActive op:%s.", node_name.c_str());
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, STREAMACTIVE);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamActive:%s.", node_name.c_str());
return nullptr;
}

NodePtr active_node = graph->AddNode(op_desc);
GE_CHK_BOOL_EXEC(active_node != nullptr, return nullptr, "Create StreamActive node failed.");
GE_CHK_BOOL_EXEC(active_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr, "Create StreamActive node failed.");

GE_IF_BOOL_EXEC(GraphUtils::AddEdge(node->GetOutControlAnchor(), active_node->GetInControlAnchor()) != SUCCESS,
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add edge failed");
return nullptr);

GE_IF_BOOL_EXEC(SetSwitchBranchNodeLabel(active_node, node_name) != SUCCESS,
REPORT_CALL_ERROR("E19999", "Set switch branch node label:%s to node:%s(%s) failed",
node_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set switch branch node label failed");
return nullptr);

@@ -529,6 +584,7 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con
GELOGI("Create cast_node: %s, input datatype:DT_BOOL, out datatype:DT_INT32", cast_name.c_str());
OpDescPtr cast_desc = MakeShared<OpDesc>(cast_name, CAST);
if (cast_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Cast:%s.", cast_name.c_str());
return nullptr;
}
@@ -536,6 +592,10 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con
AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, (int64_t)DT_INT32) &&
AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, (int64_t)DT_INT32) &&
AttrUtils::SetBool(cast_desc, CAST_ATTR_TRUNCATE, false))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s or %s or %s or %s to op:%s(%s) failed",
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(),
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(),
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
GELOGE(FAILED, "Set CAST_ATTR_SRCT or CAST_ATTR_DSTT or CAST_ATTR_DST_TYPE or CAST_ATTR_TRUNCATE failed, node: %s.",
cast_name.c_str());
return nullptr;
@@ -543,14 +603,24 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con

GeTensorDesc tensor_desc = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx());
tensor_desc.SetDataType(DT_BOOL);
GE_CHK_BOOL_EXEC(cast_desc->AddInputDesc(tensor_desc) == SUCCESS, return nullptr,
GE_CHK_BOOL_EXEC(cast_desc->AddInputDesc(tensor_desc) == SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
return nullptr,
"Cast_node add input desc failed.");
tensor_desc.SetDataType(DT_INT32);
GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS, return nullptr,
GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
return nullptr,
"Cast_node add output desc failed.");

NodePtr cast_node = graph->AddNode(cast_desc);
GE_CHK_BOOL_EXEC(cast_node != nullptr, return nullptr, "Create cast_node failed.");
GE_CHK_BOOL_EXEC(cast_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(),
graph->GetName().c_str());
return nullptr, "Create cast_node failed.");
// Cast node has and only has one input
GE_CHK_STATUS(GraphUtils::AddEdge(peer_cond_anchor, cast_node->GetInDataAnchor(0)), "Cast add data edge failed.");

@@ -567,13 +637,18 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons
OpDescPtr op_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(op_desc);
bool value = false;
GE_CHK_BOOL_EXEC(AttrUtils::GetBool(op_desc, ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, value), return FAILED,
GE_CHK_BOOL_EXEC(AttrUtils::GetBool(op_desc, ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, value),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed",
ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED,
"StreamSwitch get attr TRUE_BRANCH_STREAM failed.");

const std::string &const_node_name = op_desc->GetName() + "_Constant_" + (value ? "t" : "f");
GELOGI("Create const op: %s", const_node_name.c_str());
OpDescPtr const_op_desc = MakeShared<OpDesc>(const_node_name, CONSTANT);
if (const_op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Constant:%s.", const_node_name.c_str());
return FAILED;
}
@@ -583,15 +658,26 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons
GeTensorPtr const_value =
MakeShared<GeTensor>(data_desc, reinterpret_cast<uint8_t *>(&resize_value), sizeof(int32_t));
if (const_value == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "Create tensor failed.");
return FAILED;
}
GE_CHK_BOOL_EXEC(AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value), return FAILED);
GE_CHK_BOOL_EXEC(const_op_desc->AddOutputDesc(data_desc) == GRAPH_SUCCESS, return FAILED,
GE_CHK_BOOL_EXEC(AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return FAILED);
GE_CHK_BOOL_EXEC(const_op_desc->AddOutputDesc(data_desc) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return FAILED,
"Create Const op: add output desc failed.");

NodePtr const_node = graph->AddNode(const_op_desc);
GE_CHK_BOOL_EXEC(const_node != nullptr, return FAILED, "Insert Const node failed.");
GE_CHK_BOOL_EXEC(const_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str(),
graph->GetName().c_str());
return FAILED, "Insert Const node failed.");
GE_CHK_STATUS(GraphUtils::AddEdge(const_node->GetOutDataAnchor(0), stream_switch->GetInDataAnchor(1)),
"StreamSwitch node add ctl edge failed.");

@@ -613,6 +699,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no
OpDescPtr switch_desc = switch_node->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc);
if (!AttrUtils::GetStr(switch_desc, ATTR_NAME_ORIG_NODE_NAME, orig_switch_name) || orig_switch_name.empty()) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(),
switch_desc->GetName().c_str(), switch_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ORIG_NODE_NAME failed, node: %s", switch_desc->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -634,6 +722,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no

auto find_res1 = switch_node_map_.find(in_ctrl_node);
GE_IF_BOOL_EXEC(find_res1 == switch_node_map_.end(), {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid",
in_ctrl_node->GetName().c_str(), in_ctrl_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", in_ctrl_node->GetName().c_str());
return INTERNAL_ERROR;
});
@@ -662,10 +752,14 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
stream_switch->GetName().c_str(), active_node->GetName().c_str());
auto find_res = switch_node_map_.find(switch_node);
GE_IF_BOOL_EXEC(find_res == switch_node_map_.end(), {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", switch_node->GetName().c_str());
return INTERNAL_ERROR;
});
GE_IF_BOOL_EXEC(find_res->second.empty(), {
REPORT_INNER_ERROR("E19999", "True_nodes of StreamSwitch node:%s(%s) is empty, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "true_nodes of StreamSwitch node %s is empty.", switch_node->GetName().c_str());
return INTERNAL_ERROR;
});
@@ -678,6 +772,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
std::string orig_name = op_desc->GetName();
GE_IF_BOOL_EXEC(op_desc->HasAttr(ATTR_NAME_ORIG_NODE_NAME), {
if (!AttrUtils::GetStr(op_desc, ATTR_NAME_ORIG_NODE_NAME, orig_name) || orig_name.empty()) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ORIG_NODE_NAME failed, node: %s.", op_desc->GetName().c_str());
return INTERNAL_ERROR;
}


+ 1
- 0
ge/graph/passes/transop_breadth_fusion_pass.cc View File

@@ -31,6 +31,7 @@ Status TransOpBreadthFusionPass::Run(ge::ComputeGraphPtr graph) {
// breadth fusion pass requires new topologic
Status ret_topo = graph->TopologicalSorting();
if (ret_topo != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Topological sorting for graph:%s failed", graph->GetName().c_str());
GELOGE(ret_topo, "TopologicalSorting the merged graph failed.");
return ret_topo;
}


Loading…
Cancel
Save