Browse Source

add error msg

tags/v1.3.0
wangxiaotian22 3 years ago
parent
commit
13684001ce
24 changed files with 614 additions and 25 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. +4
    -1
      ge/graph/passes/transop_breadth_fusion_pass.cc
  15. +6
    -0
      ge/graph/passes/transop_depth_fusion_pass.cc
  16. +11
    -0
      ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc
  17. +24
    -0
      ge/graph/passes/transop_symmetry_elimination_pass.cc
  18. +107
    -7
      ge/graph/passes/transop_without_reshape_fusion_pass.cc
  19. +11
    -0
      ge/graph/passes/transpose_transdata_pass.cc
  20. +6
    -0
      ge/graph/passes/unused_args_clean_pass.cc
  21. +2
    -0
      ge/graph/passes/unused_const_pass.cc
  22. +36
    -0
      ge/graph/passes/var_is_initialized_op_pass.cc
  23. +38
    -0
      ge/graph/passes/variable_op_pass.cc
  24. +10
    -0
      ge/graph/passes/variable_ref_delete_op_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(); auto father_node = out_data_anchor->GetOwnerNode();
// link father_node's in control nodes to node // link father_node's in control nodes to node
if (GraphUtils::CopyInCtrlEdges(father_node, node) != GRAPH_SUCCESS) { 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 FAILED;
} }
return SUCCESS; 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); auto cast_op = ge::OpDescUtils::GetOpDescFromOperator(node_op);
node_op.BreakConnect(); node_op.BreakConnect();
if (cast_op == nullptr) { 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!"); GELOGE(INTERNAL_ERROR, "new fusion cast op failed!");
return nullptr; 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()))) { 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"); GELOGE(INTERNAL_ERROR, "set dst_type attr failed");
return nullptr; return nullptr;
} }
@@ -204,6 +207,12 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
GELOGI("remove edge.src:%s, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(), GELOGI("remove edge.src:%s, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str()); transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::RemoveEdge(out_anchor, transdata_peer_in_anchor) != GRAPH_SUCCESS) { 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(), 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()); transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
return GRAPH_FAILED; 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(), GELOGI("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_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) { 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", GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_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(), GELOGD("remove edge.src:%s, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_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) { 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(), 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()); transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
@@ -240,6 +260,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(), GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_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) { 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", GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_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(), 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()); transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_peer_out_control_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) { 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", GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_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(), GELOGD("remove edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->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) { 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!"); GELOGE(GRAPH_FAILED, "remove transdata control edge failed!");
return GRAPH_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(), GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_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) { 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!"); GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_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(), 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()); transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_peer_out_control_anchor, transdata_peer_in_control_anchor) != GRAPH_SUCCESS) { 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!"); GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
@@ -329,6 +374,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
GELOGD("remove edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(), GELOGD("remove edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->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) { 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!"); GELOGE(GRAPH_FAILED, "remove transdata control edge failed!");
return GRAPH_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(), GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_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) { 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!"); GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_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(), 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()); transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_peer_out_control_anchor, transdata_peer_in_data_anchor) != GRAPH_SUCCESS) { 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!"); GELOGE(GRAPH_FAILED, "add control edge failed!");
return GRAPH_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()); 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) { 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(), GELOGE(GRAPH_FAILED, "add edge failed!out node %s, in node %s", head_node->GetName().c_str(),
transdata_node_keep->GetName().c_str()); transdata_node_keep->GetName().c_str());
return GRAPH_FAILED; 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(), GELOGI("add edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetName().c_str()); head_node_peer_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(transdata_out_anchor, head_node_peer_anchor) != GRAPH_SUCCESS) { 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(), GELOGE(GRAPH_FAILED, "add edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetName().c_str()); head_node_peer_anchor->GetOwnerNode()->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
@@ -562,6 +635,8 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
auto input_desc = in_op_desc->GetInputDesc(in_data_anchor->GetIdx()); auto input_desc = in_op_desc->GetInputDesc(in_data_anchor->GetIdx());
CopyTensorDesc(transdata_output_desc, input_desc); CopyTensorDesc(transdata_output_desc, input_desc);
if (in_op_desc->UpdateInputDesc(in_data_anchor->GetIdx(), input_desc) != GRAPH_SUCCESS) { 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."); GELOGE(FAILED, "UpdateInputDesc fail.");
return FAILED; return FAILED;
} }
@@ -569,6 +644,8 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
auto output_desc = in_op_desc->GetOutputDesc(output_idx); auto output_desc = in_op_desc->GetOutputDesc(output_idx);
CopyTensorDesc(transdata_output_desc, output_desc); CopyTensorDesc(transdata_output_desc, output_desc);
GE_IF_BOOL_EXEC(in_op_desc->UpdateOutputDesc(output_idx, output_desc) != GRAPH_SUCCESS, 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"); GELOGE(GRAPH_FAILED, "update input desc failed");
return GRAPH_FAILED); return GRAPH_FAILED);
// relink control edge // 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(), GELOGI("remove edge.src:%s, dst:%s", transdata_peer_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_remove_in_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) { 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; return GRAPH_FAILED;
} }


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


if (graph->RemoveNode(transdata_node_remove) != GRAPH_SUCCESS) { 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()); GELOGE(GRAPH_FAILED, "remove node %s failed!", transdata_node_remove->GetName().c_str());
return GRAPH_FAILED; 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(), GELOGD("remove edge.src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_src->GetName().c_str()); node_src->GetName().c_str());
if (GraphUtils::RemoveEdge(peer_out_control_anchor, node_src->GetInControlAnchor()) != GRAPH_SUCCESS) { 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", GELOGE(GRAPH_FAILED, "remove edge faliled!src:%s, dst:%s",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), node_src->GetName().c_str()); peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), node_src->GetName().c_str());
return GRAPH_FAILED; 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(), GELOGD("add edge.src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_dst->GetName().c_str()); node_dst->GetName().c_str());
if (GraphUtils::AddEdge(peer_out_control_anchor, node_dst->GetInControlAnchor()) != GRAPH_SUCCESS) { 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(), GELOGE(GRAPH_FAILED, "add edge failed!src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_dst->GetName().c_str()); node_dst->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
@@ -713,10 +808,16 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g


auto cast_node = graph->AddNode(cast_op_desc); auto cast_node = graph->AddNode(cast_op_desc);
if (cast_node == nullptr) { 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; return GRAPH_FAILED;
} }
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(), cast_node->GetName().c_str()); 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) { 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; return GRAPH_FAILED;
} }
if (i == 0) { if (i == 0) {
@@ -724,6 +825,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
} }


if (!AttrUtils::SetBool(cast_op_desc, ATTR_NEED_COMPILE, true)) { 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."); GELOGE(FAILED, "SetExtAttr fail.");
return FAILED; return FAILED;
} }
@@ -738,6 +841,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat
std::vector<std::pair<OutDataAnchorPtr, InDataAnchorPtr>> &nodes_list) { std::vector<std::pair<OutDataAnchorPtr, InDataAnchorPtr>> &nodes_list) {
graphStatus ret = GRAPH_SUCCESS; graphStatus ret = GRAPH_SUCCESS;
if (out_anchor == nullptr) { 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!"); GELOGE(GRAPH_FAILED, "out data anchor is null!This should not happen!");
return GRAPH_FAILED; 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()); out_index.emplace_back(out_anchor->GetIdx());
ge::OpDescPtr op_desc = peer_node->GetOpDesc(); ge::OpDescPtr op_desc = peer_node->GetOpDesc();
GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave), 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) { for (auto &node_ptr : del_nodes) {
auto ret = graph->RemoveNode(node_ptr); auto ret = graph->RemoveNode(node_ptr);
if (ret != SUCCESS) { 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."); GELOGE(ret, "GraphUtils::RemoveNodeWithoutRelink failed.");
return ret; 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; std::vector<int64_t> input_offset_of_node;
input_offset_of_node = op_desc->GetInputOffset(); input_offset_of_node = op_desc->GetInputOffset();
if (input_offset_of_node.size() < i) { 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); GELOGE(PARAM_INVALID, "not get input_offset of %zu", i);
return PARAM_INVALID; return PARAM_INVALID;
} }
@@ -77,10 +79,15 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vector<int64
int64_t relative_offset = input_offset - out_offset; int64_t relative_offset = input_offset - out_offset;
zero_copy_relative_offset.emplace_back(relative_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), 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."); GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED); return FAILED);
GE_CHK_BOOL_EXEC( GE_CHK_BOOL_EXEC(
ge::AttrUtils::SetListInt(data_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset), 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."); GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED); return FAILED);
} }
@@ -115,10 +122,15 @@ Status SetInputOutputOffsetPass::SetInputOffsetForHcom(const ge::NodePtr &node,
zero_copy_basic_offset.emplace_back(output_offset); zero_copy_basic_offset.emplace_back(output_offset);
zero_copy_relative_offset.emplace_back(relative_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), 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."); GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED); return FAILED);
GE_CHK_BOOL_EXEC( GE_CHK_BOOL_EXEC(
ge::AttrUtils::SetListInt(in_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset), 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."); GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED); return FAILED);
} }
@@ -159,6 +171,9 @@ Status SetInputOutputOffsetPass::SetOutputOffsetForConcat(const NodePtr &node) {
output_offset_of_concat = op_desc->GetOutputOffset(); output_offset_of_concat = op_desc->GetOutputOffset();
// phony_concat has one output // phony_concat has one output
GE_IF_BOOL_EXEC(output_offset_of_concat.size() != 1, 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()); GELOGE(PARAM_INVALID, "%s should has one output.", node->GetName().c_str());
return PARAM_INVALID); return PARAM_INVALID);
NodePtr net_output = node->GetOutDataNodes().at(0); 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); 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), 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."); GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED); return FAILED);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset), 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."); GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED); return FAILED);
return SUCCESS; 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), 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."); GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
return FAILED); return FAILED);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset), 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."); GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED); return FAILED);
return SUCCESS; return SUCCESS;


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

@@ -29,6 +29,8 @@ Status SnapshotPass::Run(NodePtr &node) {
string type; string type;
Status status_ret = GetOriginalType(node, type); Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) { 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."); GELOGE(status_ret, "SnapshotPass get original type failed.");
return status_ret; return status_ret;
} }


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

@@ -20,12 +20,15 @@
namespace ge { namespace ge {
Status StopGradientPass::Run(NodePtr &node) { Status StopGradientPass::Run(NodePtr &node) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null."); GELOGE(FAILED, "parameter is null.");
return FAILED; return FAILED;
} }
string type; string type;
Status status_ret = GetOriginalType(node, type); Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) { 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."); GELOGE(status_ret, "StopGradientPass get original type failed.");
return status_ret; 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()) { for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name); const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) { 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()); GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH; return GE_GRAPH_EMPTY_SUBGRAPH;
} }
@@ -156,6 +158,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap


uint32_t parent_index = 0; uint32_t parent_index = 0;
if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { 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()); GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -229,6 +233,7 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
const auto &data_nodes = it->second; const auto &data_nodes = it->second;
auto data_it = data_nodes.find(node_idx); auto data_it = data_nodes.find(node_idx);
if (data_it == data_nodes.end()) { 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); GELOGE(FAILED, "Data: %s not fount, index: %u", base_node->GetName().c_str(), node_idx);
return false; return false;
} }
@@ -238,12 +243,15 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
const auto &in_anchors = out_anchor->GetPeerInDataAnchors(); const auto &in_anchors = out_anchor->GetPeerInDataAnchors();
const auto &in_anchor = in_anchors.at(anchor_idx); const auto &in_anchor = in_anchors.at(anchor_idx);
if (in_anchor == nullptr) { 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()); GELOGE(FAILED, "Data anchor size: %u, anchor size: %zu", anchor_idx, in_anchors.size());
return false; return false;
} }


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


uint32_t data_index = item.second - kCaseInputBase; uint32_t data_index = item.second - kCaseInputBase;
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) { 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()); GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED; return FAILED;
} }


if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, item.second)) { 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()); GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -392,12 +405,14 @@ Status SubexpressionMigrationPass::DetachParallelNode(const map<uint32_t, NodePt
for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) { for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) {
auto it_idx = outputs.find(i); auto it_idx = outputs.find(i);
if (it_idx == outputs.end()) { 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); GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i);
return FAILED; return FAILED;
} }


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


move_node = in_anchor->GetOwnerNode(); move_node = in_anchor->GetOwnerNode();
if (move_node == nullptr) { 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); GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), base_index);
return FAILED; 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()) { for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name); const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) { 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()); GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH; return GE_GRAPH_EMPTY_SUBGRAPH;
} }
@@ -152,6 +154,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
if (node->GetType() == DATA) { if (node->GetType() == DATA) {
uint32_t parent_index = kInvalidParent; uint32_t parent_index = kInvalidParent;
if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { 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; return FAILED;
} }


@@ -326,17 +330,22 @@ Status SubgraphConstMigrationPass::AppendParallelNode(const NodePtr &func_node,
OpDescBuilder op_builder(data_name, DATA); OpDescBuilder op_builder(data_name, DATA);
const auto op_desc = op_builder.AddInput("x").AddOutput("y").Build(); const auto op_desc = op_builder.AddInput("x").AddOutput("y").Build();
if (op_desc == nullptr) { 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"); GELOGE(OUT_OF_MEMORY, "Create multi-batch subgraph data desc failed");
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


uint32_t data_index = parent_index - kCaseInputBase; uint32_t data_index = parent_index - kCaseInputBase;
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) { 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()); GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED; return FAILED;
} }


if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { 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()); GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -460,6 +469,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
const map<ComputeGraphPtr, map<uint32_t, NodePtr>> &all_data_nodes, const map<ComputeGraphPtr, map<uint32_t, NodePtr>> &all_data_nodes,
const string &node_key, uint32_t parent_index) { const string &node_key, uint32_t parent_index) {
if (node_key.empty() || parent_index == kInvalidParent) { 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", GELOGE(FAILED, "Graph: %s, node key: %s, parent index: %u invalid",
graph->GetName().c_str(), node_key.c_str(), parent_index); graph->GetName().c_str(), node_key.c_str(), parent_index);
return FAILED; return FAILED;
@@ -470,6 +481,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
const auto &subgraph = item.first; const auto &subgraph = item.first;
const auto it_const = item.second.find(node_key); const auto it_const = item.second.find(node_key);
if (it_const == item.second.end()) { 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()); GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
return FAILED; return FAILED;
} }
@@ -477,11 +490,15 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph


const auto it_nodes = all_data_nodes.find(subgraph); const auto it_nodes = all_data_nodes.find(subgraph);
if (it_nodes == all_data_nodes.end()) { 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()); GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
return FAILED; return FAILED;
} }
const auto it_data = it_nodes->second.find(parent_index); const auto it_data = it_nodes->second.find(parent_index);
if (it_data == it_nodes->second.end()) { 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()); GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
return FAILED; 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; uint32_t parent_index = 0;
if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { 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()); GELOGE(FAILED, "Get attr PARENT_NODE_INDEX failed, node:%s.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -208,6 +210,8 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
// index of body_subgraph is 1 // index of body_subgraph is 1
ComputeGraphPtr while_body = NodeUtils::GetSubgraph(*node, 1); ComputeGraphPtr while_body = NodeUtils::GetSubgraph(*node, 1);
if (while_body == nullptr) { 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()); GELOGE(FAILED, "while_body of %s is NULL.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -242,12 +246,16 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
if (output_node == nullptr) { if (output_node == nullptr) {
output_node = n; output_node = n;
} else { } 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()); GELOGE(FAILED, "while_body %s exists multi NetOutput nodes.", while_body->GetName().c_str());
return FAILED; return FAILED;
} }
} }
} }
if (output_node == nullptr) { 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()); GELOGE(FAILED, "while_body %s has no output.", while_body->GetName().c_str());
return FAILED; 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_NO_NEED_CONSTANT_FOLDING, false);
(void)AttrUtils::SetBool(op_desc, ATTR_NAME_CANNOT_BE_DELETED, true); (void)AttrUtils::SetBool(op_desc, ATTR_NAME_CANNOT_BE_DELETED, true);
if (GraphUtils::InsertNodeAfter(out_anchor, in_anchors, graph->AddNode(op_desc)) != GRAPH_SUCCESS) { 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()); GELOGE(FAILED, "Insert IDENTITY node %s after %s failed.", name.c_str(), in_node->GetName().c_str());
return FAILED; 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, Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::vector<InDataAnchorPtr> &dsts,
const NodePtr &insert_node, uint32_t input_index, uint32_t output_index) { const NodePtr &insert_node, uint32_t input_index, uint32_t output_index) {
if (GraphUtils::AddEdge(src, insert_node->GetInDataAnchor(input_index)) != GRAPH_SUCCESS) { 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.", GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.",
src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index); src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index);
return FAILED; return FAILED;
@@ -490,6 +505,12 @@ Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::v
dst->GetOwnerNode()->GetName().c_str()); dst->GetOwnerNode()->GetName().c_str());
if ((GraphUtils::RemoveEdge(src, dst) != GRAPH_SUCCESS) || if ((GraphUtils::RemoveEdge(src, dst) != GRAPH_SUCCESS) ||
(GraphUtils::AddEdge(insert_node->GetOutDataAnchor(output_index), 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.", GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.",
src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), src->GetOwnerNode()->GetName().c_str(), src->GetIdx(),
dst->GetOwnerNode()->GetName().c_str(), dst->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) { std::vector<std::pair<NodePtr, InDataAnchorPtr>> GetOutDataNodesByIndex(const NodePtr &node, int index) {
auto out_anchor = node->GetOutDataAnchor(index); auto out_anchor = node->GetOutDataAnchor(index);
if (out_anchor == nullptr) { 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, 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()); node->GetName().c_str());
return {}; return {};
@@ -84,18 +86,23 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {


auto node_desc = node->GetOpDesc(); auto node_desc = node->GetOpDesc();
if (node_desc == nullptr) { 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", GELOGE(INTERNAL_ERROR, "Failed to add identity after node %s index %d, the op desc is null",
node->GetName().c_str(), index); node->GetName().c_str(), index);
return nullptr; return nullptr;
} }
auto tensor = node_desc->GetOutputDescPtr(index); auto tensor = node_desc->GetOutputDescPtr(index);
if (tensor == nullptr) { 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, 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()); node->GetName().c_str());
return nullptr; return nullptr;
} }
auto anchor = node->GetOutDataAnchor(index); auto anchor = node->GetOutDataAnchor(index);
if (anchor == nullptr) { 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", GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d, the out anchor does not exists",
node->GetName().c_str(), index); node->GetName().c_str(), index);
return nullptr; return nullptr;
@@ -104,6 +111,7 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {
auto identity_opdesc = auto identity_opdesc =
MakeShared<OpDesc>("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY); MakeShared<OpDesc>("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY);
if (identity_opdesc == nullptr) { 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); GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index);
return nullptr; return nullptr;
} }
@@ -111,6 +119,9 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {
auto ret2 = identity_opdesc->AddOutputDesc("y", *tensor); auto ret2 = identity_opdesc->AddOutputDesc("y", *tensor);
auto identity = node->GetOwnerComputeGraph()->AddNode(identity_opdesc); auto identity = node->GetOwnerComputeGraph()->AddNode(identity_opdesc);
if (ret1 != GRAPH_SUCCESS || ret2 != GRAPH_SUCCESS || identity == nullptr) { 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); GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index);
return nullptr; return nullptr;
} }
@@ -124,18 +135,23 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) {


auto node_desc = node->GetOpDesc(); auto node_desc = node->GetOpDesc();
if (node_desc == nullptr) { 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(), GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, null op desc", node->GetName().c_str(),
index); index);
return nullptr; return nullptr;
} }
auto tensor = node_desc->GetInputDescPtr(index); auto tensor = node_desc->GetInputDescPtr(index);
if (tensor == nullptr) { 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, 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()); node->GetName().c_str());
return nullptr; return nullptr;
} }
auto anchor = node->GetInDataAnchor(index); auto anchor = node->GetInDataAnchor(index);
if (anchor == nullptr) { 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", GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, the in anchor does not exists",
node->GetName().c_str(), index); node->GetName().c_str(), index);
return nullptr; 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); auto memcpy_opdesc = MakeShared<OpDesc>("SwitchDataEdgesByPass_Memcpy_" + std::to_string(counter), MEMCPYASYNC);
if (memcpy_opdesc == nullptr) { 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); GELOGE(OUT_OF_MEMORY, "Failed to add memcpy before node %s index %d", node->GetName().c_str(), index);
return nullptr; return nullptr;
} }
@@ -150,6 +167,9 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) {
auto ret2 = memcpy_opdesc->AddOutputDesc(*tensor); auto ret2 = memcpy_opdesc->AddOutputDesc(*tensor);
auto memcpy_node = node->GetOwnerComputeGraph()->AddNode(memcpy_opdesc); auto memcpy_node = node->GetOwnerComputeGraph()->AddNode(memcpy_opdesc);
if (ret1 != GRAPH_SUCCESS || ret2 != GRAPH_SUCCESS || memcpy_node == nullptr) { 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); GELOGE(OUT_OF_MEMORY, "Failed to add memcpy before node %s index %d", node->GetName().c_str(), index);
return nullptr; 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) { bool ParsePred(const ConstGeTensorPtr &tensor) {
if (tensor == nullptr) { if (tensor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param tensor is nullptr, check invalid");
GELOGE(FAILED, "parameter is null."); GELOGE(FAILED, "parameter is null.");
return false; return false;
} }
@@ -65,6 +66,8 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA
OutDataAnchorPtr &inactive_out_data_anchor) { OutDataAnchorPtr &inactive_out_data_anchor) {
auto tensors = OpDescUtils::MutableWeights(pred_node); auto tensors = OpDescUtils::MutableWeights(pred_node);
if (tensors.empty()) { 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; return false;
} }


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


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


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


Status SwitchDeadBranchElimination::Run(NodePtr &node) { Status SwitchDeadBranchElimination::Run(NodePtr &node) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Param [node] must not be null."); GELOGE(PARAM_INVALID, "Param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }
@@ -168,6 +179,8 @@ Status SwitchDeadBranchElimination::Run(NodePtr &node) {
std::vector<NodePtr> end_nodes; std::vector<NodePtr> end_nodes;
Status ret = PassUtils::RemoveInactiveBranchToMerge(inactive_out_data_anchor, del_nodes, end_nodes); Status ret = PassUtils::RemoveInactiveBranchToMerge(inactive_out_data_anchor, del_nodes, end_nodes);
if (ret != SUCCESS) { 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; 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); GE_CHECK_NOTNULL(switch_node);
auto pred_in_anchor = switch_node->GetInDataAnchor(kSwitchPredIndex); auto pred_in_anchor = switch_node->GetInDataAnchor(kSwitchPredIndex);
if (pred_in_anchor == nullptr) { 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()); GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, no pred anchor", switch_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor(); auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor();
if (pred_node_anchor == nullptr) { 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, GELOGE(INTERNAL_ERROR,
"Failed to get pred node for switch %s, node peer out anchor", "Failed to get pred node for switch %s, node peer out anchor",
switch_node->GetName().c_str()); 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(); auto pred_node = pred_node_anchor->GetOwnerNode();
if (pred_node == nullptr) { 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, GELOGE(INTERNAL_ERROR,
"Failed to get pred node for switch %s, null node", "Failed to get pred node for switch %s, null node",
switch_node->GetName().c_str()); switch_node->GetName().c_str());
@@ -89,11 +95,15 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) {
} }
for (auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { for (auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
if (in_anchor == nullptr) { 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()); GELOGE(INTERNAL_ERROR, "The in-anchor from out anchor %d node %s is null", i, node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
auto dst_node = in_anchor->GetOwnerNode(); auto dst_node = in_anchor->GetOwnerNode();
if (dst_node == nullptr) { 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()); GELOGE(INTERNAL_ERROR, "The peer node from out anchor %d node %s is null", i, node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -143,6 +153,8 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt
std::vector<NodePtr> end_nodes; std::vector<NodePtr> end_nodes;
auto ret = PassUtils::RemoveInactiveBranchToMerge(out_anchor, deleted_nodes, end_nodes); auto ret = PassUtils::RemoveInactiveBranchToMerge(out_anchor, deleted_nodes, end_nodes);
if (ret != SUCCESS) { 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; 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."); GE_CHK_STATUS_RET(CombineSwitchNode(graph), "Combine StreamSwitch nodes failed.");


for (const auto &node : bypass_nodes_) { 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."); "Remove switch node failed.");
} }


@@ -159,7 +165,11 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc(); OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc();
GE_CHECK_NOTNULL(cond_desc); GE_CHECK_NOTNULL(cond_desc);
DataType cond_data_type = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx()).GetDataType(); 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.", "pred_input of Switch only support DT_BOOL data_type, but %s exactly.",
TypeUtils::DataTypeToSerialString(cond_data_type).c_str()); 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); 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."); GE_CHK_BOOL_EXEC(stream_switch != nullptr, return FAILED, "Create stream_switch node failed.");
if (SetSwitchTrueBranchFlag(stream_switch, true_branch_flag) != SUCCESS) { 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()); GELOGE(FAILED, "SetSwitchTrueBranchFlag for node %s failed.", stream_switch->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -204,6 +216,8 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
MoveCtrlEdges(switch_node, stream_switch); MoveCtrlEdges(switch_node, stream_switch);
switch_node_map_[stream_switch] = out_node_list; switch_node_map_[stream_switch] = out_node_list;
if (SetOriginalNodeName(stream_switch, switch_node->GetName()) != SUCCESS) { 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()); GELOGE(FAILED, "SetOriginalNodeName for node %s failed.", stream_switch->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -230,6 +244,10 @@ Status SwitchToStreamSwitchPass::BypassSwitchNode(const NodePtr &switch_node, Ou
GE_CHECK_NOTNULL(peer_out_anchor); GE_CHECK_NOTNULL(peer_out_anchor);
// Remove Switch data input. // Remove Switch data input.
if (GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor) != GRAPH_SUCCESS) { 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(), GELOGE(FAILED, "Remove data edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
switch_node->GetName().c_str()); switch_node->GetName().c_str());
return FAILED; return FAILED;
@@ -284,8 +302,13 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
const std::string &suffix, const std::string &suffix,
const OutDataAnchorPtr &peer_cond_anchor) { const OutDataAnchorPtr &peer_cond_anchor) {
OpDescPtr switch_op_desc = switch_node->GetOpDesc(); 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, { 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(), GELOGE(FAILED, "Switch input param invalid, input_size=%lu, should be %u.", switch_op_desc->GetInputsSize(),
SWITCH_INPUT_NUM); SWITCH_INPUT_NUM);
return nullptr; return nullptr;
@@ -295,6 +318,7 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
GELOGI("Create StreamSwitch, name=%s.", node_name.c_str()); GELOGI("Create StreamSwitch, name=%s.", node_name.c_str());
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, STREAMSWITCH); OpDescPtr op_desc = MakeShared<OpDesc>(node_name, STREAMSWITCH);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamSwitch:%s.", node_name.c_str()); GELOGE(FAILED, "Create op_desc failed, StreamSwitch:%s.", node_name.c_str());
return nullptr; return nullptr;
} }
@@ -316,6 +340,9 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &


if (!AttrUtils::SetInt(op_desc, ATTR_NAME_SWITCH_DATA_TYPE, RT_SWITCH_INT32) || 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)) { !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"); GELOGE(INTERNAL_ERROR, "set int failed");
return nullptr; return nullptr;
} }
@@ -323,13 +350,22 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
// Already checked, first input is Variable will passed, second is condition will checked. // 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 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); 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."); "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."); "Create StreamSwitch node: add input desc failed.");


NodePtr stream_switch = graph->AddNode(op_desc); 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)), GE_CHK_STATUS(GraphUtils::AddEdge(peer_cond_anchor, stream_switch->GetInDataAnchor(0)),
"StreamSwitch node add cond edge failed."); "StreamSwitch node add cond edge failed.");


@@ -361,6 +397,8 @@ Status SwitchToStreamSwitchPass::MarkBranches(const OutDataAnchorPtr &peer_cond_
it->second[switch_group_id] = switch_list; it->second[switch_group_id] = switch_list;
} else { } else {
GE_IF_BOOL_EXEC(switch_group_it->second.size() != SWITCH_OUTPUT_NUM, { 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()); GELOGE(INTERNAL_ERROR, "Check size failed, node: %s", stream_switch->GetName().c_str());
return FAILED; return FAILED;
}); });
@@ -443,6 +481,8 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph)
GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()),
"StreamActive add ctl edge failed."); "StreamActive add ctl edge failed.");
if (SetActiveLabelList(active_node, { cast_node->GetName() }) != SUCCESS) { 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()); GELOGE(FAILED, "Set active_label_list attr for node %s failed.", active_node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -456,7 +496,13 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph)
// select first stream_switch // select first stream_switch
NodePtr stream_switch = switch_list.front(); NodePtr stream_switch = switch_list.front();
// set stream_label // 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(); OpDescPtr switch_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc); GE_CHECK_NOTNULL(switch_desc);
switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f"))); 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()); GELOGI("Create StreamActive op:%s.", node_name.c_str());
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, STREAMACTIVE); OpDescPtr op_desc = MakeShared<OpDesc>(node_name, STREAMACTIVE);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamActive:%s.", node_name.c_str()); GELOGE(FAILED, "Create op_desc failed, StreamActive:%s.", node_name.c_str());
return nullptr; return nullptr;
} }


NodePtr active_node = graph->AddNode(op_desc); 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, 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"); GELOGE(INTERNAL_ERROR, "add edge failed");
return nullptr); return nullptr);


GE_IF_BOOL_EXEC(SetSwitchBranchNodeLabel(active_node, node_name) != SUCCESS, 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"); GELOGE(INTERNAL_ERROR, "set switch branch node label failed");
return nullptr); 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()); 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); OpDescPtr cast_desc = MakeShared<OpDesc>(cast_name, CAST);
if (cast_desc == nullptr) { if (cast_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Cast:%s.", cast_name.c_str()); GELOGE(FAILED, "Create op_desc failed, Cast:%s.", cast_name.c_str());
return nullptr; 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_DSTT, (int64_t)DT_INT32) &&
AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, (int64_t)DT_INT32) && AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, (int64_t)DT_INT32) &&
AttrUtils::SetBool(cast_desc, CAST_ATTR_TRUNCATE, false))) { 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.", 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()); cast_name.c_str());
return nullptr; return nullptr;
@@ -543,14 +603,24 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con


GeTensorDesc tensor_desc = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx()); GeTensorDesc tensor_desc = cond_desc->GetOutputDesc(peer_cond_anchor->GetIdx());
tensor_desc.SetDataType(DT_BOOL); 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."); "Cast_node add input desc failed.");
tensor_desc.SetDataType(DT_INT32); 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."); "Cast_node add output desc failed.");


NodePtr cast_node = graph->AddNode(cast_desc); 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 // 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."); 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(); OpDescPtr op_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(op_desc);
bool value = false; 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."); "StreamSwitch get attr TRUE_BRANCH_STREAM failed.");


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


NodePtr const_node = graph->AddNode(const_op_desc); 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)), GE_CHK_STATUS(GraphUtils::AddEdge(const_node->GetOutDataAnchor(0), stream_switch->GetInDataAnchor(1)),
"StreamSwitch node add ctl edge failed."); "StreamSwitch node add ctl edge failed.");


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


auto find_res1 = switch_node_map_.find(in_ctrl_node); auto find_res1 = switch_node_map_.find(in_ctrl_node);
GE_IF_BOOL_EXEC(find_res1 == switch_node_map_.end(), { 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()); GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", in_ctrl_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });
@@ -662,10 +752,14 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
stream_switch->GetName().c_str(), active_node->GetName().c_str()); stream_switch->GetName().c_str(), active_node->GetName().c_str());
auto find_res = switch_node_map_.find(switch_node); auto find_res = switch_node_map_.find(switch_node);
GE_IF_BOOL_EXEC(find_res == switch_node_map_.end(), { 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()); GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", switch_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });
GE_IF_BOOL_EXEC(find_res->second.empty(), { 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()); GELOGE(INTERNAL_ERROR, "true_nodes of StreamSwitch node %s is empty.", switch_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });
@@ -678,6 +772,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
std::string orig_name = op_desc->GetName(); std::string orig_name = op_desc->GetName();
GE_IF_BOOL_EXEC(op_desc->HasAttr(ATTR_NAME_ORIG_NODE_NAME), { 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()) { 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()); GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ORIG_NODE_NAME failed, node: %s.", op_desc->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


+ 4
- 1
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 // breadth fusion pass requires new topologic
Status ret_topo = graph->TopologicalSorting(); Status ret_topo = graph->TopologicalSorting();
if (ret_topo != SUCCESS) { 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."); GELOGE(ret_topo, "TopologicalSorting the merged graph failed.");
return ret_topo; return ret_topo;
} }
@@ -60,7 +61,9 @@ std::string TransOpBreadthFusionPass::GetNodeId(const int anchor_index, const No
bool trans_format = false; bool trans_format = false;
bool trans_shape = false; bool trans_shape = false;


GE_IF_BOOL_EXEC(node == nullptr || node->GetOpDesc() == nullptr, GELOGE(FAILED, "node is null"); return "");
GE_IF_BOOL_EXEC(node == nullptr || node->GetOpDesc() == nullptr,
REPORT_INNER_ERROR("E19999", "Param node or its op_desc is nullptr, check invalid");
GELOGE(FAILED, "node is null"); return "");
if (node->GetType() == CAST) { if (node->GetType() == CAST) {
trans_data_type = true; trans_data_type = true;
} else if (node->GetType() == TRANSPOSE || node->GetType() == TRANSPOSED || node->GetType() == EXPANDDIMS) { } else if (node->GetType() == TRANSPOSE || node->GetType() == TRANSPOSED || node->GetType() == EXPANDDIMS) {


+ 6
- 0
ge/graph/passes/transop_depth_fusion_pass.cc View File

@@ -82,6 +82,7 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_


if (dst_in_anchor == nullptr || dst_in_anchor->GetOwnerNode() == nullptr || if (dst_in_anchor == nullptr || dst_in_anchor->GetOwnerNode() == nullptr ||
dst_in_anchor->GetOwnerNode()->GetOpDesc() == nullptr) { dst_in_anchor->GetOwnerNode()->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param dst_in_anchor related node info has nullptr, check invalid");
GELOGE(FAILED, "parameter is null."); GELOGE(FAILED, "parameter is null.");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
@@ -257,11 +258,13 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_
const OutDataAnchorPtr &old_out_anchor, const OutDataAnchorPtr &old_out_anchor,
const InDataAnchorPtr &in_data_anchor) { const InDataAnchorPtr &in_data_anchor) {
if (new_out_anchor == nullptr || old_out_anchor == nullptr || in_data_anchor == nullptr) { if (new_out_anchor == nullptr || old_out_anchor == nullptr || in_data_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param anchor info has nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "new_out_anchor or old_out_anchor or in_data_anchor is nullptr"); GELOGE(INTERNAL_ERROR, "new_out_anchor or old_out_anchor or in_data_anchor is nullptr");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
if (new_out_anchor->GetOwnerNode() == nullptr || old_out_anchor->GetOwnerNode() == nullptr || if (new_out_anchor->GetOwnerNode() == nullptr || old_out_anchor->GetOwnerNode() == nullptr ||
in_data_anchor->GetOwnerNode() == nullptr) { in_data_anchor->GetOwnerNode() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param anchor info owner node has nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "anchor's owner node is nullptr"); GELOGE(INTERNAL_ERROR, "anchor's owner node is nullptr");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
@@ -305,11 +308,14 @@ graphStatus TransOpDepthFusionPass::RemoveNode(const NodePtr &node, const ge::Co
return GRAPH_FAILED; return GRAPH_FAILED;
} }
if (GraphUtils::IsolateNode(node, {0}) != GRAPH_SUCCESS) { if (GraphUtils::IsolateNode(node, {0}) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", node->GetName().c_str(), GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", node->GetName().c_str(),
node->GetType().c_str()); node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != GRAPH_SUCCESS) { if (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());
GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", node->GetName().c_str(), GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", node->GetName().c_str(),
node->GetType().c_str()); node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;


+ 11
- 0
ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc View File

@@ -99,6 +99,9 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt
auto in_data_anchors = node->GetAllInDataAnchors(); auto in_data_anchors = node->GetAllInDataAnchors();
auto out_data_anchors = node->GetAllOutDataAnchors(); auto out_data_anchors = node->GetAllOutDataAnchors();
if (in_data_anchors.size() != out_data_anchors.size()) { if (in_data_anchors.size() != out_data_anchors.size()) {
REPORT_INNER_ERROR("E19999", "In data anchors size:%zu not equal to out data anchors size:%zu in node:%s(%s), "
"check invalid", in_data_anchors.size(), out_data_anchors.size(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "in and out data anchor size are not equal, node=%s, in_size=%zu, out_size=%zu", GELOGE(FAILED, "in and out data anchor size are not equal, node=%s, in_size=%zu, out_size=%zu",
node->GetName().c_str(), in_data_anchors.size(), out_data_anchors.size()); node->GetName().c_str(), in_data_anchors.size(), out_data_anchors.size());
return FAILED; return FAILED;
@@ -143,6 +146,8 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt


// delete in_node // delete in_node
if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) { if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
in_node->GetName().c_str(), in_node->GetType().c_str());
GELOGE(FAILED, "remove node %s failed", in_node->GetName().c_str()); GELOGE(FAILED, "remove node %s failed", in_node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -150,6 +155,8 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt


// delete out_node // delete out_node
if (IsolateAndDeleteNode(out_node, {0}) != SUCCESS) { if (IsolateAndDeleteNode(out_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
out_node->GetName().c_str(), out_node->GetType().c_str());
GELOGE(FAILED, "remove node %s failed", out_node->GetName().c_str()); GELOGE(FAILED, "remove node %s failed", out_node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -162,9 +169,13 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt
auto input_desc = in_node->GetOpDesc()->GetInputDesc(0); auto input_desc = in_node->GetOpDesc()->GetInputDesc(0);
auto output_desc = out_node->GetOpDesc()->GetOutputDesc(0); auto output_desc = out_node->GetOpDesc()->GetOutputDesc(0);
if (node->GetOpDesc()->UpdateInputDesc(static_cast<uint32_t>(i), input_desc) != GRAPH_SUCCESS) { if (node->GetOpDesc()->UpdateInputDesc(static_cast<uint32_t>(i), input_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update input:%zu desc in op:%s(%s) failed",
i, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "UpdateInputDesc fail."); GELOGE(FAILED, "UpdateInputDesc fail.");
} }
if (node->GetOpDesc()->UpdateOutputDesc(static_cast<uint32_t>(i), output_desc) != GRAPH_SUCCESS) { if (node->GetOpDesc()->UpdateOutputDesc(static_cast<uint32_t>(i), output_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update output:%zu desc in op:%s(%s) failed",
i, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "UpdateOutputDesc"); GELOGE(FAILED, "UpdateOutputDesc");
} }
GELOGI("successfully remove paired transop (%s and %s) for node %s", GELOGI("successfully remove paired transop (%s and %s) for node %s",


+ 24
- 0
ge/graph/passes/transop_symmetry_elimination_pass.cc View File

@@ -172,6 +172,12 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
// 1.Unlink T1->T2 // 1.Unlink T1->T2
auto ret = src_out_anchor->Unlink(dst_in_anchor); auto ret = src_out_anchor->Unlink(dst_in_anchor);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d unlink from op:%s(%s) in index:%d failed",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(),
dst_in_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx());
GELOGE(FAILED, "Unlink data anchor from %s to %s.", src_node->GetName().c_str(), dst_node->GetName().c_str()); GELOGE(FAILED, "Unlink data anchor from %s to %s.", src_node->GetName().c_str(), dst_node->GetName().c_str());
return ret; return ret;
} }
@@ -183,6 +189,11 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
auto pre_normal_node = in_anchor->GetPeerOutAnchor()->GetOwnerNode(); auto pre_normal_node = in_anchor->GetPeerOutAnchor()->GetOwnerNode();
ret = GraphUtils::AddEdge(in_anchor->GetPeerOutAnchor(), dst_in_anchor); ret = GraphUtils::AddEdge(in_anchor->GetPeerOutAnchor(), dst_in_anchor);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_normal_node->GetName().c_str(), pre_normal_node->GetType().c_str(),
in_anchor->GetPeerOutAnchor()->GetIdx(),
dst_in_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx());
GELOGE(FAILED, "Add data edge from %s to %s failed.", pre_normal_node->GetName().c_str(), GELOGE(FAILED, "Add data edge from %s to %s failed.", pre_normal_node->GetName().c_str(),
dst_node->GetName().c_str()); dst_node->GetName().c_str());
return ret; return ret;
@@ -190,6 +201,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
// 3.Copy in-control/data-in-control from T1->T2 // 3.Copy in-control/data-in-control from T1->T2
ret = GraphUtils::CopyInCtrlEdges(src_node, dst_node); ret = GraphUtils::CopyInCtrlEdges(src_node, dst_node);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(),
dst_node->GetName().c_str(), dst_node->GetType().c_str());
GELOGE(FAILED, "Copy control edge from %s to %s failed.", src_node->GetName().c_str(), dst_node->GetName().c_str()); GELOGE(FAILED, "Copy control edge from %s to %s failed.", src_node->GetName().c_str(), dst_node->GetName().c_str());
return ret; return ret;
} }
@@ -198,6 +212,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
if (in_node->GetName() == pre_normal_node->GetName()) { continue; } if (in_node->GetName() == pre_normal_node->GetName()) { continue; }
ret = GraphUtils::AddEdge(in_node->GetOutControlAnchor(), dst_node->GetInControlAnchor()); ret = GraphUtils::AddEdge(in_node->GetOutControlAnchor(), dst_node->GetInControlAnchor());
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
in_node->GetName().c_str(), in_node->GetType().c_str(),
dst_node->GetName().c_str(), dst_node->GetType().c_str());
GELOGE(FAILED, "Add control edge from %s to %s failed.", in_node->GetName().c_str(), dst_node->GetName().c_str()); GELOGE(FAILED, "Add control edge from %s to %s failed.", in_node->GetName().c_str(), dst_node->GetName().c_str());
return ret; return ret;
} }
@@ -205,6 +222,8 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
// 5.IsolateAndDelete T2, A will link to B automatically, and all control edge will also relink. // 5.IsolateAndDelete T2, A will link to B automatically, and all control edge will also relink.
ret = IsolateAndDeleteNode(dst_node, {0}); ret = IsolateAndDeleteNode(dst_node, {0});
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
dst_node->GetName().c_str(), dst_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", dst_node->GetName().c_str(), GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", dst_node->GetName().c_str(),
dst_node->GetType().c_str()); dst_node->GetType().c_str());
return ret; return ret;
@@ -223,6 +242,9 @@ Status TransOpSymmetryEliminationPass::RemoveTransOpWithoutOutput(NodePtr &pre_n
// 6.1 Copy out control to pre normal node // 6.1 Copy out control to pre normal node
Status ret = GraphUtils::CopyOutCtrlEdges(trans_node, pre_node); Status ret = GraphUtils::CopyOutCtrlEdges(trans_node, pre_node);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy out control edge from node:%s(%s) to node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str(),
pre_node->GetName().c_str(), pre_node->GetType().c_str());
GELOGE(FAILED, "Copy control edge from %s to %s failed.", trans_node->GetName().c_str(), GELOGE(FAILED, "Copy control edge from %s to %s failed.", trans_node->GetName().c_str(),
pre_node->GetName().c_str()); pre_node->GetName().c_str());
return ret; return ret;
@@ -230,6 +252,8 @@ Status TransOpSymmetryEliminationPass::RemoveTransOpWithoutOutput(NodePtr &pre_n
// 6.2 Isolate and delete T1 // 6.2 Isolate and delete T1
ret = IsolateAndDeleteNode(trans_node, {}); ret = IsolateAndDeleteNode(trans_node, {});
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", trans_node->GetName().c_str(), GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", trans_node->GetName().c_str(),
trans_node->GetType().c_str()); trans_node->GetType().c_str());
return ret; return ret;


+ 107
- 7
ge/graph/passes/transop_without_reshape_fusion_pass.cc View File

@@ -63,7 +63,10 @@ void TransOpWithoutReshapeFusionPass::SetRemainNode(
continue; continue;
} }
GELOGI("SetRemainNode node is %s", op_desc->GetName().c_str()); GELOGI("SetRemainNode node is %s", op_desc->GetName().c_str());
GE_IF_BOOL_EXEC(!op_desc->SetExtAttr(kRemainNode, true), GELOGE(INTERNAL_ERROR, "set ext attr failed"); return);
GE_IF_BOOL_EXEC(!op_desc->SetExtAttr(kRemainNode, true),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kRemainNode,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ext attr failed"); return);
} }
} }


@@ -74,17 +77,29 @@ bool TransOpWithoutReshapeFusionPass::FormatContinuousCheck(const OutDataAnchorP
return false; return false;
} }
auto in_node = in_anchor->GetOwnerNode(); auto in_node = in_anchor->GetOwnerNode();
GE_IF_BOOL_EXEC(in_node == nullptr, GELOGE(INTERNAL_ERROR, "in_node is null"); return false);
GE_IF_BOOL_EXEC(in_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param in_anchor's owner node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "in_node is null"); return false);
auto in_op = in_node->GetOpDesc(); auto in_op = in_node->GetOpDesc();
auto out_owner_node = out_anchor->GetOwnerNode(); auto out_owner_node = out_anchor->GetOwnerNode();
GE_IF_BOOL_EXEC(out_owner_node == nullptr, GELOGE(INTERNAL_ERROR, "out_owner_node is null"); return false);
GE_IF_BOOL_EXEC(out_owner_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param out_anchor's owner node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "out_owner_node is null"); return false);
auto out_op = out_owner_node->GetOpDesc(); auto out_op = out_owner_node->GetOpDesc();
GE_IF_BOOL_EXEC(in_op == nullptr, GELOGE(INTERNAL_ERROR, "in_op is null"); return false);
GE_IF_BOOL_EXEC(out_op == nullptr, GELOGE(INTERNAL_ERROR, "out_op is null"); return false);
GE_IF_BOOL_EXEC(in_op == nullptr,
REPORT_INNER_ERROR("E19999", "Param in_anchor's owner op_desc is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "in_op is null"); return false);
GE_IF_BOOL_EXEC(out_op == nullptr,
REPORT_INNER_ERROR("E19999", "Param out_anchor's owner op_desc is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "out_op is null"); return false);
auto in_op_desc = in_op->GetInputDescPtr(in_anchor->GetIdx()); auto in_op_desc = in_op->GetInputDescPtr(in_anchor->GetIdx());
auto out_op_desc = out_op->GetOutputDescPtr(out_anchor->GetIdx()); auto out_op_desc = out_op->GetOutputDescPtr(out_anchor->GetIdx());
GE_IF_BOOL_EXEC(in_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "in_op_desc is null"); return false);
GE_IF_BOOL_EXEC(out_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "out_op_desc is null"); return false);
GE_IF_BOOL_EXEC(in_op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Param in_anchor corresponding tensor is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "in_op_desc is null"); return false);
GE_IF_BOOL_EXEC(out_op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Param out_anchor corresponding tensor is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "out_op_desc is null"); return false);
if (!ShapeEqualCheck(in_op_desc->GetShape(), out_op_desc->GetShape())) { if (!ShapeEqualCheck(in_op_desc->GetShape(), out_op_desc->GetShape())) {
return false; return false;
} }
@@ -357,6 +372,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkSubGraphControlEdges(
GELOGI("add control edge.src:%s, dst:%s", out_owner_node->GetName().c_str(), in_owner_node->GetName().c_str()); GELOGI("add control edge.src:%s, dst:%s", out_owner_node->GetName().c_str(), in_owner_node->GetName().c_str());
if (GraphUtils::AddEdge(out_owner_node->GetOutControlAnchor(), in_owner_node->GetInControlAnchor()) != if (GraphUtils::AddEdge(out_owner_node->GetOutControlAnchor(), in_owner_node->GetInControlAnchor()) !=
GRAPH_SUCCESS) { GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -365,6 +383,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkSubGraphControlEdges(
GELOGI("add out data 2 in contorl edge.src:%s, dst:%s", out_owner_node->GetName().c_str(), GELOGI("add out data 2 in contorl edge.src:%s, dst:%s", out_owner_node->GetName().c_str(),
in_owner_node->GetName().c_str()); in_owner_node->GetName().c_str());
if (GraphUtils::AddEdge(out_anchor, in_owner_node->GetInControlAnchor()) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_anchor, in_owner_node->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -392,6 +413,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
GELOGI("add control edge.src:%s, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(), GELOGI("add control edge.src:%s, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
if (GraphUtils::AddEdge(out_owner_node->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_owner_node->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -401,6 +426,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
GELOGI("add control edge.src:%s, src idx:%d, dst:%s", peer_out_anchor->GetOwnerNode()->GetName().c_str(), GELOGI("add control edge.src:%s, src idx:%d, dst:%s", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetIdx(), in_owner_node->GetName().c_str()); peer_out_anchor->GetIdx(), in_owner_node->GetName().c_str());
if (GraphUtils::AddEdge(peer_out_anchor, in_owner_node->GetInControlAnchor()) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(peer_out_anchor, in_owner_node->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -410,6 +439,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
GELOGI("add out control 2 in data edge.src:%s, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(), GELOGI("add out control 2 in data edge.src:%s, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
if (GraphUtils::AddEdge(out_owner_node->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_owner_node->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -419,6 +452,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
GELOGI("add out data 2 in control edge.src:%s, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(), GELOGI("add out data 2 in control edge.src:%s, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx()); peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
if (GraphUtils::AddEdge(out_anchor, peer_in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_anchor, peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -443,6 +480,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkNodesWhenDescNotChanged(
GELOGI("relink node.src node:%s, src idx:%d, dst node:%s, dst idx:%d", out_owner_node->GetName().c_str(), GELOGI("relink node.src node:%s, src idx:%d, dst node:%s, dst idx:%d", out_owner_node->GetName().c_str(),
out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx()); out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx());
if (GraphUtils::AddEdge(out_anchor, in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_anchor, in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge failed!src:%s, src idx:%d, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(), GELOGE(GRAPH_FAILED, "add edge failed!src:%s, src idx:%d, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(),
out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx()); out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx());
return GRAPH_FAILED; return GRAPH_FAILED;
@@ -466,16 +506,21 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes
format_transfer_op_name << "fusion_format_transfer_" << fusion_format_transfer_op_count; format_transfer_op_name << "fusion_format_transfer_" << fusion_format_transfer_op_count;
OpDescPtr format_transfer_op = MakeShared<OpDesc>(format_transfer_op_name.str().c_str(), TRANSDATA); OpDescPtr format_transfer_op = MakeShared<OpDesc>(format_transfer_op_name.str().c_str(), TRANSDATA);
if (format_transfer_op == nullptr) { if (format_transfer_op == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(INTERNAL_ERROR, "new format transfer op failed!"); GELOGE(INTERNAL_ERROR, "new format transfer op failed!");
return nullptr; return nullptr;
} }


GE_IF_BOOL_EXEC(!AttrUtils::SetInt(format_transfer_op, ATTR_NAME_INPUT_FORMAT, GE_IF_BOOL_EXEC(!AttrUtils::SetInt(format_transfer_op, ATTR_NAME_INPUT_FORMAT,
static_cast<int64_t>(format_trans_input_desc.GetFormat())), static_cast<int64_t>(format_trans_input_desc.GetFormat())),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(),
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_NAME_INPUT_FORMAT failed"); GELOGE(INTERNAL_ERROR, "set ATTR_NAME_INPUT_FORMAT failed");
return nullptr); return nullptr);
GE_IF_BOOL_EXEC(!AttrUtils::SetInt(format_transfer_op, ATTR_NAME_OUTPUT_FORMAT, GE_IF_BOOL_EXEC(!AttrUtils::SetInt(format_transfer_op, ATTR_NAME_OUTPUT_FORMAT,
static_cast<int64_t>(format_trans_output_desc.GetFormat())), static_cast<int64_t>(format_trans_output_desc.GetFormat())),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(),
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_NAME_OUTPUT_FORMAT failed"); GELOGE(INTERNAL_ERROR, "set ATTR_NAME_OUTPUT_FORMAT failed");
return nullptr); return nullptr);


@@ -483,22 +528,32 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes
string dst_format = TypeUtils::FormatToSerialString(format_trans_output_desc.GetFormat()); string dst_format = TypeUtils::FormatToSerialString(format_trans_output_desc.GetFormat());


GE_IF_BOOL_EXEC(!AttrUtils::SetStr(format_transfer_op, kAttrNameSrcFormat, src_format), GE_IF_BOOL_EXEC(!AttrUtils::SetStr(format_transfer_op, kAttrNameSrcFormat, src_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kAttrNameSrcFormat,
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set kAttrNameSrcFormat failed"); GELOGE(INTERNAL_ERROR, "set kAttrNameSrcFormat failed");
return nullptr); return nullptr);


GE_IF_BOOL_EXEC(!AttrUtils::SetStr(format_transfer_op, kAttrNameDstFormat, dst_format), GE_IF_BOOL_EXEC(!AttrUtils::SetStr(format_transfer_op, kAttrNameDstFormat, dst_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kAttrNameDstFormat,
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set kAttrNameDstFormat failed"); GELOGE(INTERNAL_ERROR, "set kAttrNameDstFormat failed");
return nullptr); return nullptr);


GE_IF_BOOL_EXEC(format_transfer_op->AddInputDesc(format_trans_input_desc) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(format_transfer_op->AddInputDesc(format_trans_input_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add input desc failed"); GELOGE(INTERNAL_ERROR, "add input desc failed");
return nullptr); return nullptr);


GE_IF_BOOL_EXEC(format_transfer_op->AddOutputDesc(format_trans_output_desc) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(format_transfer_op->AddOutputDesc(format_trans_output_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add output desc failed"); GELOGE(INTERNAL_ERROR, "add output desc failed");
return nullptr); return nullptr);


GE_IF_BOOL_EXEC(!ge::AttrUtils::SetBool(format_transfer_op, ATTR_NEED_COMPILE, true), GE_IF_BOOL_EXEC(!ge::AttrUtils::SetBool(format_transfer_op, ATTR_NEED_COMPILE, true),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ext attr failed"); GELOGE(INTERNAL_ERROR, "set ext attr failed");
return nullptr); return nullptr);
return format_transfer_op; return format_transfer_op;
@@ -515,6 +570,7 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in
auto cast_op = ge::OpDescUtils::GetOpDescFromOperator(node_op); auto cast_op = ge::OpDescUtils::GetOpDescFromOperator(node_op);
node_op.BreakConnect(); node_op.BreakConnect();
if (cast_op == nullptr) { if (cast_op == nullptr) {
REPORT_CALL_ERROR("E19999", "Create operator:%s(%s) failed", cast_op_name.str().c_str(), CAST);
GELOGE(INTERNAL_ERROR, "new cast op failed!"); GELOGE(INTERNAL_ERROR, "new cast op failed!");
return nullptr; return nullptr;
} }
@@ -522,29 +578,41 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in
const int default_output_index = 0; const int default_output_index = 0;
if (cast_op->GetInputsSize() == 0) { if (cast_op->GetInputsSize() == 0) {
GE_IF_BOOL_EXEC(cast_op->AddInputDesc(cast_input_desc) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(cast_op->AddInputDesc(cast_input_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add input desc failed"); GELOGE(INTERNAL_ERROR, "add input desc failed");
return nullptr); return nullptr);
} else { } else {
GE_IF_BOOL_EXEC(cast_op->UpdateInputDesc(default_input_index, cast_input_desc) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(cast_op->UpdateInputDesc(default_input_index, cast_input_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Update input:%d desc of op:%s(%s) failed", default_input_index,
cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "update input desc failed"); GELOGE(INTERNAL_ERROR, "update input desc failed");
return nullptr); return nullptr);
} }


if (cast_op->GetOutputsSize() == 0) { if (cast_op->GetOutputsSize() == 0) {
GE_IF_BOOL_EXEC(cast_op->AddOutputDesc(cast_output_desc) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(cast_op->AddOutputDesc(cast_output_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add output desc failed"); GELOGE(INTERNAL_ERROR, "add output desc failed");
return nullptr); return nullptr);
} else { } else {
GE_IF_BOOL_EXEC(cast_op->UpdateOutputDesc(default_output_index, cast_output_desc) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(cast_op->UpdateOutputDesc(default_output_index, cast_output_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Update output:%d desc of op:%s(%s) failed", default_output_index,
cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "update output desc failed"); GELOGE(INTERNAL_ERROR, "update output desc failed");
return nullptr); return nullptr);
} }


if (!AttrUtils::SetInt(cast_op, CAST_ATTR_DST_TYPE, static_cast<int64_t>(cast_output_desc.GetDataType()))) { if (!AttrUtils::SetInt(cast_op, CAST_ATTR_DST_TYPE, static_cast<int64_t>(cast_output_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"); GELOGE(INTERNAL_ERROR, "set dst_type attr failed");
return nullptr; return nullptr;
} }
if (!AttrUtils::SetBool(cast_op, ATTR_NEED_COMPILE, true)) { if (!AttrUtils::SetBool(cast_op, ATTR_NEED_COMPILE, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set need_compile attr failed"); GELOGE(INTERNAL_ERROR, "set need_compile attr failed");
return nullptr; return nullptr;
} }
@@ -879,6 +947,8 @@ graphStatus TransOpWithoutReshapeFusionPass::AddTransNode(const ComputeGraphPtr


trans_node = graph->AddNode(transop); trans_node = graph->AddNode(transop);
if (trans_node == nullptr) { if (trans_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
transop->GetName().c_str(), transop->GetType().c_str(), graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "add node failed!"); GELOGE(GRAPH_FAILED, "add node failed!");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
@@ -945,6 +1015,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph
GELOGI("add edge.src:%s, src idx:%d, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetIdx(), GELOGI("add edge.src:%s, src idx:%d, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetIdx(),
new_trans_nodes.front()->GetName().c_str()); new_trans_nodes.front()->GetName().c_str());
if (GraphUtils::AddEdge(out_anchor, new_trans_nodes.front()->GetInAnchor(0)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_anchor, new_trans_nodes.front()->GetInAnchor(0)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(),
new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} else { } else {
auto old_peer_in_anchor = begin_out.second; auto old_peer_in_anchor = begin_out.second;
@@ -957,6 +1030,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph
new_trans_nodes.back()->GetName().c_str()); new_trans_nodes.back()->GetName().c_str());
if (GraphUtils::AddEdge(new_trans_nodes.front()->GetOutAnchor(0), new_trans_nodes.back()->GetInAnchor(0)) != if (GraphUtils::AddEdge(new_trans_nodes.front()->GetOutAnchor(0), new_trans_nodes.back()->GetInAnchor(0)) !=
GRAPH_SUCCESS) { GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str(),
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} else { } else {
auto old_peer_out_anchor = end_in.first; auto old_peer_out_anchor = end_in.first;
@@ -967,6 +1043,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph
GELOGI("add edge.src:%s, dst:%s, dst idx:%d", new_trans_nodes.back()->GetName().c_str(), GELOGI("add edge.src:%s, dst:%s, dst idx:%d", new_trans_nodes.back()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx()); in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx());
if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutAnchor(0), in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutAnchor(0), in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx());
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -977,6 +1056,7 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
const vector<NodePtr> &new_trans_nodes) { const vector<NodePtr> &new_trans_nodes) {
GE_CHECK_NOTNULL(out_anchor); GE_CHECK_NOTNULL(out_anchor);
if (new_trans_nodes.front() == nullptr || new_trans_nodes.back() == nullptr) { if (new_trans_nodes.front() == nullptr || new_trans_nodes.back() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param new_trans_nodes front or back is nullptr, check invalid");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
if (sub_graph_has_control_edge_[index]) { if (sub_graph_has_control_edge_[index]) {
@@ -984,6 +1064,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
new_trans_nodes.front()->GetName().c_str()); new_trans_nodes.front()->GetName().c_str());
if (GraphUtils::AddEdge(out_anchor->GetOwnerNode()->GetOutControlAnchor(), if (GraphUtils::AddEdge(out_anchor->GetOwnerNode()->GetOutControlAnchor(),
new_trans_nodes.front()->GetInControlAnchor()) != GRAPH_SUCCESS) { new_trans_nodes.front()->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -993,6 +1076,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
GELOGI("add control edge.src:%s, dst:%s", new_trans_nodes.back()->GetName().c_str(), GELOGI("add control edge.src:%s, dst:%s", new_trans_nodes.back()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str()); peer_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -1002,6 +1089,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
GELOGI("add control edge.src:%s, dst:%s", peer_out_anchor->GetOwnerNode()->GetName().c_str(), GELOGI("add control edge.src:%s, dst:%s", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
new_trans_nodes.front()->GetName().c_str()); new_trans_nodes.front()->GetName().c_str());
if (GraphUtils::AddEdge(peer_out_anchor, new_trans_nodes.front()->GetInControlAnchor()) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(peer_out_anchor, new_trans_nodes.front()->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(),
new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -1011,6 +1102,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
GELOGI("add control edge.src:%s, dst:%s", new_trans_nodes.back()->GetName().c_str(), GELOGI("add control edge.src:%s, dst:%s", new_trans_nodes.back()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str()); peer_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutControlAnchor(), peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -1020,6 +1115,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
GELOGI("add control edge.src:%s, dst:%s", new_trans_nodes.back()->GetName().c_str(), GELOGI("add control edge.src:%s, dst:%s", new_trans_nodes.back()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str()); peer_in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutDataAnchor(0), peer_in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutDataAnchor(0), peer_in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -1081,6 +1180,7 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphsBetweenNormalNode(
vector<std::pair<OutDataAnchorPtr, InDataAnchorPtr>> &nodes_list) { vector<std::pair<OutDataAnchorPtr, InDataAnchorPtr>> &nodes_list) {
graphStatus ret = GRAPH_SUCCESS; graphStatus ret = GRAPH_SUCCESS;
if (out_anchor == nullptr) { if (out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid");
return GRAPH_FAILED; return GRAPH_FAILED;
} }




+ 11
- 0
ge/graph/passes/transpose_transdata_pass.cc View File

@@ -34,11 +34,13 @@ const char *const kAttrNameSrcFormat = "src_format";
namespace ge { namespace ge {
Status TransposeTransDataPass::Run(NodePtr &node) { Status TransposeTransDataPass::Run(NodePtr &node) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [node] must not be null."); GELOGE(PARAM_INVALID, "param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }
auto op_desc = node->GetOpDesc(); auto op_desc = node->GetOpDesc();
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid");
GELOGE(PARAM_INVALID, "OpDesc of param [node] must not be null."); GELOGE(PARAM_INVALID, "OpDesc of param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }
@@ -77,6 +79,7 @@ Status TransposeTransDataPass::Run(NodePtr &node) {
GE_CHECK_NOTNULL(out_node); GE_CHECK_NOTNULL(out_node);
OpDescPtr out_op_desc = out_node->GetOpDesc(); OpDescPtr out_op_desc = out_node->GetOpDesc();
if (out_op_desc == nullptr) { if (out_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(FAILED, "OpDesc of out data node of [%s] must not be null.", node->GetName().c_str()); GELOGE(FAILED, "OpDesc of out data node of [%s] must not be null.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -111,6 +114,10 @@ Status TransposeTransDataPass::CheckOneInAndOneOutDataAnchor(NodePtr &node) cons
// Trans op has one input data node, maybe has N output data nodes // Trans op has one input data node, maybe has N output data nodes
uint32_t in_data_node_nums = node->GetInDataNodes().size(); uint32_t in_data_node_nums = node->GetInDataNodes().size();
if (in_data_anchor_nums != 1 || out_data_anchor_nums != 1 || in_data_node_nums != 1) { if (in_data_anchor_nums != 1 || out_data_anchor_nums != 1 || in_data_node_nums != 1) {
REPORT_INNER_ERROR("E19999", "In data anchor num:%u, out data anchor num:%u, in data node num:%u of node:%s(%s) "
"must be all equal to 1, check invalid",
in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums,
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[%s] %s has %u in %u out data anchor, has %u in data node.", node->GetType().c_str(), GELOGE(FAILED, "[%s] %s has %u in %u out data anchor, has %u in data node.", node->GetType().c_str(),
node->GetName().c_str(), in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums); node->GetName().c_str(), in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums);
return FAILED; return FAILED;
@@ -122,6 +129,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) {
GE_CHECK_NOTNULL(node); GE_CHECK_NOTNULL(node);
ComputeGraphPtr graph = node->GetOwnerComputeGraph(); ComputeGraphPtr graph = node->GetOwnerComputeGraph();
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str()); GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -146,6 +155,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) {
} }
AddNodeDeleted(node); AddNodeDeleted(node);
if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != GRAPH_SUCCESS) { if (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());
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str()); GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }


+ 6
- 0
ge/graph/passes/unused_args_clean_pass.cc View File

@@ -101,6 +101,8 @@ Status UnusedArgsCleanPass::ClassifyDataNodes(const ComputeGraphPtr &graph, cons
for (const auto &name : func_desc->GetSubgraphInstanceNames()) { for (const auto &name : func_desc->GetSubgraphInstanceNames()) {
const auto &subgraph = graph->GetSubgraph(name); const auto &subgraph = graph->GetSubgraph(name);
if (subgraph == nullptr) { if (subgraph == nullptr) {
REPORT_CALL_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()); GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH; return GE_GRAPH_EMPTY_SUBGRAPH;
} }
@@ -113,6 +115,8 @@ Status UnusedArgsCleanPass::ClassifyDataNodes(const ComputeGraphPtr &graph, cons


uint32_t parent_index = 0; uint32_t parent_index = 0;
if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { 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()); GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -150,6 +154,8 @@ Status UnusedArgsCleanPass::UpdateInputTensor(const map<ComputeGraphPtr, map<uin
const auto data = it->second; const auto data = it->second;


if (!AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, update_index)) { if (!AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, update_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, "Set parent index failed, name: %s", data->GetName().c_str()); GELOGE(FAILED, "Set parent index failed, name: %s", data->GetName().c_str());
return FAILED; return FAILED;
} }


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

@@ -27,10 +27,12 @@ namespace ge {
/// ///
Status UnusedConstPass::Run(NodePtr &node) { Status UnusedConstPass::Run(NodePtr &node) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null."); GELOGE(FAILED, "parameter is null.");
return FAILED; return FAILED;
} }
if (node->GetOpDesc() == nullptr) { if (node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [opDesc] must not be null."); GELOGE(PARAM_INVALID, "param [opDesc] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }


+ 36
- 0
ge/graph/passes/var_is_initialized_op_pass.cc View File

@@ -61,6 +61,8 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c
GE_CHECK_NOTNULL(node); GE_CHECK_NOTNULL(node);
auto input_nodes = node->GetInDataNodes(); auto input_nodes = node->GetInDataNodes();
if (input_nodes.size() != kVarIsInitializedIOCnt) { if (input_nodes.size() != kVarIsInitializedIOCnt) {
REPORT_INNER_ERROR("E19999", "In data node num:%zu of node:%s(%s) not equal to %d, check invalid",
input_nodes.size(), node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt);
GELOGE(FAILED, GELOGE(FAILED,
"[%s] Node input data nodes size [%zu] is not equal 1.", "[%s] Node input data nodes size [%zu] is not equal 1.",
node->GetName().c_str(), node->GetName().c_str(),
@@ -73,6 +75,9 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c
auto input_node_name = input_node->GetName(); auto input_node_name = input_node->GetName();
auto input_node_type = input_node->GetType(); auto input_node_type = input_node->GetType();
if (input_node_type != VARIABLE) { if (input_node_type != VARIABLE) {
REPORT_INNER_ERROR("E19999", "Index:%d In data node of node:%s(%s), type:%s not %s, check invalid",
kVarIsInitVarInputIndex, node->GetName().c_str(), node->GetType().c_str(),
input_node_type.c_str(), VARIABLE);
GELOGE(FAILED, "[%s] Src node %s is not Variable, is %s.", node->GetName().c_str(), input_node_name.c_str(), GELOGE(FAILED, "[%s] Src node %s is not Variable, is %s.", node->GetName().c_str(), input_node_name.c_str(),
input_node_type.c_str()); input_node_type.c_str());
return FAILED; return FAILED;
@@ -95,6 +100,7 @@ Status VarIsInitializedOpPass::CreateConstant(NodePtr &node, OpDescPtr &op_desc,
// 1. create Constant OpDesc // 1. create Constant OpDesc
op_desc = MakeShared<OpDesc>(node->GetName().c_str(), CONSTANT); op_desc = MakeShared<OpDesc>(node->GetName().c_str(), CONSTANT);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "[%s] Make shared of Constant op desc failed.", node->GetName().c_str()); GELOGE(FAILED, "[%s] Make shared of Constant op desc failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -102,6 +108,7 @@ Status VarIsInitializedOpPass::CreateConstant(NodePtr &node, OpDescPtr &op_desc,
// 2. get OpDesc of VarIsInitializedOp // 2. get OpDesc of VarIsInitializedOp
OpDescPtr original_op_desc = node->GetOpDesc(); OpDescPtr original_op_desc = node->GetOpDesc();
if (original_op_desc == nullptr) { if (original_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(FAILED, "[%s] Op desc must not be null.", node->GetName().c_str()); GELOGE(FAILED, "[%s] Op desc must not be null.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -111,10 +118,13 @@ Status VarIsInitializedOpPass::CreateConstant(NodePtr &node, OpDescPtr &op_desc,
bool val = inited; bool val = inited;
GeTensorPtr const_tensor_ptr = MakeShared<GeTensor>(original_desc, reinterpret_cast<uint8_t *>(&val), sizeof(bool)); GeTensorPtr const_tensor_ptr = MakeShared<GeTensor>(original_desc, reinterpret_cast<uint8_t *>(&val), sizeof(bool));
if (const_tensor_ptr == nullptr) { if (const_tensor_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", node->GetName().c_str()); GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }
if (!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_tensor_ptr)) { if (!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_tensor_ptr)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "get ATTR_NAME_WEIGHTS failed"); GELOGE(INTERNAL_ERROR, "get ATTR_NAME_WEIGHTS failed");
return FAILED; return FAILED;
} }
@@ -131,6 +141,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
auto out_anchors = node->GetAllOutDataAnchors(); auto out_anchors = node->GetAllOutDataAnchors();
if ((in_anchors.size() != kVarIsInitializedIOCnt) || if ((in_anchors.size() != kVarIsInitializedIOCnt) ||
(out_anchors.size() != kVarIsInitializedIOCnt)) { (out_anchors.size() != kVarIsInitializedIOCnt)) {
REPORT_INNER_ERROR("E19999", "In data anchor num:%zu and out data anchor num:%zu of node:%s(%s), "
"must botch equal to %d, check invalid", in_anchors.size(), out_anchors.size(),
node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt);
GELOGE(FAILED, GELOGE(FAILED,
"[%s] Node input/output data anchors" "[%s] Node input/output data anchors"
" size [%lu][%lu] is not all equal 1.", " size [%lu][%lu] is not all equal 1.",
@@ -144,22 +157,36 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
auto peer_out_anchor = in_anchor->GetPeerOutAnchor(); auto peer_out_anchor = in_anchor->GetPeerOutAnchor();
GE_CHECK_NOTNULL(peer_out_anchor); GE_CHECK_NOTNULL(peer_out_anchor);
if (GraphUtils::RemoveEdge(in_anchor, peer_out_anchor) != GRAPH_SUCCESS) { if (GraphUtils::RemoveEdge(in_anchor, peer_out_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx(),
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx());
GELOGE(FAILED, "[%s] Remove in data edge failed.", node->GetName().c_str()); GELOGE(FAILED, "[%s] Remove in data edge failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }
auto src_node = peer_out_anchor->GetOwnerNode(); auto src_node = peer_out_anchor->GetOwnerNode();
if (GraphUtils::AddEdge(src_node->GetOutControlAnchor(), new_node->GetInControlAnchor()) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(src_node->GetOutControlAnchor(), new_node->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(),
new_node->GetName().c_str(), new_node->GetType().c_str());
GELOGE(FAILED, "Failed to link control edges from var %s to new const %s", GELOGE(FAILED, "Failed to link control edges from var %s to new const %s",
src_node->GetName().c_str(), new_node->GetName().c_str()); src_node->GetName().c_str(), new_node->GetName().c_str());
return FAILED; return FAILED;
} }


if (GraphUtils::MoveInCtrlEdges(node, new_node) != GRAPH_SUCCESS) { if (GraphUtils::MoveInCtrlEdges(node, new_node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Move in control edge from node:%s(%s) to node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
new_node->GetName().c_str(), new_node->GetType().c_str());
GELOGE(FAILED, "Failed to move in ctrl edges from %s to new const", node->GetName().c_str()); GELOGE(FAILED, "Failed to move in ctrl edges from %s to new const", node->GetName().c_str());
return FAILED; return FAILED;
} }


if (GraphUtils::MoveOutCtrlEdges(node, new_node) != GRAPH_SUCCESS) { if (GraphUtils::MoveOutCtrlEdges(node, new_node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Move out control edge from node:%s(%s) to node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
new_node->GetName().c_str(), new_node->GetType().c_str());
GELOGE(FAILED, "Failed to move out ctrl edges from %s to new const", node->GetName().c_str()); GELOGE(FAILED, "Failed to move out ctrl edges from %s to new const", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -177,6 +204,9 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited)


NodePtr const_node = graph->AddNodeFront(constant_op_desc); NodePtr const_node = graph->AddNodeFront(constant_op_desc);
if (const_node == nullptr) { if (const_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s front failed",
constant_op_desc->GetName().c_str(), constant_op_desc->GetType().c_str(),
graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -185,11 +215,16 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited)
} }


if (NodeUtils::MoveOutputEdges(node, const_node) != GRAPH_SUCCESS) { if (NodeUtils::MoveOutputEdges(node, const_node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Move out edge from node:%s(%s) to node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str());
GELOGE(FAILED, "[%s] Move output edges to new node failed.", node->GetName().c_str()); GELOGE(FAILED, "[%s] Move output edges to new node failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }


if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != SUCCESS) { if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != 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());
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str()); GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -263,6 +298,7 @@ Status VarIsInitializedOpPass::UpdateInitedVars(const NodePtr &node) {
std::set<int64_t> *VarIsInitializedOpPass::CreateInitedVars() { std::set<int64_t> *VarIsInitializedOpPass::CreateInitedVars() {
std::unique_ptr<std::set<int64_t>> inited_vars_keeper(new(std::nothrow) std::set<int64_t>()); std::unique_ptr<std::set<int64_t>> inited_vars_keeper(new(std::nothrow) std::set<int64_t>());
if (inited_vars_keeper == nullptr) { if (inited_vars_keeper == nullptr) {
REPORT_CALL_ERROR("E19999", "New set failed");
GELOGE(OUT_OF_MEMORY, "Failed to alloc set memory"); GELOGE(OUT_OF_MEMORY, "Failed to alloc set memory");
return nullptr; return nullptr;
} }


+ 38
- 0
ge/graph/passes/variable_op_pass.cc View File

@@ -47,6 +47,9 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
GELOGD("Begin to bypass trans node %s", trans_node->GetName().c_str()); GELOGD("Begin to bypass trans node %s", trans_node->GetName().c_str());
auto ret = GraphUtils::CopyInCtrlEdges(trans_node, ref_node); auto ret = GraphUtils::CopyInCtrlEdges(trans_node, ref_node);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str(),
ref_node->GetName().c_str(), ref_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, GELOGE(INTERNAL_ERROR,
"Failed to move control edges from trans " "Failed to move control edges from trans "
"node %s to var-ref %s", "node %s to var-ref %s",
@@ -55,6 +58,8 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
} }
auto ref_in_anchor = ref_node->GetInDataAnchor(0); auto ref_in_anchor = ref_node->GetInDataAnchor(0);
if (ref_in_anchor == nullptr) { if (ref_in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid",
ref_node->GetName().c_str(), ref_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, GELOGE(INTERNAL_ERROR,
"The variable ref node %s does not have an " "The variable ref node %s does not have an "
"input anchor", "input anchor",
@@ -64,6 +69,8 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
ref_in_anchor->UnlinkAll(); ref_in_anchor->UnlinkAll();
auto trans_in_anchor = trans_node->GetInDataAnchor(0); auto trans_in_anchor = trans_node->GetInDataAnchor(0);
if (trans_in_anchor == nullptr) { if (trans_in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid",
trans_node->GetName().c_str(), trans_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, GELOGE(INTERNAL_ERROR,
"Failed to get the in data anchor from trans" "Failed to get the in data anchor from trans"
" node %s type %s", " node %s type %s",
@@ -79,6 +86,11 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
} else { } else {
ret = GraphUtils::AddEdge(prev_trans_node_out_anchor, ref_in_anchor); ret = GraphUtils::AddEdge(prev_trans_node_out_anchor, ref_in_anchor);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
prev_trans_node_out_anchor->GetOwnerNode()->GetName().c_str(),
prev_trans_node_out_anchor->GetOwnerNode()->GetType().c_str(),
prev_trans_node_out_anchor->GetIdx(),
ref_node->GetName().c_str(), ref_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, GELOGE(INTERNAL_ERROR,
"Failed to add edge between ref node %s " "Failed to add edge between ref node %s "
"and the prev node of trans node %s", "and the prev node of trans node %s",
@@ -115,6 +127,7 @@ bool IsTransSupport(const TransNodeInfo &trans_info) {


Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to run variable op pass, null graph"); GELOGE(INTERNAL_ERROR, "Failed to run variable op pass, null graph");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -124,6 +137,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {
GetContext().SessionId(), graph_id); GetContext().SessionId(), graph_id);


if (var_accelerate_ctrl_ == nullptr) { if (var_accelerate_ctrl_ == nullptr) {
REPORT_INNER_ERROR("E19999", "The variable accelerate control is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null"); GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -174,11 +188,15 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {


ret = VarManager::Instance(graph->GetSessionID())->SetTransRoad(node->GetName(), fusion_road); ret = VarManager::Instance(graph->GetSessionID())->SetTransRoad(node->GetName(), fusion_road);
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set Trans road for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID());
GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str()); GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph_id); ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph_id);
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update graph_id:%u for node:%s(%s) failed, session_id:%lu",
graph_id, node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID());
GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str()); GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -210,10 +228,14 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) {
trans_node->GetType().c_str(), var_node->GetName().c_str()); trans_node->GetType().c_str(), var_node->GetName().c_str());


if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }


if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) { if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
} }
@@ -245,9 +267,13 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) {
" one output data nodes, isolate and remove it.", " one output data nodes, isolate and remove it.",
trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str());
if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) { if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
} }
@@ -365,6 +391,7 @@ Status VariableOpPass::CheckVariableRefLegally(const ge::NodePtr &var_node, bool


Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node) { Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node) {
if (node == nullptr || node->GetOpDesc() == nullptr) { if (node == nullptr || node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node or its op_desc is nullptr, check invalid");
GELOGE(FAILED, "node or opdesc is nullptr"); GELOGE(FAILED, "node or opdesc is nullptr");
return FAILED; return FAILED;
} }
@@ -377,6 +404,8 @@ Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final
auto node_desc = node->GetOpDesc()->GetOutputDesc(0); auto node_desc = node->GetOpDesc()->GetOutputDesc(0);
CopyVariableFormatDataTypeAndShape(final_output, node_desc); CopyVariableFormatDataTypeAndShape(final_output, node_desc);
if (node->GetOpDesc()->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) { if (node->GetOpDesc()->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update ouput:0 desc in op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "update output desc fail."); GELOGE(FAILED, "update output desc fail.");
return FAILED; return FAILED;
} }
@@ -460,6 +489,10 @@ Status VariableOpPass::CheckVarAndVarRefAreAlike(const NodePtr &var_node, const
GELOGD("var_ref_node_trans_nodes size is %zu.", var_ref_node_trans_nodes.size()); GELOGD("var_ref_node_trans_nodes size is %zu.", var_ref_node_trans_nodes.size());


if (var_ref_node_trans_nodes.size() > 1) { if (var_ref_node_trans_nodes.size() > 1) {
REPORT_INNER_ERROR("E19999", "In data node num:%zu of node:%s(%s) bigger than 1, check invalid",
var_ref_node_trans_nodes.size(),
var_ref_node->GetName().c_str(), var_ref_node->GetType().c_str());

GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "var_ref_node_trans_nodes.size() > 1."); GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "var_ref_node_trans_nodes.size() > 1.");
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
@@ -525,6 +558,7 @@ void VariableOpPass::CopyVariableFormatDataTypeAndShape(const GeTensorDesc &src_


Status VariableOpPass::CheckIfCouldBeOptimized(const ge::NodePtr &node, bool &flag, VarTransRoad &fusion_road) { Status VariableOpPass::CheckIfCouldBeOptimized(const ge::NodePtr &node, bool &flag, VarTransRoad &fusion_road) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
return FAILED; return FAILED;
} }
bool is_matched = false; bool is_matched = false;
@@ -602,6 +636,8 @@ Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) {
GE_CHECK_NOTNULL(node->GetOpDesc()); GE_CHECK_NOTNULL(node->GetOpDesc());
ret = ge::VarManager::Instance(graph->GetSessionID())->RenewCurVarDesc(node->GetName(), node->GetOpDesc()); ret = ge::VarManager::Instance(graph->GetSessionID())->RenewCurVarDesc(node->GetName(), node->GetOpDesc());
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID());
GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -626,6 +662,8 @@ Status VariableOpPass::RenewVarDesc(uint64_t session_id, const NodePtr &node, co
GE_CHECK_NOTNULL(node->GetOpDesc()); GE_CHECK_NOTNULL(node->GetOpDesc());
Status ret = ge::VarManager::Instance(session_id)->RenewCurVarDesc(node->GetName(), node->GetOpDesc()); Status ret = ge::VarManager::Instance(session_id)->RenewCurVarDesc(node->GetName(), node->GetOpDesc());
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), session_id);
GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str());
return FAILED; return FAILED;
} }


+ 10
- 0
ge/graph/passes/variable_ref_delete_op_pass.cc View File

@@ -35,6 +35,8 @@ Status VariableRefDeleteOpPass::Run(ge::ComputeGraphPtr graph) {
continue; continue;
} }
if (all_var_names.count(ref_var_src_var_name) == 0) { if (all_var_names.count(ref_var_src_var_name) == 0) {
REPORT_INNER_ERROR("E19999", "Can not find source variable[%s] of variable ref[%s], check invalid",
ref_var_src_var_name.c_str(), node->GetName().c_str());
GELOGE(FAILED, "Can not find source variable[%s] of variable ref[%s]", ref_var_src_var_name.c_str(), GELOGE(FAILED, "Can not find source variable[%s] of variable ref[%s]", ref_var_src_var_name.c_str(),
node->GetName().c_str()); node->GetName().c_str());
return FAILED; return FAILED;
@@ -53,6 +55,8 @@ Status VariableRefDeleteOpPass::DealVariableRef(ge::ComputeGraphPtr &graph, ge::
GE_CHECK_NOTNULL(variable_ref); GE_CHECK_NOTNULL(variable_ref);
auto inAnchor0 = variable_ref->GetInDataAnchor(0); auto inAnchor0 = variable_ref->GetInDataAnchor(0);
if (inAnchor0 == nullptr) { if (inAnchor0 == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str());
GELOGE(FAILED, "variable_ref [%s] no input", variable_ref->GetName().c_str()); GELOGE(FAILED, "variable_ref [%s] no input", variable_ref->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -73,17 +77,23 @@ Status VariableRefDeleteOpPass::DealVariableRef(ge::ComputeGraphPtr &graph, ge::
GELOGI("[%s-%d]: add attr [REF_VAR_SRC_VAR_NAME: %s ] ", peer_node->GetName().c_str(), index, GELOGI("[%s-%d]: add attr [REF_VAR_SRC_VAR_NAME: %s ] ", peer_node->GetName().c_str(), index,
ref_var_src_var_name.c_str()); ref_var_src_var_name.c_str());
} else { } else {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%d desc of op:%s(%s) failed", REF_VAR_SRC_VAR_NAME.c_str(),
index, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[%s-%d]: add attr [REF_VAR_SRC_VAR_NAME: %s ] failed", peer_node->GetName().c_str(), index, GELOGE(FAILED, "[%s-%d]: add attr [REF_VAR_SRC_VAR_NAME: %s ] failed", peer_node->GetName().c_str(), index,
ref_var_src_var_name.c_str()); ref_var_src_var_name.c_str());
return FAILED; return FAILED;
} }
// remove variable_ref // remove variable_ref
if (GraphUtils::IsolateNode(variable_ref, {0}) != GRAPH_SUCCESS) { if (GraphUtils::IsolateNode(variable_ref, {0}) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", variable_ref->GetName().c_str(), GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", variable_ref->GetName().c_str(),
variable_ref->GetType().c_str()); variable_ref->GetType().c_str());
return FAILED; return FAILED;
} }
if (GraphUtils::RemoveNodeWithoutRelink(graph, variable_ref) != GRAPH_SUCCESS) { if (GraphUtils::RemoveNodeWithoutRelink(graph, variable_ref) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", variable_ref->GetName().c_str(), GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", variable_ref->GetName().c_str(),
variable_ref->GetType().c_str()); variable_ref->GetType().c_str());
return FAILED; return FAILED;


Loading…
Cancel
Save