Browse Source

!1724 modify geloge message

Merge pull request !1724 from liudingyan/master
tags/v1.3.0
计晨 Gitee 3 years ago
parent
commit
6539de2889
64 changed files with 1907 additions and 1106 deletions
  1. +2
    -4
      ge/common/helper/model_helper.cc
  2. +51
    -39
      ge/graph/passes/hccl_continuous_memcpy_pass.cc
  3. +46
    -29
      ge/graph/passes/hccl_memcpy_pass.cc
  4. +4
    -3
      ge/graph/passes/hccl_tailing_optimization_pass.cc
  5. +6
    -7
      ge/graph/passes/identity_pass.cc
  6. +7
    -5
      ge/graph/passes/infershape_pass.cc
  7. +3
    -1
      ge/graph/passes/inplace_support_check_pass.cc
  8. +18
    -21
      ge/graph/passes/input_output_connection_identify_pass.cc
  9. +87
    -59
      ge/graph/passes/iterator_op_pass.cc
  10. +4
    -2
      ge/graph/passes/link_gen_mask_nodes_pass.cc
  11. +1
    -1
      ge/graph/passes/mark_agnostic_pass.cc
  12. +2
    -1
      ge/graph/passes/mark_force_unknown_for_cond_pass.cc
  13. +1
    -1
      ge/graph/passes/mark_graph_unknown_status_pass.cc
  14. +80
    -58
      ge/graph/passes/memcpy_addr_async_pass.cc
  15. +21
    -10
      ge/graph/passes/merge_input_memcpy_pass.cc
  16. +21
    -14
      ge/graph/passes/merge_pass.cc
  17. +42
    -23
      ge/graph/passes/merge_to_stream_merge_pass.cc
  18. +222
    -132
      ge/graph/passes/multi_batch_clone_pass.cc
  19. +118
    -72
      ge/graph/passes/multi_batch_pass.cc
  20. +78
    -51
      ge/graph/passes/net_output_pass.cc
  21. +46
    -31
      ge/graph/passes/next_iteration_pass.cc
  22. +5
    -4
      ge/graph/passes/no_use_reshape_remove_pass.cc
  23. +7
    -5
      ge/graph/passes/parallel_concat_start_op_pass.cc
  24. +3
    -3
      ge/graph/passes/pass_manager.cc
  25. +51
    -29
      ge/graph/passes/pass_utils.cc
  26. +8
    -5
      ge/graph/passes/permute_pass.cc
  27. +1
    -1
      ge/graph/passes/placeholder_with_default_pass.cc
  28. +1
    -1
      ge/graph/passes/prevent_gradient_pass.cc
  29. +2
    -2
      ge/graph/passes/print_op_pass.cc
  30. +2
    -2
      ge/graph/passes/prune_pass.cc
  31. +18
    -11
      ge/graph/passes/ref_identity_delete_op_pass.cc
  32. +5
    -3
      ge/graph/passes/remove_same_const_pass.cc
  33. +30
    -13
      ge/graph/passes/replace_transshape_pass.cc
  34. +2
    -2
      ge/graph/passes/replace_with_empty_const_pass.cc
  35. +13
    -3
      ge/graph/passes/reshape_recovery_pass.cc
  36. +3
    -3
      ge/graph/passes/resource_pair_add_control_pass.cc
  37. +3
    -3
      ge/graph/passes/resource_pair_remove_control_pass.cc
  38. +95
    -34
      ge/graph/passes/same_transdata_breadth_fusion_pass.cc
  39. +5
    -2
      ge/graph/passes/save_pass.cc
  40. +38
    -26
      ge/graph/passes/set_input_output_offset_pass.cc
  41. +4
    -1
      ge/graph/passes/shape_operate_op_remove_pass.cc
  42. +4
    -2
      ge/graph/passes/snapshot_pass.cc
  43. +3
    -2
      ge/graph/passes/stop_gradient_pass.cc
  44. +49
    -27
      ge/graph/passes/subexpression_migration_pass.cc
  45. +44
    -21
      ge/graph/passes/subgraph_const_migration_pass.cc
  46. +31
    -20
      ge/graph/passes/subgraph_pass.cc
  47. +23
    -21
      ge/graph/passes/switch_data_edges_bypass.cc
  48. +15
    -6
      ge/graph/passes/switch_dead_branch_elimination.cc
  49. +16
    -10
      ge/graph/passes/switch_logic_remove_pass.cc
  50. +159
    -80
      ge/graph/passes/switch_to_stream_switch_pass.cc
  51. +2
    -2
      ge/graph/passes/transop_breadth_fusion_pass.cc
  52. +36
    -20
      ge/graph/passes/transop_depth_fusion_pass.cc
  53. +8
    -6
      ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc
  54. +22
    -10
      ge/graph/passes/transop_symmetry_elimination_pass.cc
  55. +119
    -32
      ge/graph/passes/transop_without_reshape_fusion_pass.cc
  56. +15
    -11
      ge/graph/passes/transpose_transdata_pass.cc
  57. +25
    -10
      ge/graph/passes/unused_args_clean_pass.cc
  58. +2
    -2
      ge/graph/passes/unused_const_pass.cc
  59. +51
    -35
      ge/graph/passes/var_is_initialized_op_pass.cc
  60. +46
    -28
      ge/graph/passes/variable_op_pass.cc
  61. +70
    -33
      ge/graph/passes/variable_prepare_op_pass.cc
  62. +9
    -9
      ge/graph/passes/variable_ref_delete_op_pass.cc
  63. +1
    -1
      metadef
  64. +1
    -1
      parser

+ 2
- 4
ge/common/helper/model_helper.cc View File

@@ -469,10 +469,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) {
if (output_file.empty()) { if (output_file.empty()) {
GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s",
output_file.c_str());
REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s",
output_file.c_str());
GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s", output_file.c_str());
REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s", output_file.c_str());
return FAILED; return FAILED;
} }
// Get computegraph from graph // Get computegraph from graph


+ 51
- 39
ge/graph/passes/hccl_continuous_memcpy_pass.cc View File

@@ -39,19 +39,20 @@ Status HcclContinuousMemcpyPass::Run(ge::ComputeGraphPtr graph) {
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Node with nullptr op_desc exist in Param graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Node with nullptr op_desc exist in Param graph:%s, check invalid",
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "node has no op_desc, node_name : %s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, Node with nullptr op_desc exist in Param graph:%s.",
graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


Status ret = ContinuousInputProcess(graph, node); Status ret = ContinuousInputProcess(graph, node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "failed ProcessBroadcastMemcpy, node_name:%s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Call][ContinuousInputProcess] failed, node_name:%s.", node->GetName().c_str());
return ret; return ret;
} }


ret = P2pmemInputProcess(graph, node); ret = P2pmemInputProcess(graph, node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "failed P2pmemInputProcess, node_name:%s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Call][P2pmemInputProcess] failed, node_name:%s.", node->GetName().c_str());
return ret; return ret;
} }


@@ -82,14 +83,16 @@ Status HcclContinuousMemcpyPass::ContinuousInputProcess(const ComputeGraphPtr &g
REPORT_INNER_ERROR("E19999", "Node:%s(%s) input:%d anchor, peer anchor is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) input:%d anchor, peer anchor is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
hccl_in_anchor->GetIdx()); hccl_in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "hcom op input has no peer anchor, node_name:%s", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][PeerOutAnchor] failed, Node:%s(%s) input:%d anchor, peer anchor is nullptr",
node->GetName().c_str(), node->GetType().c_str(), hccl_in_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) { if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) {
Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to modify the connection.");
GELOGE(INTERNAL_ERROR, "[Modify][EdgeConnection] between %s and %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -122,16 +125,17 @@ Status HcclContinuousMemcpyPass::P2pmemInputProcess(const ComputeGraphPtr &graph
auto src_out_anchor = hccl_in_anchor->GetPeerOutAnchor(); auto src_out_anchor = hccl_in_anchor->GetPeerOutAnchor();
if (src_out_anchor == nullptr) { if (src_out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) input:%u anchor, peer anchor is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) input:%u anchor, peer anchor is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str(),
index);
GELOGE(INTERNAL_ERROR, "hcom op input has no peer anchor, node_name:%s", node->GetName().c_str());
node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "[Get][PeerOutAnchor] failed, Node:%s(%s) input:%u anchor, peer anchor is nullptr",
node->GetName().c_str(), node->GetType().c_str(), index);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) { if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) {
Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to modify the connection.");
GELOGE(INTERNAL_ERROR, "[Modify][EdgeConnection] between %s and %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -156,7 +160,7 @@ NodePtr HcclContinuousMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &grap
OpDescPtr pre_op_desc = pre_node->GetOpDesc(); OpDescPtr pre_op_desc = pre_node->GetOpDesc();
if (pre_op_desc == nullptr) { if (pre_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "OpDesc of pre node is invalid.");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, OpDesc of pre node is invalid.");
return nullptr; return nullptr;
} }


@@ -175,7 +179,8 @@ NodePtr HcclContinuousMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &grap
if (identity_node == nullptr) { if (identity_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str()); identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Insert Identity node fail.");
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str());
return nullptr; return nullptr;
} }
return identity_node; return identity_node;
@@ -213,7 +218,7 @@ Status HcclContinuousMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &gra


Status ret = InsertIdentityBeforeHccl(graph, src_out_anchor, hccl_in_anchor); Status ret = InsertIdentityBeforeHccl(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "add identity failed, var_node:%s, hccl_node:%s.",
GELOGE(INTERNAL_ERROR, "[Add][Identity] failed, var_node:%s, hccl_node:%s.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), src_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str()); hccl_in_anchor->GetOwnerNode()->GetName().c_str());
return ret; return ret;
@@ -221,7 +226,7 @@ Status HcclContinuousMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &gra


ret = InsertAssignAfterBroadcastIfNeed(graph, src_out_anchor, hccl_in_anchor); ret = InsertAssignAfterBroadcastIfNeed(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "add assign failed, var_node:%s, hccl_node:%s.",
GELOGE(INTERNAL_ERROR, "[Add][Assign] failed, var_node:%s, hccl_node:%s.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), src_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str()); hccl_in_anchor->GetOwnerNode()->GetName().c_str());
return ret; return ret;
@@ -246,16 +251,14 @@ Status HcclContinuousMemcpyPass::InsertIdentityBeforeHccl(const ComputeGraphPtr


auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex); auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex);
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
REPORT_CALL_ERROR("E19999", "Op:Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), identity_node->GetName().c_str(), identity_node->GetType().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str(), hccl_in_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetType().c_str(), hccl_in_anchor->GetOwnerNode()->GetType().c_str(),
hccl_in_anchor->GetIdx()); hccl_in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
GELOGE(INTERNAL_ERROR, "[Insert][Node] %s(%s) before %s(%s) on index:%d input anchor failed.",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), identity_node->GetName().c_str(), identity_node->GetType().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetType().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str(), hccl_in_anchor->GetOwnerNode()->GetType().c_str(),
hccl_in_anchor->GetIdx()); hccl_in_anchor->GetIdx());
return FAILED; return FAILED;
} }
@@ -300,27 +303,29 @@ Status HcclContinuousMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeG


Status ret = hccl_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignValueIndex)); Status ret = hccl_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignValueIndex));
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
hccl_out_anchor->GetOwnerNode()->GetName().c_str(), hccl_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_out_anchor->GetOwnerNode()->GetType().c_str(), hccl_out_anchor->GetIdx(), hccl_out_anchor->GetOwnerNode()->GetType().c_str(), hccl_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(), assign_node->GetName().c_str(), assign_node->GetType().c_str(),
kAnchorAssignValueIndex); kAnchorAssignValueIndex);
GELOGE(INTERNAL_ERROR, "The op %s link anchor %s fail.", hccl_out_anchor->GetOwnerNode()->GetName().c_str(),
assign_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
hccl_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_out_anchor->GetOwnerNode()->GetType().c_str(), hccl_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(), kAnchorAssignValueIndex);
return FAILED; return FAILED;
} }


ret = var_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignRefIndex)); ret = var_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignRefIndex));
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
var_out_anchor->GetOwnerNode()->GetName().c_str(), var_out_anchor->GetOwnerNode()->GetName().c_str(),
var_out_anchor->GetOwnerNode()->GetType().c_str(), var_out_anchor->GetIdx(), var_out_anchor->GetOwnerNode()->GetType().c_str(), var_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(), assign_node->GetName().c_str(), assign_node->GetType().c_str(),
kAnchorAssignRefIndex); kAnchorAssignRefIndex);
GELOGE(INTERNAL_ERROR, "The op %s link anchor %s fail.", var_out_anchor->GetOwnerNode()->GetName().c_str(),
assign_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
var_out_anchor->GetOwnerNode()->GetName().c_str(),
var_out_anchor->GetOwnerNode()->GetType().c_str(), var_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(), kAnchorAssignRefIndex);
return FAILED; return FAILED;
} }


@@ -339,9 +344,10 @@ Status HcclContinuousMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeG
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(), assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetType().c_str()); in_data_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(INTERNAL_ERROR, "The op %s link control anchor %s fail.",
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) link control to op:%s(%s) failed",
assign_out_control_anchor->GetOwnerNode()->GetName().c_str(), assign_out_control_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str());
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -357,9 +363,11 @@ Status HcclContinuousMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeG
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(), assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
in_control_anchor->GetOwnerNode()->GetName().c_str(), in_control_anchor->GetOwnerNode()->GetName().c_str(),
in_control_anchor->GetOwnerNode()->GetType().c_str()); in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(INTERNAL_ERROR, "The op %s link control anchor %s fail.",
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) link control to op:%s(%s) failed",
assign_out_control_anchor->GetOwnerNode()->GetName().c_str(), assign_out_control_anchor->GetOwnerNode()->GetName().c_str(),
in_control_anchor->GetOwnerNode()->GetName().c_str());
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
in_control_anchor->GetOwnerNode()->GetName().c_str(),
in_control_anchor->GetOwnerNode()->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -379,7 +387,7 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph,
OpDescPtr pre_op_desc = pre_node->GetOpDesc(); OpDescPtr pre_op_desc = pre_node->GetOpDesc();
if (pre_op_desc == nullptr) { if (pre_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "OpDesc of pre node is invalid.");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, OpDesc of pre node is invalid.");
return nullptr; return nullptr;
} }


@@ -388,16 +396,16 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph,
OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), ASSIGN); OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), ASSIGN);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(INTERNAL_ERROR, "Create Assign op: MakeShared op_desc fail.");
GELOGE(INTERNAL_ERROR, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }
GELOGI("Create Assign op:%s.", op_desc->GetName().c_str()); GELOGI("Create Assign op:%s.", op_desc->GetName().c_str());


if (!AttrUtils::SetBool(op_desc, ATTR_NEED_COMPILE, true)) { if (!AttrUtils::SetBool(op_desc, ATTR_NEED_COMPILE, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NEED_COMPILE.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Set ATTR_NEED_COMPILE Attr for node:%s fail.", op_desc->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -405,7 +413,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph,
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:ref", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Assign op: add ref input desc fail.");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -413,7 +422,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph,
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:value", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:value",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Assign op: add value input desc fail.");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed, name:value",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -421,7 +431,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph,
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:ref", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Assign op: add output desc fail.");
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -429,7 +440,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph,
if (assign_node == nullptr) { if (assign_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Insert Identity node fail.");
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr; return nullptr;
} }




+ 46
- 29
ge/graph/passes/hccl_memcpy_pass.cc View File

@@ -42,13 +42,14 @@ Status HcclMemcpyPass::Run(ge::ComputeGraphPtr graph) {
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Node with nullptr op_desc exist in Param graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Node with nullptr op_desc exist in Param graph:%s, check invalid",
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "node has no op_desc, node_name : %s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, Node with nullptr op_desc exist in Param graph:%s.",
graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


Status ret = MutableInputProcess(graph, node); Status ret = MutableInputProcess(graph, node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "failed MutableInputProcess, node_name:%s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Call][MutableInputProcess] failed, node_name:%s.", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -80,7 +81,8 @@ Status HcclMemcpyPass::MutableInputProcess(const ComputeGraphPtr &graph, const N
if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) { if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) {
Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to modify the connection.");
GELOGE(INTERNAL_ERROR, "[Modify][EdgeConnection] between %s and %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -89,7 +91,8 @@ Status HcclMemcpyPass::MutableInputProcess(const ComputeGraphPtr &graph, const N


Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to modify the connection.");
GELOGE(INTERNAL_ERROR, "[Modify][EdgeConnection] between %s and %s failed.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -112,7 +115,7 @@ NodePtr HcclMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &graph, const O
OpDescPtr pre_op_desc = pre_node->GetOpDesc(); OpDescPtr pre_op_desc = pre_node->GetOpDesc();
if (pre_op_desc == nullptr) { if (pre_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "OpDesc of pre node is invalid.");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, OpDesc of pre node is invalid.");
return nullptr; return nullptr;
} }


@@ -131,7 +134,8 @@ NodePtr HcclMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &graph, const O
if (identity_node == nullptr) { if (identity_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str()); identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Insert Identity node fail.");
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str());
return nullptr; return nullptr;
} }
return identity_node; return identity_node;
@@ -168,7 +172,7 @@ Status HcclMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &graph, const


Status ret = InsertIdentityBeforeHccl(graph, src_out_anchor, hccl_in_anchor); Status ret = InsertIdentityBeforeHccl(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "add identity failed, var_node:%s, hccl_node:%s.",
GELOGE(INTERNAL_ERROR, "[Add][Identity] failed, var_node:%s, hccl_node:%s.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), src_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str()); hccl_in_anchor->GetOwnerNode()->GetName().c_str());
return ret; return ret;
@@ -176,7 +180,7 @@ Status HcclMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &graph, const


ret = InsertAssignAfterBroadcastIfNeed(graph, src_out_anchor, hccl_in_anchor); ret = InsertAssignAfterBroadcastIfNeed(graph, src_out_anchor, hccl_in_anchor);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "add assign failed, var_node:%s, hccl_node:%s.",
GELOGE(INTERNAL_ERROR, "[Add][Assign] failed, var_node:%s, hccl_node:%s.",
src_out_anchor->GetOwnerNode()->GetName().c_str(), src_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str()); hccl_in_anchor->GetOwnerNode()->GetName().c_str());
return ret; return ret;
@@ -200,13 +204,12 @@ Status HcclMemcpyPass::InsertIdentityBeforeHccl(const ComputeGraphPtr &graph, co


auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex); auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex);
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
REPORT_CALL_ERROR("E19999", "Op:Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), identity_node->GetName().c_str(), identity_node->GetType().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str(), hccl_in_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetType().c_str(), hccl_in_anchor->GetOwnerNode()->GetType().c_str(),
hccl_in_anchor->GetIdx()); hccl_in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
GELOGE(INTERNAL_ERROR, "[Insert][Node] %s(%s) before %s(%s) on index:%d input anchor failed.",
identity_node->GetName().c_str(), identity_node->GetType().c_str(), identity_node->GetName().c_str(), identity_node->GetType().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str(), hccl_in_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetType().c_str(), hccl_in_anchor->GetOwnerNode()->GetType().c_str(),
@@ -254,27 +257,31 @@ Status HcclMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeGraphPtr &g


Status ret = hccl_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignValueIndex)); Status ret = hccl_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignValueIndex));
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
hccl_out_anchor->GetOwnerNode()->GetName().c_str(), hccl_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_out_anchor->GetOwnerNode()->GetType().c_str(), hccl_out_anchor->GetIdx(), hccl_out_anchor->GetOwnerNode()->GetType().c_str(), hccl_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(), assign_node->GetName().c_str(), assign_node->GetType().c_str(),
kAnchorAssignValueIndex); kAnchorAssignValueIndex);
GELOGE(INTERNAL_ERROR, "The op %s link anchor %s fail.", hccl_out_anchor->GetOwnerNode()->GetName().c_str(),
assign_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
hccl_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_out_anchor->GetOwnerNode()->GetType().c_str(), hccl_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(),
kAnchorAssignValueIndex);
return FAILED; return FAILED;
} }


ret = var_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignRefIndex)); ret = var_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignRefIndex));
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
var_out_anchor->GetOwnerNode()->GetName().c_str(), var_out_anchor->GetOwnerNode()->GetName().c_str(),
var_out_anchor->GetOwnerNode()->GetType().c_str(), var_out_anchor->GetIdx(), var_out_anchor->GetOwnerNode()->GetType().c_str(), var_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(), assign_node->GetName().c_str(), assign_node->GetType().c_str(),
kAnchorAssignRefIndex); kAnchorAssignRefIndex);
GELOGE(INTERNAL_ERROR, "The op %s link anchor %s fail.", var_out_anchor->GetOwnerNode()->GetName().c_str(),
assign_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
var_out_anchor->GetOwnerNode()->GetName().c_str(),
var_out_anchor->GetOwnerNode()->GetType().c_str(), var_out_anchor->GetIdx(),
assign_node->GetName().c_str(), assign_node->GetType().c_str(),
kAnchorAssignRefIndex);
return FAILED; return FAILED;
} }


@@ -295,9 +302,13 @@ Status HcclMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeGraphPtr &g
in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetType().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str(),
in_data_anchor->GetIdx()); in_data_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "The op %s link control anchor %s fail.",
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) out index:%d link to op:%s(%s) in index:%d failed",
assign_out_control_anchor->GetOwnerNode()->GetName().c_str(), assign_out_control_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str());
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
assign_out_control_anchor->GetIdx(),
in_data_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetType().c_str(),
in_data_anchor->GetIdx());
return FAILED; return FAILED;
} }
} }
@@ -313,9 +324,11 @@ Status HcclMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeGraphPtr &g
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(), assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
in_control_anchor->GetOwnerNode()->GetName().c_str(), in_control_anchor->GetOwnerNode()->GetName().c_str(),
in_control_anchor->GetOwnerNode()->GetType().c_str()); in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(INTERNAL_ERROR, "The op %s link control anchor %s fail.",
GELOGE(INTERNAL_ERROR, "[Add][Edge] Op:%s(%s) link control to op:%s(%s) failed",
assign_out_control_anchor->GetOwnerNode()->GetName().c_str(), assign_out_control_anchor->GetOwnerNode()->GetName().c_str(),
in_control_anchor->GetOwnerNode()->GetName().c_str());
assign_out_control_anchor->GetOwnerNode()->GetType().c_str(),
in_control_anchor->GetOwnerNode()->GetName().c_str(),
in_control_anchor->GetOwnerNode()->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -334,7 +347,7 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out
OpDescPtr pre_op_desc = pre_node->GetOpDesc(); OpDescPtr pre_op_desc = pre_node->GetOpDesc();
if (pre_op_desc == nullptr) { if (pre_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "OpDesc of pre node is invalid.");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, OpDesc of pre node is invalid.");
return nullptr; return nullptr;
} }


@@ -343,7 +356,7 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out
OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), ASSIGN); OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), ASSIGN);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(INTERNAL_ERROR, "Create Assign op: MakeShared op_desc fail.");
GELOGE(INTERNAL_ERROR, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }
GELOGI("Create Assign op:%s.", op_desc->GetName().c_str()); GELOGI("Create Assign op:%s.", op_desc->GetName().c_str());
@@ -352,7 +365,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:ref", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Assign op: add ref input desc fail.");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -360,7 +374,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:value", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:value",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Assign op: add value input desc fail.");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed, name:value",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -368,7 +383,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:ref", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Assign op: add output desc fail.");
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed, name:ref",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -376,7 +392,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out
if (assign_node == nullptr) { if (assign_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Insert Identity node fail.");
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr; return nullptr;
} }




+ 4
- 3
ge/graph/passes/hccl_tailing_optimization_pass.cc View File

@@ -61,9 +61,10 @@ Status HcclTailingOptimizationPass::CopyControlEdgesForTransOp(NodePtr &first_tr


for (auto &src_out_ctrl_anchor : src_out_ctrl_anchors) { for (auto &src_out_ctrl_anchor : src_out_ctrl_anchors) {
if (!src_out_ctrl_anchor->IsLinkedWith(dst_in_ctrl_anchor)) { if (!src_out_ctrl_anchor->IsLinkedWith(dst_in_ctrl_anchor)) {
GE_CHK_GRAPH_STATUS_RET(
GraphUtils::AddEdge(src_out_ctrl_anchor, dst_in_ctrl_anchor), "Failed to add edge between %s->%s",
src_out_ctrl_anchor->GetOwnerNode()->GetName().c_str(), first_trans_op->GetName().c_str());
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(src_out_ctrl_anchor, dst_in_ctrl_anchor),
"[Add][Edge] between %s->%s failed",
src_out_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
first_trans_op->GetName().c_str());
} }
} }




+ 6
- 7
ge/graph/passes/identity_pass.cc View File

@@ -54,7 +54,7 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) {
} }


GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type), GE_CHK_STATUS_RET(GetOriginalType(in_node, node_type),
"Failed to get node type from node %s", node->GetName().c_str());
"[Get][OriginalType] of node:%s failed", in_node->GetName().c_str());
bool need_skip = (node_type != SWITCH) && (node_type != REFSWITCH) && (node_type != SWITCHN); bool need_skip = (node_type != SWITCH) && (node_type != REFSWITCH) && (node_type != SWITCHN);
if (need_skip) { if (need_skip) {
GELOGD("skip identity %s connected to switch", node->GetName().c_str()); GELOGD("skip identity %s connected to switch", node->GetName().c_str());
@@ -76,7 +76,7 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) {
return SUCCESS; return SUCCESS;
} }
GE_CHK_STATUS_RET(GetOriginalType(out_node, node_type), GE_CHK_STATUS_RET(GetOriginalType(out_node, node_type),
"Failed to get node type from node %s", node->GetName().c_str());
"[Get][OriginalType] of node:%s failed", out_node->GetName().c_str());
if ((node_type != MERGE) && (node_type != REFMERGE)) { if ((node_type != MERGE) && (node_type != REFMERGE)) {
GELOGD("skip identity %s connected to merge", node->GetName().c_str()); GELOGD("skip identity %s connected to merge", node->GetName().c_str());
break; break;
@@ -99,9 +99,8 @@ Status IdentityPass::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 original type for node:%s failed",
node->GetName().c_str());
GELOGE(status_ret, "Identity pass get original type fail.");
REPORT_CALL_ERROR("E19999", "Get original type of node:%s failed", node->GetName().c_str());
GELOGE(status_ret, "[Get][OriginalType] of node:%s failed.", node->GetName().c_str());
return status_ret; return status_ret;
} }
if ((type != IDENTITY) && (type != IDENTITYN) && (type != READVARIABLEOP)) { if ((type != IDENTITY) && (type != IDENTITYN) && (type != READVARIABLEOP)) {
@@ -123,8 +122,8 @@ Status IdentityPass::Run(NodePtr &node) {
REPORT_CALL_ERROR("E19999", "Num:%zu of input desc node:%s(%s) not equal to it's output desc num:%zu, " REPORT_CALL_ERROR("E19999", "Num:%zu of input desc node:%s(%s) not equal to it's output desc num:%zu, "
"check invalid", node->GetOpDesc()->GetInputsSize(), "check invalid", node->GetOpDesc()->GetInputsSize(),
node->GetName().c_str(), node->GetType().c_str(), n); node->GetName().c_str(), node->GetType().c_str(), n);
GELOGE(PARAM_INVALID, "Identity input / output size must be equal. in size:%lu, out size:%lu",
node->GetOpDesc()->GetInputsSize(), n);
GELOGE(PARAM_INVALID, "[Check][Param] Num:%zu of input desc node:%s(%s) not equal to it's output desc num:%zu",
node->GetOpDesc()->GetInputsSize(), node->GetName().c_str(), node->GetType().c_str(), n);
return PARAM_INVALID; return PARAM_INVALID;
} }
std::vector<int> io_map; std::vector<int> io_map;


+ 7
- 5
ge/graph/passes/infershape_pass.cc View File

@@ -86,14 +86,15 @@ Status InferShapePass::Run(NodePtr &node) {
auto root_graph = ge::GraphUtils::FindRootGraph(graph); auto root_graph = ge::GraphUtils::FindRootGraph(graph);
GE_CHECK_NOTNULL(root_graph); GE_CHECK_NOTNULL(root_graph);
analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(), analyzer::DataInfo analyze_info{root_graph->GetSessionID(), root_graph->GetGraphID(),
analyzer::INFER_SHAPE, node, "InferShapeFailed!"};
analyzer::INFER_SHAPE, node, "InferShapeFailed!"};
(void)Analyzer::GetInstance()->DoAnalyze(analyze_info); (void)Analyzer::GetInstance()->DoAnalyze(analyze_info);
(void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), (void)Analyzer::GetInstance()->SaveAnalyzerDataToFile(root_graph->GetSessionID(),
root_graph->GetGraphID()); root_graph->GetGraphID());


REPORT_CALL_ERROR("E19999", "Call InferShapeAndType for node:%s(%s) failed, input_tensor:%s", REPORT_CALL_ERROR("E19999", "Call InferShapeAndType for node:%s(%s) failed, input_tensor:%s",
node->GetName().c_str(), node->GetType().c_str(), GetInTensorInfoWithString(node).c_str()); node->GetName().c_str(), node->GetType().c_str(), GetInTensorInfoWithString(node).c_str());
GELOGE(GE_GRAPH_INFERSHAPE_FAILED, "infershape failed. node: %s", node->GetName().c_str());
GELOGE(GE_GRAPH_INFERSHAPE_FAILED, "[Call][InferShapeAndType] for node:%s(%s) failed, input_tensor:%s",
node->GetName().c_str(), node->GetType().c_str(), GetInTensorInfoWithString(node).c_str());
return GE_GRAPH_INFERSHAPE_FAILED; return GE_GRAPH_INFERSHAPE_FAILED;
} }


@@ -120,7 +121,7 @@ Status InferShapePass::RePassLoopNode(const NodePtr &node) {
for (auto &n : node->GetOutDataNodes()) { for (auto &n : node->GetOutDataNodes()) {
GE_CHECK_NOTNULL(n); GE_CHECK_NOTNULL(n);
std::string node_type; std::string node_type;
GE_CHK_STATUS_RET(GetOriginalType(n, node_type), "Get original node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(n, node_type), "[Get][OriginalType] of node:%s failed.", n->GetName().c_str());
if (re_pass_types.count(node_type) > 0) { if (re_pass_types.count(node_type) > 0) {
AddImmediateRePassNode(n); AddImmediateRePassNode(n);
(void)AttrUtils::SetBool(n->GetOpDesc(), ATTR_NAME_NEED_INFER_AGAIN, false); (void)AttrUtils::SetBool(n->GetOpDesc(), ATTR_NAME_NEED_INFER_AGAIN, false);
@@ -136,7 +137,7 @@ Status InferShapePass::RePassLoopNode(const NodePtr &node) {
for (auto &n : node->GetOutDataNodes()) { for (auto &n : node->GetOutDataNodes()) {
GE_CHECK_NOTNULL(n); GE_CHECK_NOTNULL(n);
std::string node_type; std::string node_type;
GE_CHK_STATUS_RET(GetOriginalType(n, node_type), "Get original node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(n, node_type), "[Get][OriginalType] of node:%s failed.", n->GetName().c_str());
if (proc_types.count(node_type) > 0) { if (proc_types.count(node_type) > 0) {
proc_func(this, n); proc_func(this, n);
GELOGD("Node %s %s after %s.", n->GetName().c_str(), info.c_str(), node->GetName().c_str()); GELOGD("Node %s %s after %s.", n->GetName().c_str(), info.c_str(), node->GetName().c_str());
@@ -146,7 +147,8 @@ Status InferShapePass::RePassLoopNode(const NodePtr &node) {
}; };


std::string node_type; std::string node_type;
GE_CHK_STATUS_RET(GetOriginalType(node, node_type), "Get original node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(node, node_type),
"[Get][OriginalType] of node:%s failed.", node->GetName().c_str());
if (kNextIterationOpTypes.count(node_type) > 0) { if (kNextIterationOpTypes.count(node_type) > 0) {
return RePassNode(kMergeOpTypes); // Re-Pass Merge return RePassNode(kMergeOpTypes); // Re-Pass Merge
} }


+ 3
- 1
ge/graph/passes/inplace_support_check_pass.cc View File

@@ -72,7 +72,9 @@ Status InplaceSupportCheckPass::Run(NodePtr &node) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%u tensor of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%u tensor of op:%s(%s) failed",
INPLACE_SUPPORT_INPUT_INDEX.c_str(), kInplaceSupportOutputIndex, INPLACE_SUPPORT_INPUT_INDEX.c_str(), kInplaceSupportOutputIndex,
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Set attr INPLACE_SUPPORT_INPUT_INDEX on node %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to output:%u tensor of op:%s(%s) failed",
INPLACE_SUPPORT_INPUT_INDEX.c_str(), kInplaceSupportOutputIndex,
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
AddRePassNode(node); AddRePassNode(node);


+ 18
- 21
ge/graph/passes/input_output_connection_identify_pass.cc View File

@@ -43,7 +43,8 @@ inline bool IsDataOp(const std::string &node_type) {
Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) { Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) {
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Input param graph is null, skip identification of nodes that connect to input and output.");
GELOGE(PARAM_INVALID, "[Check][Param] Input param graph is nullptr, "
"skip identification of nodes that connect to input and output.");
return PARAM_INVALID; return PARAM_INVALID;
} }


@@ -55,16 +56,14 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) {


GELOGD("Start to identify nodes that connect to input and output."); GELOGD("Start to identify nodes that connect to input and output.");
if (graph->TopologicalSorting() != GRAPH_SUCCESS) { if (graph->TopologicalSorting() != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Topological Sorting graph:%s failed",
graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Graph topological sort failed.");
REPORT_CALL_ERROR("E19999", "Topological Sorting graph:%s failed", graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Call][TopologicalSorting] for graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (GraphUtils::GetRefMapping(graph, symbol_to_anchors_, anchor_to_symbol_) != GRAPH_SUCCESS) { if (GraphUtils::GetRefMapping(graph, symbol_to_anchors_, anchor_to_symbol_) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get ref mapping from graph:%s failed",
graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Get ref-mapping for graph %s failed.", graph->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Get ref mapping from graph:%s failed", graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][RefMapping] for graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -77,7 +76,7 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) {
GELOGD("Find nodes that connect to root graph input node: %s.", node->GetName().c_str()); GELOGD("Find nodes that connect to root graph input node: %s.", node->GetName().c_str());
status = ProcessInputNode(node, connect_input_node_idx_map, connect_output_node_idx_map); status = ProcessInputNode(node, connect_input_node_idx_map, connect_output_node_idx_map);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(status, "Failed to process nodes that connect to input node: %s.", node->GetName().c_str());
GELOGE(status, "[Process][Nodes] that connect to input node:%s failed.", node->GetName().c_str());
return status; return status;
} }
} }
@@ -86,7 +85,7 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) {
GELOGD("Find nodes that connect to root graph output node: %s.", node->GetName().c_str()); GELOGD("Find nodes that connect to root graph output node: %s.", node->GetName().c_str());
status = ProcessOutputNode(node, connect_input_node_idx_map, connect_output_node_idx_map); status = ProcessOutputNode(node, connect_input_node_idx_map, connect_output_node_idx_map);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(status, "Failed to process nodes that connect to output node: %s.", node->GetName().c_str());
GELOGE(status, "[Process][Nodes] that connect to output node:%s failed.", node->GetName().c_str());
return status; return status;
} }
} }
@@ -94,7 +93,7 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) {


status = SetNodeAttrOfConnectingInputOutput(connect_input_node_idx_map, connect_output_node_idx_map); status = SetNodeAttrOfConnectingInputOutput(connect_input_node_idx_map, connect_output_node_idx_map);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(status, "Failed to set attr for nodes that connect to input and output.");
GELOGE(status, "[Set][Attr] for nodes that connect to input and output failed.");
return status; return status;
} }


@@ -118,7 +117,7 @@ Status InputOutputConnectionIdentifyPass::ProcessInputNode(const NodePtr &node,
const string &symbol = anchor_iter->second; const string &symbol = anchor_iter->second;
auto status = UpdateNodeIdxMap(symbol, connect_input_node_idx, connect_output_node_idx); auto status = UpdateNodeIdxMap(symbol, connect_input_node_idx, connect_output_node_idx);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(status, "Failed to update node anchor_index map.");
GELOGE(status, "[Call][UpdateNodeIdxMap] Failed to update node anchor_index map.");
return status; return status;
} }
} }
@@ -132,7 +131,7 @@ Status InputOutputConnectionIdentifyPass::UpdateNodeIdxMap(const string &symbol_
if (symbol_iter == symbol_to_anchors_.end()) { if (symbol_iter == symbol_to_anchors_.end()) {
REPORT_CALL_ERROR("E19999", "Can't find symbol:%s in symbol_to_anchors map, check invalid", REPORT_CALL_ERROR("E19999", "Can't find symbol:%s in symbol_to_anchors map, check invalid",
symbol_string.c_str()); symbol_string.c_str());
GELOGE(PARAM_INVALID, "Input param symbol string: %s is invalid.", symbol_string.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Input param symbol string:%s is invalid.", symbol_string.c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
const auto &node_index_io_list = symbol_iter->second; const auto &node_index_io_list = symbol_iter->second;
@@ -164,7 +163,7 @@ Status InputOutputConnectionIdentifyPass::ProcessOutputNode(const NodePtr &node,
const string &symbol = anchor_iter->second; const string &symbol = anchor_iter->second;
auto status = UpdateNodeIdxMap(symbol, connect_input_node_idx, connect_output_node_idx); auto status = UpdateNodeIdxMap(symbol, connect_input_node_idx, connect_output_node_idx);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(status, "Failed to update node anchor_index map.");
GELOGE(status, "[Call][UpdateNodeIdxMap] Failed to update node anchor_index map.");
return status; return status;
} }
} }
@@ -178,11 +177,10 @@ Status InputOutputConnectionIdentifyPass::SetNodeAttrOfConnectingInputOutput(
GE_CHECK_NOTNULL(iter.first); GE_CHECK_NOTNULL(iter.first);
if (iter.first->GetOpDesc() != nullptr) { if (iter.first->GetOpDesc() != nullptr) {
if (!AttrUtils::SetListInt(iter.first->GetOpDesc(), ATTR_NAME_NODE_CONNECT_INPUT, iter.second)) { if (!AttrUtils::SetListInt(iter.first->GetOpDesc(), ATTR_NAME_NODE_CONNECT_INPUT, iter.second)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
iter.first->GetName().c_str(), iter.first->GetType().c_str()); iter.first->GetName().c_str(), iter.first->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to set attr %s for node %s.", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
iter.first->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
iter.first->GetName().c_str(), iter.first->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -192,11 +190,10 @@ Status InputOutputConnectionIdentifyPass::SetNodeAttrOfConnectingInputOutput(
GE_CHECK_NOTNULL(iter.first); GE_CHECK_NOTNULL(iter.first);
if (iter.first->GetOpDesc() != nullptr) { if (iter.first->GetOpDesc() != nullptr) {
if (!AttrUtils::SetListInt(iter.first->GetOpDesc(), ATTR_NAME_NODE_CONNECT_OUTPUT, iter.second)) { if (!AttrUtils::SetListInt(iter.first->GetOpDesc(), ATTR_NAME_NODE_CONNECT_OUTPUT, iter.second)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_NODE_CONNECT_OUTPUT.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_OUTPUT.c_str(),
iter.first->GetName().c_str(), iter.first->GetType().c_str()); iter.first->GetName().c_str(), iter.first->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to set attr %s for node %s.", ATTR_NAME_NODE_CONNECT_OUTPUT.c_str(),
iter.first->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_OUTPUT.c_str(),
iter.first->GetName().c_str(), iter.first->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }


+ 87
- 59
ge/graph/passes/iterator_op_pass.cc View File

@@ -59,7 +59,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) {
if (status != ge::SUCCESS) { if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set cycle event to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set cycle event to op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str()); memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str());
GELOGE(status, "Set cycle event failed.");
GELOGE(status, "[Set][CycleEvent] to op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str());
return status; return status;
} }


@@ -68,7 +69,9 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetName().c_str(), memcpy_async_node->GetName().c_str(), memcpy_async_node->GetName().c_str(),
memcpy_async_node->GetType().c_str()); memcpy_async_node->GetType().c_str());
GELOGE(status, "set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetName().c_str(),
memcpy_async_node->GetType().c_str());
return status; return status;
} }


@@ -76,7 +79,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) {
if (status != ge::SUCCESS) { if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed",
node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str());
GELOGE(status, "set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str());
return status; return status;
} }


@@ -99,7 +103,10 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) {
ret = SetRtContext(graph->GetSessionID(), graph->GetGraphID(), rtContext_t(), RT_CTX_GEN_MODE); ret = SetRtContext(graph->GetSessionID(), graph->GetGraphID(), rtContext_t(), RT_CTX_GEN_MODE);


// The following process will be affected if ret is not SUCCESS. // The following process will be affected if ret is not SUCCESS.
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "Set rt context RT_CTX_GEN_MODE failed."); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(ret, "[Set][RtContext] RT_CTX_GEN_MODE failed, session_id:%lu, graph_id:%u.",
graph->GetSessionID(), graph->GetGraphID());
return ret);


GE_IF_BOOL_EXEC(status != SUCCESS, GELOGW("Get variable value of NODE_NAME_FLOWCTRL_LOOP_PER_ITER failed."); GE_IF_BOOL_EXEC(status != SUCCESS, GELOGW("Get variable value of NODE_NAME_FLOWCTRL_LOOP_PER_ITER failed.");
continue); continue);
@@ -113,7 +120,9 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed",
end_of_sequence_node->GetName().c_str(), end_of_sequence_node->GetName().c_str(), end_of_sequence_node->GetName().c_str(), end_of_sequence_node->GetName().c_str(),
end_of_sequence_node->GetType().c_str()); end_of_sequence_node->GetType().c_str());
GELOGE(status, "set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
end_of_sequence_node->GetName().c_str(), end_of_sequence_node->GetName().c_str(),
end_of_sequence_node->GetType().c_str());
return status; return status;
} }
GELOGI("Insert EndOfSequence node success."); GELOGI("Insert EndOfSequence node success.");
@@ -134,9 +143,8 @@ Status IteratorOpPass::GetVariableValue(uint64_t session_id, const ge::GeTensorD
uint8_t *dev_ptr = nullptr; uint8_t *dev_ptr = nullptr;
auto status = VarManager::Instance(session_id)->GetVarAddr(var_name, tensor_desc, &dev_ptr); auto status = VarManager::Instance(session_id)->GetVarAddr(var_name, tensor_desc, &dev_ptr);
if (status != ge::SUCCESS) { if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get Var add by name:%s failed, session_id:%lu",
var_name.c_str(), session_id);
GELOGE(status, "Get variable %s address failed.", var_name.c_str());
REPORT_CALL_ERROR("E19999", "Get Var add by name:%s failed, session_id:%lu", var_name.c_str(), session_id);
GELOGE(status, "[Get][VarAddr] by name:%s failed, session_id:%lu", var_name.c_str(), session_id);
return status; return status;
} }
int64_t offset = static_cast<int64_t>(reinterpret_cast<intptr_t>(dev_ptr)); int64_t offset = static_cast<int64_t>(reinterpret_cast<intptr_t>(dev_ptr));
@@ -164,7 +172,9 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node,
ge::OpDescPtr end_of_seq_op_desc = CreateEndOfSequenceOp(pre_node); ge::OpDescPtr end_of_seq_op_desc = CreateEndOfSequenceOp(pre_node);
GE_CHK_BOOL_EXEC(end_of_seq_op_desc != nullptr, GELOGW("Create EndOfSequence op fail."); return nullptr); GE_CHK_BOOL_EXEC(end_of_seq_op_desc != nullptr, GELOGW("Create EndOfSequence op fail."); return nullptr);
ge::NodePtr end_of_seq_node = graph->AddNode(end_of_seq_op_desc); ge::NodePtr end_of_seq_node = graph->AddNode(end_of_seq_op_desc);
GE_CHK_BOOL_EXEC(end_of_seq_node != nullptr, return nullptr, "Insert EndOfSequence node fail.");
GE_CHK_BOOL_EXEC(end_of_seq_node != nullptr, return nullptr,
"[Add][Node] %s to graph:%s failed.", end_of_seq_op_desc->GetName().c_str(),
graph->GetName().c_str());


// getnext(data) --> EOS // getnext(data) --> EOS
GE_CHK_BOOL_EXEC(pre_node->GetAllOutDataAnchorsSize() != 0, GELOGW("Pre node has no output."); return nullptr); GE_CHK_BOOL_EXEC(pre_node->GetAllOutDataAnchorsSize() != 0, GELOGW("Pre node has no output."); return nullptr);
@@ -176,8 +186,9 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node,
pre_node->GetName().c_str(), pre_node->GetType().c_str(), pre_node->GetName().c_str(), pre_node->GetType().c_str(),
end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str()); end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str());
return nullptr, return nullptr,
"Graph add EndOfSequence op input edge fail, dst node: %s.",
end_of_seq_node->GetName().c_str());
"[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(),
end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str());
// EOS(control) --> subsequent of memcpy // EOS(control) --> subsequent of memcpy
OutControlAnchorPtr out_ctrl_anchor = end_of_seq_node->GetOutControlAnchor(); OutControlAnchorPtr out_ctrl_anchor = end_of_seq_node->GetOutControlAnchor();
GE_CHK_BOOL_EXEC(out_ctrl_anchor != nullptr, GELOGW("out_ctrl_anchor is null."); return nullptr); GE_CHK_BOOL_EXEC(out_ctrl_anchor != nullptr, GELOGW("out_ctrl_anchor is null."); return nullptr);
@@ -193,8 +204,9 @@ ge::NodePtr IteratorOpPass::InsertEndOfSequenceNode(const ge::NodePtr &pre_node,
end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str(), end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str(),
out_node->GetName().c_str(), out_node->GetType().c_str()); out_node->GetName().c_str(), out_node->GetType().c_str());
return nullptr, return nullptr,
"Graph add EndOfSequence op out ctrl edge fail, dst node: %s.",
out_node->GetName().c_str());
"[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str(),
out_node->GetName().c_str(), out_node->GetType().c_str());
GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.", GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.",
out_node->GetName().c_str()); out_node->GetName().c_str());
} }
@@ -212,26 +224,26 @@ ge::OpDescPtr IteratorOpPass::CreateEndOfSequenceOp(const ge::NodePtr &pre_node)
GELOGI("Start to create endOfSequence op."); GELOGI("Start to create endOfSequence op.");
GE_CHK_BOOL_EXEC(pre_node != nullptr, GE_CHK_BOOL_EXEC(pre_node != nullptr,
REPORT_INNER_ERROR("E19999", "Param pre_node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param pre_node is nullptr, check invalid");
return nullptr, "Input param invalid.");
return nullptr, "[Check][Param] Input param pre_node invalid.");


string node_name = pre_node->GetName() + "_EndOfSequence"; string node_name = pre_node->GetName() + "_EndOfSequence";
ge::OpDescPtr op_desc = MakeShared<OpDesc>(node_name, ENDOFSEQUENCE); ge::OpDescPtr op_desc = MakeShared<OpDesc>(node_name, ENDOFSEQUENCE);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "MakeShared fail.");
GELOGE(FAILED, "[New][OpDesc] failed.");
return op_desc; return op_desc;
} }
ge::OpDescPtr pre_node_op_desc = pre_node->GetOpDesc(); ge::OpDescPtr pre_node_op_desc = pre_node->GetOpDesc();
GE_CHK_BOOL_EXEC(pre_node_op_desc != nullptr, GE_CHK_BOOL_EXEC(pre_node_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
return nullptr, "OpDesc of pre_node is invalid.");
return nullptr, "[Get][OpDesc] failed, OpDesc of pre_node is invalid.");


GELOGI("Create EndOfSequence op:%s.", op_desc->GetName().c_str()); GELOGI("Create EndOfSequence op:%s.", op_desc->GetName().c_str());
GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(pre_node_op_desc->GetOutputDesc(0)) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(pre_node_op_desc->GetOutputDesc(0)) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr, return nullptr,
"Create EndOfSequence op:add input desc fail.");
"[Add][InputDesc] to op:%s(%s) failed", op_desc->GetName().c_str(), op_desc->GetType().c_str());
return op_desc; return op_desc;
} }


@@ -252,7 +264,9 @@ ge::NodePtr IteratorOpPass::InsertMemcpyAsyncNode(const ge::NodePtr &pre_node, c
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
memcpy_async_op_desc->GetName().c_str(), memcpy_async_op_desc->GetType().c_str(), memcpy_async_op_desc->GetName().c_str(), memcpy_async_op_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
return nullptr, "Insert mencpy node fail.");
return nullptr,
"[Add][Node] %s(%s) to graph:%s failed", memcpy_async_op_desc->GetName().c_str(),
memcpy_async_op_desc->GetType().c_str(), graph->GetName().c_str());


// Data out // Data out
for (auto &out_anchor : pre_node->GetAllOutDataAnchors()) { for (auto &out_anchor : pre_node->GetAllOutDataAnchors()) {
@@ -265,37 +279,45 @@ ge::NodePtr IteratorOpPass::InsertMemcpyAsyncNode(const ge::NodePtr &pre_node, c
GE_IF_BOOL_EXEC(peer_in_anchor == nullptr, GELOGW("peer_in_anchor is nullptr"); return nullptr); GE_IF_BOOL_EXEC(peer_in_anchor == nullptr, GELOGW("peer_in_anchor is nullptr"); return nullptr);
status = GraphUtils::RemoveEdge(out_anchor, peer_in_anchor); status = GraphUtils::RemoveEdge(out_anchor, peer_in_anchor);
GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(), out_anchor->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(),
peer_in_anchor->GetIdx());
return nullptr, "Remove edge failed, index:%d.", out_anchor->GetIdx());
REPORT_CALL_ERROR("E19999",
"Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_node->GetName().c_str(),
pre_node->GetType().c_str(), out_anchor->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(),
peer_in_anchor->GetIdx());
return nullptr,
"[Remove][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(), out_anchor->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(),
peer_in_anchor->GetIdx());
status = GraphUtils::AddEdge(memcpy_async_node->GetOutDataAnchor(out_anchor->GetIdx()), peer_in_anchor); status = GraphUtils::AddEdge(memcpy_async_node->GetOutDataAnchor(out_anchor->GetIdx()), peer_in_anchor);
GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
out_anchor->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(),
peer_in_anchor->GetIdx());
REPORT_CALL_ERROR("E19999",
"Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
out_anchor->GetIdx(), peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx());
return nullptr, return nullptr,
"Graph add memcpyAsync op out edge fail, src index:%d, dst index:%d, dst node: %s.",
out_anchor->GetIdx(), peer_in_anchor->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
"Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
out_anchor->GetIdx(), peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx());
GELOGI("Graph add memcpyAsync op out edge, src index:%d, dst index:%d, dst node: %s.", out_anchor->GetIdx(), GELOGI("Graph add memcpyAsync op out edge, src index:%d, dst index:%d, dst node: %s.", out_anchor->GetIdx(),
peer_in_anchor->GetIdx(), peer_in_anchor->GetOwnerNode()->GetName().c_str()); peer_in_anchor->GetIdx(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
} }
status = GraphUtils::AddEdge(out_anchor, memcpy_async_node->GetInDataAnchor(out_anchor->GetIdx())); status = GraphUtils::AddEdge(out_anchor, memcpy_async_node->GetInDataAnchor(out_anchor->GetIdx()));
GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(), out_anchor->GetIdx(),
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
out_anchor->GetIdx());
return nullptr, "Graph add memcpyAsync op in edge fail, index:%d.",
REPORT_CALL_ERROR("E19999",
"Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(), out_anchor->GetIdx(),
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
out_anchor->GetIdx());
return nullptr,
"[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(), out_anchor->GetIdx(),
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
out_anchor->GetIdx()); out_anchor->GetIdx());
} }
// Control out // Control out
@@ -304,23 +326,27 @@ ge::NodePtr IteratorOpPass::InsertMemcpyAsyncNode(const ge::NodePtr &pre_node, c
for (auto &peer_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) { for (auto &peer_in_ctrl_anchor : out_ctrl_anchor->GetPeerInControlAnchors()) {
ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor); ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor);
GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
return nullptr, "Remove edge failed, dst node: %s.",
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str());
REPORT_CALL_ERROR("E19999",
"Remove control edge between op:%s(%s) and op:%s(%s) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
return nullptr,
"[Remove][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
status = GraphUtils::AddEdge(memcpy_async_node->GetOutControlAnchor(), peer_in_ctrl_anchor); status = GraphUtils::AddEdge(memcpy_async_node->GetOutControlAnchor(), peer_in_ctrl_anchor);
GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(status == GRAPH_SUCCESS,
REPORT_CALL_ERROR(
"E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
return nullptr, return nullptr,
"Graph add memcpyAsync op out ctrl edge fail, dst node: %s.",
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str());
"[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
memcpy_async_node->GetName().c_str(), memcpy_async_node->GetType().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
GELOGI("Graph add memcpyAsync op out ctrl edge, dst node: %s.", GELOGI("Graph add memcpyAsync op out ctrl edge, dst node: %s.",
peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str()); peer_in_ctrl_anchor->GetOwnerNode()->GetName().c_str());
}); });
@@ -342,7 +368,7 @@ ge::OpDescPtr IteratorOpPass::CreateMemcpyAsyncOp(const ge::NodePtr &pre_node) {
ge::OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), MEMCPYASYNC); ge::OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), MEMCPYASYNC);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "MakeShared fail.");
GELOGE(FAILED, "[New][OpDesc] failed");
return op_desc; return op_desc;
} }
GELOGI("Create memcpyAsync op:%s.", op_desc->GetName().c_str()); GELOGI("Create memcpyAsync op:%s.", op_desc->GetName().c_str());
@@ -350,7 +376,7 @@ ge::OpDescPtr IteratorOpPass::CreateMemcpyAsyncOp(const ge::NodePtr &pre_node) {
ge::OpDescPtr pre_node_op_desc = pre_node->GetOpDesc(); ge::OpDescPtr pre_node_op_desc = pre_node->GetOpDesc();
GE_CHK_BOOL_EXEC(pre_node_op_desc != nullptr, GE_CHK_BOOL_EXEC(pre_node_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
return nullptr, "OpDesc of pre_node is invalid.");
return nullptr, "[Get][OpDesc] failed, OpDesc of pre_node is invalid.");


size_t out_size = pre_node_op_desc->GetOutputsSize(); size_t out_size = pre_node_op_desc->GetOutputsSize();
GELOGI("Create memcpyAsync op, pre_node out_size: %zu.", out_size); GELOGI("Create memcpyAsync op, pre_node out_size: %zu.", out_size);
@@ -359,12 +385,14 @@ ge::OpDescPtr IteratorOpPass::CreateMemcpyAsyncOp(const ge::NodePtr &pre_node) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str()); pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str());
return nullptr, return nullptr,
"Create memcpyAsync op:add input desc fail.");
"[Add][InputDesc] to op:%s(%s) failed",
pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str());
GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(pre_node_op_desc->GetOutputDesc(i)) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(pre_node_op_desc->GetOutputDesc(i)) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str()); pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str());
return nullptr, return nullptr,
"Create memcpyAsync op:add output desc fail.");
"[Add][OutputDesc] to op:%s(%s) failed",
pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str());
} }


return op_desc; return op_desc;


+ 4
- 2
ge/graph/passes/link_gen_mask_nodes_pass.cc View File

@@ -46,7 +46,7 @@ Status LinkGenMaskNodesPass::Run(ComputeGraphPtr graph) {
size_t gen_mask_group_size = gen_mask_nodes.size(); size_t gen_mask_group_size = gen_mask_nodes.size();
Status status = GetGenMaskGroupSize(gen_mask_nodes, gen_mask_group_size); Status status = GetGenMaskGroupSize(gen_mask_nodes, gen_mask_group_size);
if (status != SUCCESS) { if (status != SUCCESS) {
GELOGE(FAILED, "Get GenMask group size failed.");
GELOGE(FAILED, "[Get][GenMaskGroupSize] failed.");
return FAILED; return FAILED;
} }


@@ -73,7 +73,9 @@ Status LinkGenMaskNodesPass::Run(ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Op:%s(%s) link control to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Op:%s(%s) link control to op:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(), src_node->GetName().c_str(), src_node->GetType().c_str(),
dest_node->GetName().c_str(), dest_node->GetType().c_str()); dest_node->GetName().c_str(), dest_node->GetType().c_str());
GELOGE(FAILED, "Link from %s to %s failed.", src_node->GetName().c_str(), dest_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] Op:%s(%s) link control to op:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(),
dest_node->GetName().c_str(), dest_node->GetType().c_str());
return FAILED; return FAILED;
} }
GELOGD("Link from %s to %s.", src_node->GetName().c_str(), dest_node->GetName().c_str()); GELOGD("Link from %s to %s.", src_node->GetName().c_str(), dest_node->GetName().c_str());


+ 1
- 1
ge/graph/passes/mark_agnostic_pass.cc View File

@@ -68,7 +68,7 @@ Status MarkAgnosticPass::Run(ComputeGraphPtr graph) {


// Set attr for enter and nextiteration // Set attr for enter and nextiteration
if (HandWhileLoop(node) != SUCCESS) { if (HandWhileLoop(node) != SUCCESS) {
GELOGE(FAILED, "Node: %s type merge handle while loop failed", node->GetName().c_str());
GELOGE(FAILED, "[Hand][WhileLoop] for node:%s failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }
continue; continue;


+ 2
- 1
ge/graph/passes/mark_force_unknown_for_cond_pass.cc View File

@@ -45,7 +45,8 @@ Status MarkForceUnknownForCondPass::Run(ComputeGraphPtr graph) {
std::map<NodePtr, std::vector<NodePtr>> switch_groups; std::map<NodePtr, std::vector<NodePtr>> switch_groups;
for (const auto &node : graph->GetDirectNode()) { for (const auto &node : graph->GetDirectNode()) {
std::string node_type; std::string node_type;
GE_CHK_STATUS_RET(GetOriginalType(node, node_type), "Get original type failed.");
GE_CHK_STATUS_RET(GetOriginalType(node, node_type),
"[Get][OriginalType] of node in graph:%s failed.", graph->GetName().c_str());
if (kMergeOpTypes.count(node_type) == 0) { if (kMergeOpTypes.count(node_type) == 0) {
continue; continue;
} }


+ 1
- 1
ge/graph/passes/mark_graph_unknown_status_pass.cc View File

@@ -29,7 +29,7 @@ Status MarkGraphUnknownStatusPass::Run(ComputeGraphPtr graph) {
bool forced_unknown = false; bool forced_unknown = false;
for (const auto &node : graph->GetDirectNode()) { for (const auto &node : graph->GetDirectNode()) {
GE_CHK_GRAPH_STATUS_RET(ge::NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown_shape), GE_CHK_GRAPH_STATUS_RET(ge::NodeUtils::GetNodeUnknownShapeStatus(*node, is_unknown_shape),
"Get node[%s] shape status failed!", node->GetName().c_str());
"[Get][ShapeStatus] of node[%s] failed!", node->GetName().c_str());
if (is_unknown_shape) { if (is_unknown_shape) {
break; break;
} }


+ 80
- 58
ge/graph/passes/memcpy_addr_async_pass.cc View File

@@ -30,7 +30,9 @@ Status MemcpyAddrAsyncPass::Run(ComputeGraphPtr graph) {
if (node->GetType() == STREAMSWITCH) { if (node->GetType() == STREAMSWITCH) {
auto sub_graph = node->GetOwnerComputeGraph(); auto sub_graph = node->GetOwnerComputeGraph();
if (sub_graph != nullptr && !sub_graph->GetGraphUnknownFlag()) { if (sub_graph != nullptr && !sub_graph->GetGraphUnknownFlag()) {
GE_CHK_STATUS_RET(AddMemcpyAsyncNode(node), "Add memcpyasync node failed in known subgraph.");
GE_CHK_STATUS_RET(AddMemcpyAsyncNode(node),
"[Add][MemcpyAsyncNode] for node:%s in known subgraph:%s failed.",
node->GetName().c_str(), sub_graph->GetName().c_str());
} }
} }
} }
@@ -41,9 +43,8 @@ Status MemcpyAddrAsyncPass::Run(ComputeGraphPtr graph) {
int64_t value = 0; int64_t value = 0;
rtError_t rt_ret = rtGetRtCapability(FEATURE_TYPE_MEMCPY, MEMCPY_INFO_SUPPORT_ZEROCOPY, &value); rtError_t rt_ret = rtGetRtCapability(FEATURE_TYPE_MEMCPY, MEMCPY_INFO_SUPPORT_ZEROCOPY, &value);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtGetRtCapability failed, ret = 0x%X",
rt_ret);
GELOGE(RT_FAILED, "rtGetRtCapability failed, error=0x%x.", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtGetRtCapability failed, ret = 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtGetRtCapability] failed, ret = 0x%x.", rt_ret);
return RT_FAILED; return RT_FAILED;
} }


@@ -59,7 +60,8 @@ Status MemcpyAddrAsyncPass::Run(ComputeGraphPtr graph) {
if (op_desc->GetType() == STREAMSWITCHN || op_desc->GetType() == STREAMMERGE) { if (op_desc->GetType() == STREAMSWITCHN || op_desc->GetType() == STREAMMERGE) {
Status ret = AddMemcpyAddrAsyncNode(graph, node); Status ret = AddMemcpyAddrAsyncNode(graph, node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "AddMemcpyAddrAsyncNode failed.");
GELOGE(ret, "[Add][MemcpyAddrAsyncNode] for %s in graph:%s failed.", node->GetName().c_str(),
graph->GetName().c_str());
return ret; return ret;
} }
} }
@@ -69,7 +71,8 @@ Status MemcpyAddrAsyncPass::Run(ComputeGraphPtr graph) {
if (node->GetOwnerComputeGraph()->GetParentNode() == nullptr) { if (node->GetOwnerComputeGraph()->GetParentNode() == nullptr) {
Status ret = InsertMemAddrAsyncNodeBeforeNetoutput(node->GetOwnerComputeGraph(), node); Status ret = InsertMemAddrAsyncNodeBeforeNetoutput(node->GetOwnerComputeGraph(), node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "AddMemcpyAddrAsyncNode failed.");
GELOGE(ret, "[Insert][MemAddrAsyncNode] Before Netoutput for node:%s in graph:%s failed.",
node->GetName().c_str(), graph->GetName().c_str());
return ret; return ret;
} }
} }
@@ -88,12 +91,13 @@ Status MemcpyAddrAsyncPass::AddMemcpyAsyncNode(const NodePtr &node) {
GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue);
auto memcpy_async_node = CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor, node); auto memcpy_async_node = CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor, node);
if (memcpy_async_node == nullptr) { if (memcpy_async_node == nullptr) {
GELOGE(INTERNAL_ERROR, "Create memcpyasync node failed.");
GELOGE(INTERNAL_ERROR, "[Create][MemcpyAddrAsyncNode] for node:%s in subgraph failed.",
node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_async_node); Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_async_node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "Insert memcpyasync node failed.");
GELOGE(ret, "[Insert][MemcpyAddrAsyncNode] failed, memcpy_async_node:%s.", memcpy_async_node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -114,18 +118,23 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph,
if (owner_graph->GetParentGraph() == nullptr) { if (owner_graph->GetParentGraph() == nullptr) {
GELOGI("Need to insert MemcpyAddrAsync directly when data in parent graph."); GELOGI("Need to insert MemcpyAddrAsync directly when data in parent graph.");
NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor, node); NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor, node);
GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr, GELOGE(INTERNAL_ERROR, "CreateMemcpyAddrAsyncNode failed.");
GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr,
GELOGE(INTERNAL_ERROR, "[Create][MemcpyAddrAsyncNode] failed, node:%s.",
node->GetName().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);


Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_addr_async_node); Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_addr_async_node);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "InsertMemcpyAddrAsyncNode failed."); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(ret, "[Insert][MemcpyAddrAsyncNode] failed, memcpy_addr_async_node:%s.",
memcpy_addr_async_node->GetName().c_str());
return ret);
} else { } else {
uint32_t parent_index = 0; uint32_t parent_index = 0;
if (!AttrUtils::GetInt(in_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { if (!AttrUtils::GetInt(in_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(),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
in_node->GetName().c_str(), in_node->GetType().c_str()); in_node->GetName().c_str(), in_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to get parent index of %s", in_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
in_node->GetName().c_str(), in_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
// Data is in sub_graph // Data is in sub_graph
@@ -141,11 +150,15 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph,
GE_CHECK_NOTNULL(peer_out_anchor_); GE_CHECK_NOTNULL(peer_out_anchor_);
NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor_, out_of_user_data_); NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor_, out_of_user_data_);
GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr, GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr,
GELOGE(INTERNAL_ERROR, "CreateMemcpyAddrAsyncNode failed.");
GELOGE(INTERNAL_ERROR, "[Create][MemcpyAddrAsyncNode] failed, out_of_user_data_:%s.",
out_of_user_data_->GetName().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);


Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor_, in_anchor_, memcpy_addr_async_node); Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor_, in_anchor_, memcpy_addr_async_node);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "InsertMemcpyAddrAsyncNode failed."); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(ret, "[Insert][MemcpyAddrAsyncNode] failed, memcpy_addr_async_node:%s.",
memcpy_addr_async_node->GetName().c_str());
return ret);
} }
if (find_user_data_for_known_) { if (find_user_data_for_known_) {
GELOGI("Insert memcpy_addr_async for known graph."); GELOGI("Insert memcpy_addr_async for known graph.");
@@ -153,12 +166,17 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph,
NodePtr memcpy_addr_async_node = NodePtr memcpy_addr_async_node =
CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_); CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_);
GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr, GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr,
GELOGE(INTERNAL_ERROR, "CreateMemcpyAddrAsyncNode for known failed.");
GELOGE(INTERNAL_ERROR,
"[Create][MemcpyAddrAsyncNode] for known failed, out_of_user_data_for_known_:%s",
out_of_user_data_for_known_->GetName().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);


Status ret = Status ret =
InsertMemcpyAddrAsyncNode(peer_out_anchor_for_known_, in_anchor_for_known_, memcpy_addr_async_node); InsertMemcpyAddrAsyncNode(peer_out_anchor_for_known_, in_anchor_for_known_, memcpy_addr_async_node);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "InsertMemcpyAddrAsyncNode for known failed."); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(ret, "[Insert][MemcpyAddrAsyncNode] for known failed, memcpy_addr_async_node:%s.",
memcpy_addr_async_node->GetName().c_str());
return ret);
} }
} }
} }
@@ -188,9 +206,9 @@ void MemcpyAddrAsyncPass::FindUserDataForNonDynamic(const ge::NodePtr &parent_no
OutDataAnchorPtr out_anchor = in_data_anchor->GetPeerOutAnchor(); OutDataAnchorPtr out_anchor = in_data_anchor->GetPeerOutAnchor();
GE_IF_BOOL_EXEC(out_anchor == nullptr, GE_IF_BOOL_EXEC(out_anchor == nullptr,
REPORT_INNER_ERROR("E19999", "Index:%u in data node of op:%s(%s) not exist, check invalid", REPORT_INNER_ERROR("E19999", "Index:%u in data node of op:%s(%s) not exist, check invalid",
parent_index,
parent_node->GetName().c_str(), parent_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Cannot find out_anchor of %s.", parent_node->GetName().c_str());
parent_index, parent_node->GetName().c_str(), parent_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Get][PeerOutAnchor] Index:%u in data node of op:%s(%s) not exist",
parent_index, parent_node->GetName().c_str(), parent_node->GetType().c_str());
return); return);
NodePtr in_node = out_anchor->GetOwnerNode(); NodePtr in_node = out_anchor->GetOwnerNode();
GELOGI("in_node of parent_node is %s.", in_node->GetName().c_str()); GELOGI("in_node of parent_node is %s.", in_node->GetName().c_str());
@@ -203,10 +221,10 @@ void MemcpyAddrAsyncPass::FindUserDataForNonDynamic(const ge::NodePtr &parent_no
in_anchor_for_known_ = in_data_anchor; in_anchor_for_known_ = in_data_anchor;
NodePtr pre_in_node = in_node->GetOwnerComputeGraph()->GetParentNode(); NodePtr pre_in_node = in_node->GetOwnerComputeGraph()->GetParentNode();
if (!AttrUtils::GetInt(in_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { if (!AttrUtils::GetInt(in_node->GetOpDesc(), 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(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
in_node->GetName().c_str(), in_node->GetType().c_str()); in_node->GetName().c_str(), in_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to refresh parent index of %s", in_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
in_node->GetName().c_str(), in_node->GetType().c_str());
return; return;
} }
FindUserData(pre_in_node, parent_index); FindUserData(pre_in_node, parent_index);
@@ -222,10 +240,10 @@ void MemcpyAddrAsyncPass::FindUserDataForNonDynamic(const ge::NodePtr &parent_no
} }
} else if (in_node->GetType() == IF || in_node->GetType() == WHILE || in_node->GetType() == CASE) { } else if (in_node->GetType() == IF || in_node->GetType() == WHILE || in_node->GetType() == CASE) {
if (!AttrUtils::GetInt(parent_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { if (!AttrUtils::GetInt(parent_node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s to op:%s(%s) failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
parent_node->GetName().c_str(), parent_node->GetType().c_str()); parent_node->GetName().c_str(), parent_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to refresh parent index of %s", in_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
parent_node->GetName().c_str(), parent_node->GetType().c_str());
return; return;
} }
FindUserData(in_node, parent_index); FindUserData(in_node, parent_index);
@@ -258,7 +276,7 @@ NodePtr MemcpyAddrAsyncPass::CreateMemcpyAddrAsyncNode(const ComputeGraphPtr &gr
OpDescPtr pre_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc(); OpDescPtr pre_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc();
GE_CHK_BOOL_EXEC(pre_op_desc != nullptr, GE_CHK_BOOL_EXEC(pre_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
return nullptr, "Op_desc of pre node is invalid.");
return nullptr, "[Get][OpDesc] failed, Op_desc of pre node is invalid.");


OpDescPtr op_desc = nullptr; OpDescPtr op_desc = nullptr;
if (known_sub_graph_) { // insert memcpyasync node when known sub graph if (known_sub_graph_) { // insert memcpyasync node when known sub graph
@@ -268,21 +286,21 @@ NodePtr MemcpyAddrAsyncPass::CreateMemcpyAddrAsyncNode(const ComputeGraphPtr &gr
string node_name = pre_op_desc->GetName() + "_" + MEMCPYADDRASYNC + "_" + std::to_string(new_node_index++); string node_name = pre_op_desc->GetName() + "_" + MEMCPYADDRASYNC + "_" + std::to_string(new_node_index++);
op_desc = MakeShared<OpDesc>(node_name, MEMCPYADDRASYNC); op_desc = MakeShared<OpDesc>(node_name, MEMCPYADDRASYNC);
} }
GE_CHECK_NOTNULL_EXEC(op_desc,
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
return nullptr);
GE_CHECK_NOTNULL_EXEC(op_desc, REPORT_CALL_ERROR("E19999", "New OpDesc failed"); return nullptr);


if (op_desc->AddInputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) != GRAPH_SUCCESS) { if (op_desc->AddInputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
pre_op_desc->GetName().c_str(), pre_op_desc->GetType().c_str()); pre_op_desc->GetName().c_str(), pre_op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add memcpy_addr_async input desc failed.");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed",
pre_op_desc->GetName().c_str(), pre_op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


if (op_desc->AddOutputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) != GRAPH_SUCCESS) { if (op_desc->AddOutputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
pre_op_desc->GetName().c_str(), pre_op_desc->GetType().c_str()); pre_op_desc->GetName().c_str(), pre_op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add memcpy_addr_async output desc failed.");
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed",
pre_op_desc->GetName().c_str(), pre_op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -302,19 +320,17 @@ NodePtr MemcpyAddrAsyncPass::CreateMemcpyAddrAsyncNode(const ComputeGraphPtr &gr
(void)ge::AttrUtils::GetBool(out_of_user_data->GetOpDesc(), ATTR_NAME_NODE_CONNECT_INPUT, labeled_input); (void)ge::AttrUtils::GetBool(out_of_user_data->GetOpDesc(), ATTR_NAME_NODE_CONNECT_INPUT, labeled_input);
if (labeled_input) { if (labeled_input) {
if (!ge::AttrUtils::SetBool(out_of_user_data->GetOpDesc(), ATTR_NAME_NODE_CONNECT_INPUT, false)) { if (!ge::AttrUtils::SetBool(out_of_user_data->GetOpDesc(), ATTR_NAME_NODE_CONNECT_INPUT, false)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
out_of_user_data->GetName().c_str(), out_of_user_data->GetType().c_str()); out_of_user_data->GetName().c_str(), out_of_user_data->GetType().c_str());
GELOGE(FAILED, "Failed to unset attr %s for node %s.", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
out_of_user_data->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
out_of_user_data->GetName().c_str(), out_of_user_data->GetType().c_str());
return nullptr; return nullptr;
} }
if (!ge::AttrUtils::SetBool(op_desc, ATTR_NAME_NODE_CONNECT_INPUT, true)) { if (!ge::AttrUtils::SetBool(op_desc, ATTR_NAME_NODE_CONNECT_INPUT, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Failed to set attr %s for node %s.", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_NODE_CONNECT_INPUT.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
} }
@@ -335,29 +351,30 @@ Status MemcpyAddrAsyncPass::InsertMemcpyAddrAsyncNode(const OutDataAnchorPtr &ou
if (GraphUtils::RemoveEdge(out_anchor, in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::RemoveEdge(out_anchor, in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", 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->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
out_anchor->GetIdx(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Remove edge of %s and %s failed.", out_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str());
out_anchor->GetIdx(), in_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetType().c_str(), in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "[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(), in_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetType().c_str(), in_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (GraphUtils::AddEdge(out_anchor, node->GetInDataAnchor(0)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(out_anchor, node->GetInDataAnchor(0)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
out_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add edge of %s and %s failed.", out_anchor->GetOwnerNode()->GetName().c_str(),
node->GetName().c_str());
out_anchor->GetIdx(), node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
out_anchor->GetIdx(), node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (GraphUtils::AddEdge(node->GetOutDataAnchor(0), in_anchor) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(node->GetOutDataAnchor(0), in_anchor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Add edge of %s and %s failed.", node->GetName().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), in_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetType().c_str(), in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), in_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetType().c_str(), in_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
return SUCCESS; return SUCCESS;
@@ -381,11 +398,16 @@ Status MemcpyAddrAsyncPass::InsertMemAddrAsyncNodeBeforeNetoutput(const ComputeG
} }
GELOGI("Need to insert MemcpyAddrAsync before netoutput on parent graph."); GELOGI("Need to insert MemcpyAddrAsync before netoutput on parent graph.");
NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor, in_node); NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor, in_node);
GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr, GELOGE(INTERNAL_ERROR, "CreateMemcpyAddrAsyncNode failed.");
GE_IF_BOOL_EXEC(memcpy_addr_async_node == nullptr,
GELOGE(INTERNAL_ERROR, "[Create][MemcpyAddrAsyncNode] failed, in_node:%s.",
in_node->GetName().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);


Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_addr_async_node); Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_addr_async_node);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "InsertMemcpyAddrAsyncNode failed."); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(ret, "[Insert][MemcpyAddrAsyncNode] failed, memcpy_addr_async_node:%s.",
memcpy_addr_async_node->GetName().c_str());
return ret);
GELOGI("Insert mem_addr_async node %s success between %s and %s.", memcpy_addr_async_node->GetName().c_str(), GELOGI("Insert mem_addr_async node %s success between %s and %s.", memcpy_addr_async_node->GetName().c_str(),
in_node->GetName().c_str(), node->GetName().c_str()); in_node->GetName().c_str(), node->GetName().c_str());
// if src node is const, need to update attr and offset here because this pass process is after offset set. // if src node is const, need to update attr and offset here because this pass process is after offset set.


+ 21
- 10
ge/graph/passes/merge_input_memcpy_pass.cc View File

@@ -26,14 +26,16 @@ Status MergeInputMemcpyPass::Run(ComputeGraphPtr graph) {
std::unordered_map<NodePtr, std::vector<NodePtr>> switch_groups; std::unordered_map<NodePtr, std::vector<NodePtr>> switch_groups;
for (const auto &node : graph->GetDirectNode()) { for (const auto &node : graph->GetDirectNode()) {
std::string type; std::string type;
GE_CHK_STATUS_RET(GetOriginalType(node, type), "Get node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(node, type),
"[Get][OriginalType] of node in graph:%s failed.", graph->GetName().c_str());
if ((type != MERGE) && (type != REFMERGE)) { if ((type != MERGE) && (type != REFMERGE)) {
continue; continue;
} }


GE_CHECK_NOTNULL(node->GetOpDesc()); GE_CHECK_NOTNULL(node->GetOpDesc());
GE_CHK_STATUS_RET(AddMemcpyAsyncNodes(graph, node, node->GetOpDesc()->HasAttr(ATTR_INSERT_BY_MBATCH)), GE_CHK_STATUS_RET(AddMemcpyAsyncNodes(graph, node, node->GetOpDesc()->HasAttr(ATTR_INSERT_BY_MBATCH)),
"Merge add memcpy node failed.");
"[Add][MemcpyAsyncNodes] failed, graph:%s, node:%s.", graph->GetName().c_str(),
node->GetName().c_str());
} }


GELOGD("MergeInputMemcpyPass Leave"); GELOGD("MergeInputMemcpyPass Leave");
@@ -60,13 +62,17 @@ Status MergeInputMemcpyPass::AddMemcpyAsyncNodes(const ComputeGraphPtr &graph, c


const std::string &memcpy_name = node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()); const std::string &memcpy_name = node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx());
NodePtr memcpy_node = CreateMemcpyAsyncNode(graph, memcpy_name, peer_out_anchor, multi_batch_flag); NodePtr memcpy_node = CreateMemcpyAsyncNode(graph, memcpy_name, peer_out_anchor, multi_batch_flag);
GE_CHK_BOOL_EXEC(memcpy_node != nullptr, return FAILED, "Create MemcpyAsync node failed.");
GE_CHK_BOOL_EXEC(memcpy_node != nullptr, return FAILED,
"[Create][MemcpyAsyncNode] failed, memcpy_name:%s.", memcpy_name.c_str());
GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor), GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor),
"MemcpyAsync node remove edge failed.");
"[Remove][Edge] between %s and %s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(peer_out_anchor, memcpy_node->GetInDataAnchor(0)), GE_CHK_STATUS(GraphUtils::AddEdge(peer_out_anchor, memcpy_node->GetInDataAnchor(0)),
"MemcpyAsync node add edge failed.");
"[Add][Edge] between %s and %s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
memcpy_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(memcpy_node->GetOutDataAnchor(0), in_data_anchor), GE_CHK_STATUS(GraphUtils::AddEdge(memcpy_node->GetOutDataAnchor(0), in_data_anchor),
"MemcpyAsync node add edge failed.");
"[Add][Edge] between %s and %s failed.", memcpy_node->GetName().c_str(),
node->GetName().c_str());
} }


return SUCCESS; return SUCCESS;
@@ -83,25 +89,30 @@ Status MergeInputMemcpyPass::AddMemcpyAsyncNodes(const ComputeGraphPtr &graph, c
NodePtr MergeInputMemcpyPass::CreateMemcpyAsyncNode(const ComputeGraphPtr &graph, const std::string &name, NodePtr MergeInputMemcpyPass::CreateMemcpyAsyncNode(const ComputeGraphPtr &graph, const std::string &name,
const OutDataAnchorPtr &out_data_anchor, bool multi_batch_flag) { const OutDataAnchorPtr &out_data_anchor, bool multi_batch_flag) {
OpDescPtr pre_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc(); OpDescPtr pre_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc();
GE_CHK_BOOL_EXEC(pre_op_desc != nullptr, return nullptr, "OpDesc of pre node is invalid.");
GE_CHK_BOOL_EXEC(pre_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "opdesc of pre node is nullptr, check invalid");
return nullptr, "[Get][OpDesc] failed, OpDesc of pre node is invalid.");


const std::string &memcpy_type = multi_batch_flag ? MEMCPYADDRASYNC : MEMCPYASYNC; const std::string &memcpy_type = multi_batch_flag ? MEMCPYADDRASYNC : MEMCPYASYNC;
const std::string &node_name = name + "_" + memcpy_type; const std::string &node_name = name + "_" + memcpy_type;
GELOGI("Create MemcpyAsync op:%s.", node_name.c_str()); GELOGI("Create MemcpyAsync op:%s.", node_name.c_str());
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, memcpy_type); OpDescPtr op_desc = MakeShared<OpDesc>(node_name, memcpy_type);
if (op_desc == nullptr) { if (op_desc == nullptr) {
GELOGE(FAILED, "Create op_desc failed, MemcpyAsync:%s.", node_name.c_str());
REPORT_CALL_ERROR("E19999", "Create OpDesc failed, node_name:%s", node_name.c_str());
GELOGE(FAILED, "[Create][OpDesc] failed, MemcpyAsync:%s.", node_name.c_str());
return nullptr; return nullptr;
} }


GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr, "Create MemcpyAsync op: add input desc failed.");
return nullptr,
"[Add][InputDesc] to op:%s(%s) failed", op_desc->GetName().c_str(), op_desc->GetType().c_str());
GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx())) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr, "Create MemcpyAsync op: add output desc failed.");
return nullptr,
"[Add][OutputDesc] to op:%s(%s) failed", op_desc->GetName().c_str(), op_desc->GetType().c_str());


return graph->AddNode(op_desc); return graph->AddNode(op_desc);
} }


+ 21
- 14
ge/graph/passes/merge_pass.cc View File

@@ -36,12 +36,12 @@ Status MergePass::Run(NodePtr &node) {
GELOGD("MergePass running"); GELOGD("MergePass running");
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [node] must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }


std::string op_type; std::string op_type;
GE_CHK_STATUS_RET(GetOriginalType(node, op_type), "get original type failed");
GE_CHK_STATUS_RET(GetOriginalType(node, op_type), "[Get][OriginalType] of node:%s failed", node->GetName().c_str());
if (op_type != MERGE) { if (op_type != MERGE) {
return SUCCESS; return SUCCESS;
} }
@@ -49,7 +49,8 @@ Status MergePass::Run(NodePtr &node) {
if (node->GetAllOutDataAnchors().empty()) { if (node->GetAllOutDataAnchors().empty()) {
REPORT_INNER_ERROR("E19999", "Param node:%s(%s) all data anchor size is 0, check invalid", REPORT_INNER_ERROR("E19999", "Param node:%s(%s) all data anchor size is 0, check invalid",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(PARAM_INVALID, "[%s] Merge node output anchor is empty", node->GetName().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Param node:%s(%s) all data anchor size is 0",
node->GetName().c_str(), node->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }


@@ -75,7 +76,7 @@ Status MergePass::Run(NodePtr &node) {
if (merge_io_map[0] != -1 && IsNeedChangeIndexToConstant(node)) { if (merge_io_map[0] != -1 && IsNeedChangeIndexToConstant(node)) {
int index = merge_io_map[0]; int index = merge_io_map[0];
if (ChangeIndexToConstant(node, index) != SUCCESS) { if (ChangeIndexToConstant(node, index) != SUCCESS) {
GELOGE(FAILED, "[%s] Change value index to be Constant failed.", node->GetName().c_str());
GELOGE(FAILED, "[Change][Index] to be Constant failed, node:%s.", node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -84,7 +85,7 @@ Status MergePass::Run(NodePtr &node) {
if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) { if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
in_node->GetName().c_str(), in_node->GetType().c_str()); in_node->GetName().c_str(), in_node->GetType().c_str());
GELOGE(FAILED, "Isolate and delete node %s failed.", in_node->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s failed.", in_node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -122,7 +123,8 @@ Status MergePass::ChangeIndexToConstant(NodePtr &node, int &value_index) {
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str());
GELOGE(FAILED, "[Get][ComputeGraph] failed, Owner graph of node:%s(%s) is nullptr.",
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -143,7 +145,9 @@ Status MergePass::ChangeIndexToConstant(NodePtr &node, int &value_index) {
REPORT_CALL_ERROR("E19999", "Replace node:%s(%s) by node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Replace node:%s(%s) by node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str()); const_node->GetName().c_str(), const_node->GetType().c_str());
GELOGE(FAILED, "[%s] ReplaceNodeAnchors failed.", node->GetName().c_str());
GELOGE(FAILED, "[Replace][Node] %s(%s) by node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str());
return FAILED; return FAILED;
} }
auto out_control_anchor = node->GetOutControlAnchor(); auto out_control_anchor = node->GetOutControlAnchor();
@@ -165,7 +169,7 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr &
op_desc = MakeShared<OpDesc>(constant_name, CONSTANT); op_desc = MakeShared<OpDesc>(constant_name, CONSTANT);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "[%s] Make shared of Constant op desc failed.", constant_name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed, name:%s.", constant_name.c_str());
return FAILED; return FAILED;
} }


@@ -173,7 +177,7 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr &
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"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(FAILED, "[%s] Op desc must not be null.", constant_name.c_str());
GELOGE(FAILED, "[Get][OpDesc] failed, Op desc must not be null.");
return FAILED; return FAILED;
} }
GeTensorDesc original_out_tensor_desc = original_op_desc->GetOutputDesc(1); GeTensorDesc original_out_tensor_desc = original_op_desc->GetOutputDesc(1);
@@ -184,18 +188,21 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr &
MakeShared<GeTensor>(original_out_tensor_desc, reinterpret_cast<uint8_t *>(&value_index), sizeof(int)); MakeShared<GeTensor>(original_out_tensor_desc, reinterpret_cast<uint8_t *>(&value_index), sizeof(int));
if (const_tensor_ptr == nullptr) { if (const_tensor_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed"); REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", constant_name.c_str());
GELOGE(FAILED, "[New][GeTensor] failed.");
return FAILED; return FAILED;
} }


GE_IF_BOOL_EXEC(!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_tensor_ptr), GE_IF_BOOL_EXEC(!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(),
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()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "get ATTR_NAME_WEIGHTS failed"); return FAILED);
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED);


// 4. set Constant output desc // 4. set Constant output desc
GE_CHK_GRAPH_STATUS_RET(op_desc->AddOutputDesc(original_out_tensor_desc), "add out put desc failed");
GE_CHK_GRAPH_STATUS_RET(op_desc->AddOutputDesc(original_out_tensor_desc),
"[Add][OutputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return SUCCESS; return SUCCESS;
} }




+ 42
- 23
ge/graph/passes/merge_to_stream_merge_pass.cc View File

@@ -26,7 +26,8 @@ Status MergeToStreamMergePass::Run(ComputeGraphPtr graph) {
bypass_nodes_.clear(); bypass_nodes_.clear();
for (const auto &node : graph->GetDirectNode()) { for (const auto &node : graph->GetDirectNode()) {
std::string type; std::string type;
GE_CHK_STATUS_RET(GetOriginalType(node, type), "Get node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(node, type),
"[Get][OriginalType] of node in graph:%s failed.", graph->GetName().c_str());
if ((type != MERGE) && (type != REFMERGE)) { if ((type != MERGE) && (type != REFMERGE)) {
continue; continue;
} }
@@ -39,21 +40,24 @@ Status MergeToStreamMergePass::Run(ComputeGraphPtr graph) {
if (status != ge::SUCCESS) { if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str());
return status; return status;
} }
} else { } else {
GE_CHK_STATUS_RET(ReplaceMergeNode(graph, node), "Add StreamMerge node failed.");
GE_CHK_STATUS_RET(ReplaceMergeNode(graph, node),
"[Replace][MergeNode] %s in graph:%s failed.", node->GetName().c_str(),
graph->GetName().c_str());
} }
} }


for (const auto &node : bypass_nodes_) { for (const auto &node : bypass_nodes_) {
GE_CHK_BOOL_EXEC(GraphUtils::RemoveNodeWithoutRelink(graph, node) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(GraphUtils::RemoveNodeWithoutRelink(graph, node) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", 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());
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED, return FAILED,
"Remove merge node failed.");
"[Remove][Node] %s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
} }


GELOGD("MergeToStreamMergePass Leave"); GELOGD("MergeToStreamMergePass Leave");
@@ -83,7 +87,7 @@ Status MergeToStreamMergePass::ReplaceMergeNode(const ComputeGraphPtr &graph, co
Status MergeToStreamMergePass::AddActiveNodes(const ComputeGraphPtr &graph, const NodePtr &node) { Status MergeToStreamMergePass::AddActiveNodes(const ComputeGraphPtr &graph, const NodePtr &node) {
GE_CHK_BOOL_EXEC(node != nullptr, GE_CHK_BOOL_EXEC(node != nullptr,
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
return FAILED, "Param of pre node is null.");
return FAILED, "[Check][Param] Param of pre node is nullptr.");
int64_t group_index = -1; int64_t group_index = -1;
bool force_unknown = AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_CONTROL_FLOW_GROUP, group_index); bool force_unknown = AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_CONTROL_FLOW_GROUP, group_index);
MarkForceUnknownShape(node, force_unknown, group_index); MarkForceUnknownShape(node, force_unknown, group_index);
@@ -96,11 +100,13 @@ Status MergeToStreamMergePass::AddActiveNodes(const ComputeGraphPtr &graph, cons
GE_IF_BOOL_EXEC((type == ENTER) || (type == REFENTER) || (type == NEXTITERATION) || (type == REFNEXTITERATION), GE_IF_BOOL_EXEC((type == ENTER) || (type == REFENTER) || (type == NEXTITERATION) || (type == REFNEXTITERATION),
continue); continue);
NodePtr active_node = CreateActiveNode(graph, in_node); NodePtr active_node = CreateActiveNode(graph, in_node);
GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed.");
GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED,
"[Create][StreamActiveNode] failed, in_node:%s.", in_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(active_node->GetOutControlAnchor(), node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(active_node->GetOutControlAnchor(), node->GetInControlAnchor()),
"StreamActive add ctrl edge failed.");
"[Add][CtrlEdge] between %s and %s failed.",
active_node->GetName().c_str(), node->GetName().c_str());
if (SetActiveLabelList(active_node, { node->GetName() }) != SUCCESS) { if (SetActiveLabelList(active_node, { node->GetName() }) != SUCCESS) {
GELOGE(FAILED, "SetActiveLabelList for node %s failed.", active_node->GetName().c_str());
GELOGE(FAILED, "[Set][ActiveLabelList] for node %s failed.", active_node->GetName().c_str());
return FAILED; return FAILED;
} }
MarkForceUnknownShape(active_node, force_unknown, group_index); MarkForceUnknownShape(active_node, force_unknown, group_index);
@@ -120,8 +126,8 @@ NodePtr MergeToStreamMergePass::CreateActiveNode(const ComputeGraphPtr &graph, c
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 GeTensor failed");
GELOGE(FAILED, "Create op_desc failed, StreamActive:%s.", node_name.c_str());
REPORT_CALL_ERROR("E19999", "New OpDesc failed, name:%s, type:%s.", node_name.c_str(), STREAMACTIVE);
GELOGE(FAILED, "[New][OpDesc] failed, name:%s, type:%s.", node_name.c_str(), STREAMACTIVE);
return nullptr; return nullptr;
} }


@@ -129,15 +135,20 @@ NodePtr MergeToStreamMergePass::CreateActiveNode(const ComputeGraphPtr &graph, c
GE_CHK_BOOL_EXEC(active_node != nullptr, GE_CHK_BOOL_EXEC(active_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr, "Create StreamActive node failed.");
return nullptr,
"[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
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", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str()); active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add edge failed");
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] 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());
return nullptr); return nullptr);
GE_IF_BOOL_EXEC(SetSwitchBranchNodeLabel(active_node, node_name) != SUCCESS, GE_IF_BOOL_EXEC(SetSwitchBranchNodeLabel(active_node, node_name) != SUCCESS,
GELOGE(INTERNAL_ERROR, "set switch branch node label failed");
GELOGE(INTERNAL_ERROR, "[Set][SwitchBranchNodeLabel] failed, node:%s, label:%s",
active_node->GetName().c_str(), node_name.c_str());
return nullptr); return nullptr);


return active_node; return active_node;
@@ -155,32 +166,40 @@ Status MergeToStreamMergePass::MoveEdges(const NodePtr &old_node, const NodePtr
GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue);


GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor), GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor),
"Merge remove in data edge failed.");
"[Remove][Edge] between %s and %s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
old_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(peer_out_anchor, new_node->GetInDataAnchor(in_data_anchor->GetIdx())), GE_CHK_STATUS(GraphUtils::AddEdge(peer_out_anchor, new_node->GetInDataAnchor(in_data_anchor->GetIdx())),
"StreamMerge add in data edge failed.");
"[Add][Edge] between %s and %s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
new_node->GetName().c_str());
} }


for (const OutDataAnchorPtr &out_data_anchor : old_node->GetAllOutDataAnchors()) { for (const OutDataAnchorPtr &out_data_anchor : old_node->GetAllOutDataAnchors()) {
for (const InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { for (const InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor), GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor),
"Merge remove out data edge failed.");
"[Remove][Edge] between %s and %s failed.", old_node->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutDataAnchor(out_data_anchor->GetIdx()), peer_in_anchor), GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutDataAnchor(out_data_anchor->GetIdx()), peer_in_anchor),
"StreamMerge add out data edge failed.");
"[Add][Edge] between %s and %s failed.", new_node->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
} }
} }


for (const NodePtr &in_ctrl_node : old_node->GetInControlNodes()) { for (const NodePtr &in_ctrl_node : old_node->GetInControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), old_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), old_node->GetInControlAnchor()),
"Merge remove in ctrl edge failed.");
"[Remove][CtrlEdge] between %s and %s failed.", in_ctrl_node->GetName().c_str(),
old_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(in_ctrl_node->GetOutControlAnchor(), new_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(in_ctrl_node->GetOutControlAnchor(), new_node->GetInControlAnchor()),
"StreamMerge add in ctrl edge failed.");
"[Add][CtrlEdge] between %s and %s failed.", in_ctrl_node->GetName().c_str(),
new_node->GetName().c_str());
} }


for (const NodePtr &out_ctrl_node : old_node->GetOutControlNodes()) { for (const NodePtr &out_ctrl_node : old_node->GetOutControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(old_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(old_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()),
"Merge remove out ctrl edge failed.");
"[Remove][CtrlEdge] between %s and %s failed.", old_node->GetName().c_str(),
out_ctrl_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()),
"StreamMerge add out ctrl edge failed.");
"[Add][CtrlEdge] between %s and %s failed.", new_node->GetName().c_str(),
out_ctrl_node->GetName().c_str());
} }


return SUCCESS; return SUCCESS;


+ 222
- 132
ge/graph/passes/multi_batch_clone_pass.cc View File

@@ -55,7 +55,7 @@ inline bool IsGetNextType(const NodePtr &node) {
Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { Status MultiBatchClonePass::Run(ComputeGraphPtr graph) {
GE_IF_BOOL_EXEC(graph == nullptr, GE_IF_BOOL_EXEC(graph == nullptr,
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(FAILED, "Original graph is nullptr"); return FAILED);
GELOGE(FAILED, "[Check][Param] Original graph is nullptr"); return FAILED);
if (graph->GetParentGraph() != nullptr) { if (graph->GetParentGraph() != nullptr) {
GELOGD("Subgraph %s skip the MultiBatchClonePass", graph->GetName().c_str()); GELOGD("Subgraph %s skip the MultiBatchClonePass", graph->GetName().c_str());
return SUCCESS; return SUCCESS;
@@ -68,15 +68,16 @@ Status MultiBatchClonePass::Run(ComputeGraphPtr graph) {
std::vector<NodePtr> getnext_nosink_nodes; std::vector<NodePtr> getnext_nosink_nodes;
std::vector<NodePtr> getnext_sink_nodes; std::vector<NodePtr> getnext_sink_nodes;
if (multibatch::CheckSequenceOfOptions(graph, data_nodes, getnext_nosink_nodes, getnext_sink_nodes) != SUCCESS) { if (multibatch::CheckSequenceOfOptions(graph, data_nodes, getnext_nosink_nodes, getnext_sink_nodes) != SUCCESS) {
GELOGE(PARAM_INVALID, "[Train_Dynamic] CheckSequenceOfOptions failed.");
GELOGE(PARAM_INVALID, "[Train_Dynamic] [Check][SequenceOfOptions] failed, graph:%s.", graph->GetName().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
if (multibatch::UpdateNameOfInputShape(graph, data_nodes, getnext_nosink_nodes, getnext_sink_nodes) != SUCCESS) { if (multibatch::UpdateNameOfInputShape(graph, data_nodes, getnext_nosink_nodes, getnext_sink_nodes) != SUCCESS) {
GELOGE(PARAM_INVALID, "[Train_Dynamic] UpdateNameForInputShapeOfOption failed.");
GELOGE(PARAM_INVALID, "[Train_Dynamic] [Update][Name] Of InputShape failed, graph:%s.", graph->GetName().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
if (multibatch::DeleteIdentityInsertByAdapter(graph) != SUCCESS) { if (multibatch::DeleteIdentityInsertByAdapter(graph) != SUCCESS) {
GELOGE(PARAM_INVALID, "[Train_Dynamic] DeleteIdentityInsertByAdapter failed.");
GELOGE(PARAM_INVALID, "[Train_Dynamic] [Delete][IdentityInsertByAdapter] failed, graph:%s.",
graph->GetName().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
if (!multibatch::InitDynamicParams(batch_shapes_)) { if (!multibatch::InitDynamicParams(batch_shapes_)) {
@@ -84,37 +85,38 @@ Status MultiBatchClonePass::Run(ComputeGraphPtr graph) {
return SUCCESS; return SUCCESS;
} }
if (multibatch::CheckNegativeCountOfOptions(batch_shapes_) != SUCCESS) { if (multibatch::CheckNegativeCountOfOptions(batch_shapes_) != SUCCESS) {
GELOGE(PARAM_INVALID, "[Train_Dynamic] Input_shape and dynamic_dims should set correct params.");
GELOGE(PARAM_INVALID, "[Train_Dynamic] [Check][Param] Input_shape and dynamic_dims should set correct params.");
return PARAM_INVALID; return PARAM_INVALID;
} }
GELOGD("Begin to run Multi-batch clone on graph: %s", graph->GetName().c_str()); GELOGD("Begin to run Multi-batch clone on graph: %s", graph->GetName().c_str());
GE_CHK_STATUS_RET(multibatch::CheckDynamicParams(batch_shapes_), "Invalid multi-batch param");
GE_CHK_STATUS_RET(multibatch::CheckDynamicParams(batch_shapes_), "[Check][Params] Invalid multi-batch param");
if (CollectIoNodes(graph) != SUCCESS) { if (CollectIoNodes(graph) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Collect input output nodes failed");
GELOGE(INTERNAL_ERROR, "[Collect][IoNodes] failed, graph:%s", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


// parser data dynamic info from atc parameter --input_shape // parser data dynamic info from atc parameter --input_shape
if (CheckAndParseDynamicData() != SUCCESS) { if (CheckAndParseDynamicData() != SUCCESS) {
GELOGE(PARAM_INVALID, "Parse each data's own dynamic info failed");
GELOGE(PARAM_INVALID, "[CheckAndParse][DynamicData] failed");
return PARAM_INVALID; return PARAM_INVALID;
} }


(void)AttrUtils::GetStr(graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); (void)AttrUtils::GetStr(graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_);
ComputeGraphPtr branch = MakeShared<ComputeGraph>(graph->GetName()); ComputeGraphPtr branch = MakeShared<ComputeGraph>(graph->GetName());
GE_IF_BOOL_EXEC(branch == nullptr, GE_IF_BOOL_EXEC(branch == nullptr,
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Create multi batch graph failed"); return OUT_OF_MEMORY);
REPORT_CALL_ERROR("E19999", "New ComputeGraph failed");
GELOGE(OUT_OF_MEMORY, "[New][ComputeGraph] failed"); return OUT_OF_MEMORY);
(void)AttrUtils::SetStr(branch, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); (void)AttrUtils::SetStr(branch, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_);


graph->InValid(); // Will modify, need topological again. graph->InValid(); // Will modify, need topological again.
graph->Swap(*branch); graph->Swap(*branch);
GE_CHK_STATUS_RET(CreateRootGraph(graph), "Construct root graph failed.");
GE_CHK_STATUS_RET(CreateOriGraph(branch), "Construct original graph failed.")
GE_CHK_STATUS_RET(CreateSubgraphs(graph, branch), "Construct subgraph failed.");
GE_CHK_STATUS_RET(CreateRootGraph(graph), "[Construct][RootGraph] for graph:%s failed.", graph->GetName().c_str());
GE_CHK_STATUS_RET(CreateOriGraph(branch), "[Construct][OriGraph] for graph:%s failed.", graph->GetName().c_str());
GE_CHK_STATUS_RET(CreateSubgraphs(graph, branch),
"[Construct][Subgraphs] for graph:%s failed.", graph->GetName().c_str());


GE_CHK_STATUS_RET(PruneDirectOutput(graph), "Prune direct output failed");
GE_CHK_STATUS_RET(UpdateSubgraphOutput(), "Update subgraph output failed");
GE_CHK_STATUS_RET(PruneDirectOutput(graph), "[Prune][DirectOutput] for graph:%s failed.", graph->GetName().c_str());
GE_CHK_STATUS_RET(UpdateSubgraphOutput(), "[Update][SubgraphOutput] failed, graph:%s", graph->GetName().c_str());
GELOGD("MultiBatchClonePass Leave"); GELOGD("MultiBatchClonePass Leave");
return SUCCESS; return SUCCESS;
} }
@@ -129,7 +131,7 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) {
for (const auto &node : graph->GetDirectNode()) { for (const auto &node : graph->GetDirectNode()) {
if (!GetLocalOmgContext().dynamic_node_type.empty() && IsGetNextType(node)) { if (!GetLocalOmgContext().dynamic_node_type.empty() && IsGetNextType(node)) {
all_data_nodes_.emplace_back(node); all_data_nodes_.emplace_back(node);
GE_CHK_STATUS_RET(InitParamsOfGetNext(node), "Init params of %s failed.", node->GetName().c_str());
GE_CHK_STATUS_RET(InitParamsOfGetNext(node), "[Init][Params] of %s failed.", node->GetName().c_str());
} }
if (node->GetType() == DATA) { if (node->GetType() == DATA) {
all_data_nodes_.emplace_back(node); all_data_nodes_.emplace_back(node);
@@ -147,7 +149,7 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) {
if (all_data_nodes_.empty() || all_output_nodes_.size() != 1) { if (all_data_nodes_.empty() || all_output_nodes_.size() != 1) {
REPORT_INNER_ERROR("E19999", "Data node num is 0 or output node num != 1, graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Data node num is 0 or output node num != 1, graph:%s, check invalid",
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(FAILED, "data nodes: %zu, output nodes: %zu", all_data_nodes_.size(), all_output_nodes_.size());
GELOGE(FAILED, "[Check][Param] Data node num is 0 or output node num != 1, graph:%s", graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -172,9 +174,10 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) {
const auto data_node = out_anchor->GetOwnerNode(); const auto data_node = out_anchor->GetOwnerNode();
if (data_node->GetType() == DATA) { if (data_node->GetType() == DATA) {
direct_output_[i] = data_node->GetName(); direct_output_[i] = data_node->GetName();
GE_CHK_GRAPH_STATUS_RET(
GraphUtils::RemoveEdge(data_node->GetOutDataAnchor(kDataOutIndex), output->GetInDataAnchor(i)),
"Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(data_node->GetOutDataAnchor(kDataOutIndex),
output->GetInDataAnchor(i)),
"[Remove][Edge] between %s(index:%u) and %s(index:%zu) failed",
data_node->GetName().c_str(), kDataOutIndex, output->GetName().c_str(), i);
} }
} }
GELOGD("Data count is %zu, const count is %zu, getnext count is %zu, output count is %zu, direct out count is %zu.", GELOGD("Data count is %zu, const count is %zu, getnext count is %zu, output count is %zu, direct out count is %zu.",
@@ -208,16 +211,18 @@ Status MultiBatchClonePass::CheckAndParseDynamicData() {
if (iter == data_name_order.end()) { if (iter == data_name_order.end()) {
if (!GetLocalOmgContext().dynamic_batch_size.empty()) { if (!GetLocalOmgContext().dynamic_batch_size.empty()) {
auto ret = multibatch::CheckDynamicBatchShape(data_shape_dims, data_name); auto ret = multibatch::CheckDynamicBatchShape(data_shape_dims, data_name);
GE_IF_BOOL_EXEC(ret == false, GELOGE(PARAM_INVALID, "Failed to check dynamic batch shape of %s.",
data_name.c_str()); return PARAM_INVALID);
GE_IF_BOOL_EXEC(ret == false,
GELOGE(PARAM_INVALID, "[Check][DynamicBatchShape] of %s failed.", data_name.c_str());
return PARAM_INVALID);
} else if (!GetLocalOmgContext().dynamic_image_size.empty()) { } else if (!GetLocalOmgContext().dynamic_image_size.empty()) {
auto ret = multibatch::CheckDynamicImageSizeShape(data_shape_dims, data_name, data_format); auto ret = multibatch::CheckDynamicImageSizeShape(data_shape_dims, data_name, data_format);
GE_IF_BOOL_EXEC(ret == false, GELOGE(PARAM_INVALID, "Failed to check dynamic image size shape of %s.",
data_name.c_str()); return PARAM_INVALID);
GE_IF_BOOL_EXEC(ret == false,
GELOGE(PARAM_INVALID, "[Check][DynamicImageSizeShape] of %s failed.", data_name.c_str());
return PARAM_INVALID);
} else if (!GetLocalOmgContext().dynamic_dims.empty()) { } else if (!GetLocalOmgContext().dynamic_dims.empty()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "reason"}, ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "reason"},
{"--input_shape", "all dynamic data must be set in --input_shape"}); {"--input_shape", "all dynamic data must be set in --input_shape"});
GELOGE(INTERNAL_ERROR, "data: %s shape:%s must be set int --input_shape",
GELOGE(INTERNAL_ERROR, "[Check][Param] data:%s shape:%s must be set int --input_shape",
node->GetName().c_str(), data_shape.ToString().c_str()); node->GetName().c_str(), data_shape.ToString().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -226,11 +231,11 @@ Status MultiBatchClonePass::CheckAndParseDynamicData() {
} }
} }
auto ret = multibatch::ParserDataToDynamicInfo(batch_shapes_, data_name_and_shape, data_to_dynamic_info_); auto ret = multibatch::ParserDataToDynamicInfo(batch_shapes_, data_name_and_shape, data_to_dynamic_info_);
GE_CHK_STATUS_RET(ret, "Failed to parse data to dynamic info.");
GE_CHK_STATUS_RET(ret, "[Parser][DataToDynamicInfo] failed.");
if (!getnext_sink_dynamic_dims_ && unknown_shape_count == 0) { if (!getnext_sink_dynamic_dims_ && unknown_shape_count == 0) {
ErrorManager::GetInstance().ATCReportErrMessage("E10040"); ErrorManager::GetInstance().ATCReportErrMessage("E10040");
GELOGE(PARAM_INVALID,
"Need unknow shape data when user set --dynamic_batch_size, --dynamic_image_size or --dynamic_dims");
GELOGE(PARAM_INVALID, "[Check][Param] Need unknow shape data "
"when user set --dynamic_batch_size, --dynamic_image_size or --dynamic_dims");
return PARAM_INVALID; return PARAM_INVALID;
} }
return SUCCESS; return SUCCESS;
@@ -288,7 +293,7 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) {
const OpDescPtr op_desc = op_builder.Build(); const OpDescPtr op_desc = op_builder.Build();
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Build op:%s(%s) failed", kMultiBatchCaseNode.c_str(), CASE); REPORT_INNER_ERROR("E19999", "Build op:%s(%s) failed", kMultiBatchCaseNode.c_str(), CASE);
GELOGE(OUT_OF_MEMORY, "Create multi-batch case desc failed");
GELOGE(OUT_OF_MEMORY, "[Build][Op] %s(%s) failed", kMultiBatchCaseNode.c_str(), CASE);
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -297,7 +302,8 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) {
if (case_node_ == nullptr) { if (case_node_ == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch case node failed");
GELOGE(OUT_OF_MEMORY, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -305,7 +311,8 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) {
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_BATCH_NUM, batch_num)) { if (!AttrUtils::SetInt(op_desc, ATTR_NAME_BATCH_NUM, batch_num)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_BATCH_NUM.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_BATCH_NUM.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set attr ATTR_NAME_BATCH_NUM failed, Case: %s.", op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_BATCH_NUM.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -314,7 +321,8 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) {
if (!AttrUtils::SetListInt(op_desc, attr_name, batch_shapes_[i])) { if (!AttrUtils::SetListInt(op_desc, attr_name, batch_shapes_[i])) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", attr_name.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", attr_name.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set attr ATTR_NAME_PRED_VALUE failed, Case: %s.", op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", attr_name.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -326,22 +334,25 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) {
if (!AttrUtils::SetListStr(op_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order)) { if (!AttrUtils::SetListStr(op_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Failed to add user designate shape order attr on case node %s",
op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
if (!AttrUtils::SetBool(op_desc, ATTR_INSERT_BY_MBATCH, true)) { if (!AttrUtils::SetBool(op_desc, ATTR_INSERT_BY_MBATCH, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_INSERT_BY_MBATCH.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_INSERT_BY_MBATCH.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add insert attr on case node %s", op_desc->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_INSERT_BY_MBATCH.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GE_CHK_STATUS_RET(multibatch::StampDynamicType(op_desc), "Set dynamic type failed");
GE_CHK_STATUS_RET(multibatch::StampDynamicType(op_desc),
"[Call][StampDynamicType] for op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());


GE_CHK_STATUS_RET(CreateIndexNode(graph), "Create index node failed");
GE_CHK_STATUS_RET(CreateInputNode(graph), "Create input node failed");
GE_CHK_STATUS_RET(CreateConstNode(graph), "Create const node failed");
GE_CHK_STATUS_RET(CreateOutputNode(graph), "Create output node failed");
GE_CHK_STATUS_RET(CreateIndexNode(graph), "[Create][IndexNode] for graph:%s failed", graph->GetName().c_str());
GE_CHK_STATUS_RET(CreateInputNode(graph), "[Create][InputNode] for graph:%s failed", graph->GetName().c_str());
GE_CHK_STATUS_RET(CreateConstNode(graph), "[Create][ConstNode] for graph:%s failed", graph->GetName().c_str());
GE_CHK_STATUS_RET(CreateOutputNode(graph), "[Create][OutputNode] for graph:%s failed", graph->GetName().c_str());


return SUCCESS; return SUCCESS;
} }
@@ -357,7 +368,7 @@ Status MultiBatchClonePass::CreateIndexDataNode(const ComputeGraphPtr &graph, No
const OpDescPtr data_desc = MakeShared<OpDesc>(kMultiBatchDataNode, DATA); const OpDescPtr data_desc = MakeShared<OpDesc>(kMultiBatchDataNode, DATA);
if (data_desc == nullptr) { if (data_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Create multi-batch data node failed");
GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed");
return FAILED; return FAILED;
} }


@@ -365,13 +376,15 @@ Status MultiBatchClonePass::CreateIndexDataNode(const ComputeGraphPtr &graph, No
if (data_desc->AddInputDesc(data_tensor) != GRAPH_SUCCESS) { if (data_desc->AddInputDesc(data_tensor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str());
GELOGE(FAILED, "Add input desc failed");
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str());
return FAILED; return FAILED;
} }
if (data_desc->AddOutputDesc(data_tensor) != GRAPH_SUCCESS) { if (data_desc->AddOutputDesc(data_tensor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str());
GELOGE(FAILED, "Add output desc failed");
GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -384,7 +397,8 @@ Status MultiBatchClonePass::CreateIndexDataNode(const ComputeGraphPtr &graph, No
if (shape_node == nullptr) { if (shape_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str(), graph->GetName().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch data node failed");
GELOGE(OUT_OF_MEMORY, "[Add][Node] %s(%s) to graph:%s failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str(), graph->GetName().c_str());
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -402,7 +416,7 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N
const OpDescPtr const_desc = MakeShared<OpDesc>(kMultiBatchConstNode, CONSTANT); const OpDescPtr const_desc = MakeShared<OpDesc>(kMultiBatchConstNode, CONSTANT);
if (const_desc == nullptr) { if (const_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Create multi-batch const node failed");
GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed");
return FAILED; return FAILED;
} }


@@ -423,14 +437,16 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N
if (!AttrUtils::SetTensor(const_desc, ATTR_NAME_WEIGHTS, tensor)) { if (!AttrUtils::SetTensor(const_desc, ATTR_NAME_WEIGHTS, tensor)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_desc->GetName().c_str(), const_desc->GetType().c_str()); const_desc->GetName().c_str(), const_desc->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "Failed to init tensor value for const %s", const_desc->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_desc->GetName().c_str(), const_desc->GetType().c_str());
return FAILED; return FAILED;
} }


if (const_desc->AddOutputDesc(const_tensor) != GRAPH_SUCCESS) { if (const_desc->AddOutputDesc(const_tensor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
const_desc->GetName().c_str(), const_desc->GetType().c_str()); const_desc->GetName().c_str(), const_desc->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "Failed to add output desc for const node %s", const_desc->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "[Add][OutputDesc] to op:%s(%s) failed",
const_desc->GetName().c_str(), const_desc->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -438,7 +454,8 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N
if (node == nullptr) { if (node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
const_desc->GetName().c_str(), const_desc->GetType().c_str(), graph->GetName().c_str()); const_desc->GetName().c_str(), const_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch const node failed");
GELOGE(OUT_OF_MEMORY, "[Add][Node] %s(%s) to graph:%s failed",
const_desc->GetName().c_str(), const_desc->GetType().c_str(), graph->GetName().c_str());
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -454,13 +471,16 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N
Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) { Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) {
// Data/GetDynamicDims --> MapIndex --> Case // Data/GetDynamicDims --> MapIndex --> Case
if (!getnext_sink_dynamic_dims_) { if (!getnext_sink_dynamic_dims_) {
GE_CHK_STATUS_RET(CreateIndexDataNode(graph, shape_node_), "Create data node failed");
GE_CHK_STATUS_RET(CreateIndexDataNode(graph, shape_node_),
"[Create][IndexDataNode] failed, graph:%s", graph->GetName().c_str());
} else { } else {
GE_CHK_STATUS_RET(CreateGetDynamicDimsNode(graph, shape_node_), "Create get dynamic dims node failed");
GE_CHK_STATUS_RET(CreateGetDynamicDimsNode(graph, shape_node_),
"[Create][GetDynamicDimsNode] failed, graph:%s", graph->GetName().c_str());
} }


NodePtr const_node; NodePtr const_node;
GE_CHK_STATUS_RET(CreateIndexConstNode(graph, const_node), "Create const node failed");
GE_CHK_STATUS_RET(CreateIndexConstNode(graph, const_node),
"[Create][ConstNode] failed, graph:%s", graph->GetName().c_str());
GELOGD("Shape node name is %s, type is %s, const node name is %s.", shape_node_->GetName().c_str(), GELOGD("Shape node name is %s, type is %s, const node name is %s.", shape_node_->GetName().c_str(),
shape_node_->GetType().c_str(), const_node->GetName().c_str()); shape_node_->GetType().c_str(), const_node->GetName().c_str());
OpDescBuilder op_builder(kMultiBatchMapIndexNode, "MapIndex"); OpDescBuilder op_builder(kMultiBatchMapIndexNode, "MapIndex");
@@ -471,32 +491,34 @@ Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) {
const OpDescPtr op_desc = op_builder.Build(); const OpDescPtr op_desc = op_builder.Build();
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Build op:%s(%s) failed", kMultiBatchMapIndexNode.c_str(), "MapIndex"); REPORT_INNER_ERROR("E19999", "Build op:%s(%s) failed", kMultiBatchMapIndexNode.c_str(), "MapIndex");
GELOGE(OUT_OF_MEMORY, "Create multi-batch index desc failed");
GELOGE(OUT_OF_MEMORY, "[Build][Op] %s(MapIndex) failed", kMultiBatchMapIndexNode.c_str());
return FAILED; return FAILED;
} }
NodePtr index_node = graph->AddNode(op_desc); NodePtr index_node = graph->AddNode(op_desc);
if (index_node == nullptr) { if (index_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch index node failed");
GELOGE(OUT_OF_MEMORY, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


GE_CHK_STATUS_RET(AddAttrForGetDynamicDims(shape_node_), "Failed to add attr for %s.",
GE_CHK_STATUS_RET(AddAttrForGetDynamicDims(shape_node_), "[Add][Attr] for %s failed.",
shape_node_->GetName().c_str()); shape_node_->GetName().c_str());
if (GraphUtils::AddEdge(shape_node_->GetOutDataAnchor(0), index_node->GetInDataAnchor(0)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(shape_node_->GetOutDataAnchor(0), index_node->GetInDataAnchor(0)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
shape_node_->GetName().c_str(), shape_node_->GetType().c_str(), shape_node_->GetName().c_str(), shape_node_->GetType().c_str(),
index_node->GetName().c_str(), index_node->GetType().c_str()); index_node->GetName().c_str(), index_node->GetType().c_str());
GELOGE(FAILED, "Failed to add edge between node:%s to MapIndex:%s", shape_node_->GetName().c_str(),
index_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
shape_node_->GetName().c_str(), shape_node_->GetType().c_str(),
index_node->GetName().c_str(), index_node->GetType().c_str());
return FAILED; return FAILED;
} }
if (GraphUtils::AddEdge(const_node->GetOutDataAnchor(0), index_node->GetInDataAnchor(1)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(const_node->GetOutDataAnchor(0), index_node->GetInDataAnchor(1)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:1) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:1) failed",
const_node->GetName().c_str(), const_node->GetType().c_str(), const_node->GetName().c_str(), const_node->GetType().c_str(),
index_node->GetName().c_str(), index_node->GetType().c_str()); index_node->GetName().c_str(), index_node->GetType().c_str());
GELOGE(FAILED, "Failed to add edge between node:%s to MapIndex:%s", const_node->GetName().c_str(),
GELOGE(FAILED, "[Add][Edge] between node:%s to MapIndex:%s", const_node->GetName().c_str(),
index_node->GetName().c_str()); index_node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -504,8 +526,9 @@ Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
index_node->GetName().c_str(), index_node->GetType().c_str(), index_node->GetName().c_str(), index_node->GetType().c_str(),
case_node_->GetName().c_str(), case_node_->GetType().c_str()); case_node_->GetName().c_str(), case_node_->GetType().c_str());
GELOGE(FAILED, "Failed to add edge between MapIndex:%s to Case:%s", index_node->GetName().c_str(),
case_node_->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
index_node->GetName().c_str(), index_node->GetType().c_str(),
case_node_->GetName().c_str(), case_node_->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -516,7 +539,7 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap
const OpDescPtr data_desc = MakeShared<OpDesc>(kMultiBatchGetDynamicDimsNode, GETDYNAMICDIMS); const OpDescPtr data_desc = MakeShared<OpDesc>(kMultiBatchGetDynamicDimsNode, GETDYNAMICDIMS);
if (data_desc == nullptr) { if (data_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Create multi-batch get dynamic dims node failed");
GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed");
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -532,7 +555,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str());
return FAILED); return FAILED);
continue; continue;
} }
@@ -541,7 +565,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add input desc for created data");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str());
return FAILED); return FAILED);
} }
GeTensorDesc tensor_desc(GeShape({static_cast<int32_t>(batch_shapes_.at(0).size())}), FORMAT_ND, DT_INT32); GeTensorDesc tensor_desc(GeShape({static_cast<int32_t>(batch_shapes_.at(0).size())}), FORMAT_ND, DT_INT32);
@@ -549,7 +574,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap
GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add output desc for created data");
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str());
return FAILED); return FAILED);


(void)AttrUtils::SetBool(data_desc, ATTR_INSERT_BY_MBATCH, true); (void)AttrUtils::SetBool(data_desc, ATTR_INSERT_BY_MBATCH, true);
@@ -558,7 +584,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap
if (shape_node == nullptr) { if (shape_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str(), graph->GetName().c_str()); data_desc->GetName().c_str(), data_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch dynamic dims node failed");
GELOGE(OUT_OF_MEMORY, "[Add][Node] %s(%s) to graph:%s failed",
data_desc->GetName().c_str(), data_desc->GetType().c_str(), graph->GetName().c_str());
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }
return SUCCESS; return SUCCESS;
@@ -573,7 +600,8 @@ Status MultiBatchClonePass::AddAttrForGetDynamicDims(const NodePtr &shape_node)
if (!AttrUtils::SetInt(shape_node->GetOpDesc(), ATTR_GETNEXT_SINK_DATA_COUNT, data_count_from_getnext_)) { if (!AttrUtils::SetInt(shape_node->GetOpDesc(), ATTR_GETNEXT_SINK_DATA_COUNT, data_count_from_getnext_)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_GETNEXT_SINK_DATA_COUNT.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_GETNEXT_SINK_DATA_COUNT.c_str(),
shape_node->GetName().c_str(), shape_node->GetType().c_str()); shape_node->GetName().c_str(), shape_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_GETNEXT_SINK_DATA_COUNT failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_GETNEXT_SINK_DATA_COUNT.c_str(),
shape_node->GetName().c_str(), shape_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
vector<int64_t> shape_info; vector<int64_t> shape_info;
@@ -591,7 +619,8 @@ Status MultiBatchClonePass::AddAttrForGetDynamicDims(const NodePtr &shape_node)
if (!AttrUtils::SetListInt(shape_node->GetOpDesc(), ATTR_GETNEXT_SINK_SHAPE_INFO, shape_info)) { if (!AttrUtils::SetListInt(shape_node->GetOpDesc(), ATTR_GETNEXT_SINK_SHAPE_INFO, shape_info)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_GETNEXT_SINK_SHAPE_INFO.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_GETNEXT_SINK_SHAPE_INFO.c_str(),
shape_node->GetName().c_str(), shape_node->GetType().c_str()); shape_node->GetName().c_str(), shape_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_GETNEXT_SINK_SHAPE_INFO failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_GETNEXT_SINK_SHAPE_INFO.c_str(),
shape_node->GetName().c_str(), shape_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
return SUCCESS; return SUCCESS;
@@ -611,8 +640,9 @@ Status MultiBatchClonePass::LinkGetNextToGetDynamicDims(const NodePtr &getnext_n
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed",
getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_index, getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_index,
shape_node->GetName().c_str(), shape_node->GetType().c_str(), input_index); shape_node->GetName().c_str(), shape_node->GetType().c_str(), input_index);
GELOGE(INTERNAL_ERROR, "Failed to link getnext %s to getdynamicdims %s",
getnext_node->GetName().c_str(), shape_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed",
getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_index,
shape_node->GetName().c_str(), shape_node->GetType().c_str(), input_index);
return INTERNAL_ERROR); return INTERNAL_ERROR);
} }
return SUCCESS; return SUCCESS;
@@ -623,7 +653,8 @@ Status MultiBatchClonePass::LinkGetDynamicDimsToNetOutput(const NodePtr &output_
if (!AttrUtils::SetStr(output_node->GetOpDesc(), ATTR_ALL_GEARS_INFO, GetLocalOmgContext().dynamic_dims)) { if (!AttrUtils::SetStr(output_node->GetOpDesc(), ATTR_ALL_GEARS_INFO, GetLocalOmgContext().dynamic_dims)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ALL_GEARS_INFO.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ALL_GEARS_INFO.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str()); output_node->GetName().c_str(), output_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to set all gears info attr on netoutput %s.", output_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_ALL_GEARS_INFO.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -633,7 +664,8 @@ Status MultiBatchClonePass::LinkGetDynamicDimsToNetOutput(const NodePtr &output_
if (NodeUtils::AppendInputAnchor(output_node, input_index + 1) != GRAPH_SUCCESS) { if (NodeUtils::AppendInputAnchor(output_node, input_index + 1) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Append input anchor to op:%s(%s) failed, size:%zu", REPORT_CALL_ERROR("E19999", "Append input anchor to op:%s(%s) failed, size:%zu",
output_node->GetName().c_str(), output_node->GetType().c_str(), input_index + 1); output_node->GetName().c_str(), output_node->GetType().c_str(), input_index + 1);
GELOGE(INTERNAL_ERROR, "Append input anchor of %s of %zu failed.", output_node->GetName().c_str(), input_index);
GELOGE(INTERNAL_ERROR, "[Append][InputAnchor] to op:%s(%s) failed, size:%zu",
output_node->GetName().c_str(), output_node->GetType().c_str(), input_index + 1);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
auto ret = GraphUtils::AddEdge(shape_node_->GetOutDataAnchor(kDataOutIndex), auto ret = GraphUtils::AddEdge(shape_node_->GetOutDataAnchor(kDataOutIndex),
@@ -642,14 +674,15 @@ Status MultiBatchClonePass::LinkGetDynamicDimsToNetOutput(const NodePtr &output_
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed",
shape_node_->GetName().c_str(), shape_node_->GetType().c_str(), kDataOutIndex, shape_node_->GetName().c_str(), shape_node_->GetType().c_str(), kDataOutIndex,
output_node->GetName().c_str(), output_node->GetType().c_str(), input_index); output_node->GetName().c_str(), output_node->GetType().c_str(), input_index);
GELOGE(INTERNAL_ERROR, "Failed to link netoutput %s to getdynamicdims %s",
output_node->GetName().c_str(), shape_node_->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed",
shape_node_->GetName().c_str(), shape_node_->GetType().c_str(), kDataOutIndex,
output_node->GetName().c_str(), output_node->GetType().c_str(), input_index);
return INTERNAL_ERROR); return INTERNAL_ERROR);
if (!AttrUtils::SetBool(output_node->GetOpDesc(), ATTR_GETNEXT_SINK_DYNMAIC, true)) { if (!AttrUtils::SetBool(output_node->GetOpDesc(), ATTR_GETNEXT_SINK_DYNMAIC, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_GETNEXT_SINK_DYNMAIC.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_GETNEXT_SINK_DYNMAIC.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str()); output_node->GetName().c_str(), output_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to set getnext sink dynamic attr on netoutput %s.",
output_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_GETNEXT_SINK_DYNMAIC.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -674,13 +707,16 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) {
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch Data node failed, name: %s", node->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "[Copy][OpDesc] from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


if (GraphUtils::CopyTensorAttrs(op_desc, node) != GRAPH_SUCCESS) { if (GraphUtils::CopyTensorAttrs(op_desc, node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "[Copy][TensorAttrs] from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -690,7 +726,9 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str());
return FAILED,
"[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
if (IsGetNextType(node)) { if (IsGetNextType(node)) {
getnext_node = data; getnext_node = data;
input_index_of_getnext = case_input_index; input_index_of_getnext = case_input_index;
@@ -702,25 +740,26 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%zu) failed",
data->GetName().c_str(), data->GetType().c_str(), data->GetName().c_str(), data->GetType().c_str(),
case_node_->GetName().c_str(), case_node_->GetType().c_str(), case_input_index); case_node_->GetName().c_str(), case_node_->GetType().c_str(), case_input_index);
GELOGE(FAILED, "Failed to add edge between Data:%s to Case:%s", data->GetName().c_str(),
case_node_->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%zu) failed",
data->GetName().c_str(), data->GetType().c_str(),
case_node_->GetName().c_str(), case_node_->GetType().c_str(), case_input_index);
return FAILED; return FAILED;
} }
} }


if (SetMaxShape(data) != SUCCESS) { if (SetMaxShape(data) != SUCCESS) {
GELOGE(FAILED, "Set max shape of %s failed.", data->GetName().c_str());
GELOGE(FAILED, "[Set][MaxShape] of %s failed.", data->GetName().c_str());
return FAILED; return FAILED;
} }
all_data_nodes.emplace_back(data); all_data_nodes.emplace_back(data);
} }
if (getnext_node != nullptr) { if (getnext_node != nullptr) {
if (LinkEdgeForGetNext(getnext_node, input_index_of_getnext) != SUCCESS) { if (LinkEdgeForGetNext(getnext_node, input_index_of_getnext) != SUCCESS) {
GELOGE(FAILED, "Failed to link edge for %s.", getnext_node->GetName().c_str());
GELOGE(FAILED, "[Link][Edge] for %s failed.", getnext_node->GetName().c_str());
return FAILED; return FAILED;
} }
if (SetMaxShape(getnext_node) != SUCCESS) { if (SetMaxShape(getnext_node) != SUCCESS) {
GELOGE(FAILED, "Set max shape of %s failed.", getnext_node->GetName().c_str());
GELOGE(FAILED, "[Set][MaxShape] of %s failed.", getnext_node->GetName().c_str());
return FAILED; return FAILED;
} }
all_data_nodes.emplace_back(getnext_node); all_data_nodes.emplace_back(getnext_node);
@@ -739,13 +778,14 @@ Status MultiBatchClonePass::LinkEdgeForGetNext(const NodePtr &getnext_node, size
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed",
getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_index, getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_index,
case_node_->GetName().c_str(), case_node_->GetType().c_str(), case_input_index); case_node_->GetName().c_str(), case_node_->GetType().c_str(), case_input_index);
GELOGE(FAILED, "Failed to add data edge between %zu Data:%s to %zu Case:%s", out_index,
getnext_node->GetName().c_str(), case_input_index, case_node_->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed",
getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_index,
case_node_->GetName().c_str(), case_node_->GetType().c_str(), case_input_index);
return FAILED; return FAILED;
} }
} }
if (getnext_sink_dynamic_dims_) { if (getnext_sink_dynamic_dims_) {
GE_CHK_STATUS_RET(LinkGetNextToGetDynamicDims(getnext_node, shape_node_), "Failed to add link for %s.",
GE_CHK_STATUS_RET(LinkGetNextToGetDynamicDims(getnext_node, shape_node_), "[Add][Link] for %s failed.",
shape_node_->GetName().c_str()); shape_node_->GetName().c_str());
} }
return SUCCESS; return SUCCESS;
@@ -771,7 +811,7 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) {
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch Const node failed, name: %s", node->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "[Copy][OpDesc] from op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -779,6 +819,8 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) {
if (GraphUtils::CopyTensorAttrs(op_desc, node) != GRAPH_SUCCESS) { if (GraphUtils::CopyTensorAttrs(op_desc, node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "[Copy][TensorAttrs] from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -787,13 +829,16 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str());
return FAILED,
"[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
if (GraphUtils::AddEdge(data->GetOutDataAnchor(0), case_node_->GetInDataAnchor(arg_index + i)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(data->GetOutDataAnchor(0), case_node_->GetInDataAnchor(arg_index + i)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%zu) failed",
data->GetName().c_str(), data->GetType().c_str(), data->GetName().c_str(), data->GetType().c_str(),
case_node_->GetName().c_str(), case_node_->GetType().c_str(), arg_index + i); case_node_->GetName().c_str(), case_node_->GetType().c_str(), arg_index + i);
GELOGE(FAILED, "Failed to add edge between Const:%s to Case:%s", data->GetName().c_str(),
case_node_->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%zu) failed",
data->GetName().c_str(), data->GetType().c_str(),
case_node_->GetName().c_str(), case_node_->GetType().c_str(), arg_index + i);
return FAILED; return FAILED;
} }
all_const_nodes.emplace_back(data); all_const_nodes.emplace_back(data);
@@ -842,13 +887,16 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) {
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed",
output->GetName().c_str(), output->GetType().c_str()); output->GetName().c_str(), output->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "Create multi-batch output node failed");
GELOGE(OUT_OF_MEMORY, "[Copy][OpDesc] from op:%s(%s) failed",
output->GetName().c_str(), output->GetType().c_str());
return FAILED; return FAILED;
} }


if (GraphUtils::CopyTensorAttrs(op_desc, output) != GRAPH_SUCCESS) { if (GraphUtils::CopyTensorAttrs(op_desc, output) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed",
output->GetName().c_str(), output->GetType().c_str()); output->GetName().c_str(), output->GetType().c_str());
GELOGE(OUT_OF_MEMORY, "[Copy][TensorAttrs] from op:%s(%s) failed",
output->GetName().c_str(), output->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -858,7 +906,9 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
return FAILED, "Add node[%s] to graph failed", op_desc->GetName().c_str());
return FAILED,
"[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());


for (size_t i = 0; i < case_node_->GetAllOutDataAnchorsSize(); ++i) { for (size_t i = 0; i < case_node_->GetAllOutDataAnchorsSize(); ++i) {
const auto it = direct_output_.find(i); const auto it = direct_output_.find(i);
@@ -867,28 +917,31 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed",
case_node_->GetName().c_str(), case_node_->GetType().c_str(), i, case_node_->GetName().c_str(), case_node_->GetType().c_str(), i,
node->GetName().c_str(), node->GetType().c_str(), i); node->GetName().c_str(), node->GetType().c_str(), i);
GELOGE(FAILED, "Failed to add edge between Case:%s to NetOutput:%s",
case_node_->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:%zu) and op:%s(%s)(index:%zu) failed",
case_node_->GetName().c_str(), case_node_->GetType().c_str(), i,
node->GetName().c_str(), node->GetType().c_str(), i);
return FAILED; return FAILED;
} }
} else { } else {
const auto data_node = graph->FindNode(it->second); const auto data_node = graph->FindNode(it->second);
if (data_node == nullptr) { if (data_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Find node:%s from graph:%s failed", it->second.c_str(), graph->GetName().c_str()); REPORT_CALL_ERROR("E19999", "Find node:%s from graph:%s failed", it->second.c_str(), graph->GetName().c_str());
GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "Data node:%s not found", it->second.c_str());
GELOGE(GE_GRAPH_GRAPH_NODE_NULL, "[Check][Param] Data node:%s not found in graph:%s",
it->second.c_str(), graph->GetName().c_str());
return GE_GRAPH_GRAPH_NODE_NULL; return GE_GRAPH_GRAPH_NODE_NULL;
} }
if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(kDataOutIndex), node->GetInDataAnchor(i)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(kDataOutIndex), node->GetInDataAnchor(i)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed",
data_node->GetName().c_str(), data_node->GetType().c_str(), kDataOutIndex, data_node->GetName().c_str(), data_node->GetType().c_str(), kDataOutIndex,
node->GetName().c_str(), node->GetType().c_str(), i); node->GetName().c_str(), node->GetType().c_str(), i);
GELOGE(FAILED, "Failed to add edge between Data:%s to NetOutput:%s",
data_node->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%zu) failed",
data_node->GetName().c_str(), data_node->GetType().c_str(), kDataOutIndex,
node->GetName().c_str(), node->GetType().c_str(), i);
return FAILED; return FAILED;
} }
} }
} }
GE_CHK_STATUS_RET(LinkGetDynamicDimsToNetOutput(node), "Failed to add edge between %s to netoutput: %s.",
GE_CHK_STATUS_RET(LinkGetDynamicDimsToNetOutput(node), "[Add][Edge] between %s and netoutput:%s failed.",
shape_node_->GetName().c_str(), output->GetName().c_str()); shape_node_->GetName().c_str(), output->GetName().c_str());
all_output_nodes_.clear(); all_output_nodes_.clear();
all_output_nodes_.emplace_back(node); all_output_nodes_.emplace_back(node);
@@ -905,13 +958,13 @@ Status MultiBatchClonePass::SetMaxShape(const NodePtr &data) {
GELOGD("Start set max shape for %s.", data->GetName().c_str()); GELOGD("Start set max shape for %s.", data->GetName().c_str());
if (!IsGetNextType(data)) { if (!IsGetNextType(data)) {
if (SetMaxShapeToData(data, kDataOutIndex) != SUCCESS) { if (SetMaxShapeToData(data, kDataOutIndex) != SUCCESS) {
GELOGE(PARAM_INVALID, "Failed to update max shape of %s.", data->GetName().c_str());
GELOGE(PARAM_INVALID, "[Update][MaxShape] of %s failed.", data->GetName().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
} else { } else {
for (size_t out_anchor_index = 0; out_anchor_index < data_count_from_getnext_; ++out_anchor_index) { for (size_t out_anchor_index = 0; out_anchor_index < data_count_from_getnext_; ++out_anchor_index) {
if (SetMaxShapeToData(data, out_anchor_index) != SUCCESS) { if (SetMaxShapeToData(data, out_anchor_index) != SUCCESS) {
GELOGE(PARAM_INVALID, "Failed to update max shape of %s.", data->GetName().c_str());
GELOGE(PARAM_INVALID, "[Update][MaxShape] of %s failed.", data->GetName().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
} }
@@ -938,7 +991,9 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an
if (std::all_of(dims.begin(), dims.end(), [](int64_t val) { return val >= 0; })) { if (std::all_of(dims.begin(), dims.end(), [](int64_t val) { return val >= 0; })) {
if (getnext_sink_dynamic_dims_) { if (getnext_sink_dynamic_dims_) {
// need to update shape of Shape_node when getnext node has dynamic data // need to update shape of Shape_node when getnext node has dynamic data
GE_CHK_STATUS_RET(UpdateShapeOfShapeNode(node, out_anchor_index), "Failed to update shape of shape node");
GE_CHK_STATUS_RET(UpdateShapeOfShapeNode(node, out_anchor_index),
"[Update][Shape] of shape node:%s failed, out_anchor_index:%zu",
node->GetName().c_str(), out_anchor_index);
} }
return SUCCESS; return SUCCESS;
} }
@@ -947,7 +1002,8 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an
if (!AttrUtils::SetStr(node->GetOpDesc(), kMbatchCaseName, case_node_->GetName())) { if (!AttrUtils::SetStr(node->GetOpDesc(), kMbatchCaseName, case_node_->GetName())) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed",
kMbatchCaseName, node->GetName().c_str(), node->GetType().c_str()); kMbatchCaseName, node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add switchn attr on data node %s", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to node:%s(%s) failed",
kMbatchCaseName, node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -957,7 +1013,7 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an
auto shape = data_shape; auto shape = data_shape;
auto ret = multibatch::CalcShape(data_to_dynamic_info_.at(data_name).at(i), shape); auto ret = multibatch::CalcShape(data_to_dynamic_info_.at(data_name).at(i), shape);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "Failed to calculate the shape for data node %s, the shape may not match", node->GetName().c_str());
GELOGE(ret, "[Calculate][Shape] for data node %s failed, the shape may not match", node->GetName().c_str());
return ret; return ret;
} }
tensor.SetShape(shape); tensor.SetShape(shape);
@@ -979,7 +1035,7 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an
if (INT64_MAX / dim < size) { if (INT64_MAX / dim < size) {
REPORT_INNER_ERROR("E19999", "The shape %s size will overflow after multi", REPORT_INNER_ERROR("E19999", "The shape %s size will overflow after multi",
formats::ShapeToString(data_to_dynamic_info_.at(data_name).at(i)).c_str()); formats::ShapeToString(data_to_dynamic_info_.at(data_name).at(i)).c_str());
GELOGE(PARAM_INVALID, "The shape %s size overflow",
GELOGE(PARAM_INVALID, "[Check][Param] The shape %s size overflow",
formats::ShapeToString(data_to_dynamic_info_.at(data_name).at(i)).c_str()); formats::ShapeToString(data_to_dynamic_info_.at(data_name).at(i)).c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
@@ -1006,7 +1062,7 @@ Status MultiBatchClonePass::SetShapeToData(const std::vector<int64_t> &shapes, c
size_t out_anchor_index) { size_t out_anchor_index) {
GELOGD("Start set shape to %zu out of %s.", out_anchor_index, data->GetName().c_str()); GELOGD("Start set shape to %zu out of %s.", out_anchor_index, data->GetName().c_str());
if (multibatch::CalcShape(shapes, data_shape) != SUCCESS) { if (multibatch::CalcShape(shapes, data_shape) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to calculate the batched shape for data node %s, the shapes may not match",
GELOGE(INTERNAL_ERROR, "[Calculate][Shape] for data node %s failed, the shapes may not match",
data->GetName().c_str()); data->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -1014,20 +1070,24 @@ Status MultiBatchClonePass::SetShapeToData(const std::vector<int64_t> &shapes, c
if (NodeUtils::UpdateOutputShape(*data, out_anchor_index, data_shape) != GRAPH_SUCCESS) { if (NodeUtils::UpdateOutputShape(*data, out_anchor_index, data_shape) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update ouput desc shape to op:%s(%s) failed, index:%zu", REPORT_CALL_ERROR("E19999", "Update ouput desc shape to op:%s(%s) failed, index:%zu",
data->GetName().c_str(), data->GetType().c_str(), out_anchor_index); data->GetName().c_str(), data->GetType().c_str(), out_anchor_index);
GELOGE(INTERNAL_ERROR, "Failed to update output shape for data %s", data->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Update][OutputShape] to op:%s(%s) failed, index:%zu",
data->GetName().c_str(), data->GetType().c_str(), out_anchor_index);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (!IsGetNextType(data)) { if (!IsGetNextType(data)) {
if (NodeUtils::UpdateInputShape(*data, kDataInIndex, data_shape) != GRAPH_SUCCESS) { if (NodeUtils::UpdateInputShape(*data, kDataInIndex, data_shape) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update input desc shape to op:%s(%s) failed, index:%u", REPORT_CALL_ERROR("E19999", "Update input desc shape to op:%s(%s) failed, index:%u",
data->GetName().c_str(), data->GetType().c_str(), kDataInIndex); data->GetName().c_str(), data->GetType().c_str(), kDataInIndex);
GELOGE(INTERNAL_ERROR, "Failed to update input shape for data %s", data->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Update][InputShape] to op:%s(%s) failed, index:%u",
data->GetName().c_str(), data->GetType().c_str(), kDataInIndex);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} else { } else {
if (getnext_sink_dynamic_dims_) { if (getnext_sink_dynamic_dims_) {
// need to update shape of Shape_node when getnext_sink_dynamic // need to update shape of Shape_node when getnext_sink_dynamic
GE_CHK_STATUS_RET(UpdateShapeOfShapeNode(data, out_anchor_index), "Failed to update shape of shape node");
GE_CHK_STATUS_RET(UpdateShapeOfShapeNode(data, out_anchor_index),
"[Update][ShapeOfShapeNode] for %s(%s) failed, index:%zu,",
data->GetName().c_str(), data->GetType().c_str(), out_anchor_index);
} }
} }


@@ -1048,7 +1108,8 @@ Status MultiBatchClonePass::UpdateShapeOfShapeNode(const NodePtr &node, size_t o
if (node->GetOpDesc()->UpdateOutputDesc(shape_index, output_desc) != SUCCESS) { if (node->GetOpDesc()->UpdateOutputDesc(shape_index, output_desc) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update ouput desc to op:%s(%s) failed, index:%zu", REPORT_CALL_ERROR("E19999", "Update ouput desc to op:%s(%s) failed, index:%zu",
node->GetName().c_str(), node->GetType().c_str(), shape_index); node->GetName().c_str(), node->GetType().c_str(), shape_index);
GELOGE(FAILED, "Update output desc fail.");
GELOGE(FAILED, "[Update][OutputDesc] to op:%s(%s) failed, index:%zu",
node->GetName().c_str(), node->GetType().c_str(), shape_index);
return FAILED; return FAILED;
} }
return SUCCESS; return SUCCESS;
@@ -1066,7 +1127,8 @@ Status MultiBatchClonePass::UpdateSubgraphData(const NodePtr &data, size_t batch
if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_INDEX, node_index)) { if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_INDEX, node_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_INDEX.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str()); data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Failed to get index from data[%s]", data->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -1074,7 +1136,8 @@ Status MultiBatchClonePass::UpdateSubgraphData(const NodePtr &data, size_t batch
if (!AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { if (!AttrUtils::SetInt(data->GetOpDesc(), 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(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str()); data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Failed to set parent index for node %s", data->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -1092,8 +1155,8 @@ Status MultiBatchClonePass::UpdateSubgraphData(const NodePtr &data, size_t batch
if (pos == string::npos) { if (pos == string::npos) {
REPORT_INNER_ERROR("E19999", "Cannot find key string [%s] of multi-batch in name of virtual input node:%s(%s)", REPORT_INNER_ERROR("E19999", "Cannot find key string [%s] of multi-batch in name of virtual input node:%s(%s)",
kMultiBatchNodePostfix.c_str(), data->GetName().c_str(), data->GetType().c_str()); kMultiBatchNodePostfix.c_str(), data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Cannot find key string [%s] of multi-batch in name of virtual input node, node name: %s.",
kMultiBatchNodePostfix.c_str(), data_name.c_str());
GELOGE(FAILED, "[Check][Param] Cannot find key string [%s] of multi-batch in name of virtual input node, "
"node name: %s.", kMultiBatchNodePostfix.c_str(), data_name.c_str());
return FAILED; return FAILED;
} }


@@ -1116,7 +1179,7 @@ Status MultiBatchClonePass::CreateOriGraph(const ComputeGraphPtr &graph) {
NodePtr data_node = CreateDataNode(graph, out_data_anchor, data_index); NodePtr data_node = CreateDataNode(graph, out_data_anchor, data_index);
GE_IF_BOOL_EXEC(data_node == nullptr, GE_IF_BOOL_EXEC(data_node == nullptr,
REPORT_CALL_ERROR("E19999", "Create data node in graph:%s failed", graph->GetName().c_str()); REPORT_CALL_ERROR("E19999", "Create data node in graph:%s failed", graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Create %d data node failed.", out_data_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "[Create][DataNode] in graph:%s failed", graph->GetName().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);
for (auto &in_anchor : out_data_anchor->GetPeerInDataAnchors()) { for (auto &in_anchor : out_data_anchor->GetPeerInDataAnchors()) {
GE_IF_BOOL_EXEC(in_anchor == nullptr, continue); GE_IF_BOOL_EXEC(in_anchor == nullptr, continue);
@@ -1125,8 +1188,9 @@ Status MultiBatchClonePass::CreateOriGraph(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%d) failed", REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%zu) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), out_index, node->GetName().c_str(), node->GetType().c_str(), out_index,
dst_node->GetName().c_str(), dst_node->GetType().c_str(), in_anchor->GetIdx()); dst_node->GetName().c_str(), dst_node->GetType().c_str(), in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Failed to remove edge between %s to %s", node->GetName().c_str(),
dst_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Edge] between op:%s(%s)(index:%zu) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), out_index,
dst_node->GetName().c_str(), dst_node->GetType().c_str(), in_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), dst_node->GetInDataAnchor(in_anchor->GetIdx())) != if (GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), dst_node->GetInDataAnchor(in_anchor->GetIdx())) !=
@@ -1134,8 +1198,9 @@ Status MultiBatchClonePass::CreateOriGraph(const ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
data_node->GetName().c_str(), data_node->GetType().c_str(), data_node->GetName().c_str(), data_node->GetType().c_str(),
dst_node->GetName().c_str(), dst_node->GetType().c_str(), in_anchor->GetIdx()); dst_node->GetName().c_str(), dst_node->GetType().c_str(), in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Failed to add edge between %s to %s", data_node->GetName().c_str(),
dst_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed",
data_node->GetName().c_str(), data_node->GetType().c_str(),
dst_node->GetName().c_str(), dst_node->GetType().c_str(), in_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -1143,7 +1208,8 @@ Status MultiBatchClonePass::CreateOriGraph(const ComputeGraphPtr &graph) {
if (graph->RemoveNode(node) != GRAPH_SUCCESS) { if (graph->RemoveNode(node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "Remove node %s failed!", node->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Remove][Node] %s(%s) from graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
break; break;
@@ -1159,7 +1225,7 @@ NodePtr MultiBatchClonePass::CreateDataNode(const ComputeGraphPtr &graph, const
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, DATA); OpDescPtr op_desc = MakeShared<OpDesc>(node_name, DATA);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(OUT_OF_MEMORY, "Create data node failed.");
GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }
(void)AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index); (void)AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index);
@@ -1167,19 +1233,21 @@ NodePtr MultiBatchClonePass::CreateDataNode(const ComputeGraphPtr &graph, const
OpDescPtr getnext_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc(); OpDescPtr getnext_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc();
if (getnext_op_desc == nullptr) { if (getnext_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param out_data_anchor's owner node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param out_data_anchor's owner node is nullptr, check invalid");
GELOGE(OUT_OF_MEMORY, "Op desc of %s is nullptr.", out_data_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(OUT_OF_MEMORY, "[Get][OpDesc] failed, Param out_data_anchor's owner node is nullptr.");
return nullptr; return nullptr;
} }
if (op_desc->AddInputDesc(getnext_op_desc->GetOutputDesc(out_anchor_index)) != GRAPH_SUCCESS) { if (op_desc->AddInputDesc(getnext_op_desc->GetOutputDesc(out_anchor_index)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add %s input desc failed.", op_desc->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
if (op_desc->AddOutputDesc(getnext_op_desc->GetOutputDesc(out_anchor_index)) != GRAPH_SUCCESS) { if (op_desc->AddOutputDesc(getnext_op_desc->GetOutputDesc(out_anchor_index)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
getnext_op_desc->GetName().c_str(), getnext_op_desc->GetType().c_str()); getnext_op_desc->GetName().c_str(), getnext_op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add %s output desc failed.", op_desc->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed",
getnext_op_desc->GetName().c_str(), getnext_op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
NodePtr data_node = graph->AddNode(op_desc); NodePtr data_node = graph->AddNode(op_desc);
@@ -1204,7 +1272,7 @@ Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const
ComputeGraphPtr subgraph = (i == 0) ? branch : GraphUtils::CloneGraph(branch, postfix, input_nodes, output_nodes); ComputeGraphPtr subgraph = (i == 0) ? branch : GraphUtils::CloneGraph(branch, postfix, input_nodes, output_nodes);
GE_IF_BOOL_EXEC(subgraph == nullptr, GE_IF_BOOL_EXEC(subgraph == nullptr,
REPORT_CALL_ERROR("E19999", "Clone graph from graph:%s failed", branch->GetName().c_str()); REPORT_CALL_ERROR("E19999", "Clone graph from graph:%s failed", branch->GetName().c_str());
GELOGE(FAILED, "Create multi-batch case node failed"); return FAILED);
GELOGE(FAILED, "[Clone][Graph] from graph:%s failed", branch->GetName().c_str()); return FAILED);
subgraph->SetName("Batch_" + std::to_string(i)); subgraph->SetName("Batch_" + std::to_string(i));
subgraph->SetParentNode(case_node_); subgraph->SetParentNode(case_node_);
subgraph->SetParentGraph(graph); subgraph->SetParentGraph(graph);
@@ -1217,7 +1285,9 @@ Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const


GELOGD("The %s has %zu input, %zu output.", subgraph->GetName().c_str(), input_nodes.size(), output_nodes.size()); GELOGD("The %s has %zu input, %zu output.", subgraph->GetName().c_str(), input_nodes.size(), output_nodes.size());
for (const auto &data : input_nodes) { for (const auto &data : input_nodes) {
GE_CHK_STATUS_RET(UpdateSubgraphData(data, i), "Update %s failed", subgraph->GetName().c_str());
GE_CHK_STATUS_RET(UpdateSubgraphData(data, i),
"[Update][SubgraphData] in subgraph:%s failed, node:%s, index:%zu",
subgraph->GetName().c_str(), data->GetName().c_str(), i);
} }
} }


@@ -1226,7 +1296,9 @@ Status MultiBatchClonePass::CreateSubgraphs(const ComputeGraphPtr &graph, const
const auto &op_desc = n->GetOpDesc(); const auto &op_desc = n->GetOpDesc();
op_desc->SetName(n->GetName() + kMultiBatchNodePostfix + "0"); op_desc->SetName(n->GetName() + kMultiBatchNodePostfix + "0");
if (n->GetType() == DATA) { if (n->GetType() == DATA) {
GE_CHK_STATUS_RET(UpdateSubgraphData(n, 0), "Update %s failed", branch->GetName().c_str());
GE_CHK_STATUS_RET(UpdateSubgraphData(n, 0),
"[Update][SubgraphData] in graph:%s failed, node:%s, index:0",
branch->GetName().c_str(), n->GetName().c_str());
} }
} }


@@ -1250,7 +1322,9 @@ Status MultiBatchClonePass::UpdateSubgraphOutput() {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to input:%zu tensor of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set Attr:%s to input:%zu tensor of op:%s(%s) failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), index, ATTR_NAME_PARENT_NODE_INDEX.c_str(), index,
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Failed to set parent index for node %s", output_node->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to input:%zu tensor of op:%s(%s) failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), index,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -1286,16 +1360,20 @@ Status MultiBatchClonePass::PruneDirectOutput(const ComputeGraphPtr &graph) {
continue; continue;
} }


GE_CHK_STATUS_RET(UpdateOutputTensor(i, unused_num), "Graph:%s Update output failed", graph->GetName().c_str());
GE_CHK_STATUS_RET(UpdateOutputTensor(i, unused_num),
"[Update][OutputTensor] in graph:%s failed, parent_index:%zu, unused_num:%u",
graph->GetName().c_str(), i, unused_num);
} }


if (unused_num == 0) { if (unused_num == 0) {
return SUCCESS; return SUCCESS;
} }


GE_CHK_GRAPH_STATUS_RET(NodeUtils::RemoveOutputAnchor(case_node_, output_num - unused_num), "Remove output failed");
GE_CHK_GRAPH_STATUS_RET(NodeUtils::RemoveOutputAnchor(case_node_, output_num - unused_num),
"[Remove][OutputAnchor] for node:%s failed", case_node_->GetName().c_str());
for (const auto &item : all_branch_output_) { for (const auto &item : all_branch_output_) {
GE_CHK_GRAPH_STATUS_RET(NodeUtils::RemoveInputAnchor(item.second, output_num - unused_num), "Remove input failed");
GE_CHK_GRAPH_STATUS_RET(NodeUtils::RemoveInputAnchor(item.second, output_num - unused_num),
"[Remove][InputAnchor] for node:%s failed", item.second->GetName().c_str());
} }


return SUCCESS; return SUCCESS;
@@ -1325,11 +1403,17 @@ Status MultiBatchClonePass::UpdateOutputTensor(uint32_t parent_index, uint32_t u
const auto &op_desc = node->GetOpDesc(); const auto &op_desc = node->GetOpDesc();
(void)op_desc->UpdateInputDesc(update_index, op_desc->GetInputDesc(parent_index)); (void)op_desc->UpdateInputDesc(update_index, op_desc->GetInputDesc(parent_index));


GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor),
"[Add][Edge] between %s(index:%d) and %s(index:%u) failed",
out_node->GetName().c_str(), out_anchor->GetIdx(),
new_anchor->GetOwnerNode()->GetName().c_str(), update_index);
GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u",
case_node_->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index); case_node_->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index);


GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor),
"[Remove][Edge] between %s(index:%d) and %s(index:%u) failed",
out_node->GetName().c_str(), out_anchor->GetIdx(),
old_anchor->GetOwnerNode()->GetName().c_str(), parent_index);
GELOGI("Remove edge success, func node: %s, node: %s", case_node_->GetName().c_str(), out_node->GetName().c_str()); GELOGI("Remove edge success, func node: %s, node: %s", case_node_->GetName().c_str(), out_node->GetName().c_str());
} }


@@ -1337,10 +1421,16 @@ Status MultiBatchClonePass::UpdateOutputTensor(uint32_t parent_index, uint32_t u
const auto &old_anchor = case_node_->GetOutDataAnchor(parent_index); const auto &old_anchor = case_node_->GetOutDataAnchor(parent_index);
for (const auto in_anchor : old_anchor->GetPeerInDataAnchors()) { for (const auto in_anchor : old_anchor->GetPeerInDataAnchors()) {
const auto &in_node = in_anchor->GetOwnerNode(); const auto &in_node = in_anchor->GetOwnerNode();
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(old_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(old_anchor, in_anchor),
"[Remove][Edge] between %s(index:%u) and %s(index:%d) failed",
case_node_->GetName().c_str(), parent_index,
in_node->GetName().c_str(), in_anchor->GetIdx());
GELOGI("Remove edge success, func node: %s, node: %s", case_node_->GetName().c_str(), in_node->GetName().c_str()); GELOGI("Remove edge success, func node: %s, node: %s", case_node_->GetName().c_str(), in_node->GetName().c_str());


GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(new_anchor, in_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(new_anchor, in_anchor),
"[Add][Edge] between %s(index:%u) and %s(index:%d) failed",
case_node_->GetName().c_str(), update_index,
in_node->GetName().c_str(), in_anchor->GetIdx());
GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u",
case_node_->GetName().c_str(), in_node->GetName().c_str(), parent_index, update_index); case_node_->GetName().c_str(), in_node->GetName().c_str(), parent_index, update_index);
} }


+ 118
- 72
ge/graph/passes/multi_batch_pass.cc View File

@@ -38,22 +38,22 @@ Status MultiBatchPass::Run(ComputeGraphPtr graph) {
return SUCCESS; return SUCCESS;
} }
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "FindPredValue failed.");
GELOGE(FAILED, "[Find][PredValue] in graph:%s failed.", graph->GetName().c_str());
return FAILED; return FAILED;
} }


if (GetDynamicType() != SUCCESS) { if (GetDynamicType() != SUCCESS) {
GELOGE(FAILED, "Get dynamic type failed.");
GELOGE(FAILED, "[Get][DynamicType] in graph:%s failed.", graph->GetName().c_str());
return FAILED; return FAILED;
} }
if (GetUserDesignateShape() != SUCCESS) { if (GetUserDesignateShape() != SUCCESS) {
GELOGE(FAILED, "Get user designate shape failed.");
GELOGE(FAILED, "[Get][UserDesignateShape] in graph:%s failed.", graph->GetName().c_str());
return FAILED; return FAILED;
} }
std::vector<std::vector<int64_t>> batch_shape; std::vector<std::vector<int64_t>> batch_shape;
std::vector<std::vector<int64_t>> combined_batch; std::vector<std::vector<int64_t>> combined_batch;
if (!CheckSwitchN(batch_shape, combined_batch)) { if (!CheckSwitchN(batch_shape, combined_batch)) {
GELOGE(FAILED, "CheckSwitchN failed.");
GELOGE(FAILED, "[Check][SwitchN] in graph:%s failed.", graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -62,12 +62,13 @@ Status MultiBatchPass::Run(ComputeGraphPtr graph) {
} }


if (FindSwitchOutNodes(batch_shape.size()) != SUCCESS) { if (FindSwitchOutNodes(batch_shape.size()) != SUCCESS) {
GELOGE(FAILED, "Find SwitchN out nodes failed.");
GELOGE(FAILED, "[Find][SwitchOutNodes] in graph:%s failed, batch_num:%zu.",
graph->GetName().c_str(), batch_shape.size());
return FAILED; return FAILED;
} }


if (ReplaceSwitchN(graph, pred_value, batch_shape, combined_batch) != SUCCESS) { if (ReplaceSwitchN(graph, pred_value, batch_shape, combined_batch) != SUCCESS) {
GELOGE(FAILED, "Replace SwitchN nodes failed.");
GELOGE(FAILED, "[Replace][SwitchN] in graph:%s failed.", graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -75,7 +76,8 @@ Status MultiBatchPass::Run(ComputeGraphPtr graph) {
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", 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()); node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "Remove SwitchN nodes %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -133,7 +135,9 @@ Status MultiBatchPass::SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr
Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchorPtr &pred_value) { Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchorPtr &pred_value) {
for (const NodePtr &node : graph->GetDirectNode()) { for (const NodePtr &node : graph->GetDirectNode()) {
if (node->GetType() == CASE) { if (node->GetType() == CASE) {
GE_CHK_STATUS_RET(SetCaseLabel(graph, node), "Set batch label failed");
GE_CHK_STATUS_RET(SetCaseLabel(graph, node),
"[Set][CaseLabel] for node:%s(%s) in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
continue; continue;
} }
if (node->GetType() != SWITCHN) { if (node->GetType() != SWITCHN) {
@@ -144,14 +148,16 @@ Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchor
if (in_data_anchor == nullptr) { if (in_data_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u data anchor of node:%s(%s) is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Index:%u data anchor of node:%s(%s) is nullptr, check invalid",
SWITCH_PRED_INPUT, node->GetName().c_str(), node->GetType().c_str()); SWITCH_PRED_INPUT, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "FindPredInput failed, in_data_anchor is null, node:%s.", node->GetName().c_str());
GELOGE(FAILED, "[Get][InDataAnchor] failed, Index:%u data anchor of node:%s(%s) is nullptr.",
SWITCH_PRED_INPUT, node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
const auto &pred_input = in_data_anchor->GetPeerOutAnchor(); const auto &pred_input = in_data_anchor->GetPeerOutAnchor();
if (pred_input == nullptr) { if (pred_input == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u data anchor of node:%s(%s), its peer anchor is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Index:%u data anchor of node:%s(%s), its peer anchor is nullptr, check invalid",
SWITCH_PRED_INPUT, node->GetName().c_str(), node->GetType().c_str()); SWITCH_PRED_INPUT, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "FindPredInput failed, pred_input is null, node:%s.", node->GetName().c_str());
GELOGE(FAILED, "[Get][PeerOutAnchor] failed, Index:%u data anchor of node:%s(%s), its peer anchor is nullptr.",
SWITCH_PRED_INPUT, node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -160,7 +166,7 @@ Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchor
} else if (pred_value != pred_input) { } else if (pred_value != pred_input) {
REPORT_INNER_ERROR("E19999", "Multi pred_value of case node exist in graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Multi pred_value of case node exist in graph:%s, check invalid",
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(FAILED, "Multi pred_value node exist.");
GELOGE(FAILED, "[Check][Param] Multi pred_value of case node exist in graph:%s.", graph->GetName().c_str());
return FAILED; return FAILED;
} }
switch_n_nodes_.emplace_back(node); switch_n_nodes_.emplace_back(node);
@@ -173,7 +179,7 @@ Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchor


if (pred_value == nullptr) { if (pred_value == nullptr) {
REPORT_INNER_ERROR("E19999", "Find Pred Input of case node in graph:%s failed", graph->GetName().c_str()); REPORT_INNER_ERROR("E19999", "Find Pred Input of case node in graph:%s failed", graph->GetName().c_str());
GELOGE(FAILED, "FindPredInput failed, pred_value is null.");
GELOGE(FAILED, "[Check][Param] FindPredInput in graph:%s failed, pred_value is null.", graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -191,13 +197,15 @@ Status MultiBatchPass::GetDynamicType() {
if (!AttrUtils::GetInt(switch_n->GetOpDesc(), ATTR_DYNAMIC_TYPE, dynamic_type)) { if (!AttrUtils::GetInt(switch_n->GetOpDesc(), ATTR_DYNAMIC_TYPE, dynamic_type)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_DYNAMIC_TYPE.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_DYNAMIC_TYPE.c_str(),
switch_n->GetName().c_str(), switch_n->GetType().c_str()); switch_n->GetName().c_str(), switch_n->GetType().c_str());
GELOGE(FAILED, "Get attr ATTR_DYNAMIC_TYPE of node: %s failed.", switch_n->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_DYNAMIC_TYPE.c_str(),
switch_n->GetName().c_str(), switch_n->GetType().c_str());
return FAILED; return FAILED;
} }
if (dynamic_type == static_cast<int32_t>(FIXED)) { if (dynamic_type == static_cast<int32_t>(FIXED)) {
REPORT_INNER_ERROR("E19999", "Attr:%s in op:%s(%s), value:%d check invalid", ATTR_DYNAMIC_TYPE.c_str(), REPORT_INNER_ERROR("E19999", "Attr:%s in op:%s(%s), value:%d check invalid", ATTR_DYNAMIC_TYPE.c_str(),
switch_n->GetName().c_str(), switch_n->GetType().c_str(), dynamic_type); switch_n->GetName().c_str(), switch_n->GetType().c_str(), dynamic_type);
GELOGE(FAILED, "Attr ATTR_DYNAMIC_TYPE shouldn't be 0.");
GELOGE(FAILED, "[Check][Param] Attr:%s in op:%s(%s), value:%d is invalid", ATTR_DYNAMIC_TYPE.c_str(),
switch_n->GetName().c_str(), switch_n->GetType().c_str(), dynamic_type);
return FAILED; return FAILED;
} }
if (dynamic_type_ != static_cast<int32_t>(FIXED) && dynamic_type_ != dynamic_type) { if (dynamic_type_ != static_cast<int32_t>(FIXED) && dynamic_type_ != dynamic_type) {
@@ -205,7 +213,8 @@ Status MultiBatchPass::GetDynamicType() {
"check invalid", "check invalid",
ATTR_DYNAMIC_TYPE.c_str(), switch_n->GetName().c_str(), switch_n->GetType().c_str(), ATTR_DYNAMIC_TYPE.c_str(), switch_n->GetName().c_str(), switch_n->GetType().c_str(),
dynamic_type, dynamic_type_); dynamic_type, dynamic_type_);
GELOGE(FAILED, "Attr ATTR_DYNAMIC_TYPE of all switch_n node should be same, while one is %d and another is %d.",
GELOGE(FAILED, "[Check][Param] Attr:%s in op:%s(%s), value:%d not same as attr value:%d in node before",
ATTR_DYNAMIC_TYPE.c_str(), switch_n->GetName().c_str(), switch_n->GetType().c_str(),
dynamic_type, dynamic_type_); dynamic_type, dynamic_type_);
return FAILED; return FAILED;
} }
@@ -213,7 +222,7 @@ Status MultiBatchPass::GetDynamicType() {
} }
if (dynamic_type_ == static_cast<int32_t>(FIXED)) { if (dynamic_type_ == static_cast<int32_t>(FIXED)) {
REPORT_INNER_ERROR("E19999", "Find Attr:%s in all switcnn node failed", ATTR_DYNAMIC_TYPE.c_str()); REPORT_INNER_ERROR("E19999", "Find Attr:%s in all switcnn node failed", ATTR_DYNAMIC_TYPE.c_str());
GELOGE(FAILED, "Attr ATTR_DYNAMIC_TYPE shouldn't be 0.");
GELOGE(FAILED, "[Check][Param] Find Attr:%s in all switcnn node failed", ATTR_DYNAMIC_TYPE.c_str());
return FAILED; return FAILED;
} }


@@ -232,7 +241,8 @@ Status MultiBatchPass::GetUserDesignateShape() {
if (!AttrUtils::GetListStr(switch_n->GetOpDesc(), ATTR_USER_DESIGNEATE_SHAPE_ORDER, cur_data_name_order)) { if (!AttrUtils::GetListStr(switch_n->GetOpDesc(), ATTR_USER_DESIGNEATE_SHAPE_ORDER, cur_data_name_order)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
switch_n->GetName().c_str(), switch_n->GetType().c_str()); switch_n->GetName().c_str(), switch_n->GetType().c_str());
GELOGE(FAILED, "Get attr ATTR_USER_DESIGNEATE_SHAPE_ORDER of node: %s failed.", switch_n->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
switch_n->GetName().c_str(), switch_n->GetType().c_str());
return FAILED; return FAILED;
} }
if (first_check) { if (first_check) {
@@ -245,15 +255,16 @@ Status MultiBatchPass::GetUserDesignateShape() {
switch_n->GetName().c_str(), switch_n->GetType().c_str(), switch_n->GetName().c_str(), switch_n->GetType().c_str(),
formats::JoinToString(cur_data_name_order).c_str(), formats::JoinToString(cur_data_name_order).c_str(),
formats::JoinToString(data_name_order_).c_str()); formats::JoinToString(data_name_order_).c_str());
GELOGE(FAILED, "The ATTR_USER_DESIGNEATE_SHAPE_ORDER of switchN must be same: %s failed.",
switch_n->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Attr:%s in op:%s(%s), value:%s not same as attr value:%s in node before.",
ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(), switch_n->GetName().c_str(), switch_n->GetType().c_str(),
formats::JoinToString(cur_data_name_order).c_str(), formats::JoinToString(data_name_order_).c_str());
return FAILED; return FAILED;
} }
} }
} }
if (data_name_order_.empty()) { if (data_name_order_.empty()) {
REPORT_INNER_ERROR("E19999", "Find Attr:%s in all switcnn node failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str()); REPORT_INNER_ERROR("E19999", "Find Attr:%s in all switcnn node failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str());
GELOGE(FAILED, "user shape order can not be empty");
GELOGE(FAILED, "[Check][Param] Find Attr:%s in all switcnn node failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str());
return FAILED; return FAILED;
} }


@@ -277,24 +288,25 @@ bool MultiBatchPass::CheckSwitchN(std::vector<std::vector<int64_t>> &batch_shape
} else if (batch_num != tmp_num) { } else if (batch_num != tmp_num) {
REPORT_INNER_ERROR("E19999", "Ouput size num:%u of node:%s(%s) not same as output size num:%d of node before, " REPORT_INNER_ERROR("E19999", "Ouput size num:%u of node:%s(%s) not same as output size num:%d of node before, "
"check invalid", tmp_num, node->GetName().c_str(), node->GetType().c_str(), batch_num); "check invalid", tmp_num, node->GetName().c_str(), node->GetType().c_str(), batch_num);
GELOGE(FAILED, "Output size of SwitchN not equal;");
GELOGE(FAILED, "[Check][Param] Ouput size num:%u of node:%s(%s) not same as output size num:%d of node before",
tmp_num, node->GetName().c_str(), node->GetType().c_str(), batch_num);
return false; return false;
} }
} }


if (!GetBatchInfo(batch_num, batch_shape, combined_batch)) { if (!GetBatchInfo(batch_num, batch_shape, combined_batch)) {
GELOGE(FAILED, "Get batch info failed.");
GELOGE(FAILED, "[Get][BatchInfo] failed, batch_num:%u.", batch_num);
return false; return false;
} }


if (batch_shape.empty()) { if (batch_shape.empty()) {
REPORT_INNER_ERROR("E19999", "batch_shape size is empty after GetBatchInfo, check invalid"); REPORT_INNER_ERROR("E19999", "batch_shape size is empty after GetBatchInfo, check invalid");
GELOGE(FAILED, "batch_shape is empty.");
GELOGE(FAILED, "[Check][Param] batch_shape is empty after GetBatchInfo.");
return false; return false;
} }
if (combined_batch.empty()) { if (combined_batch.empty()) {
REPORT_INNER_ERROR("E19999", "combined_batch size is empty after GetBatchInfo, check invalid"); REPORT_INNER_ERROR("E19999", "combined_batch size is empty after GetBatchInfo, check invalid");
GELOGE(FAILED, "combined_batch is empty.");
GELOGE(FAILED, "[Check][Param] combined_batch is empty after GetBatchInfo.");
return false; return false;
} }
size_t dim_num = batch_shape[0].size(); size_t dim_num = batch_shape[0].size();
@@ -304,14 +316,15 @@ bool MultiBatchPass::CheckSwitchN(std::vector<std::vector<int64_t>> &batch_shape
if (dim_num != tmp_dim_num) { if (dim_num != tmp_dim_num) {
REPORT_INNER_ERROR("E19999", "Dim num of batch_shape not equal, batch_0:%zu, batch_%u:%zu, check invalid", REPORT_INNER_ERROR("E19999", "Dim num of batch_shape not equal, batch_0:%zu, batch_%u:%zu, check invalid",
dim_num, i, tmp_dim_num); dim_num, i, tmp_dim_num);
GELOGE(FAILED, "Dim num of batch_shape not equal, batch_0:%zu, batch_%u:%zu.", dim_num, i, tmp_dim_num);
GELOGE(FAILED, "[Check][Param] Dim num of batch_shape not equal, batch_0:%zu, batch_%u:%zu.",
dim_num, i, tmp_dim_num);
return false; return false;
} }
size_t tmp_combined_dim_num = combined_batch[i].size(); size_t tmp_combined_dim_num = combined_batch[i].size();
if (combined_dim_num != tmp_combined_dim_num) { if (combined_dim_num != tmp_combined_dim_num) {
REPORT_INNER_ERROR("E19999", "Dim num of combined_batch not equal, batch_0:%zu, batch_%u:%zu, check invalid", REPORT_INNER_ERROR("E19999", "Dim num of combined_batch not equal, batch_0:%zu, batch_%u:%zu, check invalid",
combined_dim_num, i, tmp_combined_dim_num); combined_dim_num, i, tmp_combined_dim_num);
GELOGE(FAILED, "Dim num of combined_batch not equal, batch_0:%zu, batch_%u:%zu.",
GELOGE(FAILED, "[Check][Param] Dim num of combined_batch not equal, batch_0:%zu, batch_%u:%zu.",
combined_dim_num, i, tmp_combined_dim_num); combined_dim_num, i, tmp_combined_dim_num);
return false; return false;
} }
@@ -339,7 +352,7 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vector<std::vector<in
OpDescPtr op_desc = node->GetOpDesc(); OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(FAILED, "CheckDims failed, get op_desc failed, node: %s.", node->GetName().c_str());
GELOGE(FAILED, "[Get][OpDesc] failed, OpDesc in node is nullptr.");
return false; return false;
} }
std::vector<int64_t> output_dims; std::vector<int64_t> output_dims;
@@ -347,7 +360,8 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vector<std::vector<in
REPORT_CALL_ERROR("E19999", "Get Attr:%s from output:%u tensor of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get Attr:%s from output:%u tensor of op:%s(%s) failed",
ATTR_NAME_SWITCHN_PRED_VALUE.c_str(), i, ATTR_NAME_SWITCHN_PRED_VALUE.c_str(), i,
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "CheckDims failed, get attr ATTR_NAME_SWITCHN_PRED_VALUE failed, batch_index=%u.", i);
GELOGE(FAILED, "[Get][Attr] %s from output:%u tensor of op:%s(%s) failed",
ATTR_NAME_SWITCHN_PRED_VALUE.c_str(), i, op_desc->GetName().c_str(), op_desc->GetType().c_str());
return false; return false;
} }
idx_batch_shape.emplace_back(output_dims); idx_batch_shape.emplace_back(output_dims);
@@ -356,7 +370,8 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vector<std::vector<in
REPORT_CALL_ERROR("E19999", "Get Attr:%s from output:%u tensor of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get Attr:%s from output:%u tensor of op:%s(%s) failed",
ATTR_NAME_COMBINED_DYNAMIC_DIMS.c_str(), i, ATTR_NAME_COMBINED_DYNAMIC_DIMS.c_str(), i,
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "CheckDims failed, get attr ATTR_NAME_COMBINED_DYNAMIC_DIMS failed, batch_index=%u.", i);
GELOGE(FAILED, "[Get][Attr] %s from output:%u tensor of op:%s(%s) failed",
ATTR_NAME_COMBINED_DYNAMIC_DIMS.c_str(), i, op_desc->GetName().c_str(), op_desc->GetType().c_str());
return false; return false;
} }
idx_combined_batch.emplace_back(output_dims); idx_combined_batch.emplace_back(output_dims);
@@ -364,7 +379,8 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vector<std::vector<in
if (!CheckDims(idx_batch_shape)) { if (!CheckDims(idx_batch_shape)) {
REPORT_INNER_ERROR("E19999", "Attr:%s of all output:%u tensor in switcnn node not equal, or not exist, " REPORT_INNER_ERROR("E19999", "Attr:%s of all output:%u tensor in switcnn node not equal, or not exist, "
"check invalid", ATTR_NAME_SWITCHN_PRED_VALUE.c_str(), i); "check invalid", ATTR_NAME_SWITCHN_PRED_VALUE.c_str(), i);
GELOGE(FAILED, "CheckDims failed, batch_index=%u.", i);
GELOGE(FAILED, "[Check][Dims] failed, Attr:%s of all output:%u tensor in switcnn node not equal, or not exist.",
ATTR_NAME_SWITCHN_PRED_VALUE.c_str(), i);
return false; return false;
} }


@@ -398,8 +414,9 @@ Status MultiBatchPass::FindSwitchOutNodes(uint32_t batch_num) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), i, node->GetName().c_str(), node->GetType().c_str(), i,
out_node->GetName().c_str(), out_node->GetType().c_str(), peer_in_anchor->GetIdx()); out_node->GetName().c_str(), out_node->GetType().c_str(), peer_in_anchor->GetIdx());
GELOGE(FAILED, "Remove SwitchN out_data_edge failed, %s->%s.", node->GetName().c_str(),
out_node->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), i,
out_node->GetName().c_str(), out_node->GetType().c_str(), peer_in_anchor->GetIdx());
return FAILED; return FAILED;
} }
for (auto &identity_out_node : out_node->GetOutControlNodes()) { for (auto &identity_out_node : out_node->GetOutControlNodes()) {
@@ -409,8 +426,9 @@ Status MultiBatchPass::FindSwitchOutNodes(uint32_t batch_num) {
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
out_node->GetName().c_str(), out_node->GetType().c_str(), out_node->GetName().c_str(), out_node->GetType().c_str(),
identity_out_node->GetName().c_str(), identity_out_node->GetType().c_str()); identity_out_node->GetName().c_str(), identity_out_node->GetType().c_str());
GELOGE(FAILED, "Remove SwitchN out_data_edge failed, %s->%s.", node->GetName().c_str(),
out_node->GetName().c_str());
GELOGE(FAILED, "[Remove][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
out_node->GetName().c_str(), out_node->GetType().c_str(),
identity_out_node->GetName().c_str(), identity_out_node->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -438,29 +456,31 @@ Status MultiBatchPass::ReplaceSwitchN(const ComputeGraphPtr &graph, const OutDat
const std::string &switch_case_name = pred_value_node->GetName() + "_" + STREAMSWITCHN; const std::string &switch_case_name = pred_value_node->GetName() + "_" + STREAMSWITCHN;
NodePtr switch_case = CreateSwitchCaseNode(graph, switch_case_name, pred_value, batch_shape, combined_batch); NodePtr switch_case = CreateSwitchCaseNode(graph, switch_case_name, pred_value, batch_shape, combined_batch);
if (switch_case == nullptr) { if (switch_case == nullptr) {
GELOGE(FAILED, "CreateSwitchCaseNode %s failed.", switch_case_name.c_str());
GELOGE(FAILED, "[Create][SwitchCaseNode] %s failed.", switch_case_name.c_str());
return FAILED; return FAILED;
} }


for (const NodePtr &switch_n_node : switch_n_nodes_) { for (const NodePtr &switch_n_node : switch_n_nodes_) {
if (BypassSwitchN(switch_n_node, switch_case) != SUCCESS) { if (BypassSwitchN(switch_n_node, switch_case) != SUCCESS) {
GELOGE(FAILED, "Bypass SwitchN %s failed.", switch_case_name.c_str());
GELOGE(FAILED, "[Call][BypassSwitchN] for %s failed.", switch_case_name.c_str());
return FAILED; return FAILED;
} }
} }


// Add switchCase input edge // Add switchCase input edge
if (GraphUtils::AddEdge(pred_value, switch_case->GetInDataAnchor(0)) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(pred_value, switch_case->GetInDataAnchor(0)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
pred_value_node->GetName().c_str(), pred_value_node->GetType().c_str(), pred_value->GetIdx(), pred_value_node->GetName().c_str(), pred_value_node->GetType().c_str(), pred_value->GetIdx(),
switch_case->GetName().c_str(), switch_case->GetType().c_str()); switch_case->GetName().c_str(), switch_case->GetType().c_str());
GELOGE(FAILED, "Add SwitchCase in_data_edge failed, %s->%s.", pred_value_node->GetName().c_str(),
switch_case->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
pred_value_node->GetName().c_str(), pred_value_node->GetType().c_str(), pred_value->GetIdx(),
switch_case->GetName().c_str(), switch_case->GetType().c_str());
return FAILED; return FAILED;
} }


if (AttachLabel(switch_case) != SUCCESS) { if (AttachLabel(switch_case) != SUCCESS) {
GELOGE(FAILED, "AttachLabel failed.");
GELOGE(FAILED, "[Attach][Label] for node:%s(%s) failed.",
switch_case->GetName().c_str(), switch_case->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -474,7 +494,7 @@ Status MultiBatchPass::ReplaceSwitchN(const ComputeGraphPtr &graph, const OutDat
/// ///
bool MultiBatchPass::CheckDims(const std::vector<std::vector<int64_t>> &output_shape) const { bool MultiBatchPass::CheckDims(const std::vector<std::vector<int64_t>> &output_shape) const {
if (output_shape.empty()) { if (output_shape.empty()) {
GELOGE(FAILED, "CheckDims failed: output_shape is empty.");
GELOGE(FAILED, "[Check][Param] output_shape is empty.");
return false; return false;
} }


@@ -502,7 +522,7 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const
OpDescPtr op_desc = MakeShared<OpDesc>(name, STREAMSWITCHN); OpDescPtr op_desc = MakeShared<OpDesc>(name, STREAMSWITCHN);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }


@@ -510,13 +530,14 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const
OpDescPtr pred_desc = pred_value->GetOwnerNode()->GetOpDesc(); OpDescPtr pred_desc = pred_value->GetOwnerNode()->GetOpDesc();
if (pred_desc == nullptr) { if (pred_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(FAILED, "Get pred_desc failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Get][OpDesc] failed, OpDesc in node is nullptr.");
return nullptr; return nullptr;
} }
if (op_desc->AddInputDesc(pred_desc->GetOutputDesc(pred_value->GetIdx())) != GRAPH_SUCCESS) { if (op_desc->AddInputDesc(pred_desc->GetOutputDesc(pred_value->GetIdx())) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "AddInputDesc failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -524,7 +545,8 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const
if (switch_case_node == nullptr) { if (switch_case_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "Create node failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr; return nullptr;
} }


@@ -532,19 +554,22 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_BATCH_NUM, batch_num)) { if (!AttrUtils::SetInt(op_desc, ATTR_NAME_BATCH_NUM, batch_num)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_BATCH_NUM.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_BATCH_NUM.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "set attr ATTR_NAME_BATCH_NUM failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_BATCH_NUM.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
if (!AttrUtils::SetInt(op_desc, ATTR_DYNAMIC_TYPE, dynamic_type_)) { if (!AttrUtils::SetInt(op_desc, ATTR_DYNAMIC_TYPE, dynamic_type_)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_DYNAMIC_TYPE.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_DYNAMIC_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set attr ATTR_DYNAMIC_TYPE failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_DYNAMIC_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
if (!AttrUtils::SetListStr(op_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order_)) { if (!AttrUtils::SetListStr(op_desc, ATTR_USER_DESIGNEATE_SHAPE_ORDER, data_name_order_)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set attr ATTR_USER_DESIGNEATE_SHAPE_ORDER failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_USER_DESIGNEATE_SHAPE_ORDER.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
for (uint32_t i = 0; i < batch_num; i++) { for (uint32_t i = 0; i < batch_num; i++) {
@@ -552,14 +577,16 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const
if (!AttrUtils::SetListInt(op_desc, attr_name, batch_shape[i])) { if (!AttrUtils::SetListInt(op_desc, attr_name, batch_shape[i])) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", attr_name.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", attr_name.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "set attr ATTR_NAME_PRED_VALUE failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", attr_name.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
const std::string &attr_combined_batch = ATTR_NAME_COMBINED_BATCH + "_" + std::to_string(i); const std::string &attr_combined_batch = ATTR_NAME_COMBINED_BATCH + "_" + std::to_string(i);
if (!AttrUtils::SetListInt(op_desc, attr_combined_batch, combined_batch[i])) { if (!AttrUtils::SetListInt(op_desc, attr_combined_batch, combined_batch[i])) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", attr_combined_batch.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", attr_combined_batch.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "set attr ATTR_NAME_COMBINED_BATCH failed, StreamSwitchN:%s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", attr_combined_batch.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }
} }
@@ -578,14 +605,16 @@ Status MultiBatchPass::BypassSwitchN(const NodePtr &switch_n_node, const NodePtr
if (in_data_anchor == nullptr) { if (in_data_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u in data anchor of node:%s(%s) is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Index:%u in data anchor of node:%s(%s) is nullptr, check invalid",
SWITCH_DATA_INPUT, switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str()); SWITCH_DATA_INPUT, switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str());
GELOGE(FAILED, "Check in_data_anchor failed, SwitchN:%s.", switch_n_node->GetName().c_str());
GELOGE(FAILED, "[Get][InDataAnchor] failed, Index:%u in data anchor of node:%s(%s) is nullptr",
SWITCH_DATA_INPUT, switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str());
return FAILED; return FAILED;
} }
OutDataAnchorPtr peer_data_anchor = in_data_anchor->GetPeerOutAnchor(); OutDataAnchorPtr peer_data_anchor = in_data_anchor->GetPeerOutAnchor();
if (peer_data_anchor == nullptr) { if (peer_data_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u in data anchor of node:%s(%s), its peer ahcnhor is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Index:%u in data anchor of node:%s(%s), its peer ahcnhor is nullptr, check invalid",
SWITCH_DATA_INPUT, switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str()); SWITCH_DATA_INPUT, switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str());
GELOGE(FAILED, "Check peer_data_anchor failed, SwitchN:%s.", switch_n_node->GetName().c_str());
GELOGE(FAILED, "[Get][PeerOutAnchor] failed, Index:%u in data anchor of node:%s(%s), its peer ahcnhor is nullptr",
SWITCH_DATA_INPUT, switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str());
return FAILED; return FAILED;
} }
NodePtr data_input = peer_data_anchor->GetOwnerNode(); NodePtr data_input = peer_data_anchor->GetOwnerNode();
@@ -595,16 +624,18 @@ Status MultiBatchPass::BypassSwitchN(const NodePtr &switch_n_node, const NodePtr
REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed", REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed",
data_input->GetName().c_str(), data_input->GetType().c_str(), peer_data_anchor->GetIdx(), data_input->GetName().c_str(), data_input->GetType().c_str(), peer_data_anchor->GetIdx(),
switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str(), SWITCH_DATA_INPUT); switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str(), SWITCH_DATA_INPUT);
GELOGE(FAILED, "Remove SwitchN in_data_edge failed, %s->%s.", data_input->GetName().c_str(),
switch_n_node->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed",
data_input->GetName().c_str(), data_input->GetType().c_str(), peer_data_anchor->GetIdx(),
switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str(), SWITCH_DATA_INPUT);
return FAILED; return FAILED;
} }
if (GraphUtils::AddEdge(data_input->GetOutControlAnchor(), switch_case->GetInControlAnchor()) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(data_input->GetOutControlAnchor(), switch_case->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
data_input->GetName().c_str(), data_input->GetType().c_str(), data_input->GetName().c_str(), data_input->GetType().c_str(),
switch_case->GetName().c_str(), switch_case->GetType().c_str()); switch_case->GetName().c_str(), switch_case->GetType().c_str());
GELOGE(FAILED, "Add StreamSwitchN in_control_edge failed, %s->%s.", data_input->GetName().c_str(),
switch_case->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
data_input->GetName().c_str(), data_input->GetType().c_str(),
switch_case->GetName().c_str(), switch_case->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -620,21 +651,28 @@ Status MultiBatchPass::BypassSwitchN(const NodePtr &switch_n_node, const NodePtr
data_output->GetName().c_str(), data_output->GetType().c_str(), peer_in_anchor->GetIdx(), data_output->GetName().c_str(), data_output->GetType().c_str(), peer_in_anchor->GetIdx(),
data_input->GetName().c_str(), data_input->GetType().c_str(), peer_data_anchor->GetIdx(), data_input->GetName().c_str(), data_input->GetType().c_str(), peer_data_anchor->GetIdx(),
data_output->GetName().c_str(), data_output->GetType().c_str(), peer_in_anchor->GetIdx()); data_output->GetName().c_str(), data_output->GetType().c_str(), peer_in_anchor->GetIdx());
GELOGE(FAILED, "Bypass SwitchN data_edge failed, %s->%s->%s.", data_input->GetName().c_str(),
switch_n_node->GetName().c_str(), data_output->GetName().c_str());
GELOGE(FAILED, "[Replace][Edge] failed, Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) or "
"Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
switch_n_node->GetName().c_str(), switch_n_node->GetType().c_str(), out_data_anchor->GetIdx(),
data_output->GetName().c_str(), data_output->GetType().c_str(), peer_in_anchor->GetIdx(),
data_input->GetName().c_str(), data_input->GetType().c_str(), peer_data_anchor->GetIdx(),
data_output->GetName().c_str(), data_output->GetType().c_str(), peer_in_anchor->GetIdx());
return FAILED; return FAILED;
} }
if (GraphUtils::AddEdge(switch_case->GetOutControlAnchor(), data_output->GetInControlAnchor()) != GRAPH_SUCCESS) { if (GraphUtils::AddEdge(switch_case->GetOutControlAnchor(), data_output->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
switch_case->GetName().c_str(), switch_case->GetType().c_str(), switch_case->GetName().c_str(), switch_case->GetType().c_str(),
data_output->GetName().c_str(), data_output->GetType().c_str()); data_output->GetName().c_str(), data_output->GetType().c_str());
GELOGE(FAILED, "Add SwitchCase out_control_edge failed, %s->%s.", switch_case->GetName().c_str(),
data_output->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
switch_case->GetName().c_str(), switch_case->GetType().c_str(),
data_output->GetName().c_str(), data_output->GetType().c_str());
return FAILED; return FAILED;
} }
} }
} }
GE_CHK_STATUS_RET(MoveCtrlEdges(switch_n_node, switch_case), "Move ctrl edges failed.");
GE_CHK_STATUS_RET(MoveCtrlEdges(switch_n_node, switch_case),
"[Move][CtrlEdges] from %s to %s failed.", switch_n_node->GetName().c_str(),
switch_case->GetName().c_str());


bypass_nodes_.emplace_back(switch_n_node); bypass_nodes_.emplace_back(switch_n_node);
GELOGI("Bypass SwitchN node %s success.", switch_n_node->GetName().c_str()); GELOGI("Bypass SwitchN node %s success.", switch_n_node->GetName().c_str());
@@ -650,13 +688,13 @@ Status MultiBatchPass::AttachLabel(const NodePtr &switch_case_node) {
std::vector<std::string> stream_label_list; std::vector<std::string> stream_label_list;
for (uint32_t i = 0; i < static_cast<uint32_t>(batch_head_nodes_.size()); i++) { for (uint32_t i = 0; i < static_cast<uint32_t>(batch_head_nodes_.size()); i++) {
if (AttachBatchLabel(i) != SUCCESS) { if (AttachBatchLabel(i) != SUCCESS) {
GELOGE(FAILED, "AttachBatchLabel failed, batch_idx=%u", i);
GELOGE(FAILED, "[Attach][BatchLabel] failed, batch_idx=%u", i);
return FAILED; return FAILED;
} }


const std::string &stream_label = "stream_label_batch_" + std::to_string(i); const std::string &stream_label = "stream_label_batch_" + std::to_string(i);
if (AttachStreamLabel(i, stream_label) != SUCCESS) { if (AttachStreamLabel(i, stream_label) != SUCCESS) {
GELOGE(FAILED, "AttachStreamLabel failed, stream_label=%s", stream_label.c_str());
GELOGE(FAILED, "[Attach][StreamLabel] failed, stream_label=%s, batch_idx=%u", stream_label.c_str(), i);
return FAILED; return FAILED;
} }
stream_label_list.emplace_back(stream_label); stream_label_list.emplace_back(stream_label);
@@ -692,14 +730,16 @@ Status MultiBatchPass::AttachBatchLabel(uint32_t batch_idx) {
if (!AttrUtils::GetStr(cur_desc, ATTR_NAME_BATCH_LABEL, tmp_label)) { if (!AttrUtils::GetStr(cur_desc, ATTR_NAME_BATCH_LABEL, tmp_label)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_BATCH_LABEL.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_BATCH_LABEL.c_str(),
cur_desc->GetName().c_str(), cur_desc->GetType().c_str()); cur_desc->GetName().c_str(), cur_desc->GetType().c_str());
GELOGE(FAILED, "get attr ATTR_NAME_BATCH_LABEL failed, node: %s.", cur_desc->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_BATCH_LABEL.c_str(),
cur_desc->GetName().c_str(), cur_desc->GetType().c_str());
return FAILED; return FAILED;
} }
if (tmp_label != batch_label) { if (tmp_label != batch_label) {
REPORT_INNER_ERROR("E19999", "Attr:%s from op:%s(%s) value:%s not equal to expect:%s, check invalid", REPORT_INNER_ERROR("E19999", "Attr:%s from op:%s(%s) value:%s not equal to expect:%s, check invalid",
ATTR_NAME_BATCH_LABEL.c_str(), cur_desc->GetName().c_str(), cur_desc->GetType().c_str(), ATTR_NAME_BATCH_LABEL.c_str(), cur_desc->GetName().c_str(), cur_desc->GetType().c_str(),
tmp_label.c_str(), batch_label.c_str()); tmp_label.c_str(), batch_label.c_str());
GELOGE(FAILED, "Reach other batch_branch, node:%s, cur_label:%s, batch_label:%s.", cur_desc->GetName().c_str(),
GELOGE(FAILED, "[Check][Param] Attr:%s from op:%s(%s) value:%s not equal to expect:%s",
ATTR_NAME_BATCH_LABEL.c_str(), cur_desc->GetName().c_str(), cur_desc->GetType().c_str(),
tmp_label.c_str(), batch_label.c_str()); tmp_label.c_str(), batch_label.c_str());
return FAILED; return FAILED;
} }
@@ -708,7 +748,8 @@ Status MultiBatchPass::AttachBatchLabel(uint32_t batch_idx) {
if (!AttrUtils::SetStr(cur_desc, ATTR_NAME_BATCH_LABEL, batch_label)) { if (!AttrUtils::SetStr(cur_desc, ATTR_NAME_BATCH_LABEL, batch_label)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_BATCH_LABEL.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_BATCH_LABEL.c_str(),
cur_desc->GetName().c_str(), cur_desc->GetType().c_str()); cur_desc->GetName().c_str(), cur_desc->GetType().c_str());
GELOGE(FAILED, "set attr ATTR_NAME_BATCH_LABEL failed, node:%s.", cur_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_BATCH_LABEL.c_str(),
cur_desc->GetName().c_str(), cur_desc->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -722,7 +763,7 @@ Status MultiBatchPass::AttachBatchLabel(uint32_t batch_idx) {
if (type == NETOUTPUT) { if (type == NETOUTPUT) {
REPORT_CALL_ERROR("E19999", "SReach net_output without Merge, cur_node:%s(%s), check invalid", REPORT_CALL_ERROR("E19999", "SReach net_output without Merge, cur_node:%s(%s), check invalid",
cur_node->GetName().c_str(), cur_node->GetType().c_str()); cur_node->GetName().c_str(), cur_node->GetType().c_str());
GELOGE(FAILED, "Reach net_output without Merge, cur_node:%s.", cur_node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Reach net_output without Merge, cur_node:%s.", cur_node->GetName().c_str());
return FAILED; return FAILED;
} }
nodes.push(out_node); nodes.push(out_node);
@@ -760,7 +801,8 @@ Status MultiBatchPass::AttachStreamLabel(uint32_t batch_idx, const std::string &
if (SetStreamLabel(cur_node, stream_label) != SUCCESS) { if (SetStreamLabel(cur_node, stream_label) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
stream_label.c_str(), cur_node->GetName().c_str(), cur_node->GetType().c_str()); stream_label.c_str(), cur_node->GetName().c_str(), cur_node->GetType().c_str());
GELOGE(FAILED, "Set stream_label failed, node:%s.", cur_node->GetName().c_str());
GELOGE(FAILED, "[Set][StreamLabel] %s to op:%s(%s) failed",
stream_label.c_str(), cur_node->GetName().c_str(), cur_node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -786,16 +828,20 @@ Status MultiBatchPass::MoveCtrlEdges(const NodePtr &old_node, const NodePtr &new
} }
for (const NodePtr &in_ctrl_node : old_node->GetInControlNodes()) { for (const NodePtr &in_ctrl_node : old_node->GetInControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), old_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), old_node->GetInControlAnchor()),
"Merge remove in ctrl edge failed.");
"[Remove][ControlEdge] between %s and %s failed.",
in_ctrl_node->GetName().c_str(), old_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(in_ctrl_node->GetOutControlAnchor(), new_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(in_ctrl_node->GetOutControlAnchor(), new_node->GetInControlAnchor()),
"StreamMerge add in ctrl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
in_ctrl_node->GetName().c_str(), new_node->GetName().c_str());
} }


for (const NodePtr &out_ctrl_node : old_node->GetOutControlNodes()) { for (const NodePtr &out_ctrl_node : old_node->GetOutControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(old_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(old_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()),
"Merge remove out ctrl edge failed.");
"[Remove][ControlEdge] between %s and %s failed.",
old_node->GetName().c_str(), out_ctrl_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), out_ctrl_node->GetInControlAnchor()),
"StreamMerge add out ctrl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
new_node->GetName().c_str(), out_ctrl_node->GetName().c_str());
} }
return SUCCESS; return SUCCESS;
} }


+ 78
- 51
ge/graph/passes/net_output_pass.cc View File

@@ -50,13 +50,15 @@ Status NetOutputPass::GetRetvalOutputInfo(const ge::NodePtr &node,
if (!AttrUtils::GetInt(node->GetOpDesc(), RETVAL_ATTR_NAME_INDEX, output_index)) { if (!AttrUtils::GetInt(node->GetOpDesc(), RETVAL_ATTR_NAME_INDEX, output_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", RETVAL_ATTR_NAME_INDEX.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", RETVAL_ATTR_NAME_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(PARAM_INVALID, "Get output index failed.");
GELOGE(PARAM_INVALID, "[Get][Attr] %s from op:%s(%s) failed", RETVAL_ATTR_NAME_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
if (retval_node_index_map.count(output_index) > 0) { if (retval_node_index_map.count(output_index) > 0) {
REPORT_INNER_ERROR("E19999", "Attr:%s from op:%s(%s), value:%ld duplicate with other node, check invalid", REPORT_INNER_ERROR("E19999", "Attr:%s from op:%s(%s), value:%ld duplicate with other node, check invalid",
RETVAL_ATTR_NAME_INDEX.c_str(), node->GetName().c_str(), node->GetType().c_str(), output_index); RETVAL_ATTR_NAME_INDEX.c_str(), node->GetName().c_str(), node->GetType().c_str(), output_index);
GELOGE(PARAM_INVALID, "Retval has duplicate index.");
GELOGE(PARAM_INVALID, "[Check][Param] Attr:%s from op:%s(%s), value:%ld duplicate with other node.",
RETVAL_ATTR_NAME_INDEX.c_str(), node->GetName().c_str(), node->GetType().c_str(), output_index);
return PARAM_INVALID; return PARAM_INVALID;
} }
int parent_node_index = -1; int parent_node_index = -1;
@@ -89,7 +91,7 @@ Status NetOutputPass::GetOutputNode(const ge::ComputeGraphPtr &graph, std::vecto
ret = GetRetvalOutputInfo(node, retval_node_index_map); ret = GetRetvalOutputInfo(node, retval_node_index_map);
} }
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "GetRetvalOutputInfo failed");
GELOGE(ret, "[Get][RetvalOutputInfo] for node:%s failed", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -143,13 +145,14 @@ Status NetOutputPass::CheckOutputNodeInfo(const ComputeGraphPtr &graph, const st
NodePtr node = item.output_node; NodePtr node = item.output_node;
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param outputs has item which output_node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param outputs has item which output_node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Node in outputs is null.");
GELOGE(PARAM_INVALID, "[Check][Param] Node in outputs is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} else { } else {
if (graph->FindNode(node->GetName()) == nullptr) { if (graph->FindNode(node->GetName()) == nullptr) {
REPORT_INNER_ERROR("E19999", "Find node:%s from graph:%s failed", REPORT_INNER_ERROR("E19999", "Find node:%s from graph:%s failed",
node->GetName().c_str(), graph->GetName().c_str()); node->GetName().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Out node (%s) is not in graph.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Out node (%s) is not in graph:%s.",
node->GetName().c_str(), graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GE_CHECK_NOTNULL(node->GetOpDesc()); GE_CHECK_NOTNULL(node->GetOpDesc());
@@ -158,10 +161,8 @@ Status NetOutputPass::CheckOutputNodeInfo(const ComputeGraphPtr &graph, const st
if (index < 0 || index >= out_size) { if (index < 0 || index >= out_size) {
REPORT_INNER_ERROR("E19999", "Index:%d in param outputs item, < 0 or > output size:%d of node:%s(%s)", REPORT_INNER_ERROR("E19999", "Index:%d in param outputs item, < 0 or > output size:%d of node:%s(%s)",
index, out_size, node->GetName().c_str(), node->GetType().c_str()); index, out_size, node->GetName().c_str(), node->GetType().c_str());
GELOGE(PARAM_INVALID,
"User declared out node (%s) output index:%d must be smaller "
"than node ouput size:%d and cann't be negative!",
node->GetName().c_str(), index, out_size);
GELOGE(PARAM_INVALID, "[Check][Param] User declared out node (%s) output index:%d must be smaller "
"than node ouput size:%d and cann't be negative!", node->GetName().c_str(), index, out_size);
return PARAM_INVALID; return PARAM_INVALID;
} }
} }
@@ -189,7 +190,8 @@ Status NetOutputPass::RemoveUnusedNode(const ge::ComputeGraphPtr &graph) {
if (graph->RemoveNode(node) != GRAPH_SUCCESS) { if (graph->RemoveNode(node) != GRAPH_SUCCESS) {
REPORT_INNER_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", REPORT_INNER_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Remove node failed, node name:%s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Node] %s(%s) from graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -200,13 +202,14 @@ Status NetOutputPass::UpdateNetOutputDesc(const ge::NodePtr &net_output) {
OpDescPtr net_output_desc = net_output->GetOpDesc(); OpDescPtr net_output_desc = net_output->GetOpDesc();
if (net_output_desc == nullptr) { if (net_output_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "OpDesc in Param net_output is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in Param net_output is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Opdesc of net output node is nullptr.");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, Opdesc of net output node is nullptr.");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (net_output_desc->GetInputsSize() == 0) { if (net_output_desc->GetInputsSize() == 0) {
REPORT_INNER_ERROR("E19999", "Input desc num of node:%s(%s) is 0, check invalid", REPORT_INNER_ERROR("E19999", "Input desc num of node:%s(%s) is 0, check invalid",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str()); net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Net output node input is empty.");
GELOGE(INTERNAL_ERROR, "[Get][InputsSize] Net output node:%s(%s) input is empty.",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -218,7 +221,8 @@ Status NetOutputPass::UpdateNetOutputDesc(const ge::NodePtr &net_output) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has in_anchor index:%u >= its input desc num:%zu, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) has in_anchor index:%u >= its input desc num:%zu, check invalid",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index, net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index,
net_output_desc->GetAllInputsDesc().size()); net_output_desc->GetAllInputsDesc().size());
GELOGE(INTERNAL_ERROR, "Index is invalid, index:%u, size:%zu.", index,
GELOGE(INTERNAL_ERROR, "[Check][Param] Node:%s(%s) has in_anchor index:%u >= its input desc num:%zu",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index,
net_output_desc->GetAllInputsDesc().size()); net_output_desc->GetAllInputsDesc().size());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -231,7 +235,8 @@ Status NetOutputPass::UpdateNetOutputDesc(const ge::NodePtr &net_output) {
if (net_output_desc->UpdateInputDesc(index, output_in_desc) != GRAPH_SUCCESS) { if (net_output_desc->UpdateInputDesc(index, output_in_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update input desc of op:%s(%s) failed, index:%u", REPORT_CALL_ERROR("E19999", "Update input desc of op:%s(%s) failed, index:%u",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index); net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Update input desc failed, index:%u.", index);
GELOGE(INTERNAL_ERROR, "[Update][InputDesc] of op:%s(%s) failed, index:%u",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGD("Update desc, format:%s, data type:%s, index:%u.", GELOGD("Update desc, format:%s, data type:%s, index:%u.",
@@ -245,7 +250,7 @@ Status NetOutputPass::UpdateNetOutputDesc(const ge::NodePtr &net_output) {
Status NetOutputPass::AddCtrlEdgeForTargets(const ge::NodePtr &net_out_node) { Status NetOutputPass::AddCtrlEdgeForTargets(const ge::NodePtr &net_out_node) {
if (net_out_node == nullptr) { if (net_out_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param net_out_node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param net_out_node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "net out node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] net out node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
// Add ctrl edge for targets // Add ctrl edge for targets
@@ -259,8 +264,9 @@ Status NetOutputPass::AddCtrlEdgeForTargets(const ge::NodePtr &net_out_node) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
net_out_node->GetName().c_str(), net_out_node->GetType().c_str()); net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add ctrl edge to netoutput node[%s] for target node [%s] failed!",
net_out_node->GetName().c_str(), node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGD("Add ctrl edge to netoutput node[%s] for target node [%s] success!", net_out_node->GetName().c_str(), GELOGD("Add ctrl edge to netoutput node[%s] for target node [%s] success!", net_out_node->GetName().c_str(),
@@ -293,8 +299,9 @@ Status NetOutputPass::AddEdgesForNetOutput(const ge::ComputeGraphPtr &graph, con
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%u) and op:%s(%s)(index:%d) failed", REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%u) and op:%s(%s)(index:%d) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(), item.node_output_index, src_node->GetName().c_str(), src_node->GetType().c_str(), item.node_output_index,
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_input_index); net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_input_index);
GELOGE(INTERNAL_ERROR, "AddEdge failed, src name:%s, src index:%d, dst index:%d.", src_node->GetName().c_str(),
item.node_output_index, net_input_index);
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%u) and op:%s(%s)(index:%d) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(), item.node_output_index,
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_input_index);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGD("AddEdge to output node, src name:%s, src index:%d, dst index:%d.", src_node->GetName().c_str(), GELOGD("AddEdge to output node, src name:%s, src index:%d, dst index:%d.", src_node->GetName().c_str(),
@@ -306,32 +313,36 @@ Status NetOutputPass::AddEdgesForNetOutput(const ge::ComputeGraphPtr &graph, con
if (input_desc == nullptr) { if (input_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Node:%s(%s) has no input desc index is %d, check invalid", REPORT_CALL_ERROR("E19999", "Node:%s(%s) has no input desc index is %d, check invalid",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_input_index); net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_input_index);
GELOGE(INTERNAL_ERROR, "Can not find intput tensor desc from NetOutput, index %d", net_input_index);
GELOGE(INTERNAL_ERROR, "[Check][Param] Can not find intput tensor desc from NetOutput:%s(%s), index %d",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_input_index);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (!AttrUtils::SetInt(input_desc, ATTR_NAME_PARENT_NODE_INDEX, item.parent_node_index)) { if (!AttrUtils::SetInt(input_desc, ATTR_NAME_PARENT_NODE_INDEX, item.parent_node_index)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to input:%d tensor of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set Attr:%s to input:%d tensor of op:%s(%s) failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), net_input_index, ATTR_NAME_PARENT_NODE_INDEX.c_str(), net_input_index,
net_out_node->GetName().c_str(), net_out_node->GetType().c_str()); net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add parent index to NetOutput, index %d", net_input_index);
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to input:%d tensor of op:%s(%s) failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), net_input_index,
net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
net_input_index++; net_input_index++;
} }
if (RemoveUnusedNode(graph) != SUCCESS) { if (RemoveUnusedNode(graph) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Remove unused nodes failed.");
GELOGE(INTERNAL_ERROR, "[Remove][UnusedNode] from graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (AddCtrlEdgeForTargets(net_out_node) != SUCCESS) { if (AddCtrlEdgeForTargets(net_out_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add ctrl edge for targets failed.");
GELOGE(INTERNAL_ERROR, "[Add][CtrlEdge] for targets failed, net_out_node:%s.", net_out_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
// Add true stream, netoutput is 0 // Add true stream, netoutput is 0
GE_IF_BOOL_EXEC(!ge::AttrUtils::SetInt(net_out_node->GetOpDesc(), ATTR_NAME_TRUE_BRANCH_STREAM, 0), GE_IF_BOOL_EXEC(!ge::AttrUtils::SetInt(net_out_node->GetOpDesc(), ATTR_NAME_TRUE_BRANCH_STREAM, 0),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(),
net_out_node->GetName().c_str(), net_out_node->GetType().c_str()); net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_NAME_TRUE_BRANCH_STREAM failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(),
net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);
return SUCCESS; return SUCCESS;
} }
@@ -348,7 +359,7 @@ bool NetOutputPass::CheckNodeIsInOutputNodes(const ge::ComputeGraphPtr &graph, c
Status NetOutputPass::UnLinkDataAnchorOfNetoutput(const ge::ComputeGraphPtr &graph, const ge::NodePtr &net_out_node) { Status NetOutputPass::UnLinkDataAnchorOfNetoutput(const ge::ComputeGraphPtr &graph, const ge::NodePtr &net_out_node) {
if (net_out_node == nullptr) { if (net_out_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param net_out_node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param net_out_node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "net out node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] net out node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
Status ret = SUCCESS; Status ret = SUCCESS;
@@ -372,7 +383,9 @@ Status NetOutputPass::UnLinkDataAnchorOfNetoutput(const ge::ComputeGraphPtr &gra
REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:%d unlink from op:%s(%s) in index:%d failed", REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:%d unlink from op:%s(%s) in index:%d failed",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), in_data_anchor->GetIdx(), net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), in_data_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str(), peer_out_anchor->GetIdx()); node->GetName().c_str(), node->GetType().c_str(), peer_out_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Unlink peer_out_anchor fail!");
GELOGE(INTERNAL_ERROR, "[Remove][Edge] Op:%s(%s) out index:%d unlink from op:%s(%s) in index:%d failed",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), in_data_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str(), peer_out_anchor->GetIdx());
return ret; return ret;
} }
} else { } else {
@@ -387,14 +400,16 @@ Status NetOutputPass::UnLinkControlAnchorOfNetoutput(const ge::ComputeGraphPtr &
const ge::NodePtr &net_out_node) { const ge::NodePtr &net_out_node) {
if (net_out_node == nullptr) { if (net_out_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param net_out_node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param net_out_node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "net out node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] net out node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
Status ret = SUCCESS; Status ret = SUCCESS;
auto in_control_anchor = net_out_node->GetInControlAnchor(); auto in_control_anchor = net_out_node->GetInControlAnchor();
if (in_control_anchor == nullptr) { if (in_control_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param net_out_node's in control anchor is nullptr, check invalid");
GELOGE(PARAM_INVALID, "in control anchor is null.");
REPORT_INNER_ERROR("E19999", "In control anchor of param net_out_node:%s(%s) is nullptr, check invalid",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] in control anchor of net_out_node:%s(%s) is nullptr.",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
// unlink all data anchor to control anchor of netoutput // unlink all data anchor to control anchor of netoutput
@@ -411,7 +426,9 @@ Status NetOutputPass::UnLinkControlAnchorOfNetoutput(const ge::ComputeGraphPtr &
REPORT_CALL_ERROR("E19999", "Op:%s(%s) unlink control edge from op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Op:%s(%s) unlink control edge from op:%s(%s) failed",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(), net_out_node->GetName().c_str(), net_out_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Unlink peer_out_anchor fail!");
GELOGE(INTERNAL_ERROR, "[Remove][Edge] Op:%s(%s) unlink control edge from op:%s(%s) failed",
net_out_node->GetName().c_str(), net_out_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
return ret; return ret;
} }
} else { } else {
@@ -453,16 +470,17 @@ Status NetOutputPass::UnLink(const ge::ComputeGraphPtr &graph, const ge::NodePtr


Status NetOutputPass::ProcessWithNetoutput(const ge::ComputeGraphPtr &graph, const ge::NodePtr &output_node) { Status NetOutputPass::ProcessWithNetoutput(const ge::ComputeGraphPtr &graph, const ge::NodePtr &output_node) {
if (UpdateNetOutputDesc(output_node) != SUCCESS) { if (UpdateNetOutputDesc(output_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Update net output desc failed.");
GELOGE(INTERNAL_ERROR, "[Update][NetOutputDesc] for node:%s failed.", output_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (UnLink(graph, output_node) != SUCCESS) { if (UnLink(graph, output_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "UnLink connection between netoutput node and user set target node");
GELOGE(INTERNAL_ERROR, "[UnLink][Connection] between netoutput node:%s and user set target node",
output_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (AddCtrlEdgeForTargets(output_node) != SUCCESS) { if (AddCtrlEdgeForTargets(output_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add ctrl edge for targets failed.");
GELOGE(INTERNAL_ERROR, "[Add][CtrlEdge] for targets failed, output_node:%s.", output_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
return SUCCESS; return SUCCESS;
@@ -484,7 +502,8 @@ Status NetOutputPass::AddCtrlEdgesBetweenLeafAndNetOutput(const ge::ComputeGraph
graph_has_only_one_node_except_netoutput) && graph_has_only_one_node_except_netoutput) &&
node->GetOutDataNodesSize() == 0 && node->GetOutControlNodes().size() == 0) { node->GetOutDataNodesSize() == 0 && node->GetOutControlNodes().size() == 0) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(node->GetOutControlAnchor(), net_out_node->GetInControlAnchor()), GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(node->GetOutControlAnchor(), net_out_node->GetInControlAnchor()),
"add edge failed");
"[Add][ControlEdge] between %s and %s failed",
node->GetName().c_str(), net_out_node->GetName().c_str());
GELOGD("Add ctrl edge success. src name :%s, dst name :%s", node->GetName().c_str(), GELOGD("Add ctrl edge success. src name :%s, dst name :%s", node->GetName().c_str(),
net_out_node->GetName().c_str()); net_out_node->GetName().c_str());
} }
@@ -499,7 +518,7 @@ Status NetOutputPass::CreateNetOutputNode(OpDescPtr &net_output_desc, const ge::
net_output_desc = MakeShared<OpDesc>(node_name, NETOUTPUT); net_output_desc = MakeShared<OpDesc>(node_name, NETOUTPUT);
if (net_output_desc == nullptr) { if (net_output_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(MEMALLOC_FAILED, "Make shared net output op failed.");
GELOGE(MEMALLOC_FAILED, "[New][OpDesc] failed.");
return MEMALLOC_FAILED; return MEMALLOC_FAILED;
} }
(void)AttrUtils::SetListStr(net_output_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, (void)AttrUtils::SetListStr(net_output_desc, ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES,
@@ -510,7 +529,7 @@ Status NetOutputPass::CreateNetOutputNode(OpDescPtr &net_output_desc, const ge::
Status NetOutputPass::Run(ge::ComputeGraphPtr graph) { Status NetOutputPass::Run(ge::ComputeGraphPtr graph) {
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "Compute graph is null.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] Compute graph is nullptr.");
return GE_GRAPH_PARAM_NULLPTR; return GE_GRAPH_PARAM_NULLPTR;
} }
GELOGI("[NETOUTPUT PASS] Run.graph is [%s]", graph->GetName().c_str()); GELOGI("[NETOUTPUT PASS] Run.graph is [%s]", graph->GetName().c_str());
@@ -522,12 +541,13 @@ Status NetOutputPass::Run(ge::ComputeGraphPtr graph) {
(void)AttrUtils::SetListStr(output_node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES, (void)AttrUtils::SetListStr(output_node->GetOpDesc(), ATTR_NAME_DATA_DUMP_ORIGIN_OP_NAMES,
std::move(std::vector<std::string>())); std::move(std::vector<std::string>()));
if (ProcessWithNetoutput(graph, output_node) != SUCCESS) { if (ProcessWithNetoutput(graph, output_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Process with netoutput node failed.");
GELOGE(INTERNAL_ERROR, "[Process][WithNetoutput] failed, output_node:%s, graph:%s.",
output_node->GetName().c_str(), graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} else { } else {
if (AddNetOutputNodeToGraph(graph, output_node) != SUCCESS) { if (AddNetOutputNodeToGraph(graph, output_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Set user define dtype and format for netoutput failed.");
GELOGE(INTERNAL_ERROR, "[Add][NetOutputNode] to graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -538,12 +558,12 @@ Status NetOutputPass::Run(ge::ComputeGraphPtr graph) {
Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph, NodePtr &output_node) { Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph, NodePtr &output_node) {
OpDescPtr net_output_desc = nullptr; OpDescPtr net_output_desc = nullptr;
if (CreateNetOutputNode(net_output_desc, graph) != SUCCESS) { if (CreateNetOutputNode(net_output_desc, graph) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Get net output nodes failed.");
GELOGE(INTERNAL_ERROR, "[Create][NetOutputNode] in graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
std::vector<RetvalInfo> output_nodes_info; std::vector<RetvalInfo> output_nodes_info;
if (GetOutputNode(graph, output_nodes_info) != SUCCESS) { if (GetOutputNode(graph, output_nodes_info) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Get net output nodes failed.");
GELOGE(INTERNAL_ERROR, "[Get][OutputNode] in graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGI("[NETOUTPUT PASS] OutNodesInfo size:%zu, Targets Size:%zu, is_include_special_node_:%d", GELOGI("[NETOUTPUT PASS] OutNodesInfo size:%zu, Targets Size:%zu, is_include_special_node_:%d",
@@ -554,11 +574,12 @@ Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph,
GELOGI("[NETOUTPUT PASS] Both output, target and special nodes are empty! add net output node"); GELOGI("[NETOUTPUT PASS] Both output, target and special nodes are empty! add net output node");
output_node = graph->AddNode(net_output_desc); output_node = graph->AddNode(net_output_desc);
GE_CHK_STATUS_RET(AddCtrlEdgesBetweenLeafAndNetOutput(graph, output_node), GE_CHK_STATUS_RET(AddCtrlEdgesBetweenLeafAndNetOutput(graph, output_node),
"add ctrl edge between leaf and netoutput failed");
"[Add][CtrlEdges] between leaf and netoutput in graph:%s failed", graph->GetName().c_str());
if (!ge::AttrUtils::SetInt(output_node->GetOpDesc(), ATTR_NAME_TRUE_BRANCH_STREAM, 0)) { if (!ge::AttrUtils::SetInt(output_node->GetOpDesc(), ATTR_NAME_TRUE_BRANCH_STREAM, 0)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str()); output_node->GetName().c_str(), output_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_NAME_TRUE_BRANCH_STREAM failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGI("[NETOUTPUT PASS] Add net output node succeed"); GELOGI("[NETOUTPUT PASS] Add net output node succeed");
@@ -572,15 +593,18 @@ Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Add output node failed.");
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GE_CHK_STATUS_RET(AddCtrlEdgeForTargets(output_node), "add ctrl edge for targets failed");
GE_CHK_STATUS_RET(AddCtrlEdgeForTargets(output_node),
"[Add][CtrlEdge] for targets failed, output node:%s", output_node->GetName().c_str());
// Add true stream, netoutput is 0 // Add true stream, netoutput is 0
GE_IF_BOOL_EXEC(!ge::AttrUtils::SetInt(output_node->GetOpDesc(), ATTR_NAME_TRUE_BRANCH_STREAM, 0), GE_IF_BOOL_EXEC(!ge::AttrUtils::SetInt(output_node->GetOpDesc(), ATTR_NAME_TRUE_BRANCH_STREAM, 0),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str()); output_node->GetName().c_str(), output_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_NAME_TRUE_BRANCH_STREAM failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_TRUE_BRANCH_STREAM.c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
return INTERNAL_ERROR); return INTERNAL_ERROR);
return SUCCESS; return SUCCESS;
} }
@@ -591,15 +615,16 @@ Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Add output node failed.");
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (AddEdgesForNetOutput(graph, output_node, output_nodes_info) != SUCCESS) { if (AddEdgesForNetOutput(graph, output_node, output_nodes_info) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add edges for net output node failed.");
GELOGE(INTERNAL_ERROR, "[Add][Edges] for net output node in graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (AddCtrlEdgesBetweenLeafAndNetOutput(graph, output_node) != SUCCESS) { if (AddCtrlEdgesBetweenLeafAndNetOutput(graph, output_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add control edges between leaf and netoutput failed.");
GELOGE(INTERNAL_ERROR, "[Add][CtrlEdges] between leaf and netoutput in graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGI("Add NetOutput node success."); GELOGI("Add NetOutput node success.");
@@ -626,7 +651,7 @@ void NetOutputPass::AddInOutForNetOutputOp(const ComputeGraphPtr &graph, OpDescP
if (src_node == nullptr || src_node->GetOpDesc() == nullptr || net_output_desc == nullptr) { if (src_node == nullptr || src_node->GetOpDesc() == nullptr || net_output_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param output_nodes_info has RetvalInfo item, which src_node is invalid; " REPORT_INNER_ERROR("E19999", "Param output_nodes_info has RetvalInfo item, which src_node is invalid; "
"or Param net_output_desc is nullptr, check invalid"); "or Param net_output_desc is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "src node or net output desc is null.");
GELOGE(INTERNAL_ERROR, "[Check][Param] src node or net output desc is nullptr.");
return; return;
} }
ge::GeTensorDesc out_desc = src_node->GetOpDesc()->GetOutputDesc(src_index); ge::GeTensorDesc out_desc = src_node->GetOpDesc()->GetOutputDesc(src_index);
@@ -727,13 +752,15 @@ Status NetOutputPass::SetUserDefDTypeAndFormatFromAtcParams(const NodePtr &outpu
if (!userdef_dtypes.empty() && !ge::AttrUtils::SetListStr(op_desc, ATTR_ATC_USER_DEFINE_DATATYPE, userdef_dtypes)) { if (!userdef_dtypes.empty() && !ge::AttrUtils::SetListStr(op_desc, ATTR_ATC_USER_DEFINE_DATATYPE, userdef_dtypes)) {
REPORT_INNER_ERROR("E19999", "User define datatype is empty or Set Attr:%s to op:%s(%s) failed", REPORT_INNER_ERROR("E19999", "User define datatype is empty or Set Attr:%s to op:%s(%s) failed",
ATTR_ATC_USER_DEFINE_DATATYPE.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); ATTR_ATC_USER_DEFINE_DATATYPE.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Set user_define_dtype attr list for netoutput failed.");
GELOGE(INTERNAL_ERROR, "[Check][Param] User define datatype is empty or Set Attr:%s to op:%s(%s) failed",
ATTR_ATC_USER_DEFINE_DATATYPE.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (!userdef_formats.empty() && !ge::AttrUtils::SetListStr(op_desc, ATTR_ATC_USER_DEFINE_FORMAT, userdef_formats)) { if (!userdef_formats.empty() && !ge::AttrUtils::SetListStr(op_desc, ATTR_ATC_USER_DEFINE_FORMAT, userdef_formats)) {
REPORT_INNER_ERROR("E19999", "User define format is empty or Set Attr:%s to op:%s(%s) failed", REPORT_INNER_ERROR("E19999", "User define format is empty or Set Attr:%s to op:%s(%s) failed",
ATTR_ATC_USER_DEFINE_FORMAT.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); ATTR_ATC_USER_DEFINE_FORMAT.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Set user_define_format attr list for netoutput failed.");
GELOGE(INTERNAL_ERROR, "[Check][Param] User define format is empty or Set Attr:%s to op:%s(%s) failed",
ATTR_ATC_USER_DEFINE_FORMAT.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
return SUCCESS; return SUCCESS;


+ 46
- 31
ge/graph/passes/next_iteration_pass.cc View File

@@ -38,23 +38,23 @@ Status NextIterationPass::Run(ComputeGraphPtr graph) {
continue; continue;
} }
if (GroupEnterNode(node) != SUCCESS) { if (GroupEnterNode(node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Group enter_node %s failed.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Group][EnterNode] %s failed.", node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }


if (FindWhileGroups() != SUCCESS) { if (FindWhileGroups() != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Find while groups failed.");
GELOGE(INTERNAL_ERROR, "[Find][WhileGroups] in graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (!VerifyWhileGroup()) { if (!VerifyWhileGroup()) {
GELOGE(INTERNAL_ERROR, "Verify while groups failed.");
GELOGE(INTERNAL_ERROR, "[Verify][WhileGroup] in graph:%s failed.", graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


if (HandleWhileGroup(graph) != SUCCESS) { if (HandleWhileGroup(graph) != SUCCESS) {
GELOGE(FAILED, "Handle while groups failed.");
GELOGE(FAILED, "[Handle][WhileGroup] in graph:%s failed.", graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -74,7 +74,8 @@ Status NextIterationPass::GroupEnterNode(const NodePtr &enter_node) {
if (!ge::AttrUtils::GetStr(enter_desc, ENTER_ATTR_FRAME_NAME, frame_name) || frame_name.empty()) { if (!ge::AttrUtils::GetStr(enter_desc, ENTER_ATTR_FRAME_NAME, frame_name) || frame_name.empty()) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ENTER_ATTR_FRAME_NAME.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ENTER_ATTR_FRAME_NAME.c_str(),
enter_desc->GetName().c_str(), enter_desc->GetType().c_str()); enter_desc->GetName().c_str(), enter_desc->GetType().c_str());
GELOGE(FAILED, "Get attr ENTER_ATTR_FRAME_NAME failed, node: %s", enter_desc->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ENTER_ATTR_FRAME_NAME.c_str(),
enter_desc->GetName().c_str(), enter_desc->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -88,7 +89,7 @@ Status NextIterationPass::GroupEnterNode(const NodePtr &enter_node) {
LoopCondGroupPtr loop_group = MakeShared<LoopCondGroup>(); LoopCondGroupPtr loop_group = MakeShared<LoopCondGroup>();
if (loop_group == nullptr) { if (loop_group == nullptr) {
REPORT_CALL_ERROR("E19999", "New LoopCondGroup failed"); REPORT_CALL_ERROR("E19999", "New LoopCondGroup failed");
GELOGE(FAILED, "MakeShared for LoopCondGroup failed.");
GELOGE(FAILED, "[New][LoopCondGroup] failed.");
return FAILED; return FAILED;
} }
loop_group->enter_nodes.emplace_back(enter_node); loop_group->enter_nodes.emplace_back(enter_node);
@@ -110,21 +111,21 @@ Status NextIterationPass::FindWhileGroups() {
for (const auto &enter_node : loop_group_iter.second->enter_nodes) { for (const auto &enter_node : loop_group_iter.second->enter_nodes) {
for (const auto &out_node : enter_node->GetOutAllNodes()) { for (const auto &out_node : enter_node->GetOutAllNodes()) {
std::string type; std::string type;
GE_CHK_STATUS_RET(GetOriginalType(out_node, type), "Get node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(out_node, type), "[Get][OriginalType] failed.");
if ((type != MERGE) && (type != REFMERGE)) { if ((type != MERGE) && (type != REFMERGE)) {
continue; continue;
} }


NodePtr next_node = nullptr; NodePtr next_node = nullptr;
if (FindTargetNode(out_node, NEXTITERATION, true, next_node) != SUCCESS) { if (FindTargetNode(out_node, NEXTITERATION, true, next_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Get NextIteration node failed, frame_name: %s", frame_name.c_str());
GELOGE(INTERNAL_ERROR, "[Get][NextIterationNode] failed, frame_name:%s", frame_name.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
loop_group_iter.second->merge_next_pairs.emplace_back(std::make_pair(out_node, next_node)); loop_group_iter.second->merge_next_pairs.emplace_back(std::make_pair(out_node, next_node));


NodePtr switch_node = nullptr; NodePtr switch_node = nullptr;
if (FindTargetNode(out_node, SWITCH, false, switch_node) != SUCCESS) { if (FindTargetNode(out_node, SWITCH, false, switch_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Get Switch node failed, frame_name: %s.", frame_name.c_str());
GELOGE(INTERNAL_ERROR, "[Get][SwitchNode] failed, frame_name:%s.", frame_name.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (switch_node == nullptr) { if (switch_node == nullptr) {
@@ -133,12 +134,13 @@ Status NextIterationPass::FindWhileGroups() {
if (!AttrUtils::SetInt(switch_node->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_TYPE, kLoopType)) { if (!AttrUtils::SetInt(switch_node->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_TYPE, kLoopType)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_STREAM_SWITCH_TYPE.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_STREAM_SWITCH_TYPE.c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str()); switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set int failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_STREAM_SWITCH_TYPE.c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
NodePtr loop_cond = nullptr; NodePtr loop_cond = nullptr;
if (FindTargetNode(switch_node, LOOPCOND, true, loop_cond) != SUCCESS) { if (FindTargetNode(switch_node, LOOPCOND, true, loop_cond) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Get LoopCond node failed, frame_name: %s.", frame_name.c_str());
GELOGE(INTERNAL_ERROR, "[Get][LoopCondNode] failed, frame_name:%s.", frame_name.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
loop_group_iter.second->switch_nodes.emplace_back(switch_node); loop_group_iter.second->switch_nodes.emplace_back(switch_node);
@@ -146,7 +148,7 @@ Status NextIterationPass::FindWhileGroups() {
loop_group_iter.second->loop_cond = loop_cond; loop_group_iter.second->loop_cond = loop_cond;
} else if (loop_group_iter.second->loop_cond != loop_cond) { } else if (loop_group_iter.second->loop_cond != loop_cond) {
REPORT_INNER_ERROR("E19999", "Multi LoopCond nodes exist, frame_name:%s, check invalid", frame_name.c_str()); REPORT_INNER_ERROR("E19999", "Multi LoopCond nodes exist, frame_name:%s, check invalid", frame_name.c_str());
GELOGE(FAILED, "Multi LoopCond nodes exist, frame_name: %s.", frame_name.c_str());
GELOGE(FAILED, "[Check][Param] Multi LoopCond nodes exist, frame_name:%s.", frame_name.c_str());
return FAILED; return FAILED;
} }
} }
@@ -166,12 +168,13 @@ bool NextIterationPass::VerifyWhileGroup() {
const std::string &frame_name = loop_group_iter.first; const std::string &frame_name = loop_group_iter.first;
if (frame_name.empty()) { if (frame_name.empty()) {
REPORT_INNER_ERROR("E19999", "Verify while group failed, frame_name is empty"); REPORT_INNER_ERROR("E19999", "Verify while group failed, frame_name is empty");
GELOGE(INTERNAL_ERROR, "Verify while group failed, frame_name is empty.");
GELOGE(INTERNAL_ERROR, "[Check][Param] Verify while group failed, frame_name is empty.");
return false; return false;
} }
if (loop_group_iter.second->loop_cond == nullptr) { if (loop_group_iter.second->loop_cond == nullptr) {
REPORT_INNER_ERROR("E19999", "Verify while group failed, LoopCond is null, frame_name:%s.", frame_name.c_str()); REPORT_INNER_ERROR("E19999", "Verify while group failed, LoopCond is null, frame_name:%s.", frame_name.c_str());
GELOGE(INTERNAL_ERROR, "Verify while group failed, LoopCond is null, frame_name: %s.", frame_name.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Verify while group failed, LoopCond is null, frame_name:%s.",
frame_name.c_str());
return false; return false;
} }


@@ -179,7 +182,7 @@ bool NextIterationPass::VerifyWhileGroup() {
if ((pair_iter.first == nullptr) || (pair_iter.second == nullptr)) { if ((pair_iter.first == nullptr) || (pair_iter.second == nullptr)) {
REPORT_INNER_ERROR("E19999", "Verify while group failed, merge_node/next_node is null, frame_name:%s.", REPORT_INNER_ERROR("E19999", "Verify while group failed, merge_node/next_node is null, frame_name:%s.",
frame_name.c_str()); frame_name.c_str());
GELOGE(INTERNAL_ERROR, "Verify while group failed, merge_node/next_node is null, frame_name: %s.",
GELOGE(INTERNAL_ERROR, "[Check][Param] Verify while group failed, merge_node/next_node is null, frame_name:%s.",
frame_name.c_str()); frame_name.c_str());
return false; return false;
} }
@@ -211,7 +214,7 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
NodePtr enter_active = CreateActiveNode(graph, cond_name + "_Enter_" + STREAMACTIVE); NodePtr enter_active = CreateActiveNode(graph, cond_name + "_Enter_" + STREAMACTIVE);
NodePtr next_active = CreateActiveNode(graph, cond_name + "_Next_" + STREAMACTIVE); NodePtr next_active = CreateActiveNode(graph, cond_name + "_Next_" + STREAMACTIVE);
if ((enter_active == nullptr) || (next_active == nullptr)) { if ((enter_active == nullptr) || (next_active == nullptr)) {
GELOGE(INTERNAL_ERROR, "Create active node failed, cond_name: %s.", cond_name.c_str());
GELOGE(INTERNAL_ERROR, "[Create][ActiveNode] failed, cond_name:%s.", cond_name.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -221,8 +224,9 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
enter_node->GetName().c_str(), enter_node->GetType().c_str(), enter_node->GetName().c_str(), enter_node->GetType().c_str(),
enter_active->GetName().c_str(), enter_active->GetType().c_str()); enter_active->GetName().c_str(), enter_active->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add control edge from %s to %s failed.", enter_node->GetName().c_str(),
enter_active->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
enter_node->GetName().c_str(), enter_node->GetType().c_str(),
enter_active->GetName().c_str(), enter_active->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
MarkForceUnknownShape(enter_node, loop_group.is_unknown_shape, group_index); MarkForceUnknownShape(enter_node, loop_group.is_unknown_shape, group_index);
@@ -236,7 +240,9 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
enter_active->GetName().c_str(), enter_active->GetType().c_str(), enter_active->GetName().c_str(), enter_active->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str()); merge_node->GetName().c_str(), merge_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add control edge failed.");
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
enter_active->GetName().c_str(), enter_active->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -245,13 +251,16 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
next_node->GetName().c_str(), next_node->GetType().c_str(), next_node->GetName().c_str(), next_node->GetType().c_str(),
next_active->GetName().c_str(), next_active->GetType().c_str()); next_active->GetName().c_str(), next_active->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add control edge failed.");
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
next_node->GetName().c_str(), next_node->GetType().c_str(),
next_active->GetName().c_str(), next_active->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


// break link between NextIteration and Merge // break link between NextIteration and Merge
if (BreakNextIteration(next_node, merge_node) != SUCCESS) { if (BreakNextIteration(next_node, merge_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Break NextIteration failed");
GELOGE(INTERNAL_ERROR, "[Break][NextIteration] failed, next_node:%s, merge_node:%s",
next_node->GetName().c_str(), merge_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -261,7 +270,7 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {


if ((SetActiveLabelList(enter_active, {cond_name}) != SUCCESS) || if ((SetActiveLabelList(enter_active, {cond_name}) != SUCCESS) ||
(SetActiveLabelList(next_active, {cond_name}) != SUCCESS)) { (SetActiveLabelList(next_active, {cond_name}) != SUCCESS)) {
GELOGE(INTERNAL_ERROR, "Set attr ACTIVE_LABEL_LIST failed.");
GELOGE(INTERNAL_ERROR, "[Set][ActiveLabelList] failed, cond_name:%s.", cond_name.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -307,6 +316,7 @@ NodePtr NextIterationPass::CreateActiveNode(ComputeGraphPtr &graph, const std::s
OpDescPtr op_desc = MakeShared<OpDesc>(name, STREAMACTIVE); OpDescPtr op_desc = MakeShared<OpDesc>(name, STREAMACTIVE);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }


@@ -315,14 +325,16 @@ NodePtr NextIterationPass::CreateActiveNode(ComputeGraphPtr &graph, const std::s
if (active_node == nullptr) { if (active_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Create node[%s] failed.", name.c_str());
GELOGE(INTERNAL_ERROR, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr; return nullptr;
} }


if (SetSwitchBranchNodeLabel(active_node, name) != SUCCESS) { if (SetSwitchBranchNodeLabel(active_node, name) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set switch branch node label:%s to node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set switch branch node label:%s to node:%s(%s) failed",
name.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); name.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Set attr SWITCH_BRANCH_NODE_LABEL for node: %s failed.", active_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][SwitchBranchNodeLabel] %s to node:%s(%s) failed",
name.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -337,7 +349,7 @@ NodePtr NextIterationPass::CreateActiveNode(ComputeGraphPtr &graph, const std::s
/// ///
Status NextIterationPass::BreakNextIteration(const NodePtr &next_node, NodePtr &merge_node) { Status NextIterationPass::BreakNextIteration(const NodePtr &next_node, NodePtr &merge_node) {
if ((merge_node == nullptr) || (next_node == nullptr)) { if ((merge_node == nullptr) || (next_node == nullptr)) {
GELOGE(PARAM_INVALID, "merge node or next node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] merge node or next node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
for (const auto &in_anchor : merge_node->GetAllInDataAnchors()) { for (const auto &in_anchor : merge_node->GetAllInDataAnchors()) {
@@ -350,14 +362,16 @@ Status NextIterationPass::BreakNextIteration(const NodePtr &next_node, NodePtr &
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
out_anchor->GetIdx(), out_anchor->GetIdx(),
merge_node->GetName().c_str(), merge_node->GetType().c_str(), in_anchor->GetIdx()); merge_node->GetName().c_str(), merge_node->GetType().c_str(), in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Remove data edge failed, %s->%s.", next_node->GetName().c_str(),
merge_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[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(), merge_node->GetName().c_str(), merge_node->GetType().c_str(), in_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (SetNextIteration(merge_node, next_node) != SUCCESS) { if (SetNextIteration(merge_node, next_node) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set attr NEXT_ITERATION value:%s to node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set attr NEXT_ITERATION value:%s to node:%s(%s) failed",
next_node->GetName().c_str(), merge_node->GetName().c_str(), merge_node->GetType().c_str()); next_node->GetName().c_str(), merge_node->GetName().c_str(), merge_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Set attr NEXT_ITERATION for node %s failed.", merge_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] NEXT_ITERATION value:%s to node:%s(%s) failed",
next_node->GetName().c_str(), merge_node->GetName().c_str(), merge_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -376,7 +390,7 @@ Status NextIterationPass::FindTargetNode(const NodePtr &node, const std::string
NodePtr &target_node) { NodePtr &target_node) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
std::vector<NodePtr> nodes; std::vector<NodePtr> nodes;
@@ -392,7 +406,7 @@ Status NextIterationPass::FindTargetNode(const NodePtr &node, const std::string


for (const auto &tmp_node : nodes) { for (const auto &tmp_node : nodes) {
std::string type; std::string type;
GE_CHK_STATUS_RET(GetOriginalType(tmp_node, type), "Get node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(tmp_node, type), "[Get][NodeType] failed.");
if ((target_type == LOOPCOND) && (type == target_type)) { if ((target_type == LOOPCOND) && (type == target_type)) {
target_node = tmp_node; target_node = tmp_node;
break; break;
@@ -405,7 +419,8 @@ Status NextIterationPass::FindTargetNode(const NodePtr &node, const std::string
if ((target_type != SWITCH) && (target_node == nullptr)) { if ((target_type != SWITCH) && (target_node == nullptr)) {
REPORT_INNER_ERROR("E19999", "Find target_type:%s node around node:%s(%s) failed", REPORT_INNER_ERROR("E19999", "Find target_type:%s node around node:%s(%s) failed",
target_type.c_str(), node->GetName().c_str(), node->GetType().c_str()); target_type.c_str(), node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Find node %s failed.", target_type.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Find target_type:%s node around node:%s(%s) failed",
target_type.c_str(), node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
return SUCCESS; return SUCCESS;


+ 5
- 4
ge/graph/passes/no_use_reshape_remove_pass.cc View File

@@ -38,7 +38,7 @@ Status NoUseReshapeRemovePass::Run(ge::NodePtr &node) {
OpDescPtr op_desc_ptr = node->GetOpDesc(); OpDescPtr op_desc_ptr = node->GetOpDesc();
if (op_desc_ptr == nullptr) { if (op_desc_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid");
GELOGE(PARAM_INVALID, "NoUseReshapeRemovePass enter. OpDesc is null.");
GELOGE(PARAM_INVALID, "[Check][Param] NoUseReshapeRemovePass enter. OpDesc is null.");
return PARAM_INVALID; return PARAM_INVALID;
} }
if (op_desc_ptr->GetType() != RESHAPE) { if (op_desc_ptr->GetType() != RESHAPE) {
@@ -51,7 +51,7 @@ Status NoUseReshapeRemovePass::Run(ge::NodePtr &node) {
if (op_desc_ptr->GetAllInputsDesc().empty() || op_desc_ptr->GetAllOutputsDesc().empty()) { if (op_desc_ptr->GetAllInputsDesc().empty() || op_desc_ptr->GetAllOutputsDesc().empty()) {
REPORT_INNER_ERROR("E19999", "Input or Output desc num is zero in node:%s(%s), check invalid", REPORT_INNER_ERROR("E19999", "Input or Output desc num is zero in node:%s(%s), check invalid",
op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str()); op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Input or output num is zero. node name:%s, input size:%zu, output size:%zu",
GELOGE(INTERNAL_ERROR, "[Check][Param] Input or output num is zero. node name:%s, input size:%zu, output size:%zu",
op_desc_ptr->GetName().c_str(), op_desc_ptr->GetAllInputsDesc().size(), op_desc_ptr->GetName().c_str(), op_desc_ptr->GetAllInputsDesc().size(),
op_desc_ptr->GetAllOutputsDesc().size()); op_desc_ptr->GetAllOutputsDesc().size());
return INTERNAL_ERROR; return INTERNAL_ERROR;
@@ -112,14 +112,15 @@ Status NoUseReshapeRemovePass::TryRemoveConstShapeInput(ge::NodePtr &reshape_nod
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Unlink op:%s(%s) data input:%u with control edge copy failed", REPORT_CALL_ERROR("E19999", "Unlink op:%s(%s) data input:%u with control edge copy failed",
reshape_node->GetName().c_str(), reshape_node->GetType().c_str(), kReshapeShapeIndex); reshape_node->GetName().c_str(), reshape_node->GetType().c_str(), kReshapeShapeIndex);
GELOGE(ret, "Unlink node %s with control copy failed.", shape_input->GetName().c_str());
GELOGE(ret, "[Unlink][Node] %s(%s) data input:%u with control edge copy failed",
reshape_node->GetName().c_str(), reshape_node->GetType().c_str(), kReshapeShapeIndex);
return ret; return ret;
} }


// remove const without any data_output // remove const without any data_output
if (shape_input->GetOutDataNodesSize() == 0) { if (shape_input->GetOutDataNodesSize() == 0) {
auto ret = IsolateAndDeleteNode(shape_input, {}); auto ret = IsolateAndDeleteNode(shape_input, {});
GE_CHK_GRAPH_STATUS_RET(ret, "Fail to remove node %s", shape_input->GetName().c_str());
GE_CHK_GRAPH_STATUS_RET(ret, "[Remove][Node] %s failed", shape_input->GetName().c_str());
GELOGI("Remove useless shape input const %s.", shape_input->GetName().c_str()); GELOGI("Remove useless shape input const %s.", shape_input->GetName().c_str());
} }
return SUCCESS; return SUCCESS;


+ 7
- 5
ge/graph/passes/parallel_concat_start_op_pass.cc View File

@@ -46,15 +46,15 @@ Status ParallelConcatStartOpPass::Run(NodePtr &node) {
REPORT_INNER_ERROR("E19999", "Output tensor num:%zu of node:%s(%s) != %zu, check invalid", REPORT_INNER_ERROR("E19999", "Output tensor num:%zu of node:%s(%s) != %zu, check invalid",
node_op_desc->GetOutputsSize(), node_op_desc->GetName().c_str(), node_op_desc->GetOutputsSize(), node_op_desc->GetName().c_str(),
node_op_desc->GetType().c_str(), kParallelConcatStartOutputSize); node_op_desc->GetType().c_str(), kParallelConcatStartOutputSize);
GELOGE(PARAM_INVALID, "Node[%s] output size is unexpected, the value is %zu.", node_name.c_str(),
node_op_desc->GetOutputsSize());
GELOGE(PARAM_INVALID, "[Check][Param] Node[%s] output size is unexpected, the value is %zu, expected valude:%zu.",
node_name.c_str(), node_op_desc->GetOutputsSize(), kParallelConcatStartOutputSize);
return PARAM_INVALID; return PARAM_INVALID;
} }
auto output_tensor_desc = node_op_desc->GetOutputDesc(kParallelConcatStartOutputDataIndex); auto output_tensor_desc = node_op_desc->GetOutputDesc(kParallelConcatStartOutputDataIndex);
GeTensorPtr output_ptr = MakeShared<GeTensor>(output_tensor_desc); GeTensorPtr output_ptr = MakeShared<GeTensor>(output_tensor_desc);
if (output_ptr == nullptr) { if (output_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed"); REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(MEMALLOC_FAILED, "Malloc GeTensor failed, node name %s.", node_name.c_str());
GELOGE(MEMALLOC_FAILED, "[New][GeTensor] failed");
return FAILED; return FAILED;
} }


@@ -62,7 +62,8 @@ Status ParallelConcatStartOpPass::Run(NodePtr &node) {
if (!ge::AttrUtils::GetDataType(node_op_desc, kAttrDtype, attr_dtype)) { if (!ge::AttrUtils::GetDataType(node_op_desc, kAttrDtype, attr_dtype)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", kAttrDtype, REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", kAttrDtype,
node_op_desc->GetName().c_str(), node_op_desc->GetType().c_str()); node_op_desc->GetName().c_str(), node_op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "Node:%s failed to get attribute dtype.", node_name.c_str());
GELOGE(PARAM_INVALID, "[Get][Attr] %s from op:%s(%s) failed", kAttrDtype,
node_op_desc->GetName().c_str(), node_op_desc->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
output_ptr->MutableTensorDesc().SetDataType(attr_dtype); output_ptr->MutableTensorDesc().SetDataType(attr_dtype);
@@ -71,7 +72,8 @@ Status ParallelConcatStartOpPass::Run(NodePtr &node) {
if (!ge::AttrUtils::GetListInt(node_op_desc, kAttrShape, attr_shape_list)) { if (!ge::AttrUtils::GetListInt(node_op_desc, kAttrShape, attr_shape_list)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", kAttrShape, REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", kAttrShape,
node_op_desc->GetName().c_str(), node_op_desc->GetType().c_str()); node_op_desc->GetName().c_str(), node_op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "Node:%s failed to get attribute shape.", node_name.c_str());
GELOGE(PARAM_INVALID, "[Get][Attr] %s from op:%s(%s) failed", kAttrShape,
node_op_desc->GetName().c_str(), node_op_desc->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
output_ptr->MutableTensorDesc().SetShape(GeShape(attr_shape_list)); output_ptr->MutableTensorDesc().SetShape(GeShape(attr_shape_list));


+ 3
- 3
ge/graph/passes/pass_manager.cc View File

@@ -50,12 +50,12 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vector<std::pair<std::stri
if (status == SUCCESS) { if (status == SUCCESS) {
not_changed = false; not_changed = false;
} else if (status != NOT_CHANGED) { } else if (status != NOT_CHANGED) {
GELOGE(status, "Pass Run failed on graph %s", graph->GetName().c_str());
GELOGE(status, "[Pass][Run] failed on graph %s", graph->GetName().c_str());
return status; return status;
} }
for (const auto &subgraph :graph->GetAllSubgraphs()) { for (const auto &subgraph :graph->GetAllSubgraphs()) {
GE_CHECK_NOTNULL(subgraph); GE_CHECK_NOTNULL(subgraph);
GE_CHK_STATUS_RET(pass->ClearStatus(), "pass clear status failed for subgraph %s", subgraph->GetName().c_str());
GE_CHK_STATUS_RET(pass->ClearStatus(), "[Pass][ClearStatus] failed for subgraph %s", subgraph->GetName().c_str());
string subgraph_pass_name = pass_name + "::" + graph->GetName(); string subgraph_pass_name = pass_name + "::" + graph->GetName();
GE_TIMESTAMP_START(PassRunSubgraph); GE_TIMESTAMP_START(PassRunSubgraph);
status = pass->Run(subgraph); status = pass->Run(subgraph);
@@ -63,7 +63,7 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vector<std::pair<std::stri
if (status == SUCCESS) { if (status == SUCCESS) {
not_changed = false; not_changed = false;
} else if (status != NOT_CHANGED) { } else if (status != NOT_CHANGED) {
GELOGE(status, "Pass Run failed on subgraph %s", subgraph->GetName().c_str());
GELOGE(status, "[Pass][Run] failed on subgraph %s", subgraph->GetName().c_str());
return status; return status;
} }
} }


+ 51
- 29
ge/graph/passes/pass_utils.cc View File

@@ -48,13 +48,13 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, std:
unique_ptr<int32_t[]> buf(new (std::nothrow) int32_t[dim_size]()); unique_ptr<int32_t[]> buf(new (std::nothrow) int32_t[dim_size]());
if (buf == nullptr) { if (buf == nullptr) {
REPORT_CALL_ERROR("E19999", "New buffer failed, size:%u", dim_size); REPORT_CALL_ERROR("E19999", "New buffer failed, size:%u", dim_size);
GELOGE(MEMALLOC_FAILED, "new failed");
GELOGE(MEMALLOC_FAILED, "[New][Buffer] failed, size:%u", dim_size);
return MEMALLOC_FAILED; return MEMALLOC_FAILED;
} }
for (uint32_t i = 0; i < dim_size; i++) { for (uint32_t i = 0; i < dim_size; i++) {
if (data[i] >= INT_MAX) { if (data[i] >= INT_MAX) {
REPORT_CALL_ERROR("E19999", "Param data:%s will overflow after multi", formats::JoinToString(data).c_str()); REPORT_CALL_ERROR("E19999", "Param data:%s will overflow after multi", formats::JoinToString(data).c_str());
GELOGE(PARAM_INVALID, "int32 overflow, data[%u]:%ld", i, data[i]);
GELOGE(PARAM_INVALID, "[Check][Param] int32 overflow, data[%u]:%ld", i, data[i]);
return PARAM_INVALID; return PARAM_INVALID;
} }
buf[i] = static_cast<int32_t>(data[i]); buf[i] = static_cast<int32_t>(data[i]);
@@ -64,7 +64,7 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, std:
unique_ptr<int64_t[]> buf(new (std::nothrow) int64_t[dim_size]()); unique_ptr<int64_t[]> buf(new (std::nothrow) int64_t[dim_size]());
if (buf == nullptr) { if (buf == nullptr) {
REPORT_CALL_ERROR("E19999", "New buffer failed, size:%u", dim_size); REPORT_CALL_ERROR("E19999", "New buffer failed, size:%u", dim_size);
GELOGE(MEMALLOC_FAILED, "new failed");
GELOGE(MEMALLOC_FAILED, "[New][Buffer] failed, size:%u", dim_size);
return MEMALLOC_FAILED; return MEMALLOC_FAILED;
} }
for (uint32_t i = 0; i < dim_size; i++) { for (uint32_t i = 0; i < dim_size; i++) {
@@ -74,13 +74,13 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, std:
} else { } else {
REPORT_CALL_ERROR("E19999", "Only support DT_INT32 and DT_INT64. Input data_type:%s not support", REPORT_CALL_ERROR("E19999", "Only support DT_INT32 and DT_INT64. Input data_type:%s not support",
formats::JoinToString(data).c_str()); formats::JoinToString(data).c_str());
GELOGE(PARAM_INVALID, "Only support DT_INT32 and DT_INT64. data_type:%s",
GELOGE(PARAM_INVALID, "[Check][Param] Only support DT_INT32 and DT_INT64. data_type:%s not support",
TypeUtils::DataTypeToSerialString(data_type).c_str()); TypeUtils::DataTypeToSerialString(data_type).c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }


if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "GetShapeTensor failed.");
GELOGE(ret, "[Get][ShapeTensor] failed, ret:%u.", ret);
return ret; return ret;
} }


@@ -99,7 +99,7 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, T *b
output_tensor_desc, reinterpret_cast<uint8_t *>(buf), sizeof(T) * len); output_tensor_desc, reinterpret_cast<uint8_t *>(buf), sizeof(T) * len);
if (output_tensor_ptr == nullptr) { if (output_tensor_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed"); REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(MEMALLOC_FAILED, "Make shared failed");
GELOGE(MEMALLOC_FAILED, "[New][GeTensor] failed");
return MEMALLOC_FAILED; return MEMALLOC_FAILED;
} }


@@ -110,7 +110,7 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, T *b
bool PassUtils::IsConstant(const ConstNodePtr &node) { bool PassUtils::IsConstant(const ConstNodePtr &node) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "node is null");
GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr");
return false; return false;
} }


@@ -122,7 +122,7 @@ bool PassUtils::IsConstant(const ConstNodePtr &node) {
Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, const NodePtr &src_node) { Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, const NodePtr &src_node) {
GE_IF_BOOL_EXEC(src_node == nullptr, GE_IF_BOOL_EXEC(src_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param src_node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param src_node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "src_node is null"); return PARAM_INVALID);
GELOGE(PARAM_INVALID, "[Check][Param] src_node is nullptr"); return PARAM_INVALID);
if (!IsConstant(src_node)) { if (!IsConstant(src_node)) {
return SUCCESS; return SUCCESS;
} }
@@ -131,6 +131,8 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons
if (weights.empty()) { if (weights.empty()) {
REPORT_INNER_ERROR("E19999", "Weight of node:%s(%s) is empty, check invalid", REPORT_INNER_ERROR("E19999", "Weight of node:%s(%s) is empty, check invalid",
src_node->GetName().c_str(), src_node->GetType().c_str()); src_node->GetName().c_str(), src_node->GetType().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Weight of node:%s(%s) is empty",
src_node->GetName().c_str(), src_node->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }


@@ -139,7 +141,8 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons
if ((src_in_ctrl == nullptr) || (out_data_anchor == nullptr)) { if ((src_in_ctrl == nullptr) || (out_data_anchor == nullptr)) {
REPORT_INNER_ERROR("E19999", "Param out_data_anchor or in control anchor in Param src_node:%s(%s) is nullptr, " REPORT_INNER_ERROR("E19999", "Param out_data_anchor or in control anchor in Param src_node:%s(%s) is nullptr, "
"check invalid", src_node->GetName().c_str(), src_node->GetType().c_str()); "check invalid", src_node->GetName().c_str(), src_node->GetType().c_str());
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] Param out_data_anchor or in control anchor in Param src_node:%s(%s) is nullptr",
src_node->GetName().c_str(), src_node->GetType().c_str());
return FAILED; return FAILED;
} }
auto src_out_control_anchors = src_in_ctrl->GetPeerAnchors(); auto src_out_control_anchors = src_in_ctrl->GetPeerAnchors();
@@ -157,7 +160,10 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons
dst_op_desc->SetIsInputConst(is_input_const); dst_op_desc->SetIsInputConst(is_input_const);
} }


GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_data_anchor, dst_in_data), "remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_data_anchor, dst_in_data),
"[Remove][Edge] between %s and %s failed",
out_data_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_data->GetOwnerNode()->GetName().c_str());
graphStatus ret = OpDescUtils::AddConstOpToAnchor(dst_in_data, weight); graphStatus ret = OpDescUtils::AddConstOpToAnchor(dst_in_data, weight);
if (ret != SUCCESS) { if (ret != SUCCESS) {
return ret; return ret;
@@ -170,7 +176,9 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons
// restore control inputs to dynamically added constant ops, if any // restore control inputs to dynamically added constant ops, if any
for (const auto &src_out_control_anchor : src_out_control_anchors) { for (const auto &src_out_control_anchor : src_out_control_anchors) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(src_out_control_anchor, dynamic_const_node->GetInControlAnchor()), GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(src_out_control_anchor, dynamic_const_node->GetInControlAnchor()),
"add edge failed");
"[Add][ControlEdge] between %s and %s failed",
src_out_control_anchor->GetOwnerNode()->GetName().c_str(),
dynamic_const_node->GetName().c_str());
} }
} }


@@ -180,7 +188,10 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons
/// Op1 - - - > Op2 /// Op1 - - - > Op2
for (const auto &dst_in_ctrl : out_data_anchor->GetPeerInControlAnchors()) { for (const auto &dst_in_ctrl : out_data_anchor->GetPeerInControlAnchors()) {
for (const auto &src_out_control_anchor : src_out_control_anchors) { for (const auto &src_out_control_anchor : src_out_control_anchors) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(src_out_control_anchor, dst_in_ctrl), "add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(src_out_control_anchor, dst_in_ctrl),
"[Add][ControlEdge] between %s and %s failed",
src_out_control_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_ctrl->GetOwnerNode()->GetName().c_str());
} }
} }


@@ -191,7 +202,7 @@ Status PassUtils::RemoveBranch(const NodePtr &node, std::vector<NodePtr> &delete
std::vector<NodePtr> &end_nodes) { std::vector<NodePtr> &end_nodes) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
return FAILED; return FAILED;
} }
GELOGI("Remove branch starting from node %s", node->GetName().c_str()); GELOGI("Remove branch starting from node %s", node->GetName().c_str());
@@ -213,25 +224,30 @@ Status PassUtils::RemoveBranch(const NodePtr &node, std::vector<NodePtr> &delete
} }
auto dst_node = dst_in_anchor->GetOwnerNode(); auto dst_node = dst_in_anchor->GetOwnerNode();
std::string node_type; std::string node_type;
GE_CHK_STATUS_RET(GetOriginalType(dst_node, node_type), "get original type failed");
GE_CHK_STATUS_RET(GetOriginalType(dst_node, node_type),
"[Get][OriginalType] of node:%s failed", dst_node->GetName().c_str());
if (node_type == NETOUTPUT) { if (node_type == NETOUTPUT) {
if (dst_in_anchor->IsTypeOf<InDataAnchor>()) { if (dst_in_anchor->IsTypeOf<InDataAnchor>()) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) nactive branch connected to NetOutput with data anchor, " REPORT_INNER_ERROR("E19999", "Node:%s(%s) nactive branch connected to NetOutput with data anchor, "
"check invalid", node->GetName().c_str(), node->GetType().c_str()); "check invalid", node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"[%s] Inactive branch connected to "
"NetOutput with data anchor.",
GELOGE(INTERNAL_ERROR, "[Check][Param] [%s] Inactive branch connected to NetOutput with data anchor.",
node->GetName().c_str()); node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} else { } else {
// safe to unlink control edges // safe to unlink control edges
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(src_out_anchor, dst_in_anchor), "remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(src_out_anchor, dst_in_anchor),
"[Remove][Edge] between %s and %s failed",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_anchor->GetOwnerNode()->GetName().c_str());
end_nodes.push_back(dst_node); end_nodes.push_back(dst_node);
} }
} else if (node_type == MERGE) { } else if (node_type == MERGE) {
/// Unlink connection between the inactive branch and Merge/NetOutput. /// Unlink connection between the inactive branch and Merge/NetOutput.
/// The removal of inactive nodes will be handled in PrunePass /// The removal of inactive nodes will be handled in PrunePass
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(src_out_anchor, dst_in_anchor), "remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(src_out_anchor, dst_in_anchor),
"[Remove][Edge] between %s and %s failed",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_anchor->GetOwnerNode()->GetName().c_str());
end_nodes.push_back(dst_node); end_nodes.push_back(dst_node);
GELOGD("Reach the end merge node %s, the branch removing stop", dst_node->GetName().c_str()); GELOGD("Reach the end merge node %s, the branch removing stop", dst_node->GetName().c_str());
} else { } else {
@@ -291,7 +307,7 @@ int PassUtils::GetUniqueInDataAnchorIndex(const NodePtr &node_ptr) {
const int invalid_index = -1; const int invalid_index = -1;
if (node_ptr == nullptr) { if (node_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node_ptr is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node_ptr is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "GetUniqueInDataAnchorIndex: node is null");
GELOGE(INTERNAL_ERROR, "[Check][Param] node is nullptr");
return invalid_index; return invalid_index;
} }
for (const auto &in_anchor : node_ptr->GetAllInDataAnchors()) { for (const auto &in_anchor : node_ptr->GetAllInDataAnchors()) {
@@ -303,17 +319,15 @@ int PassUtils::GetUniqueInDataAnchorIndex(const NodePtr &node_ptr) {


REPORT_INNER_ERROR("E19999", "Failed to find in data anchor of node:%s(%s) with a valid peer out node", REPORT_INNER_ERROR("E19999", "Failed to find in data anchor of node:%s(%s) with a valid peer out node",
node_ptr->GetName().c_str(), node_ptr->GetType().c_str()); node_ptr->GetName().c_str(), node_ptr->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"GetUniqueInDataAnchorIndex: [%s] failed to find "
"in data anchor with a valid peer out node",
node_ptr->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to find in data anchor of node:%s(%s) with a valid peer out node",
node_ptr->GetName().c_str(), node_ptr->GetType().c_str());
return invalid_index; return invalid_index;
} }


Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) { Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) {
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
auto in_data_anchor = node->GetInDataAnchor(index); auto in_data_anchor = node->GetInDataAnchor(index);
@@ -325,7 +339,8 @@ Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) {
if (out_data_anchor == nullptr) { if (out_data_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%d in data anchor of node:%s(%s), its peer anchor is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Index:%d in data anchor of node:%s(%s), its peer anchor is nullptr, check invalid",
index, node->GetName().c_str(), node->GetType().c_str()); index, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[%s] peer out_data_anchor is null with index [%d].", node->GetName().c_str(), index);
GELOGE(FAILED, "[Get][PeerOutAnchor] failed, Index:%d in data anchor of node:%s(%s), its peer anchor is nullptr.",
index, node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
// Remove link between father_node and node // Remove link between father_node and node
@@ -337,6 +352,9 @@ Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) {
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed", 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(), father_node->GetName().c_str(), father_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Copy][InCtrlEdges] 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;
@@ -346,7 +364,7 @@ Status PassUtils::RemoveInactiveBranchToMerge(const OutDataAnchorPtr &inactive_o
std::vector<NodePtr> &delete_nodes, std::vector<NodePtr> &end_nodes) { std::vector<NodePtr> &delete_nodes, std::vector<NodePtr> &end_nodes) {
if (inactive_output_anchor == nullptr) { if (inactive_output_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param inactive_output_anchor is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param inactive_output_anchor is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter inactive_output_anchor is nullptr.");
return FAILED; return FAILED;
} }
for (const auto &dst_anchor : inactive_output_anchor->GetPeerAnchors()) { for (const auto &dst_anchor : inactive_output_anchor->GetPeerAnchors()) {
@@ -356,10 +374,14 @@ Status PassUtils::RemoveInactiveBranchToMerge(const OutDataAnchorPtr &inactive_o
auto dst_node = dst_anchor->GetOwnerNode(); auto dst_node = dst_anchor->GetOwnerNode();
if (dst_node != nullptr) { if (dst_node != nullptr) {
std::string dst_node_type; std::string dst_node_type;
GE_CHK_STATUS_RET(GetOriginalType(dst_node, dst_node_type), "get original type failed");
GE_CHK_STATUS_RET(GetOriginalType(dst_node, dst_node_type),
"[Get][OriginalType] of node:%s failed", dst_node->GetName().c_str());
if (dst_node_type == MERGE) { if (dst_node_type == MERGE) {
GELOGD("[%s] Switch connected directly to Merge", inactive_output_anchor->GetOwnerNode()->GetName().c_str()); GELOGD("[%s] Switch connected directly to Merge", inactive_output_anchor->GetOwnerNode()->GetName().c_str());
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(inactive_output_anchor, dst_anchor), "remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(inactive_output_anchor, dst_anchor),
"[Remove][Edge] between %s and %s failed",
inactive_output_anchor->GetOwnerNode()->GetName().c_str(),
dst_node->GetName().c_str());
continue; continue;
} }




+ 8
- 5
ge/graph/passes/permute_pass.cc View File

@@ -68,8 +68,10 @@ Status PermutePass::Run(ComputeGraphPtr graph) {
int64_t permute_src_format = 0; int64_t permute_src_format = 0;
GE_IF_BOOL_EXEC(!AttrUtils::GetInt(op_desc_ptr, "permute_src_format", permute_src_format), continue); GE_IF_BOOL_EXEC(!AttrUtils::GetInt(op_desc_ptr, "permute_src_format", permute_src_format), continue);
// Get dim_index_ // Get dim_index_
std::vector<int64_t> index_list; GE_CHK_BOOL_RET_STATUS(
AttrUtils::GetListInt(op_desc_ptr, PERMUTE_ATTR_ORDER, index_list), INTERNAL_ERROR, "get index list failed");
std::vector<int64_t> index_list;
GE_CHK_BOOL_RET_STATUS(AttrUtils::GetListInt(op_desc_ptr, PERMUTE_ATTR_ORDER, index_list), INTERNAL_ERROR,
"[Get][Attr] %s from op:%s(%s) failed", PERMUTE_ATTR_ORDER.c_str(),
op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str());


size_t index_size = index_list.size(); GE_IF_BOOL_EXEC(index_size == 0, continue); size_t index_size = index_list.size(); GE_IF_BOOL_EXEC(index_size == 0, continue);


@@ -110,12 +112,13 @@ Status PermutePass::Run(ComputeGraphPtr graph) {
if (!AttrUtils::SetBool(op_desc_ptr, ATTR_NAME_PRED_PERMUTE_DELETED, true)) { if (!AttrUtils::SetBool(op_desc_ptr, ATTR_NAME_PRED_PERMUTE_DELETED, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PRED_PERMUTE_DELETED.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PRED_PERMUTE_DELETED.c_str(),
op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str()); op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ATTR_NAME_PRED_PERMUTE_DELETED failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_PRED_PERMUTE_DELETED.c_str(),
op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
GE_RETURN_WITH_LOG_IF_ERROR(graph->RemoveNode(node), "[%s]:remove permute node failed",
node->GetOpDesc()->GetName().c_str());
GE_RETURN_WITH_LOG_IF_ERROR(graph->RemoveNode(node), "[Remove][Node] [%s] from graph:%s failed",
node->GetOpDesc()->GetName().c_str(), graph->GetName().c_str());
}); });
return SUCCESS; return SUCCESS;
} }


+ 1
- 1
ge/graph/passes/placeholder_with_default_pass.cc View File

@@ -26,7 +26,7 @@ Status PlaceholderWithDefaultPass::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) {
GELOGE(status_ret, "Placeholder with default pass get original type fail.");
GELOGE(status_ret, "[Get][OriginalType] of node:%s failed.", node->GetName().c_str());
return status_ret; return status_ret;
} }
if (type == PLACEHOLDERWITHDEFAULT) { if (type == PLACEHOLDERWITHDEFAULT) {


+ 1
- 1
ge/graph/passes/prevent_gradient_pass.cc View File

@@ -27,7 +27,7 @@ Status PreventGradientPass::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) {
GELOGE(status_ret, "PreventGradientPass get original type fail.");
GELOGE(status_ret, "[Get][OriginalType] of node:%s failed.", node->GetName().c_str());
return status_ret; return status_ret;
} }
if (type == PREVENTGRADIENT) { if (type == PREVENTGRADIENT) {


+ 2
- 2
ge/graph/passes/print_op_pass.cc View File

@@ -22,13 +22,13 @@ Status PrintOpPass::Run(ge::NodePtr &node) {
GELOGD("PrintOpPass running"); GELOGD("PrintOpPass running");
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [node] must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }
string type; string type;
Status ret = GetOriginalType(node, type); Status ret = GetOriginalType(node, type);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "PrintOpPass: Get node type fail");
GELOGE(ret, "[Get][OriginalType] of node:%s failed", node->GetName().c_str());
return ret; return ret;
} }
if (type == "Print") { if (type == "Print") {


+ 2
- 2
ge/graph/passes/prune_pass.cc View File

@@ -30,7 +30,7 @@ Status PrunePass::Run(ge::ComputeGraphPtr graph) {
GELOGD("PrunePass Start, graph is [%s]", graph->GetName().c_str()); GELOGD("PrunePass Start, graph is [%s]", graph->GetName().c_str());
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(GE_GRAPH_ISNULL, "input compute graph is NULL.");
GELOGE(GE_GRAPH_ISNULL, "[Check][Param] input compute graph is NULL.");
return GE_GRAPH_ISNULL; return GE_GRAPH_ISNULL;
} }
std::vector<NodePtr> out_nodes; std::vector<NodePtr> out_nodes;
@@ -74,7 +74,7 @@ Status PrunePass::Run(ge::ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
node_ptr->GetName().c_str(), node_ptr->GetType().c_str(), node_ptr->GetName().c_str(), node_ptr->GetType().c_str(),
out_nodes[0]->GetName().c_str(), out_nodes[0]->GetType().c_str()); out_nodes[0]->GetName().c_str(), out_nodes[0]->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[PrunePass] add control edge fail between DATA node[%s] and NETOUTPUT node[%s]!",
GELOGE(INTERNAL_ERROR, "[add][ControlEdge] failed between DATA node[%s] and NETOUTPUT node[%s]!",
node_ptr->GetOpDesc()->GetName().c_str(), out_nodes[0]->GetOpDesc()->GetName().c_str()); node_ptr->GetOpDesc()->GetName().c_str(), out_nodes[0]->GetOpDesc()->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


+ 18
- 11
ge/graph/passes/ref_identity_delete_op_pass.cc View File

@@ -31,10 +31,12 @@ Status RefIdentityDeleteOpPass::Run(ComputeGraphPtr graph) {
CHECK_FALSE_EXEC(GetRefNode(node, input_index) != nullptr, CHECK_FALSE_EXEC(GetRefNode(node, input_index) != nullptr,
REPORT_CALL_ERROR("E19999", "Get Ref node of node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get Ref node of node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Ref node of RefIdentity[%s] not found", node->GetName().c_str());
GELOGE(FAILED, "[Get][RefNode] of node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return FAILED); return FAILED);
CHECK_FALSE_EXEC(DealNoOutputRef(ref_node, node, input_index, graph) == SUCCESS, CHECK_FALSE_EXEC(DealNoOutputRef(ref_node, node, input_index, graph) == SUCCESS,
GELOGE(FAILED, "Ref identity [%s] delete failed", node->GetName().c_str());
GELOGE(FAILED, "[Deal][NoOutputRef] for node:%s failed, index:%d",
node->GetName().c_str(), input_index);
return FAILED); return FAILED);
} }
return SUCCESS; return SUCCESS;
@@ -65,8 +67,7 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP
if (variable_ref == nullptr) { if (variable_ref == nullptr) {
REPORT_CALL_ERROR("E19999", "Get variable ref of node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get variable ref of node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[RefIdentityDeleteOpPass]Can not find variable ref for %s:%d", node->GetName().c_str(),
input_index);
GELOGE(FAILED, "[Get][VariableRef] of node:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
if (first_node->GetName() != variable_ref->GetName()) { if (first_node->GetName() != variable_ref->GetName()) {
@@ -90,7 +91,9 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
first_node->GetName().c_str(), first_node->GetType().c_str()); first_node->GetName().c_str(), first_node->GetType().c_str());
GELOGE(FAILED, "Add control edge between ref node and trans node failed");
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
first_node->GetName().c_str(), first_node->GetType().c_str());
return FAILED; return FAILED;
} }
ret = ge::GraphUtils::RemoveEdge(node->GetOutControlAnchor(), variable_ref->GetInControlAnchor()); ret = ge::GraphUtils::RemoveEdge(node->GetOutControlAnchor(), variable_ref->GetInControlAnchor());
@@ -98,7 +101,9 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
first_node->GetName().c_str(), first_node->GetType().c_str()); first_node->GetName().c_str(), first_node->GetType().c_str());
GELOGE(FAILED, "Remove control edge between ref node and its peer node failed");
GELOGE(FAILED, "[Remove][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
first_node->GetName().c_str(), first_node->GetType().c_str());
return FAILED; return FAILED;
} }
} else { } else {
@@ -117,7 +122,9 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP
// +--------+ +--------+ // +--------+ +--------+
auto ret = RemoveUselessControlEdge(node, variable_ref); auto ret = RemoveUselessControlEdge(node, variable_ref);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "Remove useless control edge failed.");
GELOGE(FAILED, "[Remove][UselessControlEdge] between node:%s(%s) and node:%s(%s) failed.",
node->GetName().c_str(), node->GetType().c_str(),
variable_ref->GetName().c_str(), variable_ref->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -125,15 +132,15 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP
if (GraphUtils::IsolateNode(ref_identity, {0}) != GRAPH_SUCCESS) { if (GraphUtils::IsolateNode(ref_identity, {0}) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate op:%s(%s) failed",
ref_identity->GetName().c_str(), ref_identity->GetType().c_str()); ref_identity->GetName().c_str(), ref_identity->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", ref_identity->GetName().c_str(),
GELOGE(INTERNAL_ERROR, "[Isolate][Node] %s, type:%s failed", ref_identity->GetName().c_str(),
variable_ref->GetType().c_str()); variable_ref->GetType().c_str());
return FAILED; return FAILED;
} }
if (GraphUtils::RemoveNodeWithoutRelink(graph, ref_identity) != GRAPH_SUCCESS) { if (GraphUtils::RemoveNodeWithoutRelink(graph, ref_identity) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
ref_identity->GetName().c_str(), ref_identity->GetType().c_str(), graph->GetName().c_str()); ref_identity->GetName().c_str(), ref_identity->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", ref_identity->GetName().c_str(),
ref_identity->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Node] %s, type:%s without relink in graph:%s failed",
ref_identity->GetName().c_str(), ref_identity->GetType().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
return SUCCESS; return SUCCESS;
@@ -231,7 +238,7 @@ Status RefIdentityDeleteOpPass::RemoveUselessControlEdge(const NodePtr &ref, con
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str(), variable_ref->GetName().c_str(), variable_ref->GetType().c_str(),
peer_node->GetName().c_str(), peer_node->GetType().c_str()); peer_node->GetName().c_str(), peer_node->GetType().c_str());
GELOGE(FAILED, "Remove control edge between variable ref node[%s] and ref node's peer node[%s] failed",
GELOGE(FAILED, "[Remove][ControlEdge] between variable ref node[%s] and ref node's peer node[%s] failed",
variable_ref->GetName().c_str(), peer_node->GetName().c_str()); variable_ref->GetName().c_str(), peer_node->GetName().c_str());
return FAILED; return FAILED;
} }


+ 5
- 3
ge/graph/passes/remove_same_const_pass.cc View File

@@ -88,8 +88,9 @@ Status RemoveSameConstPass::Run(ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Replace node:%s(%s)'s anchor by node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Replace node:%s(%s)'s anchor by node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
iter->second->GetName().c_str(), iter->second->GetType().c_str()); iter->second->GetName().c_str(), iter->second->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s, ret=%u", node->GetName().c_str(),
iter->second->GetName().c_str(), ret);
GELOGE(INTERNAL_ERROR, "[Replace][Anchors] of node:%s(%s) by node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
iter->second->GetName().c_str(), iter->second->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -99,7 +100,8 @@ Status RemoveSameConstPass::Run(ComputeGraphPtr graph) {
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", 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()); node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Failed to remove node %s from graph", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Node] %s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }




+ 30
- 13
ge/graph/passes/replace_transshape_pass.cc View File

@@ -45,7 +45,8 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed",
trans_shape_node->GetName().c_str(), trans_shape_node->GetType().c_str()); trans_shape_node->GetName().c_str(), trans_shape_node->GetType().c_str());
GELOGE(FAILED, "Get node %s original type failede", trans_shape_node->GetName().c_str());
GELOGE(FAILED, "[Get][OriginalType] of op:%s(%s) failed",
trans_shape_node->GetName().c_str(), trans_shape_node->GetType().c_str());
return FAILED; return FAILED;
} }
auto src_op_desc = trans_shape_node->GetOpDesc(); auto src_op_desc = trans_shape_node->GetOpDesc();
@@ -55,7 +56,7 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node
auto dst_op_desc = MakeShared<OpDesc>(node_name, MEMCPYASYNC); auto dst_op_desc = MakeShared<OpDesc>(node_name, MEMCPYASYNC);
if (dst_op_desc == nullptr) { if (dst_op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Make node %s opdesc failed", node_name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed");
return FAILED; return FAILED;
} }
GELOGI("Create memcpy Op, name=%s.", node_name.c_str()); GELOGI("Create memcpy Op, name=%s.", node_name.c_str());
@@ -64,7 +65,8 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
dst_op_desc->GetName().c_str(), dst_op_desc->GetType().c_str()); dst_op_desc->GetName().c_str(), dst_op_desc->GetType().c_str());
GELOGE(FAILED, "Add input desc failed");
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed",
dst_op_desc->GetName().c_str(), dst_op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -73,7 +75,8 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str()); src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str());
GELOGE(FAILED, "Add output desc failed");
GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed",
src_op_desc->GetName().c_str(), src_op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -84,16 +87,22 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node
OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor();
GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue);


GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor), "Remove Memcpy data input fail.");
GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_out_anchor, in_data_anchor),
"[Remove][Edge] between %s and %s failed.",
peer_out_anchor->GetOwnerNode()->GetName().c_str(), trans_shape_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(peer_out_anchor, memcpy_node->GetInDataAnchor(in_data_anchor->GetIdx())), GE_CHK_STATUS(GraphUtils::AddEdge(peer_out_anchor, memcpy_node->GetInDataAnchor(in_data_anchor->GetIdx())),
"Memcpy node add edge fail.");
"[Add][Edge] between %s and %s failed.",
peer_out_anchor->GetOwnerNode()->GetName().c_str(), memcpy_node->GetName().c_str());
} }


for (OutDataAnchorPtr &out_data_anchor : trans_shape_node->GetAllOutDataAnchors()) { for (OutDataAnchorPtr &out_data_anchor : trans_shape_node->GetAllOutDataAnchors()) {
for (InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { for (InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor), "Remove Memcpy data output fail.");
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor),
"[Remove][Edge] between %s and %s failed.",
trans_shape_node->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(memcpy_node->GetOutDataAnchor(out_data_anchor->GetIdx()), peer_in_anchor), GE_CHK_STATUS(GraphUtils::AddEdge(memcpy_node->GetOutDataAnchor(out_data_anchor->GetIdx()), peer_in_anchor),
"Memcpy node add edge fail.");
"[Add][Edge] between %s and %s failed.",
memcpy_node->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
} }
} }
ReplaceControlEdges(trans_shape_node, memcpy_node); ReplaceControlEdges(trans_shape_node, memcpy_node);
@@ -107,14 +116,17 @@ void ReplaceTransShapePass::CopyControlEdges(NodePtr &old_node, NodePtr &new_nod
for (NodePtr &node : old_node->GetInControlNodes()) { for (NodePtr &node : old_node->GetInControlNodes()) {
auto out_control_anchor = node->GetOutControlAnchor(); auto out_control_anchor = node->GetOutControlAnchor();
GE_IF_BOOL_EXEC(!out_control_anchor->IsLinkedWith(new_node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!out_control_anchor->IsLinkedWith(new_node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(out_control_anchor, new_node->GetInControlAnchor()), "Add in ctl edge fail.");
GE_CHK_STATUS(GraphUtils::AddEdge(out_control_anchor, new_node->GetInControlAnchor()),
"[Add][ControlEdge] between %s and %s failed.",
node->GetName().c_str(), new_node->GetName().c_str());
}); });
} }


for (NodePtr &node : old_node->GetOutControlNodes()) { for (NodePtr &node : old_node->GetOutControlNodes()) {
GE_IF_BOOL_EXEC(!new_node->GetOutControlAnchor()->IsLinkedWith(node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!new_node->GetOutControlAnchor()->IsLinkedWith(node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), node->GetInControlAnchor()),
"Add out ctl edge fail.");
"[Add][ControlEdge] between %s and %s failed.",
new_node->GetName().c_str(), node->GetName().c_str());
}); });
} }
} }
@@ -123,19 +135,24 @@ void ReplaceTransShapePass::RemoveControlEdges(NodePtr &node) {
GE_CHECK_NOTNULL_JUST_RETURN(node); GE_CHECK_NOTNULL_JUST_RETURN(node);
for (NodePtr &in_node : node->GetInControlNodes()) { for (NodePtr &in_node : node->GetInControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(in_node->GetOutControlAnchor(), node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(in_node->GetOutControlAnchor(), node->GetInControlAnchor()),
"Remove in ctl edge fail.");
"[Remove][ControlEdge] between %s and %s failed.",
in_node->GetName().c_str(), node->GetName().c_str());
} }


for (auto &out_data_anchor : node->GetAllOutDataAnchors()) { for (auto &out_data_anchor : node->GetAllOutDataAnchors()) {
for (auto &in_ctrl_anchor : out_data_anchor->GetPeerInControlAnchors()) { for (auto &in_ctrl_anchor : out_data_anchor->GetPeerInControlAnchors()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, in_ctrl_anchor), "Remove in ctl edge fail.");
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, in_ctrl_anchor),
"[Remove][Edge] between %s and %s failed.",
node->GetName().c_str(), in_ctrl_anchor->GetOwnerNode()->GetName().c_str());
} }
} }


auto out_control_anchor = node->GetOutControlAnchor(); auto out_control_anchor = node->GetOutControlAnchor();
GE_CHECK_NOTNULL_JUST_RETURN(out_control_anchor); GE_CHECK_NOTNULL_JUST_RETURN(out_control_anchor);
for (auto &peer_anchor : out_control_anchor->GetPeerAnchors()) { for (auto &peer_anchor : out_control_anchor->GetPeerAnchors()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_control_anchor, peer_anchor), "Remove out ctl edge fail.");
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_control_anchor, peer_anchor),
"[Remove][OutCtlEdge] between %s and %s failed.",
node->GetName().c_str(), peer_anchor->GetOwnerNode()->GetName().c_str());
} }
} }




+ 2
- 2
ge/graph/passes/replace_with_empty_const_pass.cc View File

@@ -27,12 +27,12 @@ Status ReplaceWithEmptyConstPass::Run(NodePtr &node) {
GELOGD("ReplaceWithEmptyConstPass in."); GELOGD("ReplaceWithEmptyConstPass in.");
if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Parameter is null.");
GELOGE(PARAM_INVALID, "[Check][Param] Parameter node is nullptr.");
return PARAM_INVALID; return PARAM_INVALID;
} }
if (node->GetOpDesc() == nullptr) { if (node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid"); 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, "[Get][OpDesc] failed, Param [opDesc] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }
if (node->GetType() == CONSTANT || node->GetType() == CONSTANTOP || node->GetType() == DATA) { if (node->GetType() == CONSTANT || node->GetType() == CONSTANTOP || node->GetType() == DATA) {


+ 13
- 3
ge/graph/passes/reshape_recovery_pass.cc View File

@@ -24,24 +24,31 @@ NodePtr CreateReshape(const ConstGeTensorDescPtr &src, const ConstGeTensorDescPt
auto reshape = MakeShared<OpDesc>("Reshape_ReshapeRecoveryPass_" + std::to_string(next_num), RESHAPE); auto reshape = MakeShared<OpDesc>("Reshape_ReshapeRecoveryPass_" + std::to_string(next_num), RESHAPE);
if (reshape == nullptr) { if (reshape == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }
auto ret = reshape->AddInputDesc("x", *src); auto ret = reshape->AddInputDesc("x", *src);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:x", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:x",
reshape->GetName().c_str(), reshape->GetType().c_str()); reshape->GetName().c_str(), reshape->GetType().c_str());
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed, name:x",
reshape->GetName().c_str(), reshape->GetType().c_str());
return nullptr; return nullptr;
} }
ret = reshape->AddInputDesc("shape", GeTensorDesc(GeShape(), Format(), DT_INT32)); ret = reshape->AddInputDesc("shape", GeTensorDesc(GeShape(), Format(), DT_INT32));
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:shape", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:shape",
reshape->GetName().c_str(), reshape->GetType().c_str()); reshape->GetName().c_str(), reshape->GetType().c_str());
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed, name:shape",
reshape->GetName().c_str(), reshape->GetType().c_str());
return nullptr; return nullptr;
} }
ret = reshape->AddOutputDesc("y", *dst); ret = reshape->AddOutputDesc("y", *dst);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:y",
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:y",
reshape->GetName().c_str(), reshape->GetType().c_str()); reshape->GetName().c_str(), reshape->GetType().c_str());
GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed, name:y",
reshape->GetName().c_str(), reshape->GetType().c_str());
return nullptr; return nullptr;
} }


@@ -89,8 +96,11 @@ Status InsertReshapeIfNeed(const NodePtr &node) {
reshape->GetName().c_str(), reshape->GetType().c_str(), reshape->GetName().c_str(), reshape->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), src_anchor->GetIdx(), node->GetName().c_str(), node->GetType().c_str(), src_anchor->GetIdx(),
dst_node->GetName().c_str(), dst_node->GetType().c_str(), dst_anchor->GetIdx()); dst_node->GetName().c_str(), dst_node->GetType().c_str(), dst_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Failed to insert reshape between node %s and %s",
node->GetName().c_str(), dst_node->GetName().c_str());
GELOGE(INTERNAL_ERROR,
"[Insert][Node] %s(%s) between node:%s(%s)(out_index:%d) and node:%s(%s)(out_index:%d) failed",
reshape->GetName().c_str(), reshape->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str(), src_anchor->GetIdx(),
dst_node->GetName().c_str(), dst_node->GetType().c_str(), dst_anchor->GetIdx());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
GELOGI("Insert reshape between %s and %s to keep the shape continues", GELOGI("Insert reshape between %s and %s to keep the shape continues",


+ 3
- 3
ge/graph/passes/resource_pair_add_control_pass.cc View File

@@ -86,9 +86,9 @@ Status ResourcePairAddControlPass::Run(ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Op:%s(%s) link control edge to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Op:%s(%s) link control edge to op:%s(%s) failed",
from_node->GetName().c_str(), from_node->GetType().c_str(), from_node->GetName().c_str(), from_node->GetType().c_str(),
to_node->GetName().c_str(), to_node->GetType().c_str()); to_node->GetName().c_str(), to_node->GetType().c_str());
GELOGE(PARAM_INVALID, "link fail, from_node:%s, to_node:%s, from_type:%s, to_type:%s",
from_node->GetName().c_str(), to_node->GetName().c_str(), resource_type_pair.first.c_str(),
resource_type_pair.second.c_str());
GELOGE(PARAM_INVALID, "[Add][Edge] Op:%s(%s) link control edge to op:%s(%s) failed",
from_node->GetName().c_str(), from_node->GetType().c_str(),
to_node->GetName().c_str(), to_node->GetType().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
GELOGD("link success, from_node:%s, to_node:%s, from_type:%s, to_type:%s", from_node->GetName().c_str(), GELOGD("link success, from_node:%s, to_node:%s, from_type:%s, to_type:%s", from_node->GetName().c_str(),


+ 3
- 3
ge/graph/passes/resource_pair_remove_control_pass.cc View File

@@ -85,9 +85,9 @@ Status ResourcePairRemoveControlPass::Run(ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Op:%s(%s) unlink control edge to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Op:%s(%s) unlink control edge to op:%s(%s) failed",
from_node->GetName().c_str(), from_node->GetType().c_str(), from_node->GetName().c_str(), from_node->GetType().c_str(),
to_node->GetName().c_str(), to_node->GetType().c_str()); to_node->GetName().c_str(), to_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "unlink fail, from_node:%s, to_node:%s, from_type:%s, to_type:%s",
from_node->GetName().c_str(), to_node->GetName().c_str(), resource_type_pair.first.c_str(),
resource_type_pair.second.c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Edge] Op:%s(%s) unlink control edge to op:%s(%s) failed",
from_node->GetName().c_str(), from_node->GetType().c_str(),
to_node->GetName().c_str(), to_node->GetType().c_str());
return domi::PARAM_INVALID; return domi::PARAM_INVALID;
} }
GELOGD("unlink success, from_node:%s, to_node:%s, from_type:%s, to_type:%s", from_node->GetName().c_str(), GELOGD("unlink success, from_node:%s, to_node:%s, from_type:%s, to_type:%s", from_node->GetName().c_str(),


+ 95
- 34
ge/graph/passes/same_transdata_breadth_fusion_pass.cc View File

@@ -72,7 +72,7 @@ OpDescPtr SameTransdataBreadthFusionPass::GetCastOp(const GeTensorDesc &in_desc,
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); 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, "[Get][OpDesc] From Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST);
return nullptr; return nullptr;
} }
const int default_output_index = 0; const int default_output_index = 0;
@@ -99,7 +99,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(), 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()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set dst_type attr failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str());
return nullptr; return nullptr;
} }
return cast_op; return cast_op;
@@ -213,8 +214,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_anchor->GetIdx()); transdata_peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
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(),
@@ -226,9 +229,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_anchor->GetIdx()); transdata_peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -251,8 +255,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
out_anchor->GetOwnerNode()->GetType().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -265,9 +271,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().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][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} else { } else {
@@ -279,9 +287,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
transdata_peer_out_control_anchor->GetOwnerNode()->GetType().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()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -325,7 +335,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors
out_control_anchor->GetOwnerNode()->GetType().c_str(), out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove transdata control edge failed!");
GELOGE(GRAPH_FAILED, "[Remove][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -338,7 +352,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add control edge failed!");
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} else { } else {
@@ -350,7 +368,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors
transdata_peer_out_control_anchor->GetOwnerNode()->GetType().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()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add control edge failed!");
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -379,7 +401,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
out_control_anchor->GetOwnerNode()->GetType().c_str(), out_control_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove transdata control edge failed!");
GELOGE(GRAPH_FAILED, "[Remove][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -393,7 +419,12 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_data_anchor->GetIdx()); transdata_peer_in_data_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add control edge failed!");
GELOGE(GRAPH_FAILED, "[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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} else { } else {
@@ -405,7 +436,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors(
transdata_peer_out_control_anchor->GetOwnerNode()->GetType().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()->GetName().c_str(),
transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "add control edge failed!");
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -527,8 +562,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkRemainTransdata(const ComputeG
transdata_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_in_anchor->GetIdx()); transdata_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge failed!out node %s, in node %s", head_node->GetName().c_str(),
transdata_node_keep->GetName().c_str());
GELOGE(GRAPH_FAILED, "[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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -618,8 +655,11 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
head_node_peer_anchor->GetOwnerNode()->GetName().c_str(), head_node_peer_anchor->GetOwnerNode()->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetType().c_str(), head_node_peer_anchor->GetOwnerNode()->GetType().c_str(),
head_node_peer_anchor->GetIdx()); head_node_peer_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(),
head_node_peer_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
relink_node = head_node_peer_anchor->GetOwnerNode(); relink_node = head_node_peer_anchor->GetOwnerNode();
@@ -637,7 +677,8 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
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(), 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()); in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(FAILED, "UpdateInputDesc fail.");
GELOGE(FAILED, "[Update][InputDesc] index:%d in op:%s(%s) failed", in_data_anchor->GetIdx(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
int output_idx = sub_graph_anchors_[anchors_index][i + 1].first->GetIdx(); int output_idx = sub_graph_anchors_[anchors_index][i + 1].first->GetIdx();
@@ -646,7 +687,8 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor
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, 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()); in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(GRAPH_FAILED, "update input desc failed");
GELOGE(GRAPH_FAILED, "[Update][OutputDesc] index:%d in op:%s(%s) failed", output_idx,
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
return GRAPH_FAILED); return GRAPH_FAILED);
// relink control edge // relink control edge
if (RelinkInControlEdge(in_owner_node, transdata_node_keep) != GRAPH_SUCCESS) { if (RelinkInControlEdge(in_owner_node, transdata_node_keep) != GRAPH_SUCCESS) {
@@ -694,6 +736,11 @@ graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata(
transdata_remove_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_remove_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_remove_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_remove_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_remove_in_anchor->GetIdx()); transdata_remove_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "[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;
} }


@@ -729,7 +776,9 @@ graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata(
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed",
transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(), transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(),
graph->GetName().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(%s) from graph:%s failed",
transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(),
graph->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -751,8 +800,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkInControlEdge(const NodePtr &n
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_src->GetName().c_str(), node_src->GetType().c_str()); node_src->GetName().c_str(), node_src->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove edge faliled!src:%s, dst:%s",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), node_src->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Remove][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
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(),
@@ -762,8 +813,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkInControlEdge(const NodePtr &n
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_dst->GetName().c_str(), node_dst->GetType().c_str()); node_dst->GetName().c_str(), node_dst->GetType().c_str());
GELOGE(GRAPH_FAILED, "add edge failed!src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_dst->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -810,6 +863,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
if (cast_node == nullptr) { if (cast_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "[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());
@@ -818,6 +873,10 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(), pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(),
cast_node->GetName().c_str(), cast_node->GetType().c_str()); cast_node->GetName().c_str(), cast_node->GetType().c_str());
GELOGE(GRAPH_FAILED, "[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) {
@@ -827,7 +886,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(), 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()); cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str());
GELOGE(FAILED, "SetExtAttr fail.");
GELOGE(FAILED, "[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());
return FAILED; return FAILED;
} }
pre_out_anchor = cast_node->GetOutDataAnchor(0); pre_out_anchor = cast_node->GetOutDataAnchor(0);
@@ -842,7 +902,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat
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"); 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, "[Check][Param] out data anchor is null! This should not happen!");
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -868,7 +928,8 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat
for (auto &peer_out_anchor : peer_in_node->GetAllOutDataAnchors()) { for (auto &peer_out_anchor : peer_in_node->GetAllOutDataAnchors()) {
ret = GetSubGraphsBetweenNormalAndTransdataNode(peer_out_anchor, sub_graphs_out, nodes_list); ret = GetSubGraphsBetweenNormalAndTransdataNode(peer_out_anchor, sub_graphs_out, nodes_list);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "get all transop between normal node failed!node:%s", peer_in_node->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Get][AllTransOp] between normal node failed! node:%s",
peer_in_node->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }


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

@@ -49,7 +49,9 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) {
GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave), GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kVarAttrVarIsSave, REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kVarAttrVarIsSave,
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); return INTERNAL_ERROR);
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", kVarAttrVarIsSave,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return INTERNAL_ERROR);
} }
} }
} }
@@ -69,7 +71,8 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) {
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", 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()); node_ptr->GetName().c_str(), node_ptr->GetType().c_str(), graph->GetName().c_str());
GELOGE(ret, "GraphUtils::RemoveNodeWithoutRelink failed.");
GELOGE(ret, "[Remove][Node] %s(%s) from graph:%s failed",
node_ptr->GetName().c_str(), node_ptr->GetType().c_str(), graph->GetName().c_str());
return ret; return ret;
} }




+ 38
- 26
ge/graph/passes/set_input_output_offset_pass.cc View File

@@ -28,7 +28,7 @@ Status SetInputOutputOffsetPass::Run(ComputeGraphPtr graph) {
if (!connect_input.empty()) { if (!connect_input.empty()) {
Status ret = SetInputOffset(node, connect_input); Status ret = SetInputOffset(node, connect_input);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "SetInputOffset failed.");
GELOGE(ret, "[Set][InputOffset] for node:%s failed.", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -37,7 +37,7 @@ Status SetInputOutputOffsetPass::Run(ComputeGraphPtr graph) {
if (!connect_output.empty()) { if (!connect_output.empty()) {
Status ret = SetOutputOffset(node, connect_output); Status ret = SetOutputOffset(node, connect_output);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "SetOutputOffset failed.");
GELOGE(ret, "[Set][OutputOffset] for node:%s failed.", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -56,7 +56,8 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vector<int64
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", 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); 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, "[Check][Param] Input offsets size:%zu of node:%s(%s) < index:%zu",
input_offset_of_node.size(), op_desc->GetName().c_str(), op_desc->GetType().c_str(), i);
return PARAM_INVALID; return PARAM_INVALID;
} }
int64_t input_offset = input_offset_of_node.at(i); int64_t input_offset = input_offset_of_node.at(i);
@@ -82,14 +83,17 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vector<int64
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_BASIC_OFFSET.c_str(), ATTR_ZERO_COPY_BASIC_OFFSET.c_str(),
data_op_desc->GetName().c_str(), data_op_desc->GetType().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, "[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());
return FAILED);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(data_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET,
zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
data_op_desc->GetName().c_str(), data_op_desc->GetType().c_str());
GELOGE(FAILED, "[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());
return FAILED); return FAILED);
GE_CHK_BOOL_EXEC(
ge::AttrUtils::SetListInt(data_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
data_op_desc->GetName().c_str(), data_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED);
} }
} }
return SUCCESS; return SUCCESS;
@@ -125,14 +129,17 @@ Status SetInputOutputOffsetPass::SetInputOffsetForHcom(const ge::NodePtr &node,
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_BASIC_OFFSET.c_str(), ATTR_ZERO_COPY_BASIC_OFFSET.c_str(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().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, "[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());
return FAILED);
GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(in_op_desc,
ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(FAILED, "[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());
return FAILED); return FAILED);
GE_CHK_BOOL_EXEC(
ge::AttrUtils::SetListInt(in_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed.");
return FAILED);
} }
} }
} }
@@ -147,7 +154,7 @@ Status SetInputOutputOffsetPass::SetInputOffset(const NodePtr &node, const vecto
if (!memory_type.empty()) { if (!memory_type.empty()) {
Status ret = SetInputOffsetForFusion(memory_type, node); Status ret = SetInputOffsetForFusion(memory_type, node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "SetInputOffsetForFusion failed.");
GELOGE(ret, "[Set][InputOffset] For Fusion failed, node:%s.", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -157,7 +164,7 @@ Status SetInputOutputOffsetPass::SetInputOffset(const NodePtr &node, const vecto
if (is_input_continuous) { if (is_input_continuous) {
Status ret = SetInputOffsetForHcom(node, connect_input); Status ret = SetInputOffsetForHcom(node, connect_input);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "SetInputOffsetForHcom failed.");
GELOGE(ret, "[Set][InputOffset] For Hcom failed, node:%s.", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -174,7 +181,8 @@ Status SetInputOutputOffsetPass::SetOutputOffsetForConcat(const NodePtr &node) {
REPORT_INNER_ERROR("E19999", "Output offsets size:%zu of node:%s(%s) not equal to 1, check invalid", REPORT_INNER_ERROR("E19999", "Output offsets size:%zu of node:%s(%s) not equal to 1, check invalid",
output_offset_of_concat.size(), output_offset_of_concat.size(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); 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, "[Check][Param] Output offsets size:%zu of node:%s(%s) not equal to 1.",
output_offset_of_concat.size(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID); return PARAM_INVALID);
NodePtr net_output = node->GetOutDataNodes().at(0); NodePtr net_output = node->GetOutDataNodes().at(0);
auto out_op_desc = net_output->GetOpDesc(); auto out_op_desc = net_output->GetOpDesc();
@@ -203,13 +211,15 @@ Status SetInputOutputOffsetPass::SetOutputOffsetForConcat(const NodePtr &node) {
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(), 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()); out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
GELOGE(FAILED, "[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());
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", REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(), ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
out_op_desc->GetName().c_str(), out_op_desc->GetType().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, "[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());
return FAILED); return FAILED);
return SUCCESS; return SUCCESS;
} }
@@ -254,13 +264,15 @@ 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(), 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()); out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str());
GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed.");
GELOGE(FAILED, "[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());
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", REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(), ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(),
out_op_desc->GetName().c_str(), out_op_desc->GetType().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, "[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());
return FAILED); return FAILED);
return SUCCESS; return SUCCESS;
} }
@@ -277,7 +289,7 @@ Status SetInputOutputOffsetPass::SetOutputOffset(const NodePtr &node, const vect
if (is_input_continuous || buffer_fusion) { if (is_input_continuous || buffer_fusion) {
Status ret = SetOutputOffsetForConcat(node); Status ret = SetOutputOffsetForConcat(node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "SetOutputOffsetForConcat failed.");
GELOGE(ret, "[Set][OutputOffset] For Concat failed, node:%s.", node->GetName().c_str());
return ret; return ret;
} }
} }
@@ -288,7 +300,7 @@ Status SetInputOutputOffsetPass::SetOutputOffset(const NodePtr &node, const vect
if (is_output_continuous) { if (is_output_continuous) {
Status ret = SetOutputOffsetForHcom(node, connect_output); Status ret = SetOutputOffsetForHcom(node, connect_output);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "SetOutputOffsetForHcom failed.");
GELOGE(ret, "[Set][OutputOffset] For Hcom failed, node:%s.", node->GetName().c_str());
return ret; return ret;
} }
} }


+ 4
- 1
ge/graph/passes/shape_operate_op_remove_pass.cc View File

@@ -30,7 +30,10 @@ Status ShapeOperateOpRemovePass::Run(ComputeGraphPtr graph) {
GE_IF_BOOL_EXEC(op_desc == nullptr, continue); GE_IF_BOOL_EXEC(op_desc == nullptr, continue);
bool to_be_deleted = false; bool to_be_deleted = false;
GE_IF_BOOL_EXEC(!AttrUtils::GetBool(op_desc, ATTR_TO_BE_DELETED, to_be_deleted), to_be_deleted = false); GE_IF_BOOL_EXEC(!AttrUtils::GetBool(op_desc, ATTR_TO_BE_DELETED, to_be_deleted), to_be_deleted = false);
GE_IF_BOOL_EXEC(to_be_deleted, GE_CHK_STATUS_RET(graph->RemoveNode(node), "remove node failed!"));
GE_IF_BOOL_EXEC(to_be_deleted,
GE_CHK_STATUS_RET(graph->RemoveNode(node),
"[Remove][Node] %s from graph:%s failed!", node->GetName().c_str(),
graph->GetName().c_str()));
} }
return SUCCESS; return SUCCESS;
} }


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

@@ -23,7 +23,8 @@
namespace ge { namespace ge {
Status SnapshotPass::Run(NodePtr &node) { Status SnapshotPass::Run(NodePtr &node) {
if (node == nullptr) { if (node == nullptr) {
GELOGE(FAILED, "parameter is null.");
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
return FAILED; return FAILED;
} }
string type; string type;
@@ -31,7 +32,8 @@ Status SnapshotPass::Run(NodePtr &node) {
if (status_ret != SUCCESS) { if (status_ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(status_ret, "SnapshotPass get original type failed.");
GELOGE(status_ret, "[Get][OriginalType] of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return status_ret; return status_ret;
} }
if (type == SNAPSHOT) { if (type == SNAPSHOT) {


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

@@ -21,7 +21,7 @@ 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"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
return FAILED; return FAILED;
} }
string type; string type;
@@ -29,7 +29,8 @@ Status StopGradientPass::Run(NodePtr &node) {
if (status_ret != SUCCESS) { if (status_ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(status_ret, "StopGradientPass get original type failed.");
GELOGE(status_ret, "[Get][OriginalType] of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return status_ret; return status_ret;
} }




+ 49
- 27
ge/graph/passes/subexpression_migration_pass.cc View File

@@ -146,7 +146,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap
if (subgraph == nullptr) { if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed", REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str()); 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, "[Get][SubGraph] from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH; return GE_GRAPH_EMPTY_SUBGRAPH;
} }


@@ -160,7 +161,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap
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(), 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()); data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -234,7 +236,7 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
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); 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, "[Check][Param] Find node in data_nodes by index:%u failed", node_idx);
return false; return false;
} }


@@ -245,14 +247,15 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
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)", 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()); 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, "[Check][Param] 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());
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"); 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, "[Check][Param] Owner node of anchor is nullptr");
return false; return false;
} }


@@ -347,7 +350,7 @@ Status SubexpressionMigrationPass::AppendParallelNode(map<ComputeGraphPtr, map<u
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); 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, "[Build][Op] %s(%s) failed", data_name.c_str(), DATA);
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -355,14 +358,16 @@ Status SubexpressionMigrationPass::AppendParallelNode(map<ComputeGraphPtr, map<u
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(), 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()); 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, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().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(), 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()); 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, "[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());
return FAILED; return FAILED;
} }


@@ -372,7 +377,8 @@ Status SubexpressionMigrationPass::AppendParallelNode(map<ComputeGraphPtr, map<u
} }


// Add InputTensor to functional Node. // Add InputTensor to functional Node.
GE_CHK_GRAPH_STATUS_RET(NodeUtils::AppendInputAnchor(func_node, item.second + 1), "Append input failed");
GE_CHK_GRAPH_STATUS_RET(NodeUtils::AppendInputAnchor(func_node, item.second + 1),
"[Append][InputAnchor] for node:%s failed", func_node->GetName().c_str());
migration_append_ = true; migration_append_ = true;
} }


@@ -395,7 +401,9 @@ Status SubexpressionMigrationPass::DetachParallelNode(const map<uint32_t, NodePt
if (out_anchor == nullptr) { if (out_anchor == nullptr) {
continue; continue;
} }
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor),
"[Remove][Edge] between %s and %s failed",
out_anchor->GetOwnerNode()->GetName().c_str(), detach->GetName().c_str());


const auto &owner_node = out_anchor->GetOwnerNode(); const auto &owner_node = out_anchor->GetOwnerNode();
GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str()); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str());
@@ -405,15 +413,15 @@ 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);
REPORT_INNER_ERROR("E19999", "Node:%s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "[Check][Param] 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);
REPORT_INNER_ERROR("E19999", "Node:%s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "[Check][Param] Node:%s parent index %u not found", detach->GetName().c_str(), i);
return FAILED; return FAILED;
} }


@@ -429,12 +437,16 @@ Status SubexpressionMigrationPass::DetachParallelNode(const map<uint32_t, NodePt
if (in_anchor == nullptr) { if (in_anchor == nullptr) {
continue; continue;
} }
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor),
"[Remove][Edge] between %s and %s failed",
detach->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
const auto &owner_node = in_anchor->GetOwnerNode(); const auto &owner_node = in_anchor->GetOwnerNode();
GELOGI("Remove Edge: %s %s", detach->GetName().c_str(), owner_node->GetName().c_str()); GELOGI("Remove Edge: %s %s", detach->GetName().c_str(), owner_node->GetName().c_str());


const auto &data_out_anchor = data_node->GetOutDataAnchor(kDataOutIndex); const auto &data_out_anchor = data_node->GetOutDataAnchor(kDataOutIndex);
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_out_anchor, in_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_out_anchor, in_anchor),
"[Add][Edge] between %s and %s failed",
data_node->GetName().c_str(), owner_node->GetName().c_str());
GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), owner_node->GetName().c_str()); GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), owner_node->GetName().c_str());
} }
} }
@@ -459,8 +471,8 @@ 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);
REPORT_INNER_ERROR("E19999", "Node:%s parent index %u not found, check invalid", attach->GetName().c_str(), i);
GELOGE(FAILED, "[Check][Param] Node:%s parent index %u not found", attach->GetName().c_str(), i);
return FAILED; return FAILED;
} }
if (it_idx->second == kInvalidParent) { // Not connect, Skip. if (it_idx->second == kInvalidParent) { // Not connect, Skip.
@@ -469,7 +481,9 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra


const auto &in_anchor = func_node->GetInDataAnchor(it_idx->second); const auto &in_anchor = func_node->GetInDataAnchor(it_idx->second);
const auto &out_anchor = in_anchor->GetPeerOutAnchor(); const auto &out_anchor = in_anchor->GetPeerOutAnchor();
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, attach->GetInDataAnchor(i)), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, attach->GetInDataAnchor(i)),
"[Add][Edge] between %s and %s failed",
out_anchor->GetOwnerNode()->GetName().c_str(), attach->GetName().c_str());
const auto &owner_node = out_anchor->GetOwnerNode(); const auto &owner_node = out_anchor->GetOwnerNode();
GELOGI("Add Edge: %s %s", owner_node->GetName().c_str(), attach->GetName().c_str()); GELOGI("Add Edge: %s %s", owner_node->GetName().c_str(), attach->GetName().c_str());
} }
@@ -490,11 +504,15 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra
const auto &in_anchor = func_node->GetInDataAnchor(it_idx->second); const auto &in_anchor = func_node->GetInDataAnchor(it_idx->second);
const auto &out_anchor = in_anchor->GetPeerOutAnchor(); const auto &out_anchor = in_anchor->GetPeerOutAnchor();
if (out_anchor != nullptr) { if (out_anchor != nullptr) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor),
"[Remove][Edge] between %s and %s failed",
out_anchor->GetOwnerNode()->GetName().c_str(), func_node->GetName().c_str());
const auto &owner_node = out_anchor->GetOwnerNode(); const auto &owner_node = out_anchor->GetOwnerNode();
GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str()); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str());
} }
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(attach->GetOutDataAnchor(i), in_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(attach->GetOutDataAnchor(i), in_anchor),
"[Add][Edge] between %s and %s failed",
attach->GetName().c_str(), func_node->GetName().c_str());
GELOGI("Add Edge: %s %s", attach->GetName().c_str(), func_node->GetName().c_str()); GELOGI("Add Edge: %s %s", attach->GetName().c_str(), func_node->GetName().c_str());
} }


@@ -522,7 +540,7 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
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"); REPORT_INNER_ERROR("E19999", "Param inputs is empty, check invalid");
GELOGE(FAILED, "Graph: %s, inputs is empty", graph->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Param inputs is empty");
return FAILED; return FAILED;
} }


@@ -535,7 +553,8 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
if (it == subnodes.end()) { if (it == subnodes.end()) {
REPORT_INNER_ERROR("E19999", "Index:%u data node not found in graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Index:%u data node not found in graph:%s, check invalid",
base_index, subgraph->GetName().c_str()); base_index, subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Data: %u node not found", subgraph->GetName().c_str(), base_index);
GELOGE(FAILED, "[Check][Param] Index:%u data node not found in graph:%s",
base_index, subgraph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -546,23 +565,26 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
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)", 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()); 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, "[Check][Param] 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());
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"); 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, "[Check][Param] Owner node of anchor is nullptr");
return FAILED; return FAILED;
} }


if (DetachParallelNode(subnodes, move_node, outputs) != SUCCESS) { if (DetachParallelNode(subnodes, move_node, outputs) != SUCCESS) {
GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), base_index);
GELOGE(FAILED, "[Detach][ParallelNode] failed, move_node:%s", move_node->GetName().c_str());
return FAILED; return FAILED;
} }


GE_CHK_GRAPH_STATUS_RET(subgraph->RemoveNode(move_node), "Remove node failed");
GE_CHK_GRAPH_STATUS_RET(subgraph->RemoveNode(move_node),
"[Remove][Node] %s from graph:%s failed",
move_node->GetName().c_str(), graph->GetName().c_str());
GELOGI("Remove Node: %s %s", subgraph->GetName().c_str(), move_node->GetName().c_str()); GELOGI("Remove Node: %s %s", subgraph->GetName().c_str(), move_node->GetName().c_str());
} }




+ 44
- 21
ge/graph/passes/subgraph_const_migration_pass.cc View File

@@ -143,7 +143,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
if (subgraph == nullptr) { if (subgraph == nullptr) {
REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed", REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str()); 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, "[Get][SubGraph] from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH; return GE_GRAPH_EMPTY_SUBGRAPH;
} }


@@ -156,6 +157,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
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(), 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()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[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;
} }


@@ -205,7 +208,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra


for (auto &node : ctrl_only_const_nodes) { for (auto &node : ctrl_only_const_nodes) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(subgraph, node), GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(subgraph, node),
"Remove node without relink failed, node: %s", node->GetName().c_str());
"[Remove][Node] without relink failed, node:%s, graph:%s",
node->GetName().c_str(), subgraph->GetName().c_str());
} }
} }


@@ -331,7 +335,7 @@ Status SubgraphConstMigrationPass::AppendParallelNode(const NodePtr &func_node,
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); 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, "[Build][OpDesc] %s(%s) failed", data_name.c_str(), DATA);
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -339,14 +343,16 @@ Status SubgraphConstMigrationPass::AppendParallelNode(const NodePtr &func_node,
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(), 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()); 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, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().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(), 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()); 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, "[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());
return FAILED; return FAILED;
} }


@@ -373,22 +379,28 @@ Status SubgraphConstMigrationPass::DetachParallelNode(const ComputeGraphPtr &gra
const auto &in_anchor = const_node->GetInControlAnchor(); const auto &in_anchor = const_node->GetInControlAnchor();
const auto out_anchors = in_anchor->GetPeerOutControlAnchors(); const auto out_anchors = in_anchor->GetPeerOutControlAnchors();
for (const auto out_anchor : out_anchors) { for (const auto out_anchor : out_anchors) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor),
"[Remove][Edge] between %s and %s failed", out_anchor->GetOwnerNode()->GetName().c_str(),
const_node->GetName().c_str());
const auto owner_node = out_anchor->GetOwnerNode(); const auto owner_node = out_anchor->GetOwnerNode();
GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), const_node->GetName().c_str()); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), const_node->GetName().c_str());
if (owner_node->GetInAllNodes().empty() && owner_node->GetOutAllNodes().empty() && owner_node != data_node) { if (owner_node->GetInAllNodes().empty() && owner_node->GetOutAllNodes().empty() && owner_node != data_node) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(graph, owner_node), GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(graph, owner_node),
"Remove node without relink failed, node: %s", owner_node->GetName().c_str());
"[Remove][Node] without relink failed, node:%s", owner_node->GetName().c_str());
} }
} }


const auto &ctrl_anchor = const_node->GetOutControlAnchor(); const auto &ctrl_anchor = const_node->GetOutControlAnchor();
const auto ctrl_anchors = ctrl_anchor->GetPeerInControlAnchors(); const auto ctrl_anchors = ctrl_anchor->GetPeerInControlAnchors();
for (const auto in_anchor : ctrl_anchors) { for (const auto in_anchor : ctrl_anchors) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(ctrl_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(ctrl_anchor, in_anchor),
"[Remove][ControlEdge] between %s and %s failed",
const_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
GELOGI("Remove Edge: %s %s", const_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); GELOGI("Remove Edge: %s %s", const_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());


GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_node->GetOutControlAnchor(), in_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_node->GetOutControlAnchor(), in_anchor),
"[Add][ControlEdge] between %s and %s failed",
data_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
} }


@@ -396,10 +408,14 @@ Status SubgraphConstMigrationPass::DetachParallelNode(const ComputeGraphPtr &gra
const auto &out_anchor = const_node->GetOutDataAnchor(kZeroIndex); const auto &out_anchor = const_node->GetOutDataAnchor(kZeroIndex);
const auto in_anchors = out_anchor->GetPeerInDataAnchors(); const auto in_anchors = out_anchor->GetPeerInDataAnchors();
for (const auto in_anchor : in_anchors) { for (const auto in_anchor : in_anchors) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor),
"[Remove][Edge] between %s and %s failed",
const_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
GELOGI("Remove Edge: %s %s", const_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); GELOGI("Remove Edge: %s %s", const_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());


GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_node->GetOutDataAnchor(kZeroIndex), in_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(data_node->GetOutDataAnchor(kZeroIndex), in_anchor),
"[Add][Edge] between %s and %s failed",
data_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); GELOGI("Add Edge: %s %s", data_node->GetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str());
} }


@@ -436,15 +452,19 @@ Status SubgraphConstMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra
const auto &in_anchor = func_node->GetInDataAnchor(parent_index); const auto &in_anchor = func_node->GetInDataAnchor(parent_index);
const auto &out_anchor = in_anchor->GetPeerOutAnchor(); const auto &out_anchor = in_anchor->GetPeerOutAnchor();
if (out_anchor != nullptr) { // Break useless old link. if (out_anchor != nullptr) { // Break useless old link.
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, in_anchor),
"[Remove][Edge] between %s and %s failed",
out_anchor->GetOwnerNode()->GetName().c_str(), func_node->GetName().c_str());
const auto owner_node = out_anchor->GetOwnerNode(); const auto owner_node = out_anchor->GetOwnerNode();
GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str()); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str());
if (owner_node->GetInAllNodes().empty() && owner_node->GetOutAllNodes().empty()) { if (owner_node->GetInAllNodes().empty() && owner_node->GetOutAllNodes().empty()) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(graph, owner_node), GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(graph, owner_node),
"Remove node without relink failed, node: %s", owner_node->GetName().c_str());
"[Remove][Node] without relink failed, node:%s", owner_node->GetName().c_str());
} }
} }
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(const_node->GetOutDataAnchor(kZeroIndex), in_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(const_node->GetOutDataAnchor(kZeroIndex), in_anchor),
"[Add][Edge] between %s and %s failed",
const_node->GetName().c_str(), func_node->GetName().c_str());
GELOGI("Add Edge: %s %s, index: %u", const_node->GetName().c_str(), func_node->GetName().c_str(), parent_index); GELOGI("Add Edge: %s %s, index: %u", const_node->GetName().c_str(), func_node->GetName().c_str(), parent_index);


(void)graph->AddNode(const_node); (void)graph->AddNode(const_node);
@@ -471,8 +491,7 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
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", REPORT_INNER_ERROR("E19999", "Param node_key is empty or param parent_index is 0x%X, check invalid",
kInvalidParent); kInvalidParent);
GELOGE(FAILED, "Graph: %s, node key: %s, parent index: %u invalid",
graph->GetName().c_str(), node_key.c_str(), parent_index);
GELOGE(FAILED, "[Check][Param] Param node_key is empty or param parent_index is 0x%X", kInvalidParent);
return FAILED; return FAILED;
} }


@@ -483,7 +502,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
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", REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str()); 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, "[Check][Param] Const node name:%s not found in graph:%s",
node_key.c_str(), subgraph->GetName().c_str());
return FAILED; return FAILED;
} }
move_node = it_const->second; move_node = it_const->second;
@@ -492,24 +512,27 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
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", REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str()); 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, "[Check][Param] Const node name:%s not found in graph:%s",
node_key.c_str(), subgraph->GetName().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", REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str()); 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, "[Check][Param] Const node name:%s not found in graph:%s",
node_key.c_str(), subgraph->GetName().c_str());
return FAILED; return FAILED;
} }


if (DetachParallelNode(subgraph, move_node, it_data->second) != SUCCESS) { if (DetachParallelNode(subgraph, move_node, it_data->second) != SUCCESS) {
GELOGE(FAILED, "Data: %s not found, index: %u", move_node->GetName().c_str(), parent_index);
GELOGE(FAILED, "[Detach][ParallelNode] Data:%s not found, index:%u", move_node->GetName().c_str(), parent_index);
return FAILED; return FAILED;
} }


GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(subgraph, move_node), GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveNodeWithoutRelink(subgraph, move_node),
"Remove node without relink failed, node: %s", move_node->GetName().c_str());
"[Remove][Node] without relink failed, node:%s, graph:%s",
move_node->GetName().c_str(), subgraph->GetName().c_str());
GELOGI("Remove Node: %s %s", subgraph->GetName().c_str(), move_node->GetName().c_str()); GELOGI("Remove Node: %s %s", subgraph->GetName().c_str(), move_node->GetName().c_str());
} }




+ 31
- 20
ge/graph/passes/subgraph_pass.cc View File

@@ -31,7 +31,8 @@ Status SubgraphPass::Run(ComputeGraphPtr graph) {
for (const NodePtr &node : graph->GetDirectNode()) { for (const NodePtr &node : graph->GetDirectNode()) {
if (is_sub_graph && (node->GetType() == DATA)) { if (is_sub_graph && (node->GetType() == DATA)) {
if (SubgraphInputNode(graph, node) != SUCCESS) { if (SubgraphInputNode(graph, node) != SUCCESS) {
GELOGE(FAILED, "Handle input %s of subgraph failed.", node->GetName().c_str());
GELOGE(FAILED, "[Handle][Input] %s of subgraph:%s failed.",
node->GetName().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
continue; continue;
@@ -40,7 +41,8 @@ Status SubgraphPass::Run(ComputeGraphPtr graph) {
// NetOutput in subgraph // NetOutput in subgraph
if (is_sub_graph && (node->GetType() == NETOUTPUT)) { if (is_sub_graph && (node->GetType() == NETOUTPUT)) {
if (SubgraphOutputNode(graph, node) != SUCCESS) { if (SubgraphOutputNode(graph, node) != SUCCESS) {
GELOGE(FAILED, "Handle output %s of subgraph failed.", node->GetName().c_str());
GELOGE(FAILED, "[Handle][Output] %s of subgraph:%s failed.",
node->GetName().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
continue; continue;
@@ -49,12 +51,14 @@ Status SubgraphPass::Run(ComputeGraphPtr graph) {
if (kWhileOpTypes.count(node->GetType()) > 0) { if (kWhileOpTypes.count(node->GetType()) > 0) {
// Input->While and Input link to other nodes // Input->While and Input link to other nodes
if (WhileInputNodes(graph, node) != SUCCESS) { if (WhileInputNodes(graph, node) != SUCCESS) {
GELOGE(FAILED, "Handle input of while_body failed, while:%s.", node->GetName().c_str());
GELOGE(FAILED, "[Handle][Input] of while_body failed, while:%s, graph:%s.",
node->GetName().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
// body subgraph of While op // body subgraph of While op
if (WhileBodySubgraph(graph, node) != SUCCESS) { if (WhileBodySubgraph(graph, node) != SUCCESS) {
GELOGE(FAILED, "Handle while_body failed, while:%s.", node->GetName().c_str());
GELOGE(FAILED, "[Handle][WhileBody] failed, while:%s, graph:%s.",
node->GetName().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
continue; continue;
@@ -87,7 +91,7 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP
GELOGD("Data %s output_node required continues input.", node->GetName().c_str()); GELOGD("Data %s output_node required continues input.", node->GetName().c_str());
std::string name = node->GetName() + "_output_0_Memcpy"; std::string name = node->GetName() + "_output_0_Memcpy";
if (InsertMemcpyNode(graph, out_data_anchor, in_anchors, name) != SUCCESS) { if (InsertMemcpyNode(graph, out_data_anchor, in_anchors, name) != SUCCESS) {
GELOGE(FAILED, "Insert memcpy after %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Insert][Memcpy] after %s failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -96,7 +100,8 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP
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(), 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()); 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] %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;
} }


@@ -119,7 +124,7 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP
parent_node->GetName().c_str()); parent_node->GetName().c_str());
std::string name = parent_node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()) + "_Memcpy"; std::string name = parent_node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()) + "_Memcpy";
if (InsertMemcpyNode(parent_graph, peer_out_anchor, {in_data_anchor}, name) != SUCCESS) { if (InsertMemcpyNode(parent_graph, peer_out_anchor, {in_data_anchor}, name) != SUCCESS) {
GELOGE(FAILED, "Insert memcpy between %s and %s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
GELOGE(FAILED, "[Insert][Memcpy] between %s and %s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
parent_node->GetName().c_str()); parent_node->GetName().c_str());
return FAILED; return FAILED;
} }
@@ -160,7 +165,8 @@ Status SubgraphPass::SubgraphOutputNode(const ComputeGraphPtr &graph, const Node
GELOGD("Insert MemcpyAsync node between %s and %s.", in_node->GetName().c_str(), node->GetName().c_str()); GELOGD("Insert MemcpyAsync node between %s and %s.", in_node->GetName().c_str(), node->GetName().c_str());
std::string name = node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()) + "_Memcpy"; std::string name = node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()) + "_Memcpy";
if (InsertMemcpyNode(graph, peer_out_anchor, {in_data_anchor}, name) != SUCCESS) { if (InsertMemcpyNode(graph, peer_out_anchor, {in_data_anchor}, name) != SUCCESS) {
GELOGE(FAILED, "Insert memcpy between %s and %s failed.", in_node->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Insert][Memcpy] between %s and %s failed.",
in_node->GetName().c_str(), node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -190,7 +196,8 @@ Status SubgraphPass::WhileInputNodes(const ComputeGraphPtr &graph, const NodePtr
GELOGD("Input %s of While %s links to other nodes.", in_node->GetName().c_str(), node->GetName().c_str()); GELOGD("Input %s of While %s links to other nodes.", in_node->GetName().c_str(), node->GetName().c_str());
std::string name = node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()) + "_Memcpy"; std::string name = node->GetName() + "_input_" + std::to_string(in_data_anchor->GetIdx()) + "_Memcpy";
if (InsertMemcpyNode(graph, peer_out_anchor, {in_data_anchor}, name) != SUCCESS) { if (InsertMemcpyNode(graph, peer_out_anchor, {in_data_anchor}, name) != SUCCESS) {
GELOGE(FAILED, "Insert memcpy between %s and %s failed.", in_node->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Insert][Memcpy] between %s and %s failed.",
in_node->GetName().c_str(), node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -212,7 +219,7 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
if (while_body == nullptr) { if (while_body == nullptr) {
REPORT_INNER_ERROR("E19999", "While_body of node:%s(%s) is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "While_body of node:%s(%s) is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "while_body of %s is NULL.", node->GetName().c_str());
GELOGE(FAILED, "[Get][Subgraph] failed, while_body of %s is nullptr.", node->GetName().c_str());
return FAILED; return FAILED;
} }
if (GraphUtils::IsUnknownShapeGraph(while_body)) { if (GraphUtils::IsUnknownShapeGraph(while_body)) {
@@ -230,7 +237,8 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
cond_data_nodes.emplace_back(n); cond_data_nodes.emplace_back(n);
} }
} }
GE_CHK_STATUS_RET(InsertInputMemcpy(while_cond, cond_data_nodes), "InsertInputMemcpy failed.");
GE_CHK_STATUS_RET(InsertInputMemcpy(while_cond, cond_data_nodes),
"[Insert][InputMemcpy] %s failed.", while_cond->GetName().c_str());
} }


std::vector<NodePtr> data_nodes; std::vector<NodePtr> data_nodes;
@@ -248,7 +256,7 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
} else { } else {
REPORT_INNER_ERROR("E19999", "While_body graph:%s exists multi NetOutput nodes, check invalid", REPORT_INNER_ERROR("E19999", "While_body graph:%s exists multi NetOutput nodes, check invalid",
while_body->GetName().c_str()); while_body->GetName().c_str());
GELOGE(FAILED, "while_body %s exists multi NetOutput nodes.", while_body->GetName().c_str());
GELOGE(FAILED, "[Check][Param] while_body %s exists multi NetOutput nodes.", while_body->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -256,13 +264,13 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP
if (output_node == nullptr) { if (output_node == nullptr) {
REPORT_INNER_ERROR("E19999", "While_body graph:%s has no output, check invalid", REPORT_INNER_ERROR("E19999", "While_body graph:%s has no output, check invalid",
while_body->GetName().c_str()); while_body->GetName().c_str());
GELOGE(FAILED, "while_body %s has no output.", while_body->GetName().c_str());
GELOGE(FAILED, "[Check][Param] while_body %s has no output.", while_body->GetName().c_str());
return FAILED; return FAILED;
} }


if ((InsertInputMemcpy(while_body, data_nodes) != SUCCESS) || if ((InsertInputMemcpy(while_body, data_nodes) != SUCCESS) ||
(InsertOutputMemcpy(while_body, output_node, bypass_index) != SUCCESS)) { (InsertOutputMemcpy(while_body, output_node, bypass_index) != SUCCESS)) {
GELOGE(FAILED, "Insert memcpy node in while_body %s failed.", while_body->GetName().c_str());
GELOGE(FAILED, "[Insert][MemcpyNode] in while_body %s failed.", while_body->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -300,7 +308,7 @@ Status SubgraphPass::InsertInputMemcpy(const ComputeGraphPtr &graph, const std::
in_anchors.emplace_back(peer_in_anchor); in_anchors.emplace_back(peer_in_anchor);
} }
if (InsertNodeBetween(out_data_anchor, in_anchors, in_memcpy, i, i) != SUCCESS) { if (InsertNodeBetween(out_data_anchor, in_anchors, in_memcpy, i, i) != SUCCESS) {
GELOGE(FAILED, "Insert MemcpyAsync %s in while_body %s failed.", in_name.c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[Insert][MemcpyAsync] %s in while_body %s failed.", in_name.c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -341,7 +349,7 @@ Status SubgraphPass::InsertOutputMemcpy(const ComputeGraphPtr &graph, const Node
InDataAnchorPtr in_data_anchor = output_node->GetInDataAnchor(i); InDataAnchorPtr in_data_anchor = output_node->GetInDataAnchor(i);
OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor();
if (InsertNodeBetween(peer_out_anchor, {in_data_anchor}, out_memcpy, cnt, cnt) != SUCCESS) { if (InsertNodeBetween(peer_out_anchor, {in_data_anchor}, out_memcpy, cnt, cnt) != SUCCESS) {
GELOGE(FAILED, "Insert MemcpyAsync %s in while_body %s failed.", out_name.c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[Insert][MemcpyAsync] %s in while_body %s failed.", out_name.c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
cnt++; cnt++;
@@ -474,7 +482,9 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat
op_desc->GetName().c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(),
out_anchor->GetOwnerNode()->GetType().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][CastNode] %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());
return FAILED; return FAILED;
} }


@@ -496,8 +506,9 @@ Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::v
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed", 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(), src->GetOwnerNode()->GetName().c_str(), src->GetOwnerNode()->GetType().c_str(), src->GetIdx(),
insert_node->GetName().c_str(), insert_node->GetType().c_str(), input_index); insert_node->GetName().c_str(), insert_node->GetType().c_str(), input_index);
GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.",
src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index);
GELOGE(FAILED, "[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);
return FAILED; return FAILED;
} }
for (const auto &dst : dsts) { for (const auto &dst : dsts) {
@@ -511,7 +522,7 @@ Status SubgraphPass::InsertNodeBetween(const OutDataAnchorPtr &src, const std::v
dst->GetOwnerNode()->GetName().c_str(), dst->GetOwnerNode()->GetType().c_str(), dst->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, insert_node->GetName().c_str(), insert_node->GetType().c_str(), output_index,
dst->GetOwnerNode()->GetName().c_str(), dst->GetOwnerNode()->GetType().c_str(), dst->GetIdx()); 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][DataEdge] %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(),
insert_node->GetName().c_str(), output_index, insert_node->GetName().c_str(), output_index,


+ 23
- 21
ge/graph/passes/switch_data_edges_bypass.cc View File

@@ -52,8 +52,8 @@ std::vector<std::pair<NodePtr, InDataAnchorPtr>> GetOutDataNodesByIndex(const No
if (out_anchor == nullptr) { if (out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d out data anchor, check invalid", 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); node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(PARAM_INVALID, "Failed to get out data nodes of index %d from node %s, the anchor does not exists", index,
node->GetName().c_str());
GELOGE(PARAM_INVALID, "[Get][OutDataNodes] of index %d from node %s failed, the anchor does not exists",
index, node->GetName().c_str());
return {}; return {};
} }
std::vector<std::pair<NodePtr, InDataAnchorPtr>> nodes_and_anchors; std::vector<std::pair<NodePtr, InDataAnchorPtr>> nodes_and_anchors;
@@ -87,24 +87,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"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to add identity after node %s index %d, the op desc is null",
node->GetName().c_str(), index);
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, the op desc is nullptr");
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", 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); node_desc->GetName().c_str(), node_desc->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Failed to find the tensor by index %d from node %s, can not add the identity node", index,
node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][OutputDescPtr] failed, Node:%s(%s) has no index:%d output tensor",
node_desc->GetName().c_str(), node_desc->GetType().c_str(), index);
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", 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); node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d, the out anchor does not exists",
node->GetName().c_str(), index);
GELOGE(OUT_OF_MEMORY, "[Get][OutDataAnchor] failed, Node:%s(%s) has no index:%d out data anchor",
node->GetName().c_str(), node->GetType().c_str(), index);
return nullptr; return nullptr;
} }


@@ -112,7 +111,7 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {
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"); 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, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }
auto ret1 = identity_opdesc->AddInputDesc("x", *tensor); auto ret1 = identity_opdesc->AddInputDesc("x", *tensor);
@@ -122,7 +121,9 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) {
REPORT_CALL_ERROR("E19999", "Add input ouput desc to op:%s(%s) failed or add it to graph:%s failed", 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(), identity_opdesc->GetName().c_str(), identity_opdesc->GetType().c_str(),
node->GetOwnerComputeGraph()->GetName().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, "[Check][Param] 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());
return nullptr; return nullptr;
} }
(void)anchor->LinkTo(identity->GetInDataAnchor(0)); (void)anchor->LinkTo(identity->GetInDataAnchor(0));
@@ -136,31 +137,30 @@ 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"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, null op desc", node->GetName().c_str(),
index);
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, OpDesc in node is nullptr");
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", 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); node_desc->GetName().c_str(), node_desc->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Failed to find the tensor by index %d from node %s, can not add the memcpy node", index,
node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][InputDescPtr] failed, Node:%s(%s) has no index:%d input tensor",
node_desc->GetName().c_str(), node_desc->GetType().c_str(), index);
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", 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); node->GetName().c_str(), node->GetType().c_str(), index);
GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, the in anchor does not exists",
node->GetName().c_str(), index);
GELOGE(INTERNAL_ERROR, "[Get][InDataAnchor] failed, Node:%s(%s) has no index:%d in data anchor",
node->GetName().c_str(), node->GetType().c_str(), index);
return nullptr; return nullptr;
} }


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"); 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, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }
auto ret1 = memcpy_opdesc->AddInputDesc(*tensor); auto ret1 = memcpy_opdesc->AddInputDesc(*tensor);
@@ -170,7 +170,9 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) {
REPORT_CALL_ERROR("E19999", "Add input ouput desc to op:%s(%s) failed or add it to graph:%s failed", 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(), memcpy_opdesc->GetName().c_str(), memcpy_opdesc->GetType().c_str(),
node->GetOwnerComputeGraph()->GetName().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, "[Check][Param] 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());
return nullptr; return nullptr;
} }
(void)memcpy_node->GetOutDataAnchor(0)->LinkTo(anchor); (void)memcpy_node->GetOutDataAnchor(0)->LinkTo(anchor);
@@ -221,7 +223,7 @@ Status BypassSwitchOut(const NodePtr &switch_node, int out_index) {
Status SwitchDataEdgesBypass::Run(ComputeGraphPtr graph) { Status SwitchDataEdgesBypass::Run(ComputeGraphPtr graph) {
for (const auto &node : graph->GetDirectNode()) { for (const auto &node : graph->GetDirectNode()) {
auto ret = BypassSwitch(node); auto ret = BypassSwitch(node);
GE_CHK_STATUS_RET(ret, "By pass switch node %s failed", node->GetName().c_str())
GE_CHK_STATUS_RET(ret, "[Bypass][Switch] node %s failed", node->GetName().c_str())
} }
return SUCCESS; return SUCCESS;
} }
@@ -235,9 +237,9 @@ Status SwitchDataEdgesBypass::BypassSwitch(const NodePtr &node) {
} }


auto ret = BypassSwitchOut(node, SWITCH_FALSE_OUTPUT); auto ret = BypassSwitchOut(node, SWITCH_FALSE_OUTPUT);
GE_CHK_STATUS_RET(ret, "By pass switch node %s false output failed", node->GetName().c_str())
GE_CHK_STATUS_RET(ret, "[Bypass][Switch] node %s false output failed", node->GetName().c_str())
ret = BypassSwitchOut(node, SWITCH_TRUE_OUTPUT); ret = BypassSwitchOut(node, SWITCH_TRUE_OUTPUT);
GE_CHK_STATUS_RET(ret, "By pass switch node %s true output failed", node->GetName().c_str())
GE_CHK_STATUS_RET(ret, "[Bypass][Switch] node %s true output failed", node->GetName().c_str())


return SUCCESS; return SUCCESS;
} }


+ 15
- 6
ge/graph/passes/switch_dead_branch_elimination.cc View File

@@ -32,7 +32,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"); REPORT_INNER_ERROR("E19999", "Param tensor is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter tensor is nullptr.");
return false; return false;
} }
const uint8_t *data_ptr = tensor->GetData().data(); const uint8_t *data_ptr = tensor->GetData().data();
@@ -68,6 +68,8 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA
if (tensors.empty()) { if (tensors.empty()) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no weight, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no weight, check invalid",
pred_node->GetName().c_str(), pred_node->GetType().c_str()); pred_node->GetName().c_str(), pred_node->GetType().c_str());
GELOGE(FAILED, "[Check][Param] Node:%s(%s) has no weight",
pred_node->GetName().c_str(), pred_node->GetType().c_str());
return false; return false;
} }


@@ -76,7 +78,7 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA


if (node == nullptr) { if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
return false; return false;
} }
GELOGI("[%s] Inactive output index = %d", node->GetName().c_str(), inactive_output_index); GELOGI("[%s] Inactive output index = %d", node->GetName().c_str(), inactive_output_index);
@@ -96,7 +98,7 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre
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"); REPORT_INNER_ERROR("E19999", "Param node or active_out_data_anchor is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node or active_out_data_anchor is nullptr.");
return FAILED; return FAILED;
} }


@@ -110,6 +112,9 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed", 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(), pred_node->GetName().c_str(), pred_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Copy][InCtrlEdges] 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
@@ -124,7 +129,8 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre
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, 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()); 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, "[Check][Param] Out index:%zu of node:%s(%s) >= %zu.", out_index,
node->GetName().c_str(), node->GetType().c_str(), switch_io_map.size());
return FAILED; return FAILED;
} }
switch_io_map[out_index] = kDataInputIndex; switch_io_map[out_index] = kDataInputIndex;
@@ -134,12 +140,13 @@ 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"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Param [node] must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] Param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }


std::string op_type; std::string op_type;
GE_CHK_STATUS_RET(GetOriginalType(node, op_type), "Get original type failed");
GE_CHK_STATUS_RET(GetOriginalType(node, op_type),
"[Get][OriginalType] of node:%s failed", node->GetName().c_str());
if ((op_type != SWITCH) && (op_type != REFSWITCH)) { if ((op_type != SWITCH) && (op_type != REFSWITCH)) {
return SUCCESS; return SUCCESS;
} }
@@ -181,6 +188,8 @@ Status SwitchDeadBranchElimination::Run(NodePtr &node) {
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove inactive branch from node:%s(%s) to merge failed", REPORT_CALL_ERROR("E19999", "Remove inactive branch from node:%s(%s) to merge failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Remove][InactiveBranch] from node:%s(%s) to merge failed",
node->GetName().c_str(), node->GetType().c_str());
return ret; return ret;
} }




+ 16
- 10
ge/graph/passes/switch_logic_remove_pass.cc View File

@@ -47,7 +47,8 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index)
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", 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); 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, "[Get][InDataAnchor] failed, Node:%s(%s) has no index:%d in data anchor",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor(); auto pred_node_anchor = pred_in_anchor->GetPeerOutAnchor();
@@ -55,8 +56,8 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index)
REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d in data anchor, its peer anchor is nullptr, check invalid", 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); 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",
switch_node->GetName().c_str());
"[Get][PeerOutAnchor] failed, Node:%s(%s)'s index:%d in data anchor, its peer anchor is nullptr",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
auto pred_node = pred_node_anchor->GetOwnerNode(); auto pred_node = pred_node_anchor->GetOwnerNode();
@@ -64,8 +65,8 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index)
REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d in data anchor, its peer node is nullptr, check invalid", 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); 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",
switch_node->GetName().c_str());
"[Get][OwnerNode] failed, Node:%s(%s)'s index:%d in data anchor, its peer node is nullptr",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
pred_node_index.first = pred_node; pred_node_index.first = pred_node;
@@ -82,7 +83,7 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) {
PredNodeAndOut pred_node_and_out; PredNodeAndOut pred_node_and_out;
auto ret = GetPredNode(node, pred_node_and_out); auto ret = GetPredNode(node, pred_node_and_out);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to run switch logic remove pass, no pred node found from switch %s",
GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to run switch logic remove pass, no pred node found from switch %s",
node->GetName().c_str()); node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -97,14 +98,16 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) {
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, " 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); "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, "[Check][Param] Node:%s(%s)'s index:%d out data anchor, its peer anchors has nullptr",
node->GetName().c_str(), node->GetType().c_str(), i);
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, " 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); "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, "[Check][Param] Node:%s(%s)'s index:%d out data anchor, its peer nodes has nullptr",
node->GetName().c_str(), node->GetType().c_str(), i);
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
if (!IsSwitch(dst_node->GetType())) { if (!IsSwitch(dst_node->GetType())) {
@@ -113,7 +116,8 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) {
PredNodeAndOut pred_node_next_switch; PredNodeAndOut pred_node_next_switch;
ret = GetPredNode(dst_node, pred_node_next_switch); ret = GetPredNode(dst_node, pred_node_next_switch);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to run switch logic remove pass, no pred node found from switch %s",
GELOGE(INTERNAL_ERROR,
"[Check][Param] Failed to run switch logic remove pass, no pred node found from switch %s",
dst_node->GetName().c_str()); dst_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -153,8 +157,10 @@ 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",
REPORT_CALL_ERROR("E19999", "Remove inactivate branch from node:%s(%s) to merge failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str()); switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(FAILED, "[Remove][InactiveBranch] from node:%s(%s) to merge failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str());
return ret; return ret;
} }




+ 159
- 80
ge/graph/passes/switch_to_stream_switch_pass.cc View File

@@ -26,22 +26,28 @@ namespace ge {
Status SwitchToStreamSwitchPass::Run(ComputeGraphPtr graph) { Status SwitchToStreamSwitchPass::Run(ComputeGraphPtr graph) {
GELOGD("SwitchToStreamSwitchPass Enter"); GELOGD("SwitchToStreamSwitchPass Enter");


GE_CHK_STATUS_RET(CheckCycleDependence(graph), "Check cyclic dependence failed.");
GE_CHK_STATUS_RET(CheckCycleDependence(graph),
"[Check][CycleDependence] in graph:%s failed.", graph->GetName().c_str());
for (const auto &switch_node : switch_nodes_) { for (const auto &switch_node : switch_nodes_) {
GE_CHK_STATUS_RET(ReplaceSwitchNode(graph, switch_node), "Replace Switch by StreamSwitch failed.");
GE_CHK_STATUS_RET(ReplaceSwitchNode(graph, switch_node),
"[Replace][Switch] by StreamSwitch in graph:%s failed.", graph->GetName().c_str());
} }
GE_CHK_STATUS_RET(CombineSwitchNode(graph), "Combine StreamSwitch nodes failed.");
GE_CHK_STATUS_RET(CombineSwitchNode(graph),
"[Combine][SwitchNode] in graph:%s failed.", graph->GetName().c_str());


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


GELOGD("SwitchToStreamSwitchPass Leave"); GELOGD("SwitchToStreamSwitchPass Leave");
@@ -72,7 +78,8 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra
std::string type; std::string type;
std::unordered_map<NodePtr, std::vector<NodePtr>> cond_switch_map; std::unordered_map<NodePtr, std::vector<NodePtr>> cond_switch_map;
for (const NodePtr &node : graph->GetDirectNode()) { for (const NodePtr &node : graph->GetDirectNode()) {
GE_CHK_STATUS_RET(GetOriginalType(node, type), "Get node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(node, type),
"[Get][OriginalType] failed, graph:%s.", graph->GetName().c_str());
if ((type != SWITCH) && (type != REFSWITCH)) { if ((type != SWITCH) && (type != REFSWITCH)) {
continue; continue;
} }
@@ -81,7 +88,7 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra
OutDataAnchorPtr peer_out_anchor = in_cond_anchor->GetPeerOutAnchor(); OutDataAnchorPtr peer_out_anchor = in_cond_anchor->GetPeerOutAnchor();
GE_CHECK_NOTNULL(peer_out_anchor); GE_CHECK_NOTNULL(peer_out_anchor);
if (FindSwitchCondInput(peer_out_anchor) != SUCCESS) { if (FindSwitchCondInput(peer_out_anchor) != SUCCESS) {
GELOGE(FAILED, "Find pred_input for switch_node %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Find][PredInput] for switch_node %s failed.", node->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -159,7 +166,7 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
OutDataAnchorPtr peer_data_anchor = nullptr; OutDataAnchorPtr peer_data_anchor = nullptr;
OutDataAnchorPtr peer_cond_anchor = nullptr; OutDataAnchorPtr peer_cond_anchor = nullptr;
GE_CHK_BOOL_EXEC(BypassSwitchNode(switch_node, peer_data_anchor, peer_cond_anchor) == SUCCESS, return FAILED, GE_CHK_BOOL_EXEC(BypassSwitchNode(switch_node, peer_data_anchor, peer_cond_anchor) == SUCCESS, return FAILED,
"Bypass switch node %s failed.", switch_node->GetName().c_str());
"[Bypass][SwitchNode] %s failed.", switch_node->GetName().c_str());
GE_CHECK_NOTNULL(peer_data_anchor); GE_CHECK_NOTNULL(peer_data_anchor);
GE_CHECK_NOTNULL(peer_cond_anchor); GE_CHECK_NOTNULL(peer_cond_anchor);
OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc(); OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc();
@@ -170,7 +177,8 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
"but %s exactly", switch_node->GetName().c_str(), switch_node->GetType().c_str(), "but %s exactly", switch_node->GetName().c_str(), switch_node->GetType().c_str(),
TypeUtils::DataTypeToSerialString(cond_data_type).c_str()); TypeUtils::DataTypeToSerialString(cond_data_type).c_str());
return FAILED, return FAILED,
"pred_input of Switch only support DT_BOOL data_type, but %s exactly.",
"[Check][Param] 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()); TypeUtils::DataTypeToSerialString(cond_data_type).c_str());


OpDescPtr switch_desc = switch_node->GetOpDesc(); OpDescPtr switch_desc = switch_node->GetOpDesc();
@@ -184,31 +192,39 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
for (const auto &peer_in_anchor : out_data_anchor->GetPeerAnchors()) { for (const auto &peer_in_anchor : out_data_anchor->GetPeerAnchors()) {
GE_IF_BOOL_EXEC(stream_switch == nullptr, { GE_IF_BOOL_EXEC(stream_switch == nullptr, {
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][StreamSwitchNode] for switch node:%s in graph:%s failed.",
switch_node->GetName().c_str(), graph->GetName().c_str());
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", REPORT_CALL_ERROR("E19999", "Set switch true branch flag from node:%s(%s) failed",
stream_switch->GetName().c_str(), stream_switch->GetType().c_str()); stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "SetSwitchTrueBranchFlag for node %s failed.", stream_switch->GetName().c_str());
GELOGE(FAILED, "[Set][SwitchTrueBranchFlag] for node %s failed.", stream_switch->GetName().c_str());
return FAILED; return FAILED;
} }
if (MarkBranches(peer_cond_anchor, stream_switch, true_branch_flag) != SUCCESS) { if (MarkBranches(peer_cond_anchor, stream_switch, true_branch_flag) != SUCCESS) {
GELOGE(FAILED, "Mark branches for stream_switch %s failed.", stream_switch->GetName().c_str());
GELOGE(FAILED, "[Mark][Branches] for stream_switch %s failed.", stream_switch->GetName().c_str());
return FAILED; return FAILED;
} }


if (!cyclic_flag) { if (!cyclic_flag) {
GE_CHK_STATUS(GraphUtils::AddEdge(peer_data_anchor->GetOwnerNode()->GetOutControlAnchor(), GE_CHK_STATUS(GraphUtils::AddEdge(peer_data_anchor->GetOwnerNode()->GetOutControlAnchor(),
stream_switch->GetInControlAnchor()), stream_switch->GetInControlAnchor()),
"StreamSwitch node add ctl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
peer_data_anchor->GetOwnerNode()->GetName().c_str(), stream_switch->GetName().c_str());
} }
}); });


GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor), "Remove Switch data output failed.");
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor),
"[Remove][Edge] between %s and %s failed.",
switch_node->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());


NodePtr out_node = peer_in_anchor->GetOwnerNode(); NodePtr out_node = peer_in_anchor->GetOwnerNode();
GE_CHK_STATUS(GraphUtils::AddEdge(peer_data_anchor, peer_in_anchor), "StreamSwitch node add edge failed.");
GE_CHK_STATUS(GraphUtils::AddEdge(peer_data_anchor, peer_in_anchor),
"[Add][Edge] between %s and %s failed.",
peer_data_anchor->GetOwnerNode()->GetName().c_str(), out_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(stream_switch->GetOutControlAnchor(), out_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(stream_switch->GetOutControlAnchor(), out_node->GetInControlAnchor()),
"StreamSwitch node add ctl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
stream_switch->GetName().c_str(), out_node->GetName().c_str());
out_node_list.insert(out_node->GetName()); out_node_list.insert(out_node->GetName());
} }


@@ -218,7 +234,7 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
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(), 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()); stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "SetOriginalNodeName for node %s failed.", stream_switch->GetName().c_str());
GELOGE(FAILED, "[Set][OriginalNodeName] for node %s failed.", stream_switch->GetName().c_str());
return FAILED; return FAILED;
} }
}); });
@@ -248,8 +264,10 @@ Status SwitchToStreamSwitchPass::BypassSwitchNode(const NodePtr &switch_node, Ou
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx(), peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx(),
switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx); switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx);
GELOGE(FAILED, "Remove data edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
switch_node->GetName().c_str());
GELOGE(FAILED, "[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);
return FAILED; return FAILED;
} }


@@ -283,7 +301,7 @@ Status SwitchToStreamSwitchPass::FindSwitchCondInput(OutDataAnchorPtr &peer_cond
tmp_node = peer_cond_anchor->GetOwnerNode(); tmp_node = peer_cond_anchor->GetOwnerNode();
} }


GE_CHK_STATUS_RET(GetOriginalType(tmp_node, type), "Get node type failed.");
GE_CHK_STATUS_RET(GetOriginalType(tmp_node, type), "[Get][OriginalType] failed.");
pass_flag = ((type == SWITCH) || (type == REFSWITCH)); pass_flag = ((type == SWITCH) || (type == REFSWITCH));
} }


@@ -304,13 +322,13 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
OpDescPtr switch_op_desc = switch_node->GetOpDesc(); OpDescPtr switch_op_desc = switch_node->GetOpDesc();
GE_CHK_BOOL_EXEC(switch_op_desc != nullptr, GE_CHK_BOOL_EXEC(switch_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
return nullptr, "OpDesc of Switch node is invalid.");
return nullptr, "[Get][OpDesc] failed, 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", 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->GetInputsSize(),
switch_op_desc->GetName().c_str(), switch_op_desc->GetType().c_str(), SWITCH_INPUT_NUM); switch_op_desc->GetName().c_str(), switch_op_desc->GetType().c_str(), SWITCH_INPUT_NUM);
GELOGE(FAILED, "Switch input param invalid, input_size=%lu, should be %u.", switch_op_desc->GetInputsSize(),
SWITCH_INPUT_NUM);
GELOGE(FAILED, "[Check][Param] Switch input param invalid, input_size=%lu, should be %u.",
switch_op_desc->GetInputsSize(), SWITCH_INPUT_NUM);
return nullptr; return nullptr;
}); });


@@ -319,7 +337,7 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
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"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamSwitch:%s.", node_name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }


@@ -343,7 +361,9 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
REPORT_CALL_ERROR("E19999", "Set Attr:%s or Attr:%s to op:%s(%s) failed", 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(), ATTR_NAME_SWITCH_DATA_TYPE.c_str(), ATTR_NAME_STREAM_SWITCH_COND.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set int failed");
GELOGE(INTERNAL_ERROR, "[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());
return nullptr; return nullptr;
} }


@@ -354,20 +374,25 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr, return nullptr,
"Create StreamSwitch node: add input desc failed.");
"[Add][InputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(input_desc) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(input_desc) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr, return nullptr,
"Create StreamSwitch node: add input desc failed.");
"[Add][InputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());


NodePtr stream_switch = graph->AddNode(op_desc); NodePtr stream_switch = graph->AddNode(op_desc);
GE_CHK_BOOL_EXEC(stream_switch != nullptr, GE_CHK_BOOL_EXEC(stream_switch != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr, "Insert StreamSwitch node failed.");
return nullptr,
"[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
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.");
"[Add][Edge] between %s and %s failed.",
peer_cond_anchor->GetOwnerNode()->GetName().c_str(), stream_switch->GetName().c_str());


int64_t group_index = -1; int64_t group_index = -1;
bool force_unknown = AttrUtils::GetInt(switch_node->GetOpDesc(), ATTR_NAME_CONTROL_FLOW_GROUP, group_index); bool force_unknown = AttrUtils::GetInt(switch_node->GetOpDesc(), ATTR_NAME_CONTROL_FLOW_GROUP, group_index);
@@ -402,7 +427,8 @@ Status SwitchToStreamSwitchPass::MarkBranches(const OutDataAnchorPtr &peer_cond_
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", 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); 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][Param] switch group size:%zu not equal to %u, group_id:%ld",
switch_group_it->second.size(), SWITCH_OUTPUT_NUM, switch_group_id);
return FAILED; return FAILED;
}); });
switch_group_it->second[index].emplace_back(stream_switch); switch_group_it->second[index].emplace_back(stream_switch);
@@ -477,16 +503,20 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph)
GELOGI("CombineSwitchNode: cond_node=%s.", cond_node->GetName().c_str()); GELOGI("CombineSwitchNode: cond_node=%s.", cond_node->GetName().c_str());


NodePtr cast_node = CreateCastOp(graph, peer_cond_anchor); NodePtr cast_node = CreateCastOp(graph, peer_cond_anchor);
GE_CHK_BOOL_EXEC(cast_node != nullptr, return FAILED, "Create cast_node failed.");
GE_CHK_BOOL_EXEC(cast_node != nullptr, return FAILED,
"[Create][CastOp] for cond_node:%s failed.", cond_node->GetName().c_str());


NodePtr active_node = CreateActiveNode(graph, cond_node); NodePtr active_node = CreateActiveNode(graph, cond_node);
GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed.");
GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED,
"[Create][StreamActiveNode] for cond node:%s failed.", cond_node->GetName().c_str());
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.");
"[Add][ControlEdge] between %s and %s failed.",
cond_node->GetName().c_str(), active_node->GetName().c_str());
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", 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()); 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][ActiveLabelList] %s to op:%s(%s) failed.",
cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -505,38 +535,48 @@ 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();
OpDescPtr switch_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc);
// set stream_label // set stream_label
if (SetStreamLabel(stream_switch, cast_node->GetName()) != SUCCESS) { if (SetStreamLabel(stream_switch, cast_node->GetName()) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
cast_node->GetName().c_str(), stream_switch->GetName().c_str(), cast_node->GetName().c_str(), stream_switch->GetName().c_str(),
stream_switch->GetType().c_str()); stream_switch->GetType().c_str());
GELOGE(FAILED, "Set stream label failed.");
GELOGE(FAILED, "[Set][StreamLabel] %s to op:%s(%s) failed", cast_node->GetName().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
return FAILED; return FAILED;
} }
OpDescPtr switch_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc);
switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f"))); switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f")));
stream_switch_nodes_.emplace_back(stream_switch); stream_switch_nodes_.emplace_back(stream_switch);


// 0_input: original pred input, 1_input: constant node // 0_input: original pred input, 1_input: constant node
GE_CHK_STATUS_RET(AddConstNode(graph, stream_switch), "Add const node failed.");
GE_CHK_STATUS_RET(AddConstNode(graph, stream_switch),
"[Add][ConstNode] failed, stream_switch:%s.", stream_switch->GetName().c_str());
GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_cond_anchor, stream_switch->GetInDataAnchor(0)), GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_cond_anchor, stream_switch->GetInDataAnchor(0)),
"StreamSwitch remove data edge failed.");
"[Remove][Edge] between %s and %s failed.",
peer_cond_anchor->GetOwnerNode()->GetName().c_str(), stream_switch->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutDataAnchor(0), stream_switch->GetInDataAnchor(0)), GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutDataAnchor(0), stream_switch->GetInDataAnchor(0)),
"Cast add data edge failed.");
"[Add][Edge] between %s and %s failed.",
cast_node->GetName().c_str(), stream_switch->GetName().c_str());


MarkForceUnknownShape(stream_switch, is_unknown_shape, group_index); MarkForceUnknownShape(stream_switch, is_unknown_shape, group_index);
for (const NodePtr &node : switch_list) { for (const NodePtr &node : switch_list) {
GE_IF_BOOL_EXEC(node != stream_switch, { GE_IF_BOOL_EXEC(node != stream_switch, {
GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_cond_anchor, node->GetInDataAnchor(0)), GE_CHK_STATUS(GraphUtils::RemoveEdge(peer_cond_anchor, node->GetInDataAnchor(0)),
"StreamSwitch remove data edge failed.");
"[Remove][Edge] between %s and %s failed.",
peer_cond_anchor->GetOwnerNode()->GetName().c_str(), node->GetName().c_str());
}); });
GE_CHK_STATUS(ModifySwitchInCtlEdges(node, cast_node, same_cond_switch), "ModifySwitchInCtlEdges failed.");
GE_CHK_STATUS(ModifySwitchOutCtlEdges(node, stream_switch, active_node), "ModifySwitchOutCtlEdges failed.");
GE_CHK_STATUS(ModifySwitchInCtlEdges(node, cast_node, same_cond_switch),
"[Modify][SwitchInCtlEdges] failed, switch node:%s, cast node:%s.",
node->GetName().c_str(), cast_node->GetName().c_str());
GE_CHK_STATUS(ModifySwitchOutCtlEdges(node, stream_switch, active_node),
"[Modify][SwitchOutCtlEdges] failed, node:%s, stream_switch:%s.",
node->GetName().c_str(), stream_switch->GetName().c_str());
} }


GE_CHK_STATUS(GraphUtils::AddEdge(active_node->GetOutControlAnchor(), stream_switch->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(active_node->GetOutControlAnchor(), stream_switch->GetInControlAnchor()),
"StreamActive add ctl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
active_node->GetName().c_str(), stream_switch->GetName().c_str());
} }
} }
} }
@@ -555,7 +595,7 @@ NodePtr SwitchToStreamSwitchPass::CreateActiveNode(const ComputeGraphPtr &graph,
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"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, StreamActive:%s.", node_name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }


@@ -563,12 +603,15 @@ NodePtr SwitchToStreamSwitchPass::CreateActiveNode(const ComputeGraphPtr &graph,
GE_CHK_BOOL_EXEC(active_node != nullptr, GE_CHK_BOOL_EXEC(active_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr, "Create StreamActive node failed.");
return nullptr,
"[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());


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", 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()); 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][SwitchBranchNodeLabel] %s to node:%s(%s) failed",
node_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return nullptr); return nullptr);


return active_node; return active_node;
@@ -582,14 +625,15 @@ NodePtr SwitchToStreamSwitchPass::CreateActiveNode(const ComputeGraphPtr &graph,
/// ///
NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, const OutDataAnchorPtr &peer_cond_anchor) { NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, const OutDataAnchorPtr &peer_cond_anchor) {
OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc(); OpDescPtr cond_desc = peer_cond_anchor->GetOwnerNode()->GetOpDesc();
GE_CHK_BOOL_EXEC(cond_desc != nullptr, return nullptr, "Get cond_desc failed.");
GE_CHK_BOOL_EXEC(cond_desc != nullptr, return nullptr,
"[Get][OpDesc] failed, opdesc of Param peer_cond_anchor's owner node is nullptr.");


const std::string &cast_name = CheckDuplicateName(cond_desc->GetName() + "_" + CAST); const std::string &cast_name = CheckDuplicateName(cond_desc->GetName() + "_" + CAST);
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"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Cast:%s.", cast_name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }
if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, (int64_t)DT_BOOL) && if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, (int64_t)DT_BOOL) &&
@@ -600,8 +644,10 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(), CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(),
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(), CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(),
cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
GELOGE(FAILED, "Set CAST_ATTR_SRCT or CAST_ATTR_DSTT or CAST_ATTR_DST_TYPE or CAST_ATTR_TRUNCATE failed, node: %s.",
cast_name.c_str());
GELOGE(FAILED, "[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());
return nullptr; return nullptr;
} }


@@ -611,22 +657,29 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
return nullptr, return nullptr,
"Cast_node add input desc failed.");
"[Add][InputDesc] to op:%s(%s) failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
tensor_desc.SetDataType(DT_INT32); tensor_desc.SetDataType(DT_INT32);
GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS, GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
return nullptr, return nullptr,
"Cast_node add output desc failed.");
"[Add][OutputDesc] to op:%s(%s) failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());


NodePtr cast_node = graph->AddNode(cast_desc); NodePtr cast_node = graph->AddNode(cast_desc);
GE_CHK_BOOL_EXEC(cast_node != nullptr, GE_CHK_BOOL_EXEC(cast_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(), cast_desc->GetName().c_str(), cast_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
return nullptr, "Create cast_node failed.");
return nullptr,
"[Add][Node] %s(%s) to graph:%s failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(),
graph->GetName().c_str());
// 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)),
"[Add][Edge] between %s and %s failed.",
cond_desc->GetName().c_str(), cast_node->GetName().c_str());


return cast_node; return cast_node;
} }
@@ -646,14 +699,15 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons
ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED, return FAILED,
"StreamSwitch get attr TRUE_BRANCH_STREAM failed.");
"[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());


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"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Constant:%s.", const_node_name.c_str());
GELOGE(FAILED, "New OpDesc failed.");
return FAILED; return FAILED;
} }


@@ -663,27 +717,34 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons
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"); REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "Create tensor failed.");
GELOGE(FAILED, "[New][GeTensor] failed.");
return FAILED; return FAILED;
} }
GE_CHK_BOOL_EXEC(AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value), 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(), 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()); const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return FAILED);
return FAILED,
"[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());
GE_CHK_BOOL_EXEC(const_op_desc->AddOutputDesc(data_desc) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(const_op_desc->AddOutputDesc(data_desc) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str()); const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return FAILED, return FAILED,
"Create Const op: add output desc failed.");
"[Add][OutputDesc] to op:%s(%s) failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());


NodePtr const_node = graph->AddNode(const_op_desc); NodePtr const_node = graph->AddNode(const_op_desc);
GE_CHK_BOOL_EXEC(const_node != nullptr, GE_CHK_BOOL_EXEC(const_node != nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str(), const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
return FAILED, "Insert Const node failed.");
return FAILED,
"[Add][Node] %s(%s) to graph:%s failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str(),
graph->GetName().c_str());
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.");
"[Add][Edge] between %s and %s failed.",
const_node->GetName().c_str(), stream_switch->GetName().c_str());


return SUCCESS; return SUCCESS;
} }
@@ -705,22 +766,26 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no
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(), 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()); 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] %s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(),
switch_desc->GetName().c_str(), switch_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


for (const NodePtr &in_ctrl_node : switch_node->GetInControlNodes()) { for (const NodePtr &in_ctrl_node : switch_node->GetInControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), switch_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), switch_node->GetInControlAnchor()),
"Remove ctl edge failed.");
"[Remove][ControlEdge] between %s and %s failed.",
in_ctrl_node->GetName().c_str(), switch_node->GetName().c_str());
GE_IF_BOOL_EXEC(!in_ctrl_node->GetOutControlAnchor()->IsLinkedWith(cast_node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!in_ctrl_node->GetOutControlAnchor()->IsLinkedWith(cast_node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(in_ctrl_node->GetOutControlAnchor(), cast_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(in_ctrl_node->GetOutControlAnchor(), cast_node->GetInControlAnchor()),
"Add ctl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
in_ctrl_node->GetName().c_str(), cast_node->GetName().c_str());
}); });


GE_IF_BOOL_EXEC(in_ctrl_node->GetType() != STREAMSWITCH, continue); GE_IF_BOOL_EXEC(in_ctrl_node->GetType() != STREAMSWITCH, continue);
if (same_cond_switch.count(in_ctrl_node) > 0) { if (same_cond_switch.count(in_ctrl_node) > 0) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), cast_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(in_ctrl_node->GetOutControlAnchor(), cast_node->GetInControlAnchor()),
"Remove ctl edge failed.");
"[Remove][ControlEdge] between %s and %s failed.",
in_ctrl_node->GetName().c_str(), cast_node->GetName().c_str());
continue; continue;
} }


@@ -728,7 +793,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no
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", 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()); 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, "[Check][Param] StreamSwitch node %s not found in switch_node_map_.",
in_ctrl_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });
auto find_res2 = find_res1->second.find(orig_switch_name); auto find_res2 = find_res1->second.find(orig_switch_name);
@@ -758,27 +824,31 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
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", 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()); 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, "[Check][Param] 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", 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()); 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, "[Check][Param] true_nodes of StreamSwitch node %s is empty.",
switch_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });


for (const NodePtr &node : switch_node->GetOutControlNodes()) { for (const NodePtr &node : switch_node->GetOutControlNodes()) {
GE_CHK_STATUS(GraphUtils::RemoveEdge(switch_node->GetOutControlAnchor(), node->GetInControlAnchor()),
"Remove ctl edge failed.");
OpDescPtr op_desc = node->GetOpDesc(); OpDescPtr op_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(op_desc);
GE_CHK_STATUS(GraphUtils::RemoveEdge(switch_node->GetOutControlAnchor(), node->GetInControlAnchor()),
"[Remove][ControlEdge] between %s and %s failed.",
switch_node->GetName().c_str(), node->GetName().c_str());
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(), 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()); 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] %s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
}); });
@@ -786,13 +856,17 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
auto active_out_ctrl_anchor = active_node->GetOutControlAnchor(); auto active_out_ctrl_anchor = active_node->GetOutControlAnchor();
GE_CHECK_NOTNULL(active_out_ctrl_anchor); GE_CHECK_NOTNULL(active_out_ctrl_anchor);
GE_IF_BOOL_EXEC(!active_out_ctrl_anchor->IsLinkedWith(node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!active_out_ctrl_anchor->IsLinkedWith(node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(active_out_ctrl_anchor, node->GetInControlAnchor()), "Add ctl edge failed.");
GE_CHK_STATUS(GraphUtils::AddEdge(active_out_ctrl_anchor, node->GetInControlAnchor()),
"[Add][ControlEdge] between %s and %s failed.",
active_node->GetName().c_str(), node->GetName().c_str());
}); });
} else { } else {
auto switch_out_ctrl_anchor = stream_switch->GetOutControlAnchor(); auto switch_out_ctrl_anchor = stream_switch->GetOutControlAnchor();
GE_CHECK_NOTNULL(switch_out_ctrl_anchor); GE_CHECK_NOTNULL(switch_out_ctrl_anchor);
GE_IF_BOOL_EXEC(!switch_out_ctrl_anchor->IsLinkedWith(node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!switch_out_ctrl_anchor->IsLinkedWith(node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(switch_out_ctrl_anchor, node->GetInControlAnchor()), "Add ctl edge failed.");
GE_CHK_STATUS(GraphUtils::AddEdge(switch_out_ctrl_anchor, node->GetInControlAnchor()),
"[Add][ControlEdge] between %s and %s failed.",
stream_switch->GetName().c_str(), node->GetName().c_str());
}); });
} }
} }
@@ -835,26 +909,31 @@ void SwitchToStreamSwitchPass::MoveCtrlEdges(const NodePtr &old_node, const Node
for (const auto &out_node : old_node->GetOutAllNodes()) { for (const auto &out_node : old_node->GetOutAllNodes()) {
GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(out_node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(out_node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, out_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, out_node->GetInControlAnchor()),
"Add in ctrl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
in_node->GetName().c_str(), out_node->GetName().c_str());
}); });
} }
} else { } else {
GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(new_node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(new_node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, new_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(out_ctrl_anchor, new_node->GetInControlAnchor()),
"Add in ctrl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
in_node->GetName().c_str(), new_node->GetName().c_str());
}); });
} }
GE_CHK_STATUS(GraphUtils::RemoveEdge(out_ctrl_anchor, old_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(out_ctrl_anchor, old_node->GetInControlAnchor()),
"Remove in ctrl edge failed.");
"[Remove][ControlEdge] between %s and %s failed.",
in_node->GetName().c_str(), old_node->GetName().c_str());
} }


for (const NodePtr &out_node : old_node->GetOutControlNodes()) { for (const NodePtr &out_node : old_node->GetOutControlNodes()) {
GE_IF_BOOL_EXEC(!new_node->GetOutControlAnchor()->IsLinkedWith(out_node->GetInControlAnchor()), { GE_IF_BOOL_EXEC(!new_node->GetOutControlAnchor()->IsLinkedWith(out_node->GetInControlAnchor()), {
GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), out_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(new_node->GetOutControlAnchor(), out_node->GetInControlAnchor()),
"Add out ctrl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
new_node->GetName().c_str(), out_node->GetName().c_str());
}); });
GE_CHK_STATUS(GraphUtils::RemoveEdge(old_node->GetOutControlAnchor(), out_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::RemoveEdge(old_node->GetOutControlAnchor(), out_node->GetInControlAnchor()),
"Remove out ctrl edge failed.");
"[Remove][ControlEdge] between %s and %s failed.",
old_node->GetName().c_str(), out_node->GetName().c_str());
} }
} }
} // namespace ge } // namespace ge

+ 2
- 2
ge/graph/passes/transop_breadth_fusion_pass.cc View File

@@ -32,7 +32,7 @@ Status TransOpBreadthFusionPass::Run(ge::ComputeGraphPtr graph) {
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()); 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, "[Call][TopologicalSorting] for graph:%s failed.", graph->GetName().c_str());
return ret_topo; return ret_topo;
} }


@@ -63,7 +63,7 @@ std::string TransOpBreadthFusionPass::GetNodeId(const int anchor_index, const No


GE_IF_BOOL_EXEC(node == nullptr || node->GetOpDesc() == nullptr, GE_IF_BOOL_EXEC(node == nullptr || node->GetOpDesc() == nullptr,
REPORT_INNER_ERROR("E19999", "Param node or its op_desc is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param node or its op_desc is nullptr, check invalid");
GELOGE(FAILED, "node is null"); return "");
GELOGE(FAILED, "[Check][Param] Param node or its op_desc is nullptr"); 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) {


+ 36
- 20
ge/graph/passes/transop_depth_fusion_pass.cc View File

@@ -44,7 +44,7 @@ graphStatus TransOpDepthFusionPass::Run(ComputeGraphPtr graph) {
GE_CHECK_NOTNULL(out_anchor); GE_CHECK_NOTNULL(out_anchor);
for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) {
if (RecursiveInDepth(peer_in_anchor, graph) != GRAPH_SUCCESS) { if (RecursiveInDepth(peer_in_anchor, graph) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Recursive failed, root node is: %s, type: %s", node->GetName().c_str(),
GELOGE(INTERNAL_ERROR, "[Call][RecursiveInDepth] failed, root node is:%s, type:%s", node->GetName().c_str(),
node->GetType().c_str()); node->GetType().c_str());
} }
} }
@@ -83,7 +83,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"); REPORT_INNER_ERROR("E19999", "Param dst_in_anchor related node info has nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] Param dst_in_anchor related node info has nullptr.");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
auto node = dst_in_anchor->GetOwnerNode(); auto node = dst_in_anchor->GetOwnerNode();
@@ -98,12 +98,15 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_
auto out_anchor = node->GetOutDataAnchor(0); auto out_anchor = node->GetOutDataAnchor(0);
GE_CHECK_NOTNULL(out_anchor); GE_CHECK_NOTNULL(out_anchor);
auto in_anchors = out_anchor->GetPeerInDataAnchors(); auto in_anchors = out_anchor->GetPeerInDataAnchors();
GE_CHK_STATUS_RET(RemoveNode(node, graph), "remove edge failed");
GE_CHK_STATUS_RET(RemoveNode(node, graph),
"[Remove][Node] %s from graph:%s failed", node->GetName().c_str(), graph->GetName().c_str());
GELOGI("remove node: %s, type: %s.", node->GetName().c_str(), node->GetType().c_str()); GELOGI("remove node: %s, type: %s.", node->GetName().c_str(), node->GetType().c_str());
for (auto &in_anchor : in_anchors) { for (auto &in_anchor : in_anchors) {
GE_CHECK_NOTNULL(in_anchor); GE_CHECK_NOTNULL(in_anchor);
GE_CHK_STATUS_RET(UpdateSrcAttr(in_anchor->GetPeerOutAnchor(), out_anchor, in_anchor), "UpdateSrcAttr failed");
GE_CHK_STATUS_RET(RecursiveInDepth(in_anchor, graph), "RecursiveInDepth failed");
GE_CHK_STATUS_RET(UpdateSrcAttr(in_anchor->GetPeerOutAnchor(), out_anchor, in_anchor),
"[Update][SrcAttr] failed");
GE_CHK_STATUS_RET(RecursiveInDepth(in_anchor, graph),
"[Call][RecursiveInDepth] failed, graph:%s", graph->GetName().c_str());
} }
} else if (trans_op_.empty() || !DescAreSymmetry(trans_op_.top(), node)) { } else if (trans_op_.empty() || !DescAreSymmetry(trans_op_.top(), node)) {
GELOGD("node: %s, type: %s can't be offset, push to trans_op_", node->GetName().c_str(), node->GetType().c_str()); GELOGD("node: %s, type: %s can't be offset, push to trans_op_", node->GetName().c_str(), node->GetType().c_str());
@@ -112,11 +115,13 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_
auto out_anchor = node->GetOutDataAnchor(0); auto out_anchor = node->GetOutDataAnchor(0);
GE_CHECK_NOTNULL(out_anchor); GE_CHECK_NOTNULL(out_anchor);
for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) { for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
GE_CHK_STATUS_RET(RecursiveInDepth(in_anchor, graph), "RecursiveInDepth failed");
GE_CHK_STATUS_RET(RecursiveInDepth(in_anchor, graph),
"[Call][RecursiveInDepth] failed, graph:%s", graph->GetName().c_str());
} }


if (node->GetOutDataNodesSize() == 0) { if (node->GetOutDataNodesSize() == 0) {
GE_CHK_STATUS_RET(RemoveNode(node, graph), "remove node failed");
GE_CHK_STATUS_RET(RemoveNode(node, graph),
"[Remove][Node] %s from graph:%s failed", node->GetName().c_str(), graph->GetName().c_str());
GELOGI("backtracking, trans op: %s, type: %s will be removed", node->GetName().c_str(), node->GetType().c_str()); GELOGI("backtracking, trans op: %s, type: %s will be removed", node->GetName().c_str(), node->GetType().c_str());
} }
GELOGD("backtracking, trans_op_ fall back. pop node: %s, type: %s.", trans_op_.top()->GetName().c_str(), GELOGD("backtracking, trans_op_ fall back. pop node: %s, type: %s.", trans_op_.top()->GetName().c_str(),
@@ -136,7 +141,7 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_
auto new_out_anchor = trans_op_.top()->GetInDataAnchor(0)->GetPeerOutAnchor(); auto new_out_anchor = trans_op_.top()->GetInDataAnchor(0)->GetPeerOutAnchor();
GE_CHECK_NOTNULL(new_out_anchor); GE_CHECK_NOTNULL(new_out_anchor);
GE_IF_BOOL_EXEC(RelinkEdges(new_out_anchor, old_out_anchor, in_data_anchor) != GRAPH_SUCCESS, GE_IF_BOOL_EXEC(RelinkEdges(new_out_anchor, old_out_anchor, in_data_anchor) != GRAPH_SUCCESS,
GELOGE(FAILED, "RelinkEdges fail.");
GELOGE(FAILED, "[Relink][Edges] failed.");
return FAILED) return FAILED)
auto out_anchor = node->GetOutDataAnchor(0); auto out_anchor = node->GetOutDataAnchor(0);
GE_CHECK_NOTNULL(out_anchor); GE_CHECK_NOTNULL(out_anchor);
@@ -145,13 +150,16 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_
GELOGD("begin offset,trans_op_ pop node: %s, type: %s.", trans_op_.top()->GetName().c_str(), GELOGD("begin offset,trans_op_ pop node: %s, type: %s.", trans_op_.top()->GetName().c_str(),
trans_op_.top()->GetType().c_str()); trans_op_.top()->GetType().c_str());
GELOGI("the offset node : %s, type: %s will be removed.", node->GetName().c_str(), node->GetType().c_str()); GELOGI("the offset node : %s, type: %s will be removed.", node->GetName().c_str(), node->GetType().c_str());
GE_CHK_STATUS_RET(RemoveNode(node, graph), "remove node failed");
GE_CHK_STATUS_RET(RemoveNode(node, graph),
"[Remove][Node] %s from graph:%s failed", node->GetName().c_str(), graph->GetName().c_str());
trans_op_.pop(); trans_op_.pop();


for (const auto &in_anchor : in_anchors) { for (const auto &in_anchor : in_anchors) {
GE_CHECK_NOTNULL(in_anchor); GE_CHECK_NOTNULL(in_anchor);
GE_CHK_STATUS_RET(UpdateSrcAttr(in_anchor->GetPeerOutAnchor(), out_anchor, in_anchor), "UpdateSrcAttr failed");
GE_CHK_STATUS_RET(RecursiveInDepth(in_anchor, graph), "RecursiveInDepth failed");
GE_CHK_STATUS_RET(UpdateSrcAttr(in_anchor->GetPeerOutAnchor(), out_anchor, in_anchor),
"[Update][SrcAttr] failed");
GE_CHK_STATUS_RET(RecursiveInDepth(in_anchor, graph),
"[Call][RecursiveInDepth] failed, graph:%s", graph->GetName().c_str());
} }


GELOGD("backtracking, trans_op_ push node: %s, type: %s.", offset_op_.top()->GetName().c_str(), GELOGD("backtracking, trans_op_ push node: %s, type: %s.", offset_op_.top()->GetName().c_str(),
@@ -259,17 +267,23 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_
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"); 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, "[Check][Param] 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"); 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, "[Check][Param] anchor's owner node has nullptr");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(old_out_anchor, in_data_anchor), "remove edge failed");
GE_CHK_STATUS_RET(GraphUtils::AddEdge(new_out_anchor, in_data_anchor), "add edge failed");
GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(old_out_anchor, in_data_anchor),
"[Remove][Edge] between %s and %s failed",
old_out_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str());
GE_CHK_STATUS_RET(GraphUtils::AddEdge(new_out_anchor, in_data_anchor),
"[Add][Edge] between %s and %s failed",
new_out_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str());
GELOGD( GELOGD(
"relink edges before remove node, remove data edge between node: %s, " "relink edges before remove node, remove data edge between node: %s, "
"type: %s and node: %s, type: %s.", "type: %s and node: %s, type: %s.",
@@ -292,7 +306,9 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_
if (!src_node->GetInControlNodes().empty() && !is_linked) { if (!src_node->GetInControlNodes().empty() && !is_linked) {
auto out_ctrl_anchor = src_node->GetOutControlAnchor(); auto out_ctrl_anchor = src_node->GetOutControlAnchor();
auto in_ctrl_anchor = dst_node->GetInControlAnchor(); auto in_ctrl_anchor = dst_node->GetInControlAnchor();
GE_CHK_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor), "add edge failed");
GE_CHK_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor),
"[Add][ControlEdge] between %s and %s failed",
src_node->GetName().c_str(), dst_node->GetName().c_str());
GELOGD( GELOGD(
"relink edges before remove node, add control edge between node: %s," "relink edges before remove node, add control edge between node: %s,"
" type: %s and node: %s, type: %s.", " type: %s and node: %s, type: %s.",
@@ -309,15 +325,15 @@ graphStatus TransOpDepthFusionPass::RemoveNode(const NodePtr &node, const ge::Co
} }
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()); 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(),
node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Isolate][Node] failed, node name:%s, node type:%s",
node->GetName().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", 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()); 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(),
node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Node] without relink failed, node name:%s, node type:%s ",
node->GetName().c_str(), node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
return GRAPH_SUCCESS; return GRAPH_SUCCESS;


+ 8
- 6
ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc View File

@@ -32,7 +32,7 @@ Status TransOpNearbyAllreduceFusionPass::Run(NodePtr &node) {
GELOGI("found allreduce op %s", node->GetName().c_str()); GELOGI("found allreduce op %s", node->GetName().c_str());
Status ret = RemoveNearbyPairedTransOps(node); Status ret = RemoveNearbyPairedTransOps(node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "failed to remove paired transop for allreduce op %s", node->GetName().c_str());
GELOGE(FAILED, "[Remove][PairedTransOp] for allreduce op:%s", node->GetName().c_str());
return FAILED; return FAILED;
} }
GELOGI("successfully remove paired transop for allreduce op (%s)", node->GetName().c_str()); GELOGI("successfully remove paired transop for allreduce op (%s)", node->GetName().c_str());
@@ -102,7 +102,7 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt
REPORT_INNER_ERROR("E19999", "In data anchors size:%zu not equal to out data anchors size:%zu in node:%s(%s), " 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(), "check invalid", in_data_anchors.size(), out_data_anchors.size(),
node->GetName().c_str(), node->GetType().c_str()); 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, "[Check][Param] 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;
} }
@@ -148,7 +148,7 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt
if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) { if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
in_node->GetName().c_str(), in_node->GetType().c_str()); 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;
} }
removed_node_count++; removed_node_count++;
@@ -157,7 +157,7 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt
if (IsolateAndDeleteNode(out_node, {0}) != SUCCESS) { if (IsolateAndDeleteNode(out_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
out_node->GetName().c_str(), out_node->GetType().c_str()); 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;
} }
removed_node_count++; removed_node_count++;
@@ -171,12 +171,14 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt
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", REPORT_CALL_ERROR("E19999", "Update input:%zu desc in op:%s(%s) failed",
i, node->GetName().c_str(), node->GetType().c_str()); i, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "UpdateInputDesc fail.");
GELOGE(FAILED, "[Update][InputDesc] in op:%s(%s) failed, input index:%zu",
node->GetName().c_str(), node->GetType().c_str(), i);
} }
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", REPORT_CALL_ERROR("E19999", "Update output:%zu desc in op:%s(%s) failed",
i, node->GetName().c_str(), node->GetType().c_str()); i, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "UpdateOutputDesc");
GELOGE(FAILED, "[Update][OutputDesc] in op:%s(%s) failed, input index:%zu",
node->GetName().c_str(), node->GetType().c_str(), i);
} }
GELOGI("successfully remove paired transop (%s and %s) for node %s", GELOGI("successfully remove paired transop (%s and %s) for node %s",
in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str()); in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str());


+ 22
- 10
ge/graph/passes/transop_symmetry_elimination_pass.cc View File

@@ -178,7 +178,11 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(), src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(),
dst_in_anchor->GetOwnerNode()->GetName().c_str(), dst_in_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx()); 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][DataAnchor] from %s(%s)(index:%d) to %s(%s)(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());
return ret; return ret;
} }
// 2.Link A->T2 // 2.Link A->T2
@@ -194,8 +198,11 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
in_anchor->GetPeerOutAnchor()->GetIdx(), in_anchor->GetPeerOutAnchor()->GetIdx(),
dst_in_anchor->GetOwnerNode()->GetName().c_str(), dst_in_anchor->GetOwnerNode()->GetName().c_str(),
dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx()); 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(),
dst_node->GetName().c_str());
GELOGE(FAILED, "[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());
return ret; return ret;
} }
// 3.Copy in-control/data-in-control from T1->T2 // 3.Copy in-control/data-in-control from T1->T2
@@ -204,7 +211,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed", 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(), src_node->GetName().c_str(), src_node->GetType().c_str(),
dst_node->GetName().c_str(), dst_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][InCtrlEdges] 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());
return ret; return ret;
} }
// 4.Add control edge from T1 other input to T2, like reshape second input // 4.Add control edge from T1 other input to T2, like reshape second input
@@ -215,7 +224,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", 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(), in_node->GetName().c_str(), in_node->GetType().c_str(),
dst_node->GetName().c_str(), dst_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][ControlEdge] 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());
return ret; return ret;
} }
} }
@@ -224,15 +235,16 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
dst_node->GetName().c_str(), dst_node->GetType().c_str()); 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(),
dst_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[IsolateAndDelete][Node] failed, node name:%s, node type:%s ",
dst_node->GetName().c_str(), dst_node->GetType().c_str());
return ret; return ret;
} }
GELOGI("Trans op symmetry eliminate successfully. Node %s has been removed.", dst_node->GetName().c_str()); GELOGI("Trans op symmetry eliminate successfully. Node %s has been removed.", dst_node->GetName().c_str());
// 6.If T1 has no data out, isolate and deleted it. // 6.If T1 has no data out, isolate and deleted it.
ret = RemoveTransOpWithoutOutput(pre_normal_node, src_node); ret = RemoveTransOpWithoutOutput(pre_normal_node, src_node);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
GELOGE(ret, "Isolate removed node: %s, type: %s failed", src_node->GetName().c_str(), src_node->GetType().c_str());
GELOGE(ret, "[Call][RemoveTransOpWithoutOutput] for node:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str());
return ret; return ret;
} }
return SUCCESS; return SUCCESS;
@@ -245,7 +257,7 @@ Status TransOpSymmetryEliminationPass::RemoveTransOpWithoutOutput(NodePtr &pre_n
REPORT_CALL_ERROR("E19999", "Copy out control edge from node:%s(%s) to node:%s(%s) failed", 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(), trans_node->GetName().c_str(), trans_node->GetType().c_str(),
pre_node->GetName().c_str(), pre_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][OutCtrlEdges] from %s to %s failed.", trans_node->GetName().c_str(),
pre_node->GetName().c_str()); pre_node->GetName().c_str());
return ret; return ret;
} }
@@ -254,7 +266,7 @@ Status TransOpSymmetryEliminationPass::RemoveTransOpWithoutOutput(NodePtr &pre_n
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str()); 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, "[IsolateAndDelete][Node] %s(%s) failed", trans_node->GetName().c_str(),
trans_node->GetType().c_str()); trans_node->GetType().c_str());
return ret; return ret;
} }


+ 119
- 32
ge/graph/passes/transop_without_reshape_fusion_pass.cc View File

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


@@ -79,27 +81,33 @@ bool TransOpWithoutReshapeFusionPass::FormatContinuousCheck(const OutDataAnchorP
auto in_node = in_anchor->GetOwnerNode(); auto in_node = in_anchor->GetOwnerNode();
GE_IF_BOOL_EXEC(in_node == nullptr, GE_IF_BOOL_EXEC(in_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param in_anchor's owner node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param in_anchor's owner node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "in_node is null"); return false);
GELOGE(INTERNAL_ERROR, "[Check][Param]Param in_anchor's owner node is nullptr");
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, GE_IF_BOOL_EXEC(out_owner_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param out_anchor's owner node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param out_anchor's owner node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "out_owner_node is null"); return false);
GELOGE(INTERNAL_ERROR, "[Check][Param] Param out_anchor's owner node is nullptr");
return false);
auto out_op = out_owner_node->GetOpDesc(); auto out_op = out_owner_node->GetOpDesc();
GE_IF_BOOL_EXEC(in_op == nullptr, GE_IF_BOOL_EXEC(in_op == nullptr,
REPORT_INNER_ERROR("E19999", "Param in_anchor's owner op_desc is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param in_anchor's owner op_desc is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "in_op is null"); return false);
GELOGE(INTERNAL_ERROR, "[Check][Param] Param in_anchor's owner op_desc is nullptr");
return false);
GE_IF_BOOL_EXEC(out_op == nullptr, GE_IF_BOOL_EXEC(out_op == nullptr,
REPORT_INNER_ERROR("E19999", "Param out_anchor's owner op_desc is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param out_anchor's owner op_desc is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "out_op is null"); return false);
GELOGE(INTERNAL_ERROR, "[Check][Param] Param out_anchor's owner op_desc is nullptr");
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, GE_IF_BOOL_EXEC(in_op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Param in_anchor corresponding tensor is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param in_anchor corresponding tensor is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "in_op_desc is null"); return false);
GELOGE(INTERNAL_ERROR, "[Check][Param] Param in_anchor corresponding tensor is nullptr");
return false);
GE_IF_BOOL_EXEC(out_op_desc == nullptr, GE_IF_BOOL_EXEC(out_op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "Param out_anchor corresponding tensor is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param out_anchor corresponding tensor is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "out_op_desc is null"); return false);
GELOGE(INTERNAL_ERROR, "[Check][Param] Param out_anchor corresponding tensor is nullptr");
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;
} }
@@ -375,6 +383,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkSubGraphControlEdges(
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", 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(), out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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;
} }
} }
@@ -386,6 +397,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkSubGraphControlEdges(
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", 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(), out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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;
} }
} }
@@ -417,6 +431,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str()); peer_in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add]ControlEdge] 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;
} }
} }
@@ -430,6 +448,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(),
in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add]ControlEdge] 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;
} }
} }
@@ -443,6 +465,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str()); peer_in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add]ControlEdge] 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;
} }
} }
@@ -456,6 +482,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange
out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str()); peer_in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add]ControlEdge] 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;
} }
} }
@@ -476,15 +506,19 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkNodesWhenDescNotChanged(
GELOGI("remove edge.src %s, src idx:%d, dst:%s, dst idx:%d", GELOGI("remove edge.src %s, src idx:%d, dst:%s, dst idx:%d",
end_anchors_pair.first->GetOwnerNode()->GetName().c_str(), end_anchors_pair.first->GetIdx(), end_anchors_pair.first->GetOwnerNode()->GetName().c_str(), end_anchors_pair.first->GetIdx(),
in_owner_node->GetName().c_str(), in_anchor->GetIdx()); in_owner_node->GetName().c_str(), in_anchor->GetIdx());
GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_anchors_pair.first, in_anchor), "remove edge failed");
GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_anchors_pair.first, in_anchor),
"[Remove][Edge] between %s(%s)(index:%d) and %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());
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", 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(), 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()); 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(),
out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "[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());
return GRAPH_FAILED; return GRAPH_FAILED;
} else { } else {
auto old_peer_in_anchor = begin_anchors_pair.second; auto old_peer_in_anchor = begin_anchors_pair.second;
@@ -506,8 +540,8 @@ 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!");
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(INTERNAL_ERROR, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }


@@ -515,13 +549,15 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes
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(), 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()); 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] %s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(),
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
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(), 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()); 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] %s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(),
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
return nullptr); return nullptr);


string src_format = TypeUtils::FormatToSerialString(format_trans_input_desc.GetFormat()); string src_format = TypeUtils::FormatToSerialString(format_trans_input_desc.GetFormat());
@@ -530,31 +566,36 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes
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, 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()); format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set kAttrNameSrcFormat failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", kAttrNameSrcFormat,
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
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, 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()); format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set kAttrNameDstFormat failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", kAttrNameDstFormat,
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
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", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add input desc failed");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed",
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
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", REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add output desc failed");
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed",
format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
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(), 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()); format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set ext attr failed");
GELOGE(INTERNAL_ERROR, "[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());
return nullptr); return nullptr);
return format_transfer_op; return format_transfer_op;
} }
@@ -571,7 +612,7 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in
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); 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, "[Create][Operator] %s(%s) failed", cast_op_name.str().c_str(), CAST);
return nullptr; return nullptr;
} }
const int default_input_index = 0; const int default_input_index = 0;
@@ -580,13 +621,15 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in
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", REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
cast_op->GetName().c_str(), cast_op->GetType().c_str()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add input desc failed");
GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed",
cast_op->GetName().c_str(), cast_op->GetType().c_str());
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, 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()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "update input desc failed");
GELOGE(INTERNAL_ERROR, "[Update][InputDesc] of op:%s(%s) failed, input index:%d",
cast_op->GetName().c_str(), cast_op->GetType().c_str(), default_input_index);
return nullptr); return nullptr);
} }


@@ -594,26 +637,30 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in
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", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
cast_op->GetName().c_str(), cast_op->GetType().c_str()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "add output desc failed");
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed",
cast_op->GetName().c_str(), cast_op->GetType().c_str());
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, 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()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "update output desc failed");
GELOGE(INTERNAL_ERROR, "[Update][OutputDesc] of op:%s(%s) failed, output index:%d",
cast_op->GetName().c_str(), cast_op->GetType().c_str(), default_output_index);
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(), 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()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set dst_type attr failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str());
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(), 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()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set need_compile attr failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str());
return nullptr; return nullptr;
} }
return cast_op; return cast_op;
@@ -662,7 +709,8 @@ void TransOpWithoutReshapeFusionPass::GetBeginOutDescAndEndInDesc(const int inde
auto out_owner_node = out_peer_anchor->GetOwnerNode(); auto out_owner_node = out_peer_anchor->GetOwnerNode();
GE_CHECK_NOTNULL_JUST_RETURN(out_owner_node); GE_CHECK_NOTNULL_JUST_RETURN(out_owner_node);
auto out_peer_op_desc = out_owner_node->GetOpDesc(); auto out_peer_op_desc = out_owner_node->GetOpDesc();
GE_IF_BOOL_EXEC(out_peer_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "out_peer_op_desc is nullptr"); return);
GE_IF_BOOL_EXEC(out_peer_op_desc == nullptr,
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, out_peer_op_desc is nullptr"); return);
out_desc = out_peer_op_desc->GetInputDesc(out_peer_anchor->GetIdx()); out_desc = out_peer_op_desc->GetInputDesc(out_peer_anchor->GetIdx());


auto in_peer_anchor = nodes_anchor.back().first; auto in_peer_anchor = nodes_anchor.back().first;
@@ -670,7 +718,8 @@ void TransOpWithoutReshapeFusionPass::GetBeginOutDescAndEndInDesc(const int inde
auto in_owner_node = in_peer_anchor->GetOwnerNode(); auto in_owner_node = in_peer_anchor->GetOwnerNode();
GE_CHECK_NOTNULL_JUST_RETURN(in_owner_node); GE_CHECK_NOTNULL_JUST_RETURN(in_owner_node);
auto in_peer_op_desc = in_owner_node->GetOpDesc(); auto in_peer_op_desc = in_owner_node->GetOpDesc();
GE_IF_BOOL_EXEC(in_peer_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "in_peer_op_desc is nullptr"); return);
GE_IF_BOOL_EXEC(in_peer_op_desc == nullptr,
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, in_peer_op_desc is nullptr"); return);
in_desc = in_peer_op_desc->GetOutputDesc(in_peer_anchor->GetIdx()); in_desc = in_peer_op_desc->GetOutputDesc(in_peer_anchor->GetIdx());
} }


@@ -802,7 +851,8 @@ void TransOpWithoutReshapeFusionPass::RemoveNousedNodes(const ComputeGraphPtr &g
continue; continue;
} }


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),
GELOGE(INTERNAL_ERROR, "[Set][ExtAttr] for op:%s failed", op_desc->GetName().c_str()); return);
GELOGI("remove node:%s", node->GetName().c_str()); GELOGI("remove node:%s", node->GetName().c_str());
if (GraphUtils::IsolateNode(node, {0}) != GRAPH_SUCCESS) { if (GraphUtils::IsolateNode(node, {0}) != GRAPH_SUCCESS) {
GELOGW("Isolate node: %s failed.", node->GetName().c_str()); GELOGW("Isolate node: %s failed.", node->GetName().c_str());
@@ -949,7 +999,8 @@ graphStatus TransOpWithoutReshapeFusionPass::AddTransNode(const ComputeGraphPtr
if (trans_node == nullptr) { if (trans_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
transop->GetName().c_str(), transop->GetType().c_str(), graph->GetName().c_str()); transop->GetName().c_str(), transop->GetType().c_str(), graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "add node failed!");
GELOGE(GRAPH_FAILED, "[Add][Node] %s(%s) to graph:%s failed",
transop->GetName().c_str(), transop->GetType().c_str(), graph->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
return GRAPH_SUCCESS; return GRAPH_SUCCESS;
@@ -1011,13 +1062,18 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph
GE_CHECK_NOTNULL(in_owner_node); GE_CHECK_NOTNULL(in_owner_node);
GELOGI("remove edge.src:%s, src idx:%d, dst:%s, dst idx:%d", end_in.first->GetOwnerNode()->GetName().c_str(), GELOGI("remove edge.src:%s, src idx:%d, dst:%s, dst idx:%d", end_in.first->GetOwnerNode()->GetName().c_str(),
end_in.first->GetIdx(), in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx()); end_in.first->GetIdx(), in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx());
GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_in.first, in_anchor), "remove edge failed");
GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_in.first, in_anchor),
"[Remove][Edge] between %s and %s failed",
out_owner_node->GetName().c_str(), in_owner_node->GetName().c_str());
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", 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(), 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()); new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[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;
@@ -1033,6 +1089,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed", 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.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()); new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[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;
@@ -1046,6 +1105,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed", 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(), 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()); in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "[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;
} }


@@ -1057,6 +1119,7 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
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"); REPORT_INNER_ERROR("E19999", "Param new_trans_nodes front or back is nullptr, check invalid");
GELOGE(GRAPH_FAILED, "[Check][Param] Param new_trans_nodes front or back is nullptr");
return GRAPH_FAILED; return GRAPH_FAILED;
} }
if (sub_graph_has_control_edge_[index]) { if (sub_graph_has_control_edge_[index]) {
@@ -1067,6 +1130,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", 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(), 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()); new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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;
} }
} }
@@ -1080,6 +1146,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), 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()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str()); peer_in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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;
} }
} }
@@ -1093,6 +1162,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(),
new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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;
} }
} }
@@ -1106,6 +1178,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), 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()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str()); peer_in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] 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;
} }
} }
@@ -1119,6 +1194,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), 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()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx()); peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "[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;
} }
} }
@@ -1129,6 +1208,12 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index,
in_anchor->GetOwnerNode()->GetName().c_str()); in_anchor->GetOwnerNode()->GetName().c_str());
if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutDataAnchor(0), if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutDataAnchor(0),
in_anchor->GetOwnerNode()->GetInControlAnchor()) != GRAPH_SUCCESS) { in_anchor->GetOwnerNode()->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s) and op:%s(%s) failed",
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s) and op:%s(%s) failed",
new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -1181,6 +1266,7 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphsBetweenNormalNode(
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"); REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid");
GELOGE(GRAPH_FAILED, "[Check][Param] param out_anchor is nullptr");
return GRAPH_FAILED; return GRAPH_FAILED;
} }


@@ -1200,7 +1286,8 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphsBetweenNormalNode(
for (const auto &peer_out_anchor : peer_in_node->GetAllOutDataAnchors()) { for (const auto &peer_out_anchor : peer_in_node->GetAllOutDataAnchors()) {
ret = GetSubGraphsBetweenNormalNode(peer_out_anchor, sub_graphs_out, nodes_list); ret = GetSubGraphsBetweenNormalNode(peer_out_anchor, sub_graphs_out, nodes_list);
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "get all transops between normal node failed!node:%s", peer_in_node->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Get][SubGraphs] Between Normal Node failed! node:%s",
peer_in_node->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }


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

@@ -35,13 +35,13 @@ 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"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [node] must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] 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"); 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, "[Get][OpDesc] failed, OpDesc of param [node] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }


@@ -80,7 +80,7 @@ Status TransposeTransDataPass::Run(NodePtr &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"); 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, "[Get][OpDesc] failed, OpDesc of out data node must not be null.");
return FAILED; return FAILED;
} }
if (out_op_desc->GetType() != TRANSDATA) { if (out_op_desc->GetType() != TRANSDATA) {
@@ -115,11 +115,11 @@ Status TransposeTransDataPass::CheckOneInAndOneOutDataAnchor(NodePtr &node) cons
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) " 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(),
node->GetName().c_str(), in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums);
"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, "[Check][Param] 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.", in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums,
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
return SUCCESS; return SUCCESS;
@@ -131,7 +131,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) {
if (graph == nullptr) { if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid", REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str());
GELOGE(FAILED, "[Get][OwnerComputeGraph] failed, The owner graph of node:%s(%s) must not be null.",
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -142,7 +143,9 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) {
for (auto &peer_anchor : node->GetOutControlAnchor()->GetPeerInControlAnchors()) { for (auto &peer_anchor : node->GetOutControlAnchor()->GetPeerInControlAnchors()) {
GE_CHECK_NOTNULL(origin_node_in); GE_CHECK_NOTNULL(origin_node_in);
GE_CHECK_NOTNULL(origin_node_in->GetOutControlAnchor()); GE_CHECK_NOTNULL(origin_node_in->GetOutControlAnchor());
GE_CHK_STATUS_RET(origin_node_in->GetOutControlAnchor()->LinkTo(peer_anchor), "link failed");
GE_CHK_STATUS_RET(origin_node_in->GetOutControlAnchor()->LinkTo(peer_anchor),
"[Link][Anchor] between %s and %s failed",
origin_node_in->GetName().c_str(), peer_anchor->GetOwnerNode()->GetName().c_str());
} }


for (const auto &anchor : node->GetAllInAnchors()) { for (const auto &anchor : node->GetAllInAnchors()) {
@@ -157,7 +160,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &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", 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()); node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
return SUCCESS; return SUCCESS;


+ 25
- 10
ge/graph/passes/unused_args_clean_pass.cc View File

@@ -103,7 +103,8 @@ Status UnusedArgsCleanPass::ClassifyDataNodes(const ComputeGraphPtr &graph, cons
if (subgraph == nullptr) { if (subgraph == nullptr) {
REPORT_CALL_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed", REPORT_CALL_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str()); 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, "[Get][SubGraph] from graph:%s by name:%s failed",
graph->GetName().c_str(), name.c_str());
return GE_GRAPH_EMPTY_SUBGRAPH; return GE_GRAPH_EMPTY_SUBGRAPH;
} }


@@ -117,7 +118,8 @@ Status UnusedArgsCleanPass::ClassifyDataNodes(const ComputeGraphPtr &graph, cons
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(), 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()); data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -154,9 +156,10 @@ 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(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().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][Attr] %s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -170,11 +173,17 @@ Status UnusedArgsCleanPass::UpdateInputTensor(const map<ComputeGraphPtr, map<uin
const auto &old_desc = func_desc->GetInputDesc(parent_index); const auto &old_desc = func_desc->GetInputDesc(parent_index);
(void)func_desc->UpdateInputDesc(update_index, old_desc); (void)func_desc->UpdateInputDesc(update_index, old_desc);


GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor), "Add edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor),
"[Add][Edge] between %s(index:%d) and %s(index:%d) failed",
out_node->GetName().c_str(), out_anchor->GetIdx(),
func_node->GetName().c_str(), update_index);
GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u",
func_node->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index); func_node->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index);


GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor),
"[Remove][Edge] between %s(index:%d) and %s(index:%d) failed",
out_node->GetName().c_str(), out_anchor->GetIdx(),
func_node->GetName().c_str(), parent_index);
GELOGI("Remove edge success, func node: %s, node: %s", func_node->GetName().c_str(), out_node->GetName().c_str()); GELOGI("Remove edge success, func node: %s, node: %s", func_node->GetName().c_str(), out_node->GetName().c_str());


return SUCCESS; return SUCCESS;
@@ -199,7 +208,9 @@ Status UnusedArgsCleanPass::RemoveInputTensor(const map<ComputeGraphPtr, map<uin
} }


const auto &data = it->second; const auto &data = it->second;
GE_CHK_GRAPH_STATUS_RET(graph->RemoveNode(data), "Remove node failed: %s", data->GetName().c_str());
GE_CHK_GRAPH_STATUS_RET(graph->RemoveNode(data),
"[Remove][Node] %s from graph:%s failed",
data->GetName().c_str(), graph->GetName().c_str());
GELOGI("Remove Node: %s %s", graph->GetName().c_str(), data->GetName().c_str()); GELOGI("Remove Node: %s %s", graph->GetName().c_str(), data->GetName().c_str());
} }


@@ -207,12 +218,16 @@ Status UnusedArgsCleanPass::RemoveInputTensor(const map<ComputeGraphPtr, map<uin
const auto &out_anchor = old_anchor->GetPeerOutAnchor(); const auto &out_anchor = old_anchor->GetPeerOutAnchor();
const auto &out_node = out_anchor->GetOwnerNode(); const auto &out_node = out_anchor->GetOwnerNode();


GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed");
GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor),
"[Remove][Edge] between %s(index:%d) and %s(index:%d) failed",
out_node->GetName().c_str(), out_anchor->GetIdx(),
func_node->GetName().c_str(), parent_index);
GELOGI("Remove edge: %s %s", out_node->GetName().c_str(), func_node->GetName().c_str()); GELOGI("Remove edge: %s %s", out_node->GetName().c_str(), func_node->GetName().c_str());


if (out_node->GetInDataNodes().size() == 0 && out_node->GetOutAllNodes().size() == 0) { if (out_node->GetInDataNodes().size() == 0 && out_node->GetOutAllNodes().size() == 0) {
GE_CHK_GRAPH_STATUS_RET(out_node->GetOwnerComputeGraph()->RemoveNode(out_node), "Remove node failed: %s",
out_node->GetName().c_str());
GE_CHK_GRAPH_STATUS_RET(out_node->GetOwnerComputeGraph()->RemoveNode(out_node),
"[Remove][Node] %s from graph:%s failed",
out_node->GetName().c_str(), out_node->GetOwnerComputeGraph()->GetName().c_str());
} }
return SUCCESS; return SUCCESS;
} }

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

@@ -28,12 +28,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"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
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"); 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, "[Get][OpDesc] failed, param [opDesc] must not be null.");
return PARAM_INVALID; return PARAM_INVALID;
} }




+ 51
- 35
ge/graph/passes/var_is_initialized_op_pass.cc View File

@@ -36,7 +36,7 @@ Status VarIsInitializedOpPass::Run(NodePtr &node) {
GE_CHECK_NOTNULL(node); GE_CHECK_NOTNULL(node);
auto ret = UpdateInitedVars(node); auto ret = UpdateInitedVars(node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "Failed to run var is init pass on node %s", node->GetName().c_str());
GELOGE(ret, "[Call][UpdateInitedVars] for node:%s failed", node->GetName().c_str());
return ret; return ret;
} }


@@ -46,6 +46,7 @@ Status VarIsInitializedOpPass::Run(NodePtr &node) {


bool inited = false; bool inited = false;
if (CheckSrcNode(node, inited) != SUCCESS) { if (CheckSrcNode(node, inited) != SUCCESS) {
GELOGE(ret, "[Call][CheckSrcNode] for node:%s failed", node->GetName().c_str());
return FAILED; return FAILED;
} }
GELOGI("The variable inited status %s on node %s", GELOGI("The variable inited status %s on node %s",
@@ -63,10 +64,8 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c
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", 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); input_nodes.size(), node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt);
GELOGE(FAILED,
"[%s] Node input data nodes size [%zu] is not equal 1.",
node->GetName().c_str(),
input_nodes.size());
GELOGE(FAILED, "[Check][Param] In data node num:%zu of node:%s(%s) not equal to %d.",
input_nodes.size(), node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt);
return FAILED; return FAILED;
} }


@@ -78,8 +77,9 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c
REPORT_INNER_ERROR("E19999", "Index:%d In data node of node:%s(%s), type:%s not %s, check invalid", 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(), kVarIsInitVarInputIndex, node->GetName().c_str(), node->GetType().c_str(),
input_node_type.c_str(), VARIABLE); 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(),
input_node_type.c_str());
GELOGE(FAILED, "[Check][Param] Index:%d In data node of node:%s(%s), type:%s not equal to %s.",
kVarIsInitVarInputIndex, node->GetName().c_str(), node->GetType().c_str(),
input_node_type.c_str(), VARIABLE);
return FAILED; return FAILED;
} }


@@ -97,40 +97,43 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c


Status VarIsInitializedOpPass::CreateConstant(NodePtr &node, OpDescPtr &op_desc, bool inited) { Status VarIsInitializedOpPass::CreateConstant(NodePtr &node, OpDescPtr &op_desc, bool inited) {
GE_CHECK_NOTNULL(node); GE_CHECK_NOTNULL(node);
// 1. create Constant OpDesc
op_desc = MakeShared<OpDesc>(node->GetName().c_str(), CONSTANT);
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());
return FAILED;
}

// 2. get OpDesc of VarIsInitializedOp
// 1. 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"); 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, "[Get][OpDesc] failed, Op desc of node must not be null.");
return FAILED; return FAILED;
} }
GeTensorDesc original_desc = original_op_desc->GetOutputDesc(0); GeTensorDesc original_desc = original_op_desc->GetOutputDesc(0);


// 2. create Constant OpDesc
op_desc = MakeShared<OpDesc>(node->GetName().c_str(), CONSTANT);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "[New][OpDesc] failed.");
return FAILED;
}

// 3. create attr value of Constant, is a tensor // 3. create attr value of Constant, is a tensor
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"); REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", node->GetName().c_str());
GELOGE(FAILED, "[New][GeTensor] failed.");
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(), 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()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "get ATTR_NAME_WEIGHTS failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }


// 4. set Constant output desc // 4. set Constant output desc
GE_CHK_STATUS_RET(op_desc->AddOutputDesc(original_desc), "add out put desc failed");
GE_CHK_STATUS_RET(op_desc->AddOutputDesc(original_desc),
"[Add][OutputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return SUCCESS; return SUCCESS;
} }


@@ -142,12 +145,11 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
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), " 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(),
"must be equal to %d, check invalid", in_anchors.size(), out_anchors.size(),
node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt); node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt);
GELOGE(FAILED,
"[%s] Node input/output data anchors"
" size [%lu][%lu] is not all equal 1.",
node->GetName().c_str(), in_anchors.size(), out_anchors.size());
GELOGE(FAILED, "[Check][Param] In data anchor num:%zu and out data anchor num:%zu of node:%s(%s), "
"must be equal to %d.", in_anchors.size(), out_anchors.size(),
node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt);
return FAILED; return FAILED;
} }


@@ -159,10 +161,12 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
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", 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->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx(),
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetIdx(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx()); 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, "[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());
return FAILED; return FAILED;
} }
auto src_node = peer_out_anchor->GetOwnerNode(); auto src_node = peer_out_anchor->GetOwnerNode();
@@ -170,8 +174,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", 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(), src_node->GetName().c_str(), src_node->GetType().c_str(),
new_node->GetName().c_str(), new_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",
src_node->GetName().c_str(), new_node->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] 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());
return FAILED; return FAILED;
} }


@@ -179,7 +184,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
REPORT_CALL_ERROR("E19999", "Move in control edge from node:%s(%s) to node:%s(%s) failed", 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(), node->GetName().c_str(), node->GetType().c_str(),
new_node->GetName().c_str(), new_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, "[Move][InCtrlEdges] 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());
return FAILED; return FAILED;
} }


@@ -187,7 +194,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node)
REPORT_CALL_ERROR("E19999", "Move out control edge from node:%s(%s) to node:%s(%s) failed", 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(), node->GetName().c_str(), node->GetType().c_str(),
new_node->GetName().c_str(), new_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, "[Move][OutCtrlEdges] 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());
return FAILED; return FAILED;
} }


@@ -199,6 +208,7 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited)
ComputeGraphPtr graph = node->GetOwnerComputeGraph(); ComputeGraphPtr graph = node->GetOwnerComputeGraph();
OpDescPtr constant_op_desc = nullptr; OpDescPtr constant_op_desc = nullptr;
if (CreateConstant(node, constant_op_desc, inited) != SUCCESS) { if (CreateConstant(node, constant_op_desc, inited) != SUCCESS) {
GELOGE(FAILED, "[Create][Constant] failed, node:%s", node->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -207,10 +217,13 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited)
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s front failed", 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(), constant_op_desc->GetName().c_str(), constant_op_desc->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(FAILED, "[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;
} }


if (ProcessInAnchor(node, const_node) != SUCCESS) { if (ProcessInAnchor(node, const_node) != SUCCESS) {
GELOGE(FAILED, "[Process][InAnchor] failed, node:%s", node->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -218,14 +231,17 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited)
REPORT_CALL_ERROR("E19999", "Move out edge from node:%s(%s) to node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Move out edge from node:%s(%s) to node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(), node->GetName().c_str(), node->GetType().c_str(),
const_node->GetName().c_str(), const_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, "[Move][OutputEdges] 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());
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", 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()); node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -299,7 +315,7 @@ 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"); REPORT_CALL_ERROR("E19999", "New set failed");
GELOGE(OUT_OF_MEMORY, "Failed to alloc set memory");
GELOGE(OUT_OF_MEMORY, "[New][Set] failed");
return nullptr; return nullptr;
} }
auto inited_vars = inited_vars_keeper.get(); auto inited_vars = inited_vars_keeper.get();


+ 46
- 28
ge/graph/passes/variable_op_pass.cc View File

@@ -50,19 +50,16 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed", 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(), trans_node->GetName().c_str(), trans_node->GetType().c_str(),
ref_node->GetName().c_str(), ref_node->GetType().c_str()); ref_node->GetName().c_str(), ref_node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Failed to move control edges from trans "
"node %s to var-ref %s",
trans_node->GetName().c_str(), ref_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Copy][InCtrlEdges] 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());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
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", REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid",
ref_node->GetName().c_str(), ref_node->GetType().c_str()); ref_node->GetName().c_str(), ref_node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"The variable ref node %s does not have an "
"input anchor",
GELOGE(INTERNAL_ERROR, "[Get][InDataAnchor] failed, The variable ref node %s does not have an input anchor",
ref_node->GetName().c_str()); ref_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -71,9 +68,7 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
if (trans_in_anchor == nullptr) { if (trans_in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid",
trans_node->GetName().c_str(), trans_node->GetType().c_str()); trans_node->GetName().c_str(), trans_node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Failed to get the in data anchor from trans"
" node %s type %s",
GELOGE(INTERNAL_ERROR, "[Get][InDataAnchor] failed, Node:%s(%s) has no input anchor",
trans_node->GetName().c_str(), trans_node->GetType().c_str()); trans_node->GetName().c_str(), trans_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -91,10 +86,10 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) {
prev_trans_node_out_anchor->GetOwnerNode()->GetType().c_str(), prev_trans_node_out_anchor->GetOwnerNode()->GetType().c_str(),
prev_trans_node_out_anchor->GetIdx(), prev_trans_node_out_anchor->GetIdx(),
ref_node->GetName().c_str(), ref_node->GetType().c_str()); ref_node->GetName().c_str(), ref_node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Failed to add edge between ref node %s "
"and the prev node of trans node %s",
ref_node->GetName().c_str(), trans_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[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());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
} }
@@ -128,7 +123,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"); REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Failed to run variable op pass, null graph");
GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to run variable op pass, null graph");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


@@ -138,18 +133,18 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {


if (var_accelerate_ctrl_ == nullptr) { if (var_accelerate_ctrl_ == nullptr) {
REPORT_INNER_ERROR("E19999", "The variable accelerate control is nullptr, check invalid"); 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, "[Check][Param] Failed to run var op pass, the variable accelerate control is null");
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


GELOGD("Begin to generate ref map for variable and refs, graph name:%s.", graph->GetName().c_str()); GELOGD("Begin to generate ref map for variable and refs, graph name:%s.", graph->GetName().c_str());
if (RenewVarDesc(graph) != SUCCESS) { if (RenewVarDesc(graph) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to renew var desc on graph");
GELOGE(INTERNAL_ERROR, "[Renew][VarDesc] on graph:%s failed", graph->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }


if (GenerateVariableVariableRefMap(graph) != SUCCESS) { if (GenerateVariableVariableRefMap(graph) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Generate][VariableMap] for graph:%s failed", graph->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }


@@ -166,6 +161,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {
VarTransRoad fusion_road; VarTransRoad fusion_road;
auto ret = FusionIfNeed(node, fusion_road); auto ret = FusionIfNeed(node, fusion_road);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "[Call][FusionIfNeed] for node:%s failed", node->GetName().c_str());
return ret; return ret;
} }


@@ -190,14 +186,16 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set Trans road for node:%s(%s) failed, session_id:%lu", 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()); 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, "[Set][TransRoad] for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID());
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", 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()); 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, "[Update][GraphId] %u for node:%s(%s) failed, session_id:%lu",
graph_id, node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
var_accelerate_ctrl_->SetVarChanged(node->GetName()); var_accelerate_ctrl_->SetVarChanged(node->GetName());
@@ -211,7 +209,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) {
// renew var desc if the trans_road is all reshape or reformat // renew var desc if the trans_road is all reshape or reformat
ret = RenewVarDesc(graph->GetSessionID(), node, fusion_road); ret = RenewVarDesc(graph->GetSessionID(), node, fusion_road);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str());
GELOGE(FAILED, "[Renew][VarDesc] for var[%s] failed!", node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -230,12 +228,16 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) {
if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str()); trans_node->GetName().c_str(), trans_node->GetType().c_str());
GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[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", 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()); trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str());
GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[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;
} }
} }
@@ -257,7 +259,7 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) {
" than one output data nodes, unlink the edge between them", " than one output data nodes, unlink the edge between them",
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 (ByPassTransNode(trans_node, ref_node) != SUCCESS) { if (ByPassTransNode(trans_node, ref_node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to bypass trans node %s to ref %s", trans_node->GetName().c_str(),
GELOGE(INTERNAL_ERROR, "[ByPass][TransNode] %s to ref %s failed", trans_node->GetName().c_str(),
ref_node->GetName().c_str()); ref_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }
@@ -269,11 +271,15 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) {
if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed",
trans_node->GetName().c_str(), trans_node->GetType().c_str()); trans_node->GetName().c_str(), trans_node->GetType().c_str());
GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[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", 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()); trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str());
GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[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;
} }
} }
@@ -377,6 +383,7 @@ Status VariableOpPass::CheckVariableRefLegally(const ge::NodePtr &var_node, bool


for (const auto &var_ref_node : iterator->second) { for (const auto &var_ref_node : iterator->second) {
if (CheckVarAndVarRefAreAlike(var_node, var_ref_node, is_var_ref_legally) != SUCCESS) { if (CheckVarAndVarRefAreAlike(var_node, var_ref_node, is_var_ref_legally) != SUCCESS) {
GELOGE(FAILED, "[Call][CheckVarAndVarRefAreAlike] for node:%s failed", var_node->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }


@@ -392,7 +399,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"); REPORT_INNER_ERROR("E19999", "Param node or its op_desc is nullptr, check invalid");
GELOGE(FAILED, "node or opdesc is nullptr");
GELOGE(FAILED, "[Check][Param] node or its opdesc is nullptr");
return FAILED; return FAILED;
} }
const Format &format = final_output.GetFormat(); const Format &format = final_output.GetFormat();
@@ -406,7 +413,8 @@ Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final
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", REPORT_CALL_ERROR("E19999", "Update ouput:0 desc in op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "update output desc fail.");
GELOGE(FAILED, "[Update][OutputDesc] in op:%s(%s) failed, index:0",
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
GELOGD("node ref is (%s, %s, %lu), var_ref_name is %s.", GELOGD("node ref is (%s, %s, %lu), var_ref_name is %s.",
@@ -418,7 +426,7 @@ Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final
if (iterator == var_and_var_ref_map_.end()) { if (iterator == var_and_var_ref_map_.end()) {
auto graph = node->GetOwnerComputeGraph(); auto graph = node->GetOwnerComputeGraph();
if (GenerateVariableVariableRefMap(graph) != SUCCESS) { if (GenerateVariableVariableRefMap(graph) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Generate][VariableMap] for graph:%s failed", graph->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
} }
@@ -493,7 +501,8 @@ Status VariableOpPass::CheckVarAndVarRefAreAlike(const NodePtr &var_node, const
var_ref_node_trans_nodes.size(), var_ref_node_trans_nodes.size(),
var_ref_node->GetName().c_str(), var_ref_node->GetType().c_str()); 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, "[Check][Param] In data node num:%zu of node:%s(%s) bigger than 1.",
var_ref_node_trans_nodes.size(), var_ref_node->GetName().c_str(), var_ref_node->GetType().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }


@@ -502,6 +511,7 @@ Status VariableOpPass::CheckVarAndVarRefAreAlike(const NodePtr &var_node, const


if (CheckTransNodeAreInverse(var_node_trans_node, var_ref_node_trans_node, is_var_and_variable_ref_are_alike) != if (CheckTransNodeAreInverse(var_node_trans_node, var_ref_node_trans_node, is_var_and_variable_ref_are_alike) !=
SUCCESS) { SUCCESS) {
GELOGE(FAILED, "[Call][CheckTransNodeAreInverse] failed");
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }


@@ -559,11 +569,13 @@ 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"); REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "[Check][Param] param node is nullptr.");
return FAILED; return FAILED;
} }
bool is_matched = false; bool is_matched = false;
auto ret = CheckSameAndTransOp(node, is_matched, fusion_road); auto ret = CheckSameAndTransOp(node, is_matched, fusion_road);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "[Call][CheckSameAndTransOp] failed, node:%s", node->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
if (!is_matched) { if (!is_matched) {
@@ -574,6 +586,7 @@ Status VariableOpPass::CheckIfCouldBeOptimized(const ge::NodePtr &node, bool &fl
bool is_var_ref_legally = false; bool is_var_ref_legally = false;
ret = CheckVariableRefLegally(node, is_var_ref_legally); ret = CheckVariableRefLegally(node, is_var_ref_legally);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "[Call][CheckVariableRefLegally] failed, node:%s", node->GetName().c_str());
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
GELOGD("is_var_ref_legally is %d.", is_var_ref_legally); GELOGD("is_var_ref_legally is %d.", is_var_ref_legally);
@@ -596,6 +609,7 @@ Status VariableOpPass::FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_roa
while (true) { while (true) {
auto ret = CheckIfCouldBeOptimized(var, can_fusion, fusion_road); auto ret = CheckIfCouldBeOptimized(var, can_fusion, fusion_road);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "[Call][CheckIfCouldBeOptimized] failed");
return ret; return ret;
} }
if (!can_fusion) { if (!can_fusion) {
@@ -604,6 +618,7 @@ Status VariableOpPass::FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_roa


ret = DealFusion(var); ret = DealFusion(var);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "[Call][DealFusion] failed");
return ret; return ret;
} }
} }
@@ -614,6 +629,7 @@ Status VariableOpPass::UpdateIOFormatInfo(const GeTensorDesc &final_output, std:
for (auto &need_set_node : nodes) { for (auto &need_set_node : nodes) {
auto ret = UpdateVarAndRefOutputFormatInfo(final_output, need_set_node); auto ret = UpdateVarAndRefOutputFormatInfo(final_output, need_set_node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "[Call][UpdateVarAndRefOutputFormatInfo] failed");
return GE_GRAPH_VARIABLE_OP_PASS_FAILED; return GE_GRAPH_VARIABLE_OP_PASS_FAILED;
} }
} }
@@ -638,7 +654,8 @@ Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) {
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu", REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); 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, "[Renew][Descriptor] for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID());
return FAILED; return FAILED;
} }
} }
@@ -664,7 +681,8 @@ Status VariableOpPass::RenewVarDesc(uint64_t session_id, const NodePtr &node, co
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu", REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), session_id); 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, "[Renew][Descriptor] for node:%s(%s) failed, session_id:%lu",
node->GetName().c_str(), node->GetType().c_str(), session_id);
return FAILED; return FAILED;
} }




+ 70
- 33
ge/graph/passes/variable_prepare_op_pass.cc View File

@@ -49,7 +49,7 @@ Status VariablePrepareOpPass::Run(ComputeGraphPtr graph) {
if (node->GetOpDesc()->GetType() == VARIABLE) { if (node->GetOpDesc()->GetType() == VARIABLE) {
Status ret = DealVariableNode(node); Status ret = DealVariableNode(node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "variable add back edge failed");
GELOGE(ret, "[Deal][VariableNode] failed, node:%s(%s)", node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }
} }
@@ -71,8 +71,8 @@ Status VariablePrepareOpPass::DealVariableNode(NodePtr &var_node) {
for (auto output_index : ref_output_indexes) { for (auto output_index : ref_output_indexes) {
Status ret = DealWritableNode(dst_node, input_index, output_index, var_node); Status ret = DealWritableNode(dst_node, input_index, output_index, var_node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(FAILED, "Deal writable node[%s] failed, input index: %d, var: %s.", dst_node->GetName().c_str(),
input_index, var_node->GetName().c_str());
GELOGE(FAILED, "[Deal][WritableNode] [%s] failed, input index:%d, output index:%d var:%s.",
dst_node->GetName().c_str(), output_index, input_index, var_node->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -99,7 +99,8 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node,
const auto nodes_size = nodes_to_check.size(); const auto nodes_size = nodes_to_check.size();
// Add peer ref output node of current node to stack // Add peer ref output node of current node to stack
CHECK_FALSE_EXEC(GetPeerNodeOfRefOutput(cur_node, cur_output_index, nodes_to_check) == SUCCESS, CHECK_FALSE_EXEC(GetPeerNodeOfRefOutput(cur_node, cur_output_index, nodes_to_check) == SUCCESS,
GELOGE(FAILED, "GetPeerNodeOfRefOutput for node[%s] failed.", cur_node->GetName().c_str());
GELOGE(FAILED, "[Get][PeerNode] Of Ref Output for node[%s] failed, output index:%d.",
cur_node->GetName().c_str(), cur_output_index);
return FAILED); return FAILED);
if (nodes_size == nodes_to_check.size()) { if (nodes_size == nodes_to_check.size()) {
const auto &op_desc = cur_node->GetOpDesc(); const auto &op_desc = cur_node->GetOpDesc();
@@ -112,12 +113,14 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node,
if (static_cast<uint32_t>(cur_output_index) < op_desc->GetOutputsSize()) { if (static_cast<uint32_t>(cur_output_index) < op_desc->GetOutputsSize()) {
// Add variable ref node after ref output for final ref node // Add variable ref node after ref output for final ref node
CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS, CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS,
GELOGE(FAILED, "Add variable ref failed");
GELOGE(FAILED, "[Add][VariableRef] for node:%s failed, output index:%d var:%s",
cur_node->GetName().c_str(), cur_output_index, var_node->GetName().c_str());
return FAILED); return FAILED);
} else { } else {
// Insert variable ref node before ref input without corresponding ref output // Insert variable ref node before ref input without corresponding ref output
CHECK_FALSE_EXEC(InsertVariableRef(cur_node, cur_input_index, var_node) == SUCCESS, CHECK_FALSE_EXEC(InsertVariableRef(cur_node, cur_input_index, var_node) == SUCCESS,
GELOGE(FAILED, "Insert variable ref and ref identity failed");
GELOGE(FAILED, "[Insert][VariableRef] and ref identity failed, node:%s, in index:%d, var:%s",
cur_node->GetName().c_str(), cur_input_index, var_node->GetName().c_str());
return FAILED); return FAILED);
} }
continue; continue;
@@ -125,7 +128,8 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node,
if (HasControlOut(cur_node)) { if (HasControlOut(cur_node)) {
// Add variable ref node after ref output for ref node has control output. // Add variable ref node after ref output for ref node has control output.
CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS, CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS,
GELOGE(FAILED, "Add variable ref failed");
GELOGE(FAILED, "[Add][VariableRef] for node:%s failed, var:%s output index:%d",
cur_node->GetName().c_str(), var_node->GetName().c_str(), cur_output_index);
return FAILED); return FAILED);
} }
} }
@@ -135,7 +139,8 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node,
Status VariablePrepareOpPass::GetPeerNodeOfRefOutput(const ge::NodePtr &node, int output_index, Status VariablePrepareOpPass::GetPeerNodeOfRefOutput(const ge::NodePtr &node, int output_index,
std::stack<pair<NodePtr, pair<int, int>>> &nodes) { std::stack<pair<NodePtr, pair<int, int>>> &nodes) {
if (output_index < 0) { if (output_index < 0) {
GELOGE(PARAM_INVALID, "Invalid ref output index: %s-%d.", node->GetName().c_str(), output_index);
REPORT_INNER_ERROR("E19999", "Param output_index:%d < 0, check invalid", output_index);
GELOGE(PARAM_INVALID, "[Check][Param] Invalid ref output index: %s-%d.", node->GetName().c_str(), output_index);
return PARAM_INVALID; return PARAM_INVALID;
} }
const auto &op_desc = node->GetOpDesc(); const auto &op_desc = node->GetOpDesc();
@@ -192,7 +197,8 @@ Status VariablePrepareOpPass::AddVariableRef(ge::NodePtr &final_writable_node, c
GE_CHECK_NOTNULL(variable_ref_node); GE_CHECK_NOTNULL(variable_ref_node);
Status ret_check = CheckStreamLabel(variable_ref_node, final_writable_node); Status ret_check = CheckStreamLabel(variable_ref_node, final_writable_node);
if (ret_check != SUCCESS) { if (ret_check != SUCCESS) {
GELOGE(FAILED, "check stream lable failed");
GELOGE(FAILED, "[Check][StreamLabel] failed, var ref node:%s, writable node:%s",
variable_ref_node->GetName().c_str(), final_writable_node->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -200,12 +206,17 @@ Status VariablePrepareOpPass::AddVariableRef(ge::NodePtr &final_writable_node, c
// add control anchor between variable_ref and final peer node // add control anchor between variable_ref and final peer node
// variable_ref_node need to execute before other nodes // variable_ref_node need to execute before other nodes
CHECK_FALSE_EXEC(AddControlEdge(final_writable_node, variable_ref_node) == SUCCESS, CHECK_FALSE_EXEC(AddControlEdge(final_writable_node, variable_ref_node) == SUCCESS,
GELOGE(FAILED, "Add control edges between variable ref node and output nodes of ref node failed");
GELOGE(FAILED, "[Add][ControlEdge] between variable ref node:%s and final peer node:%s failed",
var_node->GetName().c_str(), variable_ref_node->GetName().c_str());
return FAILED); return FAILED);


graphStatus ret = ge::GraphUtils::AddEdge(out_anchor, variable_ref_node->GetInDataAnchor(0)); graphStatus ret = ge::GraphUtils::AddEdge(out_anchor, variable_ref_node->GetInDataAnchor(0));
if (ret != GRAPH_SUCCESS) { if (ret != GRAPH_SUCCESS) {
GELOGE(FAILED, "add data anchor between variable_ref and final_writable peer node failed");
REPORT_CALL_ERROR("E19999",
"add edge between variable_ref:%s(index:0) and final_writable peer node:%s(index:%d) failed",
variable_ref_node->GetName().c_str(), final_writable_node->GetName().c_str(), index);
GELOGE(FAILED, "[Add][Edge] between variable_ref:%s(index:0) and final_writable peer node:%s(index:%d) failed",
variable_ref_node->GetName().c_str(), final_writable_node->GetName().c_str(), index);
return FAILED; return FAILED;
} }
return SUCCESS; return SUCCESS;
@@ -236,7 +247,8 @@ Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index,
GE_CHECK_NOTNULL(variable_ref_node); GE_CHECK_NOTNULL(variable_ref_node);
Status ret_check = CheckStreamLabel(variable_ref_node, node); Status ret_check = CheckStreamLabel(variable_ref_node, node);
if (ret_check != SUCCESS) { if (ret_check != SUCCESS) {
GELOGE(FAILED, "check stream lable failed");
GELOGE(FAILED, "[Check][StreamLabel] failed, ref node:%s, writable node:%s",
variable_ref_node->GetName().c_str(), node->GetName().c_str());
return FAILED; return FAILED;
} }


@@ -245,29 +257,45 @@ Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index,
// add control anchor between variable_ref and node // add control anchor between variable_ref and node
// variable_ref_node need to execute before other nodes // variable_ref_node need to execute before other nodes
CHECK_FALSE_EXEC(AddControlEdge(node, variable_ref_node) == SUCCESS, CHECK_FALSE_EXEC(AddControlEdge(node, variable_ref_node) == SUCCESS,
GELOGE(FAILED, "Add control edges between variable ref node and output nodes of ref node failed");
GELOGE(FAILED, "[Add][ControlEdge] between variable ref node:%s and ref node:%s failed",
variable_ref_node->GetName().c_str(), node->GetName().c_str());
return FAILED); return FAILED);


// Insert variable ref node between two nodes and remove the original edge. // Insert variable ref node between two nodes and remove the original edge.
CHECK_FALSE_EXEC(ge::GraphUtils::RemoveEdge(peer_out_anchor, in_anchor) == SUCCESS, CHECK_FALSE_EXEC(ge::GraphUtils::RemoveEdge(peer_out_anchor, in_anchor) == SUCCESS,
GELOGE(FAILED, "Remove edge between ref node and its peer node failed");
REPORT_CALL_ERROR("E19999", "remove edge between ref node:%s and its peer node:%s failed",
node->GetName().c_str(), peer_in_node->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] between ref node:%s and its peer node:%s failed",
node->GetName().c_str(), peer_in_node->GetName().c_str());
return FAILED); return FAILED);
CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(peer_out_anchor, ref_identity_node->GetInDataAnchor(0)) == SUCCESS, CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(peer_out_anchor, ref_identity_node->GetInDataAnchor(0)) == SUCCESS,
GELOGE(FAILED, "Add data edge between pre node and ref_identity failed");
REPORT_CALL_ERROR("E19999", "Add edge between pre node:%s and ref_identity:%s failed",
peer_in_node->GetName().c_str(), ref_identity_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between pre node:%s and ref_identity:%s failed",
peer_in_node->GetName().c_str(), ref_identity_node->GetName().c_str());
return FAILED); return FAILED);
CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), in_anchor) == SUCCESS, CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), in_anchor) == SUCCESS,
GELOGE(FAILED, "Add data edge between ref_identity and ref node failed");
REPORT_CALL_ERROR("E19999", "Add edge between ref_identity:%s and ref node:%s failed",
ref_identity_node->GetName().c_str(), node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between ref_identity:%s and ref node:%s failed",
ref_identity_node->GetName().c_str(), node->GetName().c_str());
return FAILED); return FAILED);


// Add edge from ref identity node to variable ref node. // Add edge from ref identity node to variable ref node.
CHECK_FALSE_EXEC(
ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS,
GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed");
return FAILED);
CHECK_FALSE_EXEC(
ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS,
GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed");
return FAILED);
CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0),
variable_ref_node->GetInDataAnchor(0)) == SUCCESS,
REPORT_CALL_ERROR("E19999", "Add edge between ref_identity:%s and variable_ref:%s failed",
ref_identity_node->GetName().c_str(), variable_ref_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between ref_identity:%s and variable_ref:%s failed",
ref_identity_node->GetName().c_str(), variable_ref_node->GetName().c_str());
return FAILED);
CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(node->GetOutControlAnchor(),
variable_ref_node->GetInControlAnchor()) == SUCCESS,
REPORT_CALL_ERROR("E19999", "Add control edge between ref node:%s and variable_ref:%s failed",
node->GetName().c_str(), variable_ref_node->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] between ref node:%s and variable_ref:%s failed",
node->GetName().c_str(), variable_ref_node->GetName().c_str());
return FAILED);
return SUCCESS; return SUCCESS;
} }


@@ -279,10 +307,14 @@ Status VariablePrepareOpPass::AddControlEdge(const ge::NodePtr &node, const ge::
GE_CHECK_NOTNULL(peer_in_anchor); GE_CHECK_NOTNULL(peer_in_anchor);
NodePtr peer_node = peer_in_anchor->GetOwnerNode(); NodePtr peer_node = peer_in_anchor->GetOwnerNode();
GE_CHECK_NOTNULL(peer_node); GE_CHECK_NOTNULL(peer_node);
CHECK_FALSE_EXEC(
ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS,
GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed");
return FAILED);
CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(),
peer_node->GetInControlAnchor()) == SUCCESS,
REPORT_CALL_ERROR("E19999",
"Add control edge between variable_ref:%s and ref node's peer node:%s failed",
variable_ref_node->GetName().c_str(), peer_node->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] between variable_ref:%s and ref node's peer node:%s failed",
variable_ref_node->GetName().c_str(), peer_node->GetName().c_str());
return FAILED);
} }
} }
return SUCCESS; return SUCCESS;
@@ -292,13 +324,15 @@ ge::NodePtr VariablePrepareOpPass::CreateRefIdentity(const std::string &ref_iden
uint32_t input_index) { uint32_t input_index) {
OpDescPtr op_desc = node->GetOpDesc(); OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) { if (op_desc == nullptr) {
GELOGE(FAILED, "opdesc is nullptr");
REPORT_INNER_ERROR("E19999", "opdesc of param node is nullptr, check invalid");
GELOGE(FAILED, "[Get][OpDesc] failed, opdesc of param node is nullptr");
return nullptr; return nullptr;
} }


OpDescPtr ref_identity_op_desc = MakeShared<OpDesc>(ref_identity_name.c_str(), REFIDENTITY); OpDescPtr ref_identity_op_desc = MakeShared<OpDesc>(ref_identity_name.c_str(), REFIDENTITY);
if (ref_identity_op_desc == nullptr) { if (ref_identity_op_desc == nullptr) {
GELOGE(FAILED, "ref_identity op desc is nullptr");
REPORT_CALL_ERROR("E19999", "New OpDesc failed.");
GELOGE(FAILED, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }


@@ -317,13 +351,15 @@ ge::NodePtr VariablePrepareOpPass::CreateVariableRef(const std::string &variable
const ge::NodePtr &var_node) { const ge::NodePtr &var_node) {
OpDescPtr var_op_desc = var_node->GetOpDesc(); OpDescPtr var_op_desc = var_node->GetOpDesc();
if (var_op_desc == nullptr) { if (var_op_desc == nullptr) {
GELOGE(FAILED, "get var opdesc is nullptr");
REPORT_INNER_ERROR("E19999", "param var_node's opdesc is nullptr, check invalid");
GELOGE(FAILED, "[Get][OpDesc] failed, var opdesc is nullptr");
return nullptr; return nullptr;
} }


OpDescPtr var_ref_op_desc = MakeShared<OpDesc>(variable_ref_name.c_str(), var_op_desc->GetType()); OpDescPtr var_ref_op_desc = MakeShared<OpDesc>(variable_ref_name.c_str(), var_op_desc->GetType());
if (var_ref_op_desc == nullptr) { if (var_ref_op_desc == nullptr) {
GELOGE(FAILED, "var_ref opdesc is nullptr");
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "New OpDesc failed");
return nullptr; return nullptr;
} }


@@ -410,7 +446,8 @@ Status VariablePrepareOpPass::CheckStreamLabel(const ge::NodePtr &var_ref_node,
std::string stream_label; std::string stream_label;
(void)AttrUtils::GetStr(writable_desc, ATTR_NAME_STREAM_LABEL, stream_label); (void)AttrUtils::GetStr(writable_desc, ATTR_NAME_STREAM_LABEL, stream_label);
if (!stream_label.empty()) { if (!stream_label.empty()) {
GE_CHK_STATUS_RET(SetStreamLabel(var_ref_node, stream_label), "set stream label failed");
GE_CHK_STATUS_RET(SetStreamLabel(var_ref_node, stream_label),
"[Set][StreamLabel] %s failed", stream_label.c_str());
} }
return SUCCESS; return SUCCESS;
} }


+ 9
- 9
ge/graph/passes/variable_ref_delete_op_pass.cc View File

@@ -37,13 +37,13 @@ Status VariableRefDeleteOpPass::Run(ge::ComputeGraphPtr graph) {
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", 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()); 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(),
node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Can not find source variable[%s] of variable ref[%s]",
ref_var_src_var_name.c_str(), node->GetName().c_str());
return FAILED; return FAILED;
} }
Status ret = DealVariableRef(graph, node, ref_var_src_var_name); Status ret = DealVariableRef(graph, node, ref_var_src_var_name);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "variable ref [%s] delete failed", node->GetName().c_str());
GELOGE(ret, "[Deal][VariableRef] [%s] in graph:%s failed", node->GetName().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
} }
@@ -57,7 +57,7 @@ Status VariableRefDeleteOpPass::DealVariableRef(ge::ComputeGraphPtr &graph, ge::
if (inAnchor0 == nullptr) { if (inAnchor0 == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str()); variable_ref->GetName().c_str(), variable_ref->GetType().c_str());
GELOGE(FAILED, "variable_ref [%s] no input", variable_ref->GetName().c_str());
GELOGE(FAILED, "[Get][InDataAnchor] failed, variable_ref [%s] no input", variable_ref->GetName().c_str());
return FAILED; return FAILED;
} }
GE_CHECK_NOTNULL(inAnchor0->GetPeerOutAnchor()); GE_CHECK_NOTNULL(inAnchor0->GetPeerOutAnchor());
@@ -79,23 +79,23 @@ Status VariableRefDeleteOpPass::DealVariableRef(ge::ComputeGraphPtr &graph, ge::
} 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(), 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()); 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,
ref_var_src_var_name.c_str());
GELOGE(FAILED, "[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());
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", REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str()); 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][Node] name:%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", 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()); 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(),
variable_ref->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][Node] %s(%s) without relink in graph:%s failed",
variable_ref->GetName().c_str(), variable_ref->GetType().c_str(), graph->GetName().c_str());
return FAILED; return FAILED;
} }
return SUCCESS; return SUCCESS;


+ 1
- 1
metadef

@@ -1 +1 @@
Subproject commit dd0f7c4551247acc98e0d2ba0bce6f56fdec23d0
Subproject commit b27915cd37919430a61953f8998b7acce4a60177

+ 1
- 1
parser

@@ -1 +1 @@
Subproject commit 76e7e83c3b7841ec75bfa61711821c57a86a4943
Subproject commit e75eda62de2b51a0bded5481ca81eb8fc7bf376e

Loading…
Cancel
Save