Browse Source

!1742 code_sync_0604

From: @ding_fei_fei
Reviewed-by: @liucunwei,@ljl0711
Signed-off-by: @liucunwei
tags/v1.3.0
mindspore-ci-bot Gitee 4 years ago
parent
commit
61ef430599
100 changed files with 2689 additions and 2025 deletions
  1. +9
    -0
      .gitignore
  2. +0
    -0
      build.sh
  3. +53
    -22
      ge/CMakeLists.txt
  4. +13
    -7
      ge/client/ge_api.cc
  5. +21
    -26
      ge/common/CMakeLists.txt
  6. +4
    -4
      ge/common/dump/dump_op.cc
  7. +3
    -4
      ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc
  8. +5
    -8
      ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc
  9. +4
    -5
      ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc
  10. +1
    -1
      ge/common/formats/formats.cc
  11. +10
    -9
      ge/common/helper/model_helper.cc
  12. +26
    -15
      ge/common/model_parser/model_parser.cc
  13. +6
    -7
      ge/common/op/ge_op_utils.cc
  14. +22
    -11
      ge/common/profiling/profiling_manager.cc
  15. +2
    -2
      ge/engine_manager/dnnengine_manager.cc
  16. +12
    -18
      ge/executor/CMakeLists.txt
  17. +30
    -18
      ge/ge_local_engine/CMakeLists.txt
  18. +19
    -15
      ge/ge_local_engine/engine/host_cpu_engine.cc
  19. +37
    -0
      ge/generator/ge_generator.cc
  20. +52
    -10
      ge/graph/build/memory/graph_mem_assigner.cc
  21. +2
    -1
      ge/graph/build/model_builder.cc
  22. +12
    -2
      ge/graph/build/stream_allocator.cc
  23. +3
    -2
      ge/graph/build/stream_allocator.h
  24. +38
    -10
      ge/graph/build/task_generator.cc
  25. +29
    -18
      ge/graph/common/omg_util.cc
  26. +5
    -4
      ge/graph/common/omg_util.h
  27. +1
    -1
      ge/graph/execute/graph_execute.cc
  28. +30
    -30
      ge/graph/load/graph_loader.cc
  29. +24
    -9
      ge/graph/load/model_manager/davinci_model.cc
  30. +8
    -0
      ge/graph/load/model_manager/davinci_model.h
  31. +175
    -255
      ge/graph/load/model_manager/model_manager.cc
  32. +1
    -12
      ge/graph/load/model_manager/model_manager.h
  33. +67
    -50
      ge/graph/load/model_manager/model_utils.cc
  34. +1
    -1
      ge/graph/load/model_manager/model_utils.h
  35. +13
    -5
      ge/graph/load/model_manager/task_info/kernel_ex_task_info.cc
  36. +2
    -1
      ge/graph/load/model_manager/task_info/kernel_ex_task_info.h
  37. +16
    -10
      ge/graph/load/model_manager/task_info/kernel_task_info.cc
  38. +2
    -1
      ge/graph/load/model_manager/task_info/kernel_task_info.h
  39. +1
    -1
      ge/graph/load/model_manager/task_info/task_info.cc
  40. +2
    -1
      ge/graph/load/model_manager/task_info/task_info.h
  41. +8
    -9
      ge/graph/load/model_manager/tbe_handle_store.cc
  42. +4
    -4
      ge/graph/load/model_manager/ts_mem_mall.h
  43. +18
    -6
      ge/graph/load/model_manager/zero_copy_offset.cc
  44. +5
    -6
      ge/graph/load/model_manager/zero_copy_task.cc
  45. +17
    -23
      ge/graph/manager/graph_caching_allocator.cc
  46. +10
    -9
      ge/graph/manager/graph_context.cc
  47. +272
    -272
      ge/graph/manager/graph_manager.cc
  48. +9
    -6
      ge/graph/manager/graph_manager_utils.cc
  49. +6
    -12
      ge/graph/manager/graph_mem_allocator.cc
  50. +50
    -37
      ge/graph/manager/graph_var_manager.cc
  51. +8
    -5
      ge/graph/manager/host_mem_allocator.cc
  52. +9
    -13
      ge/graph/manager/host_mem_manager.cc
  53. +8
    -10
      ge/graph/manager/memory_api.cc
  54. +1
    -1
      ge/graph/manager/model_manager/event_manager.cc
  55. +10
    -11
      ge/graph/manager/rdma_pool_allocator.cc
  56. +75
    -57
      ge/graph/manager/trans_var_data_utils.cc
  57. +4
    -6
      ge/graph/manager/util/debug.cc
  58. +65
    -51
      ge/graph/manager/util/hcom_util.cc
  59. +1
    -1
      ge/graph/manager/util/variable_accelerate_ctrl.cc
  60. +86
    -27
      ge/graph/optimize/graph_optimize.cc
  61. +3
    -0
      ge/graph/optimize/graph_optimize.h
  62. +97
    -90
      ge/graph/optimize/mem_rw_conflict_optimize.cc
  63. +20
    -8
      ge/graph/optimize/summary_optimize.cc
  64. +153
    -92
      ge/graph/partition/dynamic_shape_partition.cc
  65. +10
    -3
      ge/graph/partition/dynamic_shape_partition.h
  66. +9
    -6
      ge/graph/partition/engine_place.cc
  67. +232
    -93
      ge/graph/partition/graph_partition.cc
  68. +63
    -24
      ge/graph/partition/stage_partition.cc
  69. +2
    -2
      ge/graph/passes/addn_pass.cc
  70. +44
    -41
      ge/graph/passes/aicpu_constant_folding_pass.cc
  71. +6
    -4
      ge/graph/passes/assert_pass.cc
  72. +24
    -10
      ge/graph/passes/assign_remove_pass.cc
  73. +31
    -24
      ge/graph/passes/atomic_addr_clean_pass.cc
  74. +22
    -23
      ge/graph/passes/attach_stream_label_pass.cc
  75. +22
    -14
      ge/graph/passes/base_pass.cc
  76. +34
    -17
      ge/graph/passes/bitcast_pass.cc
  77. +7
    -6
      ge/graph/passes/cast_remove_pass.cc
  78. +11
    -5
      ge/graph/passes/cast_translate_pass.cc
  79. +4
    -3
      ge/graph/passes/common_subexpression_elimination_pass.cc
  80. +11
    -12
      ge/graph/passes/compile_nodes_pass.cc
  81. +38
    -28
      ge/graph/passes/cond_pass.cc
  82. +11
    -11
      ge/graph/passes/cond_remove_pass.cc
  83. +5
    -7
      ge/graph/passes/constant_folding_pass.cc
  84. +8
    -6
      ge/graph/passes/constant_fuse_same_pass.cc
  85. +57
    -36
      ge/graph/passes/control_trigger_pass.cc
  86. +6
    -2
      ge/graph/passes/ctrl_edge_transfer_pass.cc
  87. +11
    -8
      ge/graph/passes/data_pass.cc
  88. +12
    -10
      ge/graph/passes/dimension_adjust_pass.cc
  89. +3
    -5
      ge/graph/passes/dimension_compute_pass.cc
  90. +2
    -2
      ge/graph/passes/dropout_pass.cc
  91. +7
    -5
      ge/graph/passes/end_of_sequence_add_control_pass.cc
  92. +6
    -5
      ge/graph/passes/enter_pass.cc
  93. +133
    -90
      ge/graph/passes/flow_ctrl_pass.cc
  94. +42
    -40
      ge/graph/passes/folding_pass.cc
  95. +47
    -36
      ge/graph/passes/for_pass.cc
  96. +4
    -3
      ge/graph/passes/fuse_data_nodes_with_common_input_pass.cc
  97. +19
    -10
      ge/graph/passes/get_original_format_pass.cc
  98. +12
    -7
      ge/graph/passes/global_step_insert_pass.cc
  99. +10
    -8
      ge/graph/passes/guarantee_const_pass.cc
  100. +24
    -67
      ge/graph/passes/hccl_continuous_memcpy_pass.cc

+ 9
- 0
.gitignore View File

@@ -3,8 +3,17 @@
/output
/prebuilts
/cov
/deps
.autotools
.project
.cproject
.settings/
/tests/frm/
*.ir
*.out
*.DS_Store
.DS_Store
server_config.sh

# Dynamic libraries
# *.so


+ 0
- 0
build.sh View File


+ 53
- 22
ge/CMakeLists.txt View File

@@ -10,34 +10,62 @@ elseif (ENABLE_D)
add_subdirectory(ge_runtime)
endif ()

set(PROTO_LIST
"${METADEF_DIR}/proto/fusion_model.proto"
"${GE_CODE_DIR}/ge/proto/optimizer_priority.proto"
)

set(PROTO_CLIENT_LIST
"${METADEF_DIR}/proto/ge_api.proto"
)

set(PROTO_HEADER_LIST
set(GRAPHENGINE_PROTO_LIST
"${METADEF_DIR}/proto/om.proto"
"${METADEF_DIR}/proto/task.proto"
"${METADEF_DIR}/proto/insert_op.proto"
"${METADEF_DIR}/proto/ge_ir.proto"
"${METADEF_DIR}/proto/ge_api.proto"
"${METADEF_DIR}/proto/fusion_model.proto"
"${METADEF_DIR}/proto/optimizer_priority.proto"
"${METADEF_DIR}/proto/fwk_adapter.proto"
"${METADEF_DIR}/proto/op_mapping.proto"
"${METADEF_DIR}/proto/dump_task.proto"
"${METADEF_DIR}/proto/tensorflow/graph_library.proto"
"${METADEF_DIR}/proto/tensorflow/graph.proto"
"${METADEF_DIR}/proto/tensorflow/node_def.proto"
"${METADEF_DIR}/proto/tensorflow/function.proto"
"${METADEF_DIR}/proto/tensorflow/versions.proto"
"${METADEF_DIR}/proto/tensorflow/attr_value.proto"
"${METADEF_DIR}/proto/tensorflow/op_def.proto"
"${METADEF_DIR}/proto/tensorflow/tensor.proto"
"${METADEF_DIR}/proto/tensorflow/tensor_shape.proto"
"${METADEF_DIR}/proto/tensorflow/types.proto"
"${METADEF_DIR}/proto/tensorflow/resource_handle.proto"
)

protobuf_generate(graphengine_protos GRAPHENGINE_PROTO_SRCS GRAPHENGINE_PROTO_HDRS ${GRAPHENGINE_PROTO_LIST} TARGET)

set(GE_FUSION_MODEL_PROTO_SRCS
"${CMAKE_BINARY_DIR}/proto/graphengine_protos/proto/fusion_model.pb.cc"
"${CMAKE_BINARY_DIR}/proto/graphengine_protos/proto/optimizer_priority.pb.cc"
)

protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST})
protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST})
protobuf_generate(ge_client PROTO_CLIENT_HEADER_SRCS PROTO_CLIENT_HEADER_HDRS ${PROTO_HEADER_LIST})

add_library(ge_fusion_model_protos_obj OBJECT ${GE_FUSION_MODEL_PROTO_SRCS})
add_dependencies(ge_fusion_model_protos_obj graphengine_protos)
target_include_directories(ge_fusion_model_protos_obj PRIVATE
#### blue zone ####
${PROTOBUF_SHARED_PKG_DIR}/include
#### yellow zone ####
${ASCEND_PROTOBUF_SHARED_PKG_DIR}/include
)
target_compile_definitions(ge_fusion_model_protos_obj PRIVATE
google=ascend_private
)
target_link_libraries(ge_fusion_model_protos_obj PRIVATE ascend_protobuf $<BUILD_INTERFACE:intf_pub>)
target_compile_options(ge_fusion_model_protos_obj PRIVATE
$<$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>:-O2 -fPIC>
$<$<OR:$<STREQUAL:${PRODUCT_SIDE},host>,$<STREQUAL:${ENABLE_OPEN_SRC},True>>:-fexceptions>
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>: -Wno-deprecated-declarations -fno-common>
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Debug>>:/MTd>
$<$<AND:$<STREQUAL:${TARGET_SYSTEM_NAME},Windows>,$<STREQUAL:${CMAKE_CONFIGURATION_TYPES},Release>>:/MT>
)

if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES)
############ libge_proto_common.a ############
add_library(ge_proto_common STATIC
${PROTO_HEADER_HDRS}
${PROTO_SRCS}
$<TARGET_OBJECTS:ge_fusion_model_protos_obj>
)

target_compile_definitions(ge_proto_common PRIVATE
@@ -57,8 +85,7 @@ target_link_libraries(ge_proto_common PRIVATE

############ libge_proto_client.a ############
add_library(ge_proto_client STATIC
${PROTO_CLIENT_HEADER_HDRS}
${PROTO_CLIENT_SRCS}
$<TARGET_OBJECTS:ge_fusion_model_protos_obj>
)

target_compile_definitions(ge_proto_client PRIVATE
@@ -67,8 +94,8 @@ target_compile_definitions(ge_proto_client PRIVATE
)

target_include_directories(ge_proto_client PRIVATE
${CMAKE_BINARY_DIR}/proto/ge_client
${CMAKE_BINARY_DIR}/proto/ge_client/proto
${CMAKE_BINARY_DIR}/proto/graphengine_protos
${CMAKE_BINARY_DIR}/proto/graphengine_protos/proto
)

target_compile_options(ge_proto_client PRIVATE
@@ -742,7 +769,7 @@ target_include_directories(ge_runner SYSTEM PRIVATE
${METADEF_DIR}/inc/external
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
${GE_CODE_DIR}/../inc/external
@@ -787,6 +814,10 @@ add_library(ge_compiler SHARED
${INFER_SRC_LIST}
)

add_dependencies(ge_compiler
graphengine_protos
)

target_compile_definitions(ge_compiler PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0
REUSE_MEMORY=1
@@ -819,7 +850,7 @@ target_include_directories(ge_compiler SYSTEM PRIVATE
${METADEF_DIR}/inc/external
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
${GE_CODE_DIR}/../inc/external


+ 13
- 7
ge/client/ge_api.cc View File

@@ -34,6 +34,7 @@
#include "common/ge/tbe_plugin_manager.h"
#include "common/util/error_manager/error_manager.h"
#include "toolchain/plog.h"
#include "ir_build/option_utils.h"

using domi::OpRegistry;
using std::map;
@@ -69,16 +70,21 @@ Status CheckOptionsValid(const std::map<string, string> &options) {
auto job_id_iter = options.find(OPTION_EXEC_JOB_ID);
if (job_id_iter != options.end()) {
if (job_id_iter->second.length() > kMaxStrLen) {
GELOGE(PARAM_INVALID,"[Check][JobId]Failed,"
GELOGE(PARAM_INVALID, "[Check][JobId]Failed,"
"the job_id [%s] string length: %zu > max string length: %d",
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen);
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id","length"}),
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id", "length"}),
std::vector<std::string>({job_id_iter->second,
std::to_string(kMaxStrLen)}));
return FAILED;
}
}

// check modify_mixlist is valid
if (ge::CheckModifyMixlistParamValid(options) != ge::SUCCESS) {
return FAILED;
}

return SUCCESS;
}

@@ -244,7 +250,7 @@ std::string GEGetWarningMsg() {
// Initialize session,which calls innerSession
Session::Session(const std::map<string, string> &options) {
ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther);
GELOGT(TRACE_INIT, "Session Constructor start");
GELOGT(TRACE_INIT, "Start to construct session.");

ErrorManager::GetInstance().GenWorkStreamIdDefault();
// check init status
@@ -332,7 +338,7 @@ Session::Session(const std::map<AscendString, AscendString> &options) {
// session destructor
Session::~Session() {
ErrorManager::GetInstance().SetStage(error_message::kFinalize, error_message::kFinalize);
GELOGT(TRACE_INIT, "Session Destructor start");
GELOGT(TRACE_INIT, "Start to destruct session.");
// 0.check init status
if (!g_ge_initialized) {
GELOGW("GE is not yet initialized or is finalized.");
@@ -602,16 +608,16 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s
Status Session::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const std::vector<Tensor> &inputs,
std::vector<Tensor> &outputs) {
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther);
GELOGT(TRACE_INIT, "Session run graph with stream async start");
GELOGT(TRACE_INIT, "Start to run graph with stream async.");

ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id);
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED,
"[Run][Graph]Run graph with stream asyn failed, the GELib instance is nullptr,"
"[Run][Graph]Run graph with stream async failed, the GELib instance is nullptr,"
"session id = %lu, graph id = %u, stream = %p.", sessionId_, graph_id, stream);
REPORT_INNER_ERROR("E19999",
"Run graph with stream asyn failed, the GELib instance is nullptr"
"Run graph with stream async failed, the GELib instance is nullptr"
"session id = %lu, graph id = %u, stream = %p.", sessionId_, graph_id, stream);
return FAILED;
}


+ 21
- 26
ge/common/CMakeLists.txt View File

@@ -1,23 +1,3 @@
set(PROTO_LIST
"${METADEF_DIR}/proto/om.proto"
"${METADEF_DIR}/proto/ge_ir.proto"
"${METADEF_DIR}/proto/insert_op.proto"
"${METADEF_DIR}/proto/task.proto"
"${METADEF_DIR}/proto/tensorflow/attr_value.proto"
"${METADEF_DIR}/proto/tensorflow/function.proto"
"${METADEF_DIR}/proto/tensorflow/graph.proto"
"${METADEF_DIR}/proto/tensorflow/node_def.proto"
"${METADEF_DIR}/proto/tensorflow/op_def.proto"
"${METADEF_DIR}/proto/tensorflow/resource_handle.proto"
"${METADEF_DIR}/proto/tensorflow/tensor.proto"
"${METADEF_DIR}/proto/tensorflow/tensor_shape.proto"
"${METADEF_DIR}/proto/tensorflow/types.proto"
"${METADEF_DIR}/proto/tensorflow/versions.proto"
)

protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
protobuf_generate(ge_static PROTO_STATIC_SRCS PROTO_STATIC_HDRS ${PROTO_LIST})

set(SRC_LIST
"context/ctx.cc"
"model_saver.cc"
@@ -67,7 +47,12 @@ set(SRC_LIST

if (NOT ENABLE_D AND NOT ENABLE_ACL)
############ libge_common.so ############
add_library(ge_common SHARED ${SRC_LIST} ${PROTO_HDRS})
add_library(ge_common SHARED ${SRC_LIST})

add_dependencies(ge_common
graphengine_protos
)

target_compile_definitions(ge_common PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0
HOST_VISIBILITY
@@ -97,7 +82,7 @@ target_include_directories(ge_common PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_DEPEND_DIR}/inc
${GE_DEPEND_DIR}/inc/cce
@@ -128,7 +113,12 @@ target_link_libraries(ge_common PRIVATE
)

############ libge_common.a ############
add_library(ge_common_static STATIC ${SRC_LIST} ${PROTO_STATIC_HDRS})
add_library(ge_common_static STATIC ${SRC_LIST})

add_dependencies(ge_common_static
graphengine_protos
)

target_compile_definitions(ge_common_static PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0
HOST_VISIBILITY
@@ -159,7 +149,7 @@ target_include_directories(ge_common_static PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge_static
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_DEPEND_DIR}/inc
${GE_DEPEND_DIR}/inc/cce
@@ -180,7 +170,12 @@ target_link_libraries(ge_common_static PRIVATE

else ()
############ libge_common.so w/static protobuf ############
add_library(ge_common SHARED ${SRC_LIST} ${PROTO_HDRS})
add_library(ge_common SHARED ${SRC_LIST})

add_dependencies(ge_common
graphengine_protos
)

target_compile_definitions(ge_common PRIVATE
PROTOBUF_INLINE_NOT_IN_HEADERS=0
HOST_VISIBILITY
@@ -211,7 +206,7 @@ target_include_directories(ge_common PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
${GE_CODE_DIR}/third_party/fwkacllib/inc
${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain
)


+ 4
- 4
ge/common/dump/dump_op.cc View File

@@ -66,21 +66,21 @@ void DumpOp::SetDynamicModelInfo(const string &dynamic_model_name, const string
static void SetOpMappingLoopAddr(uintptr_t step_id, uintptr_t loop_per_iter, uintptr_t loop_cond,
toolkit::aicpu::dump::OpMappingInfo &op_mapping_info) {
if (step_id != 0) {
GELOGI("step_id exists.");
GELOGI("Exists step_id.");
op_mapping_info.set_step_id_addr(static_cast<uint64_t>(step_id));
} else {
GELOGI("step_id is null.");
}

if (loop_per_iter != 0) {
GELOGI("loop_per_iter exists.");
GELOGI("Exists loop_per_iter.");
op_mapping_info.set_iterations_per_loop_addr(static_cast<uint64_t>(loop_per_iter));
} else {
GELOGI("loop_per_iter is null.");
}

if (loop_cond != 0) {
GELOGI("loop_cond exists.");
GELOGI("Exists loop_cond.");
op_mapping_info.set_loop_cond_addr(static_cast<uint64_t>(loop_cond));
} else {
GELOGI("loop_cond is null.");
@@ -253,7 +253,7 @@ Status DumpOp::LaunchDumpOp() {
}
if (device_id < 0) {
GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][DeviceId]Failed, device_id %d", device_id);
REPORT_INNER_ERROR("E19999","Check device_id %d failed", device_id);
REPORT_INNER_ERROR("E19999", "Check device_id %d failed", device_id);
return ACL_ERROR_GE_INTERNAL_ERROR;
}
toolkit::aicpu::dump::OpMappingInfo op_mapping_info;


+ 3
- 4
ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc View File

@@ -72,8 +72,7 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) {
if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 ||
src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID,
"[Check][Shape]Failed to check relationship between src and dst shape, "
"src shape %s, dst shape %s",
"[Check][Shape]Failed to check relationship between src and dst shape, src shape %s, dst shape %s",
ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str());
REPORT_INNER_ERROR("E19999", "Failed to check relationship between src and dst shape, "
"src shape %s, dst shape %s",
@@ -138,9 +137,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in
"[Operate][Memory]Failed to copy data from FracZ offset %ld to "
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d",
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret);
REPORT_CALL_ERROR("E19999","Failed to copy data from FracZ offset %ld to "
REPORT_CALL_ERROR("E19999", "Failed to copy data from FracZ offset %ld to "
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d",
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret );
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
}
}


+ 5
- 8
ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc View File

@@ -44,23 +44,20 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) {
GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "[Check][DataType]Failed, "
"shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s",
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
REPORT_INNER_ERROR("E19999", "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, "
"invalid data type %s",
REPORT_INNER_ERROR("E19999", "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s",
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str());
return ACL_ERROR_GE_DATATYPE_INVALID;
}
if (!CheckShapeValid(src_shape, kFracZDimsNum)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Value is invalid, src shape %s",
ShapeToString(src_shape).c_str());
REPORT_CALL_ERROR("E19999", "Src shape %s check invalid",
ShapeToString(src_shape).c_str());
REPORT_CALL_ERROR("E19999", "Src shape %s check invalid", ShapeToString(src_shape).c_str());
return ACL_ERROR_GE_SHAPE_INVALID;
}
if (!CheckShapeValid(dst_shape, kNhwcDimsNum)) {
GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "[Check][Shape]Value is invalid, dst shape %s",
ShapeToString(dst_shape).c_str());
REPORT_CALL_ERROR("E19999", "Dst shape %s check invalid",
ShapeToString(dst_shape).c_str());
REPORT_CALL_ERROR("E19999", "Dst shape %s check invalid", ShapeToString(dst_shape).c_str());
return ACL_ERROR_GE_SHAPE_INVALID;
}
int64_t c0 = GetCubeSizeByDataType(args.src_data_type);
@@ -138,7 +135,7 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size
"[Operate][Memory]Failed to copy data from FracZ offset %ld to "
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d",
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret);
REPORT_CALL_ERROR("E19999","Failed to copy data from FracZ offset %ld to "
REPORT_CALL_ERROR("E19999", "Failed to copy data from FracZ offset %ld to "
"NCHW[%ld, %ld, %ld, %ld] offset %ld, err-code %d",
src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret);
return ACL_ERROR_GE_MEMORY_OPERATE_FAILED;
@@ -185,7 +182,7 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &
ShapeToString(args.src_shape).c_str(),
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),
ShapeToString(args.dst_shape).c_str(), total_size, ret);
REPORT_CALL_ERROR("E19999","Failed to get data after trans, src shape %s, data type %s, "
REPORT_CALL_ERROR("E19999", "Failed to get data after trans, src shape %s, data type %s, "
"dst shape %s, memory size %ld, error_code %u",
ShapeToString(args.src_shape).c_str(),
TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(),


+ 4
- 5
ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc View File

@@ -112,11 +112,10 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in
total_size, ShapeToString(args.dst_shape).c_str(),
TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str());
REPORT_CALL_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, "
"shape %s when trans format from %s to %s",
total_size, ShapeToString(args.dst_shape).c_str(),
TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str());
REPORT_CALL_ERROR("E19999", "Failed to alloc the memory for dst buf %ld, shape %s when trans format from %s to %s",
total_size, ShapeToString(args.dst_shape).c_str(),
TypeUtils::FormatToSerialString(args.src_format).c_str(),
TypeUtils::FormatToSerialString(args.dst_format).c_str());
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}



+ 1
- 1
ge/common/formats/formats.cc View File

@@ -47,7 +47,7 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArg
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Shape]Failed, input data is null "
"or shape size not euqal to 0, src_shape %s",
ShapeToString(args.src_shape).c_str());
REPORT_CALL_ERROR("E19999","Failed to check shape, input data is null "
REPORT_CALL_ERROR("E19999", "Failed to check shape, input data is null "
"or shape size not equal to 0, src_shape %s",
ShapeToString(args.src_shape).c_str());
return ACL_ERROR_GE_PARAM_INVALID;


+ 10
- 9
ge/common/helper/model_helper.cc View File

@@ -79,7 +79,8 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil
Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) {
vector<int64_t> om_info;
auto ge_model_weight = ge_model->GetWeight();
GELOGD("SaveSizeToModelDef weight_data_size is %zu, %p", ge_model_weight.GetSize(), ge_model_weight.GetData());
GELOGD("SaveSizeToModelDef weight_data_size is %zu, ge_model_weight data is %p", ge_model_weight.GetSize(),
ge_model_weight.GetData());
om_info.push_back(ge_model_weight.GetSize());

TBEKernelStore tbe_kernel_store = ge_model->GetTBEKernelStore();
@@ -284,7 +285,7 @@ Status ModelHelper::SaveAllModelPartiton(std::shared_ptr<OmFileSaveHelper>& om_f
if (SaveModelWeights(om_file_save_helper, ge_model, model_index) != SUCCESS) {
GELOGE(FAILED, "[Save][ModelWeights]Failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
REPORT_CALL_ERROR("E19999","ModelHelper save mode weights failed, model %s, model index %zu",
REPORT_CALL_ERROR("E19999", "ModelHelper save mode weights failed, model %s, model index %zu",
ge_model->GetName().c_str(), model_index);
return FAILED;
}
@@ -441,7 +442,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
GELOGE(INTERNAL_ERROR, "[Save][AllModelPartition]Failed, model name %s, cur_index %zu",
model_name.c_str(), cur_index);
REPORT_CALL_ERROR("E19999", "Save all model %s partition failed, cur_index %zu",
model_name.c_str(), cur_index);
model_name.c_str(), cur_index);
return INTERNAL_ERROR;
}
}
@@ -459,7 +460,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
GELOGE(FAILED, "[Save][Model]OmFileSaveHelper save model eturn fail, output_file %s",
output_file.c_str());
REPORT_CALL_ERROR("E19999", "OmFileSaveHelper save model return fail, output_file %s",
output_file.c_str());
output_file.c_str());
return FAILED;
}
return SUCCESS;
@@ -601,7 +602,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadModel(c
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootModel(const ge::ModelData &model_data) {
if (model_data.model_data == nullptr || model_data.model_len == 0) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID, "[Load][RootModel] "
"Model_data is nullptr or model_data_size is 0");
"Model_data is nullptr or model data is empty.");
REPORT_INNER_ERROR("E19999", "Load root model failed, model_data is nullptr or its size is 0");
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID;
}
@@ -628,7 +629,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootMod
//model verison 1.0 file header does not have model_num member
is_unknown_shape_model_ = file_header_->version >= ge::MODEL_VERSION &&
file_header_->model_num > kStatiOmFileModelNum;
GELOGD("cur om model is ge root model or no %d, model version %u", is_unknown_shape_model_, file_header_->version);
GELOGD("Cur om model is ge root model or no %d, model version %u", is_unknown_shape_model_, file_header_->version);

OmFileLoadHelper om_load_helper;
if (is_unknown_shape_model_) {
@@ -650,7 +651,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::LoadRootMod
GELOGE(status, "[Generate][GERootModel]Failed");
return status;
}
GELOGD("in ModelHelper::LoadRootModel, is_assign_model_ is setted to true!");
GELOGD("In ModelHelper::LoadRootModel, is_assign_model_ is setted to true!");
is_assign_model_ = true;
return SUCCESS;
}
@@ -790,7 +791,7 @@ Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper) {
if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition) != SUCCESS) {
GELOGE(FAILED, "[Get][ModelWeightPartition]Failed, GetWeight size:%u", partition.size);
REPORT_CALL_ERROR("E19999", "[Get][ModelPartition]Failed, GetWeight size:%u",
partition.size);
partition.size);
return FAILED;
}
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size);
@@ -805,7 +806,7 @@ Status ModelHelper::LoadWeights(OmFileLoadHelper &om_load_helper, GeModelPtr &cu
if (om_load_helper.GetModelPartition(ModelPartitionType::WEIGHTS_DATA, partition, mode_index) != SUCCESS) {
GELOGE(FAILED, "[Get][ModelPartition]Failed, GetWeight size:%u", partition.size);
REPORT_CALL_ERROR("E19999", "[Get][ModelPartition]Failed, GetWeight size:%u",
partition.size);
partition.size);
return FAILED;
}
ge::Buffer weight = ge::Buffer::CopyFrom(partition.data, partition.size);


+ 26
- 15
ge/common/model_parser/model_parser.cc View File

@@ -62,7 +62,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro

char *data = new (std::nothrow) char[len];
if (data == nullptr) {
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Load model From file failed, bad memory allocation occur. (need:%u)", len);
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Load][ModelFromFile]Failed, "
"bad memory allocation occur(need %u), file %s", len, model_path);
REPORT_CALL_ERROR("E19999", "Load model from file %s failed, "
@@ -90,33 +89,45 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo
GE_CHECK_NOTNULL(model.model_data);

// Model length too small
GE_CHK_BOOL_RET_STATUS(model.model_len >= sizeof(ModelFileHeader), ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID,
"Invalid model. Model data size %u must be greater than or equal to %zu.", model.model_len,
sizeof(ModelFileHeader));
GE_CHK_BOOL_EXEC(model.model_len >= sizeof(ModelFileHeader),
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({"om", model.om_name.c_str(), "invalid om file"}));
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID,
"[Check][Param] Invalid model. Model data size %u must be greater than or equal to %zu.",
model.model_len, sizeof(ModelFileHeader));
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID;);
// Get file header
auto file_header = reinterpret_cast<ModelFileHeader *>(model.model_data);
// Determine whether the file length and magic number match
GE_CHK_BOOL_RET_STATUS(
file_header->length == model.model_len - sizeof(ModelFileHeader) && file_header->magic == MODEL_FILE_MAGIC_NUM,
ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID,
"Invalid model. file_header->length[%u] + sizeof(ModelFileHeader)[%zu] != model->model_len[%u] || "
"MODEL_FILE_MAGIC_NUM[%u] != file_header->magic[%u]",
file_header->length, sizeof(ModelFileHeader), model.model_len, MODEL_FILE_MAGIC_NUM, file_header->magic);

GE_CHK_BOOL_EXEC(file_header->length == model.model_len - sizeof(ModelFileHeader) &&
file_header->magic == MODEL_FILE_MAGIC_NUM,
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({"om", model.om_name.c_str(), "invalid om file"}));
GELOGE(ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID,
"[Check][Param] Invalid model, file_header->length[%u] + sizeof(ModelFileHeader)[%zu] != "
"model->model_len[%u] || MODEL_FILE_MAGIC_NUM[%u] != file_header->magic[%u]",
file_header->length, sizeof(ModelFileHeader), model.model_len,
MODEL_FILE_MAGIC_NUM, file_header->magic);
return ACL_ERROR_GE_EXEC_MODEL_DATA_SIZE_INVALID;);
Status res = SUCCESS;

// Get data address
uint8_t *data = reinterpret_cast<uint8_t *>(model.model_data) + sizeof(ModelFileHeader);
if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model
GE_CHK_BOOL_RET_STATUS(model.key.empty(), ACL_ERROR_GE_PARAM_INVALID,
"Invalid param. model is unencrypted, but key is not empty.");

if (!model.key.empty()) {
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({"om", model.om_name.c_str(), "invalid om file"}));
GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"[Check][Param] Invalid param, model is unencrypted, but key is not empty.");
return ACL_ERROR_GE_PARAM_INVALID;
}
model_data = data;
model_len = file_header->length;
GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader));
} else {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Param]Invalid, model encrypt type not supported");
REPORT_CALL_ERROR("E19999","Invalid model, encrypt type not supported");
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({"om", model.om_name.c_str(), "invalid om file"}));
res = ACL_ERROR_GE_PARAM_INVALID;
}



+ 6
- 7
ge/common/op/ge_op_utils.cc View File

@@ -444,17 +444,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType type, std::vector<int64_t> &dims) {
if (tensor == nullptr) {
GELOGE(PARAM_INVALID, "[Check][Param]Input tensor is nullptr");
REPORT_INNER_ERROR("E19999","Input tensor is nullptr");
REPORT_INNER_ERROR("E19999", "Input tensor is nullptr");
return PARAM_INVALID;
}

// If the tensor data is a vector, the shape dimension must be 1
if (tensor->GetTensorDesc().GetShape().GetDims().size() > 1) {
GELOGE(PARAM_INVALID, "[Check][Param]The dimension of the input tensor shape "
"cannot be more than 1, it is %zu",
GELOGE(PARAM_INVALID, "[Check][Param]The dimension of the input tensor shape cannot be more than 1, it is %zu",
tensor->GetTensorDesc().GetShape().GetDims().size());
REPORT_CALL_ERROR("E19999", "The dimension of the input tensor shape %zu invalid, "
"more than 1", tensor->GetTensorDesc().GetShape().GetDims().size());
REPORT_CALL_ERROR("E19999", "The dimension of the input tensor shape %zu invalid, more than 1",
tensor->GetTensorDesc().GetShape().GetDims().size());
return PARAM_INVALID;
}

@@ -473,8 +472,8 @@ OpUtils::GetShapeDataFromConstTensor(const ConstGeTensorPtr &tensor, DataType ty
dims.push_back(shape_data[i]);
}
} else {
GELOGE(PARAM_INVALID, "[Check][DataType]Invalid, type only can be DT_INT32 or DT_INT64, "
"type is %s", TypeUtils::DataTypeToSerialString(type).c_str());
GELOGE(PARAM_INVALID, "[Check][DataType]Invalid, type only can be DT_INT32 or DT_INT64, type is %s",
TypeUtils::DataTypeToSerialString(type).c_str());
REPORT_INNER_ERROR("E19999", "Data type %s check invalid, only can be DT_INT32 or DT_INT64",
TypeUtils::DataTypeToSerialString(type).c_str());
return PARAM_INVALID;


+ 22
- 11
ge/common/profiling/profiling_manager.cc View File

@@ -184,7 +184,10 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) {
if (options.find(kTrainingTrace) == std::string::npos) {
return ge::SUCCESS;
}
const std::string training_trace = prof_options[kTrainingTrace];
std::string training_trace;
if (prof_options.contains(kTrainingTrace)) {
training_trace = prof_options[kTrainingTrace];
}
if (training_trace.empty()) {
GELOGI("Training trace will not take effect.");
return ge::SUCCESS;
@@ -196,8 +199,12 @@ ge::Status ProfilingManager::ParseOptions(const std::string &options) {
REPORT_INNER_ERROR("E19999", "Training trace param:%s is invalid.", training_trace.c_str());
return ge::PARAM_INVALID;
}
fp_point_ = prof_options[kFpPoint];
bp_point_ = prof_options[kBpPoint];
if (prof_options.contains(kFpPoint)) {
fp_point_ = prof_options[kFpPoint];
}
if (prof_options.contains(kBpPoint)) {
bp_point_ = prof_options[kBpPoint];
}
if (!fp_point_.empty() && !bp_point_.empty()) {
GELOGI("Training trace bp fp is set, bp_point:%s, fp_point:%s.", bp_point_.c_str(), fp_point_.c_str());
}
@@ -316,11 +323,14 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::Profilin
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::ProfileStepInfo(
uint64_t index_id, uint64_t model_id, uint16_t tag_id, rtStream_t stream, int32_t device_id) {
#ifdef DAVINCI_SUPPORT_PROFILING
rtError_t rt_ret = RT_ERROR_NONE;
#ifndef ONLY_COMPILE_OPEN_SRC
if (!is_load_profiling_ && subscribe_count_ == 0) {
GELOGD("Profiling is not turned on, no need to profile step info.");
return SUCCESS;
}

GELOGD("Profiling Step Info TraceTask execute async start, index_id = %lu, model_id = %lu, tag_id = %u",
index_id, model_id, tag_id);
rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream);
rtError_t rt_ret = rtProfilerTraceEx(index_id, model_id, tag_id, stream);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "[Call][rtProfilerTraceEx]Failed, ret 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtProfilerTraceEx failed, ret 0x%X", rt_ret);
@@ -328,7 +338,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::Profil
}
GELOGD("Profiling Step Info TraceTask execute async success, index_id = %lu, model_id = %lu, tag_id = %u",
index_id, model_id, tag_id);
#endif

mmTimespec timespec = mmGetTickCount();
// 1000 ^ 3 converts second to nanosecond
@@ -1014,10 +1023,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetFpBpP
if (is_profiling_valid) {
try {
Json prof_options = Json::parse(profiling_options);

fp_point_ = prof_options[kFpPoint];
bp_point_ = prof_options[kBpPoint];

if (prof_options.contains(kFpPoint)) {
fp_point_ = prof_options[kFpPoint];
}
if (prof_options.contains(kBpPoint)) {
bp_point_ = prof_options[kBpPoint];
}
fp_point = fp_point_;
bp_point = bp_point_;
if (!fp_point_.empty() && !bp_point_.empty()) {


+ 2
- 2
ge/engine_manager/dnnengine_manager.cc View File

@@ -304,7 +304,7 @@ std::string DNNEngineManager::GetHostCpuEngineName(const std::vector<OpInfo> &op
GELOGE(FAILED, "[Get][HostCpuEngineName]Failed, HostCpuEngine not support [%s, %s]",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
REPORT_INNER_ERROR("E19999", "Get HostCpuEngineName failed, HostCpuEngine not support [%s, %s]",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return "";
}

@@ -436,7 +436,7 @@ Status DNNEngineManager::ParserEngineMessage(const json engines_json, const std:
GELOGE(FAILED, "[Check][Param]There are the same engine %s message in the json file",
engine_id.c_str());
REPORT_INNER_ERROR("E19999", "There are the same engine %s message in the json file",
engine_id.c_str());
engine_id.c_str());
return FAILED;
}
engines.emplace(engine_id, engine_conf_ptr);


+ 12
- 18
ge/executor/CMakeLists.txt View File

@@ -1,15 +1,3 @@
set(PROTO_LIST
"${METADEF_DIR}/proto/om.proto"
"${METADEF_DIR}/proto/ge_ir.proto"
"${METADEF_DIR}/proto/insert_op.proto"
"${METADEF_DIR}/proto/task.proto"
"${METADEF_DIR}/proto/op_mapping.proto"
"${METADEF_DIR}/proto/dump_task.proto"
)

protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
protobuf_generate(ge_static PROTO_STATIC_SRCS PROTO_STATIC_HDRS ${PROTO_LIST})

set(SRC_LIST
"ge_executor.cc"
"../common/profiling/profiling_manager.cc"
@@ -19,7 +7,6 @@ set(SRC_LIST
"../common/dump/exception_dumper.cc"
"../common/dump/dump_manager.cc"
"../common/dump/dump_op.cc"
"../common/dump/dump_server.cc"
"../common/dump/opdebug_register.cc"
"../common/profiling/ge_profiling.cc"
"../graph/load/graph_loader.cc"
@@ -168,7 +155,11 @@ set(SRC_LIST
)

######## libge_executor.a ########
add_library(ge_executor STATIC ${SRC_LIST} ${PROTO_STATIC_HDRS})
add_library(ge_executor STATIC ${SRC_LIST})

add_dependencies(ge_executor
graphengine_protos
)

target_compile_options(ge_executor PRIVATE
$<$<OR:$<STREQUAL:${TARGET_SYSTEM_NAME},Linux>,$<STREQUAL:${TARGET_SYSTEM_NAME},Android>>:-fvisibility=hidden -O2 -Werror -Wno-deprecated-declarations -fno-common>
@@ -198,7 +189,7 @@ target_include_directories(ge_executor SYSTEM PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge_static
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
${GE_CODE_DIR}/../inc/cce
@@ -217,7 +208,11 @@ target_link_libraries(ge_executor PRIVATE
)

######## libge_executor.so ########
add_library(ge_executor_shared SHARED ${SRC_LIST} ${PROTO_HDRS})
add_library(ge_executor_shared SHARED ${SRC_LIST})

add_dependencies(ge_executor_shared
graphengine_protos
)

target_compile_options(ge_executor_shared PRIVATE
-fno-common
@@ -245,13 +240,12 @@ target_include_directories(ge_executor_shared PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
${GE_CODE_DIR}/../inc/cce
#### blue zone ####
${GE_CODE_DIR}/third_party/fwkacllib/inc
${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain
)

target_link_options(ge_executor_shared PRIVATE


+ 30
- 18
ge/ge_local_engine/CMakeLists.txt View File

@@ -1,7 +1,3 @@
set(PROTO_LIST
"${METADEF_DIR}/proto/task.proto"
)

set(SRC_LIST
"engine/ge_local_engine.cc"
"ops_kernel_store/ge_local_ops_kernel_info.cc"
@@ -19,12 +15,12 @@ set(OPS_KERNEL_SRC_LIST
"ops_kernel_store/op/no_op.cc"
)

protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST})
protobuf_generate(ge_ops_shared PROTO_OPS_SHARED_SRCS PROTO_OPS_SHARED_HDRS ${PROTO_LIST})
protobuf_generate(ge_ops_static PROTO_OPS_STATIC_SRCS PROTO_OPS_STATIC_HDRS ${PROTO_LIST})

############ libge_local_engine.so ############
add_library(ge_local_engine SHARED ${SRC_LIST} ${PROTO_HDRS})
add_library(ge_local_engine SHARED ${SRC_LIST})

add_dependencies(ge_local_engine
graphengine_protos
)

target_compile_options(ge_local_engine PRIVATE
-Werror
@@ -48,7 +44,7 @@ target_include_directories(ge_local_engine PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
#### blue zone ####
@@ -70,7 +66,11 @@ target_link_libraries(ge_local_engine PRIVATE
)

######### atclib/libge_local_engine.so #############
add_library(atc_ge_local_engine SHARED ${SRC_LIST} ${PROTO_HDRS})
add_library(atc_ge_local_engine SHARED ${SRC_LIST})

add_dependencies(atc_ge_local_engine
graphengine_protos
)

target_compile_options(atc_ge_local_engine PRIVATE
-Werror
@@ -94,7 +94,7 @@ target_include_directories(atc_ge_local_engine PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
#### blue zone ####
@@ -121,7 +121,11 @@ set_target_properties(atc_ge_local_engine PROPERTIES
)

############ libge_local_opskernel_builder.so ############
add_library(ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_OPS_SHARED_HDRS})
add_library(ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST})

add_dependencies(ge_local_opskernel_builder
graphengine_protos
)

target_compile_options(ge_local_opskernel_builder PRIVATE
-Werror
@@ -145,7 +149,7 @@ target_include_directories(ge_local_opskernel_builder PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge_ops_shared
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
#### blue zone ####
@@ -168,7 +172,11 @@ target_link_libraries(ge_local_opskernel_builder PRIVATE
)

############ atclib/libge_local_opskernel_builder.so ############
add_library(atc_ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_OPS_SHARED_HDRS})
add_library(atc_ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST})

add_dependencies(atc_ge_local_opskernel_builder
graphengine_protos
)

target_compile_options(atc_ge_local_opskernel_builder PRIVATE
-Werror
@@ -192,7 +200,7 @@ target_include_directories(atc_ge_local_opskernel_builder PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge_ops_shared
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
#### blue zone ####
@@ -220,7 +228,11 @@ set_target_properties(atc_ge_local_opskernel_builder PROPERTIES
)

############ libge_local_opskernel_builder.a ############
add_library(ge_local_opskernel_builder_static STATIC ${OPS_KERNEL_SRC_LIST} ${PROTO_OPS_STATIC_HDRS})
add_library(ge_local_opskernel_builder_static STATIC ${OPS_KERNEL_SRC_LIST})

add_dependencies(ge_local_opskernel_builder_static
graphengine_protos
)

target_compile_options(ge_local_opskernel_builder_static PRIVATE
-Werror
@@ -245,7 +257,7 @@ target_include_directories(ge_local_opskernel_builder_static PRIVATE
${METADEF_DIR}/inc/external/graph
${METADEF_DIR}/inc/graph
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}/proto/ge_ops_static
${CMAKE_BINARY_DIR}/proto/graphengine_protos
#### yellow zone ####
${GE_CODE_DIR}/../inc
#### blue zone ####


+ 19
- 15
ge/ge_local_engine/engine/host_cpu_engine.cc View File

@@ -26,12 +26,15 @@
#include "common/math/math_util.h"

namespace {
#define CREATE_OUTPUT_CASE(DTYPE, TYPE) \
#define CREATE_OUTPUT_CASE(DTYPE) \
case (DTYPE): { \
GeTensorPtr ge_tensor = nullptr; \
if (need_create_flag) { \
uint64_t size = data_num * sizeof(TYPE); \
ge_tensor = MakeShared<GeTensor>(out_desc, size); \
int64_t size = ge::GetSizeInBytes(static_cast<int64_t>(data_num), DTYPE); \
if (size < 0) { \
return INTERNAL_ERROR; \
} \
ge_tensor = MakeShared<GeTensor>(out_desc, static_cast<size_t>(size)); \
GE_CHECK_NOTNULL(ge_tensor); \
GELOGD("node:%s allocate output %zu success, size=%ld", op_desc->GetName().c_str(), i, size); \
ge_tensor->MutableTensorDesc().SetDataType(out_desc.GetDataType()); \
@@ -180,18 +183,19 @@ Status HostCpuEngine::PrepareOutputs(const ge::ConstOpDescPtr &op_desc,
}
}
switch (out_desc.GetDataType()) {
CREATE_OUTPUT_CASE(DT_BOOL, bool)
CREATE_OUTPUT_CASE(DT_INT8, int8_t)
CREATE_OUTPUT_CASE(DT_INT16, int16_t)
CREATE_OUTPUT_CASE(DT_INT32, int32_t)
CREATE_OUTPUT_CASE(DT_INT64, int64_t)
CREATE_OUTPUT_CASE(DT_UINT8, uint8_t)
CREATE_OUTPUT_CASE(DT_UINT16, uint16_t)
CREATE_OUTPUT_CASE(DT_UINT32, uint32_t)
CREATE_OUTPUT_CASE(DT_UINT64, uint64_t)
CREATE_OUTPUT_CASE(DT_FLOAT16, fp16_t)
CREATE_OUTPUT_CASE(DT_FLOAT, float)
CREATE_OUTPUT_CASE(DT_DOUBLE, double)
CREATE_OUTPUT_CASE(DT_BOOL)
CREATE_OUTPUT_CASE(DT_INT8)
CREATE_OUTPUT_CASE(DT_INT16)
CREATE_OUTPUT_CASE(DT_INT32)
CREATE_OUTPUT_CASE(DT_INT64)
CREATE_OUTPUT_CASE(DT_UINT8)
CREATE_OUTPUT_CASE(DT_UINT16)
CREATE_OUTPUT_CASE(DT_UINT32)
CREATE_OUTPUT_CASE(DT_UINT64)
CREATE_OUTPUT_CASE(DT_FLOAT16)
CREATE_OUTPUT_CASE(DT_FLOAT)
CREATE_OUTPUT_CASE(DT_DOUBLE)
CREATE_OUTPUT_CASE(DT_INT4)
default:
GELOGW("data type %s not support.",
TypeUtils::DataTypeToSerialString(out_desc.GetDataType()).c_str());


+ 37
- 0
ge/generator/ge_generator.cc View File

@@ -31,6 +31,7 @@
#include "graph/ge_context.h"
#include "graph/manager/graph_manager.h"
#include "graph/manager/util/rt_context_util.h"
#include "graph/operator_factory_impl.h"
#include "graph/opsproto_manager.h"
#include "graph/utils/graph_utils.h"
#include "graph/utils/type_utils.h"
@@ -803,6 +804,41 @@ Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector<GeTensor>
return SUCCESS;
}

Status GeGenerator::InferFormatForSingleOp(OpDescPtr &op_desc) {
GE_CHECK_NOTNULL(op_desc);
if (OperatorFactoryImpl::GetInferFormatFunc(op_desc->GetType()) != nullptr) {
auto node_op = ge::OperatorFactoryImpl::CreateOperator("node_op", op_desc->GetType());
if (node_op.IsEmpty()) {
GELOGW("get op from OperatorFactory fail. op type: %s", op_desc->GetType().c_str());
} else {
GELOGD("get op from OperatorFactory success. op type: %s", op_desc->GetType().c_str());
auto temp_op_desc = ge::OpDescUtils::GetOpDescFromOperator(node_op);
if (temp_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "GetOpDescFromOperator failed, as return nullptr, type:%s",
op_desc->GetType().c_str());
GELOGE(FAILED, "[Get][OpDesc] temp op desc is null, type:%s", op_desc->GetType().c_str());
return FAILED;
}
if (!op_desc->UpdateInputName(temp_op_desc->GetAllInputName())) {
GELOGW("InferFormatForSingleOp UpdateInputName failed");
}
if (!op_desc->UpdateOutputName(temp_op_desc->GetAllOutputName())) {
GELOGW("InferFormatForSingleOp UpdateOutputName failed");
}
}
node_op.BreakConnect();
}
auto op = OpDescUtils::CreateOperatorFromOpDesc(op_desc);
auto ret = op_desc->CallInferFormatFunc(op);
if (ret != GRAPH_SUCCESS) {
REPORT_INNER_ERROR("E19999", "call InferFormatFunc for single op:%s fail",
op_desc->GetName().c_str());
GELOGE(FAILED, "[Call][InferFormatFunc] for single op:%s fail.", op_desc->GetName().c_str());
return FAILED;
}
return SUCCESS;
}

Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &inputs, const vector<GeTensor> &outputs,
const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff,
bool is_offline, int32_t compile_flag) {
@@ -843,6 +879,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
Graph graph;
GE_CHK_STATUS(BuildSingleOpGraph(op_desc, inputs, outputs, name, graph),
"[Build][Graph] for single op:%s fail.", op_desc->GetName().c_str());
GE_CHK_STATUS_RET_NOLOG(InferFormatForSingleOp(op_desc));

// 2. check engine type when compile online
if (model_file_name == kFileNameSuffix) {


+ 52
- 10
ge/graph/build/memory/graph_mem_assigner.cc View File

@@ -69,6 +69,10 @@ int64_t GetSymbolOutputOffset(const std::map<std::string, std::string> &anchor_t
}
return ge::kInvalidOffset;
}

bool isVariableMemoryNode(const ge::NodePtr &node) {
return (node->GetType() == ge::VARIABLE) || (node->GetType() == ge::CONSTANTOP);
}
} // namespace
namespace ge {
Status VariableMemoryAssigner::Assign() {
@@ -447,22 +451,31 @@ bool IsContinuousInputConflict(const ge::NodePtr &node, const OpDescPtr &peer_op
/// op1 -> node -> op2
/// return true when node is ref from input, and op1 or op2 is reuse input from output
bool GraphMemoryAssigner::IsRefFromInputOpCascade(const NodePtr &node) {
bool ref_from_input = false;
std::unordered_set<int32_t> ref_input_index;
int32_t reuse_in_index = -1;
for (const auto &out_anchor : node->GetAllOutDataAnchors()) {
ref_from_input = GraphUtils::IsRefFromInput(out_anchor, reuse_in_index);
if (ref_from_input) {
bool reuse_input = GraphUtils::IsRefFromInput(out_anchor, reuse_in_index);
if (reuse_input) {
GELOGD("IsRefFromInputOpCascade: cur node:%s:%d is ref", node->GetName().c_str(), reuse_in_index);
break;
ref_input_index.insert(reuse_in_index);
}
}
bool ref_from_input = !ref_input_index.empty();
if (!ref_from_input) {
return false;
}

for (const auto &in_anchor : node->GetAllInDataAnchors()) {
const auto &peer_out_anchor = in_anchor->GetPeerOutAnchor();
GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue);
auto in_node = peer_out_anchor->GetOwnerNode();
if (isVariableMemoryNode(in_node) && (ref_input_index.count(in_anchor->GetIdx()) > 0)) {
GELOGD("Reuse variable memory, input node:%s, type:%s.", in_node->GetName().c_str(), in_node->GetType().c_str());
return false;
}
if (ref_from_input && GraphUtils::IsRefFromInput(peer_out_anchor, reuse_in_index)) {
GELOGD("IsRefFromInputOpCascade: in node[%s] is ref, reuse index is:%d",
peer_out_anchor->GetOwnerNode()->GetName().c_str(), reuse_in_index);
in_node->GetName().c_str(), reuse_in_index);
return true;
}
}
@@ -500,6 +513,11 @@ Status GraphMemoryAssigner::UpdateRefOpOffsetReverse(const NodePtr &node) {
GE_CHECK_NOTNULL(peer_out_anchor);
auto peer_node = peer_out_anchor->GetOwnerNode();
GE_CHECK_NOTNULL(peer_node);
if (isVariableMemoryNode(peer_node)) {
GELOGW("Peer node to update is %s, skip it. Node name:%s.",
peer_node->GetType().c_str(), peer_node->GetName().c_str());
continue;
}
auto peer_op_desc = peer_node->GetOpDesc();
GE_CHECK_NOTNULL(peer_op_desc);
vector<int64_t> peer_output_list = peer_op_desc->GetOutputOffset();
@@ -666,7 +684,8 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node,
bool is_allocated_first_input = is_continuous_input_allocated && (in_data_anchor->GetIdx() == 0);
if (is_allocated_first_input) {
std::map<int32_t, int32_t> out2ins;
GE_CHK_STATUS_RET(TryGetNodeRefIndexes(node, out2ins), "[Get][RefIndexes]fail for node: %s", node->GetName().c_str());
GE_CHK_STATUS_RET(TryGetNodeRefIndexes(node, out2ins), "[Get][RefIndexes]fail for node: %s",
node->GetName().c_str());
// output is beginning offset, set offset for input; only support this case now
if ((out2ins.size() == 1) && (out2ins.begin()->second == 0) && (reverse_refresh)) {
auto peer_output_offset = output_list.at(peer_out_data_anchor->GetIdx());
@@ -1496,6 +1515,12 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector<
output_list = last_peer_out_op_desc->GetOutputOffset();
auto out_index = static_cast<unsigned long>(peer_out_anchor->GetIdx());
if (output_list.size() > static_cast<size_t>(out_index)) {
int64_t peer_out_inner_offset = 0;
if (ge::AttrUtils::GetInt(last_peer_out_op_desc->MutableOutputDesc(out_index), ATTR_NAME_INNER_OFFSET,
peer_out_inner_offset)) {
(void)ge::AttrUtils::SetInt(tmp_op_desc->MutableInputDesc(anchor->GetIdx()), ATTR_NAME_INNER_OFFSET,
peer_out_inner_offset);
}
bool is_l1_type = false;
int64_t input_offset = output_list.at(out_index);
if (has_mem_type_attr && !origin_input_list.empty()) {
@@ -1510,15 +1535,27 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node, vector<
GE_ERRORLOG_AND_ERRORMSG(ge::FAILED, error.c_str());
return ge::FAILED;
}
GELOGD("Node[%s] input[%d] has origin offset[%ld]", tmp_op_desc->GetName().c_str(), anchor->GetIdx(),
origin_input_list[valid_input_index]);
int64_t inner_offset = 0;
(void)ge::AttrUtils::GetInt(tmp_op_desc->MutableInputDesc(anchor->GetIdx()), ATTR_NAME_INNER_OFFSET,
inner_offset);
GELOGD("Node[%s] input[%d] has origin offset[%ld] origin_inner_offset[%ld]", tmp_op_desc->GetName().c_str(),
anchor->GetIdx(), origin_input_list[valid_input_index], inner_offset);
// L1 keep original input_offset
is_l1_type = (memory_type[valid_input_index] == RT_MEMORY_L1);
if (is_l1_type) {
input_offset = origin_input_list[valid_input_index];
} else {
// hbm input_offset = original input_offset + output_offset
if ((origin_input_list[valid_input_index] != 0) && (!tmp_op_desc->GetSubgraphInstanceNames().empty())) {
std::string error = "Node" + FmtToStr(tmp_op_desc->GetName()) +
+" has subgraphs which is conflict with has origin_input_list" +
FmtToStr(origin_input_list[valid_input_index]);
GE_ERRORLOG_AND_ERRORMSG(ge::FAILED, error.c_str());
return ge::FAILED;
}
input_offset = origin_input_list[valid_input_index] + output_list.at(out_index);
(void)ge::AttrUtils::SetInt(tmp_op_desc->MutableInputDesc(anchor->GetIdx()), ATTR_NAME_INNER_OFFSET,
origin_input_list[valid_input_index] + inner_offset);
}
}
const auto &in_node = GetKnownInputNode(peer_out_anchor->GetOwnerNode());
@@ -1546,6 +1583,8 @@ ge::Status GraphMemoryAssigner::UpdateRefOpOutputOffset(const NodePtr &node, con
const int ref_in, const int64_t input_offset) const {
auto opdesc = node->GetOpDesc();
GE_CHECK_NOTNULL(opdesc);
int64_t inner_offset = 0;
bool has_inner_offset = ge::AttrUtils::GetInt(opdesc->MutableInputDesc(ref_in), ATTR_NAME_INNER_OFFSET, inner_offset);
for (const auto &out2in : out2ins) {
auto out_i = out2in.first;
auto in_i = out2in.second;
@@ -1559,8 +1598,11 @@ ge::Status GraphMemoryAssigner::UpdateRefOpOutputOffset(const NodePtr &node, con
}
origin_output_list[out_i] = input_offset;
opdesc->SetOutputOffset(origin_output_list);
GELOGI("Node[%s] output[%d] is updated from reuse input index[%d] to offset[%ld]", opdesc->GetName().c_str(),
out_i, ref_in, input_offset);
if (has_inner_offset) {
(void)ge::AttrUtils::SetInt(opdesc->MutableOutputDesc(out_i), ATTR_NAME_INNER_OFFSET, inner_offset);
}
GELOGI("Node[%s] output[%d] is updated from reuse input index[%d] to offset[%ld], inner_offset[%ld]", opdesc->GetName().c_str(),
out_i, ref_in, input_offset, inner_offset);
}
}
return ge::SUCCESS;


+ 2
- 1
ge/graph/build/model_builder.cc View File

@@ -246,7 +246,8 @@ Status ModelBuilder::SetInputOutputDesc() {
}
// if user set input node format ND, the expected node for data and netoutput format is ND in
// final graph.
if ((compute_graph_->GetParentGraph() == nullptr) && (GetLocalOmgContext().format == domi::DOMI_TENSOR_ND) && (!node_op_desc->HasAttr("_is_single_op")) &&
if ((compute_graph_->GetParentGraph() == nullptr) && (GetLocalOmgContext().format == domi::DOMI_TENSOR_ND) &&
(!node_op_desc->HasAttr("_is_single_op")) &&
((node_op_desc->GetType() == DATA_TYPE) || (node_op_desc->GetType() == NETOUTPUT))) {
auto inputDescsPtr = node_op_desc->GetAllInputsDescPtr();
auto outputDescsPtr = node_op_desc->GetAllOutputsDescPtr();


+ 12
- 2
ge/graph/build/stream_allocator.cc View File

@@ -905,6 +905,7 @@ Status StreamAllocator::SplitStreams(vector<set<int64_t>> &split_streams) {
added_stream_num_vec[stream_id]++;
new_stream_id_vec[stream_id] = last_stream_id;
split_streams[stream_id].emplace(last_stream_id);
split_ori_stream_map_[last_stream_id] = stream_id;
node_split_stream_map_[cur_node] = last_stream_id;

// Add the send/recv event to the first and last nodes of the split stream.
@@ -1104,7 +1105,7 @@ Status StreamAllocator::UpdateActiveStreamsForActiveNode(const vector<set<int64_
return SUCCESS;
}

Status StreamAllocator::UpdateActiveStreamsForSubgraphs() const {
Status StreamAllocator::UpdateActiveStreamsForSubgraphs() {
// Update active stream list for active nodes
for (auto &node_stream_pair : node_split_stream_map_) {
auto node = node_stream_pair.first;
@@ -1134,6 +1135,7 @@ Status StreamAllocator::UpdateActiveStreamsForSubgraphs() const {
if (IsActivated(new_split_stream)) {
continue;
}
specific_activated_streams_.emplace(new_split_stream);
new_active_streams.emplace(static_cast<uint32_t>(new_split_stream));
active_streams.assign(new_active_streams.begin(), new_active_streams.end());
if (!AttrUtils::SetListInt(active_op, ATTR_NAME_ACTIVE_STREAM_LIST, active_streams)) {
@@ -1148,13 +1150,21 @@ Status StreamAllocator::UpdateActiveStreamsForSubgraphs() const {
}

bool StreamAllocator::IsActivated(int64_t stream_id) const {
const auto &iter = split_ori_stream_map_.find(stream_id);
if (iter == split_ori_stream_map_.end()) {
REPORT_INNER_ERROR("E19999", "Find original stream_id failed, split_stream_id=%ld", stream_id);
GELOGE(INTERNAL_ERROR, "[CheckActivated][Check] Find original stream_id failed, split_stream_id=%ld", stream_id);
return false;
}
int64_t ori_stream_id = iter->second;
for (const auto &node : whole_graph_->GetNodes(whole_graph_->GetGraphUnknownFlag())) {
auto op_desc = node->GetOpDesc();
vector<uint32_t> active_streams;
if (op_desc == nullptr || !AttrUtils::GetListInt(op_desc, ATTR_NAME_ACTIVE_STREAM_LIST, active_streams)) {
continue;
}
if (std::find(active_streams.begin(), active_streams.end(), stream_id) != active_streams.end()) {
if (std::find(active_streams.begin(), active_streams.end(), stream_id) != active_streams.end() ||
std::find(active_streams.begin(), active_streams.end(), ori_stream_id) != active_streams.end()) {
return true;
}
}


+ 3
- 2
ge/graph/build/stream_allocator.h View File

@@ -66,7 +66,7 @@ class StreamAllocator {
Status UpdateActiveStreamsForSwitchNode(NodePtr &switch_node);
Status InsertActiveNodesAfterSwitch(NodePtr &switch_nodes, std::vector<NodePtr> &switch_active_nodes);
Status UpdateActiveStreamsForActiveNode(const std::vector<std::set<int64_t>> &split_streams, NodePtr &node);
Status UpdateActiveStreamsForSubgraphs() const;
Status UpdateActiveStreamsForSubgraphs();
bool IsActivated(int64_t stream_id) const;
Status SetActiveStreamsForLoop();
Status CheckStreamActived() const;
@@ -114,6 +114,7 @@ class StreamAllocator {
std::map<int64_t, std::set<NodePtr>> specific_activated_streams_nodes_map_;

std::map<NodePtr, int64_t> node_split_stream_map_;
std::map<int64_t, int64_t> split_ori_stream_map_;
std::map<ComputeGraphPtr, NodePtr> subgraph_first_active_node_map_;

// send events corresponding to the node
@@ -123,4 +124,4 @@ class StreamAllocator {
std::map<NodePtr, std::vector<uint32_t>> node_to_recv_events_;
};
} // namespace ge
#endif // GE_GRAPH_BUILD_STREAM_ALLOCATOR_H_
#endif // GE_GRAPH_BUILD_STREAM_ALLOCATOR_H_

+ 38
- 10
ge/graph/build/task_generator.cc View File

@@ -187,33 +187,61 @@ Status TaskGenerator::AddModelTaskToModel(const ModelTaskDef &model_task_def, ui
}

Status TaskGenerator::UpdateOpIsVarAttr(const OpDescPtr &op_desc, uint64_t session_id) {
vector<int64_t> input_offsets = op_desc->GetInputOffset();
GELOGD("Update is var attr, node[name:%s(%s), id:%ld, stream_id:%ld].", op_desc->GetName().c_str(),
op_desc->GetType().c_str(), op_desc->GetId(), op_desc->GetStreamId());
// input
vector<int64_t> input_offsets = op_desc->GetInputOffset();
if (!(input_offsets.empty())) {
vector<bool> input_var;
for (int64_t input : input_offsets) {
input_var.push_back(VarManager::Instance(session_id)->IsVarAddr(input));
size_t valid_input_index = 0;
for (uint32_t i = 0; i < op_desc->GetAllInputsSize(); i++) {
vector<int64_t> output_list;
auto input_tensor_desc = op_desc->MutableInputDesc(i);
if (input_tensor_desc == nullptr) {
continue;
}
if (valid_input_index >= input_offsets.size()) {
break;
}
int64_t inner_offset = 0;
(void)ge::AttrUtils::GetInt(input_tensor_desc, ATTR_NAME_INNER_OFFSET, inner_offset);
GELOGD("Node[%s] input[%u] has inner_offset[%ld]", op_desc->GetName().c_str(), i, inner_offset);
input_var.push_back(VarManager::Instance(session_id)->IsVarAddr(input_offsets[valid_input_index] - inner_offset));
valid_input_index++;
}
GE_CHK_BOOL_EXEC(AttrUtils::SetListBool(op_desc, kIsInputVar, input_var),
REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", kIsInputVar,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", kIsInputVar,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", kIsInputVar, op_desc->GetName().c_str(),
op_desc->GetType().c_str());
return FAILED);
}

// output
vector<int64_t> output_offsets = op_desc->GetOutputOffset();
if (!(output_offsets.empty())) {
vector<bool> output_var;
for (int64_t output : output_offsets) {
output_var.push_back(VarManager::Instance(session_id)->IsVarAddr(output));
size_t valid_output_index = 0;
for (uint32_t i = 0; i < op_desc->GetAllOutputsDescSize(); i++) {
vector<int64_t> output_list;
auto output_tensor_desc = op_desc->MutableOutputDesc(i);
if (output_tensor_desc == nullptr) {
continue;
}
if (valid_output_index >= output_offsets.size()) {
break;
}
int64_t inner_offset = 0;
(void)ge::AttrUtils::GetInt(output_tensor_desc, ATTR_NAME_INNER_OFFSET, inner_offset);
GELOGD("Node[%s] output[%u] has inner_offset[%ld]", op_desc->GetName().c_str(), i, inner_offset);
output_var.push_back(
VarManager::Instance(session_id)->IsVarAddr(output_offsets[valid_output_index] - inner_offset));
valid_output_index++;
}
GE_CHK_BOOL_EXEC(AttrUtils::SetListBool(op_desc, kIsOutputVar, output_var),
REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", kIsOutputVar,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", kIsOutputVar,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", kIsOutputVar, op_desc->GetName().c_str(),
op_desc->GetType().c_str());
return FAILED);
}
return SUCCESS;


+ 29
- 18
ge/graph/common/omg_util.cc View File

@@ -193,23 +193,29 @@ Status SetCyclicDependenceFlag(const ge::NodePtr &node) {

///
/// @brief set op next_iteration name
/// @param [in] node
/// @param [in] next
/// @param [in] Merge Node
/// @param [in] NextIteration Node
/// @return Status
///
Status SetNextIteration(const ge::NodePtr &node, const std::string &next) {
Status SetNextIteration(const NodePtr &node, const NodePtr &next) {
GE_CHECK_NOTNULL(node);
OpDescPtr tmp_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(tmp_desc);
GE_CHECK_NOTNULL(next);
GE_CHECK_NOTNULL(node->GetOpDesc());
GE_CHECK_NOTNULL(next->GetOpDesc());

if (!AttrUtils::SetStr(tmp_desc, ge::ATTR_NAME_NEXT_ITERATION, next)) {
REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
const auto SetIterationName = [](const OpDescPtr &op_desc, const std::string &name) {
if (!AttrUtils::SetStr(op_desc, ATTR_NAME_NEXT_ITERATION, name)) {
REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_NEXT_ITERATION.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED;
}
return SUCCESS;
};

GE_CHK_STATUS_RET_NOLOG(SetIterationName(node->GetOpDesc(), next->GetName()));
GE_CHK_STATUS_RET_NOLOG(SetIterationName(next->GetOpDesc(), node->GetName()));
return SUCCESS;
}

@@ -272,19 +278,24 @@ bool IsUnknownShapeTensor(const GeTensorDesc &tensor_desc) {
/// @brief Set Op _force_unknown_shape flag
/// @param [in] node
/// @param [in] force_unknown, set attribute if true
/// @param [in] group_index, condition group index of node.
/// @return
///
void MarkForceUnknownShape(const NodePtr &node, bool force_unknown) {
GE_RT_VOID_CHECK_NOTNULL(node);
void MarkForceUnknownShape(const NodePtr &node, bool force_unknown, int64_t group_index) {
if (!force_unknown) {
return;
}

GELOGD("[%s] mark as force unknown shape node", node->GetName().c_str());
if (!AttrUtils::SetBool(node->GetOpDesc(), ATTR_NAME_FORCE_UNKNOWN_SHAPE, force_unknown)) {
REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_FORCE_UNKNOWN_SHAPE.c_str(),
GE_RT_VOID_CHECK_NOTNULL(node);
const auto &op_desc = node->GetOpDesc();
GE_RT_VOID_CHECK_NOTNULL(op_desc);

// op_desc as AttrHolderAdapter valid, Set attribute always success, just log for check.
GELOGD("[%s] Set control flow group index: %ld", node->GetName().c_str(), group_index);
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_CONTROL_FLOW_GROUP, group_index)) {
REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for op:%s(%s)", ATTR_NAME_CONTROL_FLOW_GROUP.c_str(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_FORCE_UNKNOWN_SHAPE.c_str(),
GELOGE(FAILED, "[Set][Attr] %s fail for op:%s(%s)", ATTR_NAME_CONTROL_FLOW_GROUP.c_str(),
node->GetName().c_str(), node->GetType().c_str());
}
}


+ 5
- 4
ge/graph/common/omg_util.h View File

@@ -96,11 +96,11 @@ Status SetCyclicDependenceFlag(const ge::NodePtr &node);

///
/// @brief set op next_iteration name
/// @param [in] node
/// @param [in] next
/// @param [in] Merge Node
/// @param [in] NextIteration Node
/// @return Status
///
Status SetNextIteration(const ge::NodePtr &node, const std::string &next);
Status SetNextIteration(const NodePtr &node, const NodePtr &next);

///
/// @brief Align the memory
@@ -129,9 +129,10 @@ bool IsUnknownShapeTensor(const GeTensorDesc &tensor_desc);
/// @brief Set Op _force_unknown_shape flag
/// @param [in] node
/// @param [in] force_unknown, set attribute if true
/// @param [in] group_index, condition group index of node.
/// @return
///
void MarkForceUnknownShape(const NodePtr &node, bool force_unknown);
void MarkForceUnknownShape(const NodePtr &node, bool force_unknown, int64_t group_index);
} // namespace ge

#endif // GE_GRAPH_COMMON_OMG_UTIL_H_

+ 1
- 1
ge/graph/execute/graph_execute.cc View File

@@ -704,7 +704,7 @@ Status GraphExecutor::GetCurShape(const uint32_t model_id, std::vector<int64_t>
}

Status GraphExecutor::GetOpAttr(uint32_t model_id, const std::string &op_name, const std::string &attr_name,
std::string &attr_value) {
std::string &attr_value) {
auto model_manager = ge::ModelManager::GetInstance();
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->GetOpAttr(model_id, op_name, attr_name, attr_value);


+ 30
- 30
ge/graph/load/graph_loader.cc View File

@@ -33,12 +33,12 @@ Status GraphLoader::UnloadModel(uint32_t model_id) {

Status ret = model_manager->Stop(model_id);
if (ret != SUCCESS) {
GELOGE(ret, "UnloadModel: Stop failed. model id:%u", model_id);
GELOGE(ret, "[Stop][Model] failed. model id:%u", model_id);
}

ret = model_manager->Unload(model_id);
if (ret != SUCCESS) {
GELOGE(ret, "UnloadModel: Unload failed. model id:%u", model_id);
GELOGE(ret, "[Unload][Model] failed. model id:%u", model_id);
return ret;
}
GELOGI("UnLoad model success, model id:%u.", model_id);
@@ -50,14 +50,13 @@ Status GraphLoader::LoadModelOnline(uint32_t &model_id, const std::shared_ptr<ge
GELOGI("Load model online begin.");
rtError_t rt_ret = rtSetDevice(GetContext().DeviceId());
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtSetDevice failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtSetDevice failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "[Call][RtSetDevice] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
return RT_FAILED;
}
if (ge_root_model_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Check param ge_root_model_ptr nullptr, check invalid");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[LoadGraph] GE load graph model_ptr is nullptr.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[LoadGraph][Check][Param] GE load graph model_ptr is nullptr.");
return GE_GRAPH_PARAM_NULLPTR;
}

@@ -65,12 +64,12 @@ Status GraphLoader::LoadModelOnline(uint32_t &model_id, const std::shared_ptr<ge
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->LoadModelOnline(model_id, ge_root_model_ptr, listener);
if (ret != SUCCESS) {
GELOGE(ret, "LoadModel: Load failed. ret = %u", ret);
GELOGE(ret, "[Load][Model] Online failed. ret = %u, model_id:%u", ret, model_id);
rt_ret = rtDeviceReset(GetContext().DeviceId());
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtDeviceReset failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtDeviceReset] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
}
return ret;
}
@@ -81,31 +80,31 @@ Status GraphLoader::LoadModelOnline(uint32_t &model_id, const std::shared_ptr<ge
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtDeviceReset failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtDeviceReset] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
}
return SUCCESS;
}
ret = model_manager->Start(model_id);
if (ret != SUCCESS) {
if (model_manager->Unload(model_id) != SUCCESS) {
GELOGE(ret, "LoadModel: Unload failed while trying to unload after a failed start.");
GELOGE(ret, "[Unload][Model] failed while trying to unload after a failed start, model_id:%u.", model_id);
}

rt_ret = rtDeviceReset(GetContext().DeviceId());
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtDeviceReset failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtDeviceReset] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
}

GELOGE(ret, "LoadModel: Start failed.");
GELOGE(ret, "[Start][Model] failed, model_id:%u.", model_id);
return ret;
}
rt_ret = rtDeviceReset(GetContext().DeviceId());
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtDeviceReset failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtDeviceReset] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
return RT_FAILED;
}
GELOGI("Load model online success, model_id:%u.", model_id);
@@ -118,7 +117,7 @@ Status GraphLoader::GetMaxUsedMemory(uint32_t model_id, uint64_t &max_size) {
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->GetMaxUsedMemory(model_id, max_size);
if (ret != SUCCESS) {
GELOGE(ret, "GetMaxUsedMemory: GetMaxUsedMemory failed.");
GELOGE(ret, "[Call][GetMaxUsedMemory] failed, model_id:%u.", model_id);
return ret;
}
return SUCCESS;
@@ -127,21 +126,20 @@ Status GraphLoader::GetMaxUsedMemory(uint32_t model_id, uint64_t &max_size) {
Status GraphLoader::LoadDataFromFile(const std::string &path, const std::string &key_path, int32_t priority,
ModelData &model_data) {
if (!CheckInputPathValid(path)) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "model path is invalid: %s", path.c_str());
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param] model path is invalid:%s", path.c_str());
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
}

GELOGI("Load model begin, model path is: %s", path.c_str());
if (!key_path.empty() && !CheckInputPathValid(key_path)) {
REPORT_INNER_ERROR("E19999", "Param key_path:%s empty or invalid",
key_path.c_str());
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "decrypt_key path is invalid: %s", key_path.c_str());
REPORT_INNER_ERROR("E19999", "Param key_path:%s empty or invalid", key_path.c_str());
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Check][Param] decrypt_key path is invalid:%s", key_path.c_str());
return ACL_ERROR_GE_PARAM_INVALID;
}

Status ret = ModelParserBase::LoadFromFile(path.c_str(), key_path.c_str(), priority, model_data);
if (ret != SUCCESS) {
GELOGE(ret, "LoadModelFromFile: Load failed. ret = %u", ret);
GELOGE(ret, "[Call][LoadFromFile] failed. ret = %u, path:%s, key path:%s", ret, path.c_str(), key_path.c_str());
if (model_data.model_data != nullptr) {
delete[] static_cast<char *>(model_data.model_data);
model_data.model_data = nullptr;
@@ -156,18 +154,19 @@ Status GraphLoader::CommandHandle(const Command &command) {
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->HandleCommand(command);
if (ret != SUCCESS) {
GELOGE(ret, "CommandHandle: Command Handle failed.");
GELOGE(ret, "[Handle][Command] failed, module_index:%lu.", command.module_index);

return ret;
}
} catch (std::bad_alloc &) {
REPORT_INNER_ERROR("E19999", "Bad memory allocation occur");
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Command handle failed, bad memory allocation occur !");
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Handle][Command] failed, "
"bad memory allocation occur, module_index:%lu.", command.module_index);

return ACL_ERROR_GE_MEMORY_ALLOCATION;
} catch (...) {
REPORT_INNER_ERROR("E19999", "Some exceptions occur");
GELOGE(FAILED, "Command handle failed, some exceptions occur !");
GELOGE(FAILED, "[Handle][Command] failed, some exceptions occur, module_index:%lu.", command.module_index);

return FAILED;
}
@@ -184,7 +183,7 @@ Status GraphLoader::LoadModelFromData(uint32_t &model_id, const ModelData &model
Status ret = model_manager->LoadModelOffline(
model_id, model_data, nullptr, dev_ptr, mem_size, weight_ptr, weight_size);
if (ret != SUCCESS) {
GELOGE(ret, "Load model failed, model_id:%u.", model_id);
GELOGE(ret, "[Load][Model] failed, model_id:%u.", model_id);
return ret;
}
GELOGI("Load model success, model_id:%u.", model_id);
@@ -210,7 +209,7 @@ Status GraphLoader::LoadModelWithQ(uint32_t &model_id, const ModelData &model_da
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->LoadModelWithQ(model_id, model_data, input_queue_ids, output_queue_ids);
if (ret != SUCCESS) {
GELOGE(ret, "Load model with queue failed, model_id:%u.", model_id);
GELOGE(ret, "[Load][Model] with queue failed, model_id:%u.", model_id);
return ret;
}

@@ -237,7 +236,7 @@ Status GraphLoader::ExecuteModel(uint32_t model_id, rtStream_t stream, bool asyn
Status ret = model_manager->ExecuteModel(model_id, stream, async_mode,
input_data, input_desc, output_data, output_desc);
if (ret != SUCCESS) {
GELOGE(ret, "Execute model failed, model_id:%u.", model_id);
GELOGE(ret, "[Execute][Model] failed, model_id:%u.", model_id);
return ret;
}

@@ -250,7 +249,7 @@ Status GraphLoader::GetMemoryInfo(int64_t &free) {
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtSetDevice failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtSetDevice] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
return RT_FAILED;
}
size_t total_mem = 0;
@@ -258,14 +257,14 @@ Status GraphLoader::GetMemoryInfo(int64_t &free) {
rt_ret = rtMemGetInfo(&free_mem, &total_mem);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemGetInfo failed, ret:0x%X", rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtMemGetInfo] failed, ret:0x%X", rt_ret);
return RT_FAILED;
}
rt_ret = rtDeviceReset(GetContext().DeviceId());
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtDeviceReset failed, device_id:%u, ret:0x%X",
GetContext().DeviceId(), rt_ret);
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtDeviceReset] failed, device_id:%u, ret:0x%X", GetContext().DeviceId(), rt_ret);
return RT_FAILED;
}
// Add small page memory size
@@ -280,7 +279,8 @@ Status GraphLoader::DestroyAicpuKernel(uint64_t session_id, uint32_t model_id, u
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->DestroyAicpuKernel(session_id, model_id, sub_model_id);
if (ret != SUCCESS) {
GELOGE(ret, "Destroy aicpu kernel failed.");
GELOGE(ret, "[Destroy][AicpuKernel] failed, session_id:%lu, model_id:%u, sub_model_id:%u.",
session_id, model_id, sub_model_id);
return ret;
}
return SUCCESS;
@@ -291,7 +291,7 @@ Status GraphLoader::DestroyAicpuSessionForInfer(uint32_t model_id) {
GE_CHECK_NOTNULL(model_manager);
Status ret = model_manager->DestroyAicpuSessionForInfer(model_id);
if (ret != SUCCESS) {
GELOGE(ret, "Destroy aicpu serrion for infer failed.");
GELOGE(ret, "[Call][DestroyAicpuSessionForInfer] failed, model_id:%u.", model_id);
return ret;
}
return SUCCESS;


+ 24
- 9
ge/graph/load/model_manager/davinci_model.cc View File

@@ -488,6 +488,8 @@ void DavinciModel::InitRuntimeParams() {
session_scope_mem_info.memory_size = static_cast<size_t>(ret ? value : 0);
runtime_param_.memory_infos[kSessionScopeMemory | RT_MEMORY_HBM] = std::move(session_scope_mem_info);

ret = ge::AttrUtils::GetInt(ge_model_, ATTR_MODEL_ZERO_COPY_MEMORY_SIZE, value);
runtime_param_.zero_copy_size = ret ? value : 0;
GELOGI("InitRuntimeParams(), %s.", runtime_param_.ToString().c_str());
}

@@ -3977,7 +3979,6 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa
is_dynamic_ = input_data.is_dynamic_batch;

bool profiling_model_execute_on = ProfilingManager::Instance().ProfilingModelExecuteOn();
bool profiling_model_load_on = ProfilingManager::Instance().ProfilingModelLoadOn();
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_PRE_PROC_START));
Status ret = CopyModelData(input_data, output_data, is_dynamic_);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return ret,
@@ -3991,10 +3992,8 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa
uint64_t model_id = static_cast<uint64_t>(model_id_);
int32_t device_id = static_cast<int32_t>(device_id_);
// tag_id 0 means step begin, 1 meas step end.
if (profiling_model_load_on) {
GE_CHK_STATUS_RET_NOLOG(
ProfilingManager::Instance().ProfileStepInfo(index_id, model_id, 0, rt_model_stream_, device_id));
}
GE_CHK_STATUS_RET_NOLOG(
ProfilingManager::Instance().ProfileStepInfo(index_id, model_id, 0, rt_model_stream_, device_id));

GELOGD("rtModelExecute do");
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_INFER_START));
@@ -4003,10 +4002,8 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_INFER_END));
GELOGD("rtModelExecute end");

if (profiling_model_load_on) {
GE_CHK_STATUS_RET_NOLOG(
ProfilingManager::Instance().ProfileStepInfo(index_id, model_id, 1, rt_model_stream_, device_id));
}
GE_CHK_STATUS_RET_NOLOG(
ProfilingManager::Instance().ProfileStepInfo(index_id, model_id, 1, rt_model_stream_, device_id));
iterator_count_++;
}

@@ -4505,4 +4502,22 @@ void DavinciModel::UpdateOpIOAddrs(uint32_t task_id, uint32_t stream_id, const s
op_desc_info->output_addrs = output_addrs;
GELOGD("[Update][OpIOAddrs] Op [%s] update input output addr success.", op_desc_info->op_name.c_str());
}

///
/// @ingroup ge
/// @brief Get total useful size, in known subgraph, no need to allocate zero copy memory during initialization.
/// @param [in] total_useful_size: total mem size - zero copy size.
/// @return Status
///
Status DavinciModel::GetTotalMemSizeExcludeZeroCopy(int64_t &total_useful_size) {
if (runtime_param_.mem_size < static_cast<uint64_t>(runtime_param_.zero_copy_size)) {
REPORT_CALL_ERROR("E19999", "total mem size[%lu] is less than zero copy size[%ld] ", runtime_param_.mem_size,
runtime_param_.zero_copy_size);
GELOGE(FAILED, "[Check][TotalMemSizeExcludeZeroCopy] failed, total mem size[%lu] is less than zero copy size[%ld]",
runtime_param_.mem_size, runtime_param_.zero_copy_size);
return FAILED;
}
total_useful_size = runtime_param_.mem_size - runtime_param_.zero_copy_size;
return SUCCESS;
}
} // namespace ge

+ 8
- 0
ge/graph/load/model_manager/davinci_model.h View File

@@ -248,6 +248,14 @@ class DavinciModel {
// get total mem size
size_t TotalMemSize() const { return runtime_param_.mem_size; }

///
/// @ingroup ge
/// @brief Get total useful size, in known subgraph, no need to allocate zero copy memory during initialization.
/// @param [in] total_useful_size: total mem size - zero copy size.
/// @return Status
///
Status GetTotalMemSizeExcludeZeroCopy(int64_t &total_useful_size);

// model name
string Name() const { return name_; }



+ 175
- 255
ge/graph/load/model_manager/model_manager.cc
File diff suppressed because it is too large
View File


+ 1
- 12
ge/graph/load/model_manager/model_manager.h View File

@@ -310,7 +310,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager {
std::lock_guard<std::mutex> lock(exeception_infos_mutex_);
auto instance = ModelManager::GetInstance();
if (instance == nullptr) {
GELOGE(FAILED, "Instance is nullptr");
GELOGE(FAILED, "[Get][Instance] failed, as ret is nullptr");
return;
}
instance->AddExceptionInfo(*rt_exception_info);
@@ -345,17 +345,6 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager {

void GenModelId(uint32_t *id);

Status InitDumPropertiesWithNewSessionId(uint64_t session_id);

bool IsDumpSeverInited(uint64_t session_id);

Status AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties);

Status UpdateSessionId(uint32_t model_id, GeModelPtr ge_model,
std::shared_ptr<DavinciModel> &davinci_model, uint64_t &session_id);

bool HasVarNode(ComputeGraphPtr &compute_graph) const;

std::map<uint32_t, std::shared_ptr<DavinciModel>> model_map_;
std::map<uint32_t, std::shared_ptr<hybrid::HybridDavinciModel>> hybrid_model_map_;
std::map<std::string, std::vector<uint64_t>> model_aicpu_kernel_;


+ 67
- 50
ge/graph/load/model_manager/model_utils.cc View File

@@ -22,16 +22,25 @@
#include "graph/manager/graph_var_manager.h"
#include "graph/types.h"
#include "graph/build/memory/block_mem_assigner.h"

#define VALIDATE_MEM_RANGE(OP, SIZE, OFFSET) \
do { \
if (SIZE <= static_cast<uint64_t>(OFFSET)) { \
REPORT_INNER_ERROR("E19999", \
"Node:%s(%s) offset:%ld out of range size:%lu, check invalid", \
OP->GetName().c_str(), OP->GetType().c_str(), OFFSET, SIZE); \
GELOGE(OUT_OF_MEMORY, "Node: %s, memory out of range[%lu: %ld]", OP->GetName().c_str(), SIZE, OFFSET); \
return {}; \
} \
#include "common/math/math_util.h"

#define VALIDATE_MEM_RANGE(OP, TOTAL_SIZE, OFFSET, SIZE) \
do { \
if (ge::CheckInt64AddOverflow((OFFSET), (SIZE)) != SUCCESS) { \
GELOGE(PARAM_INVALID, "Int64 %ld and %ld addition can result in overflow!", \
static_cast<int64_t>(OFFSET), static_cast<int64_t>(SIZE)); \
return {}; \
} \
int64_t range = (OFFSET) + (SIZE); \
if ((TOTAL_SIZE) < static_cast<uint64_t>(range)) { \
REPORT_INNER_ERROR("E19999", \
"Node:%s(%s) memory out of range, offset:%ld, size:%ld, exceed total size:%lu.", \
OP->GetName().c_str(), OP->GetType().c_str(), (OFFSET), (SIZE), (TOTAL_SIZE)); \
GELOGE(OUT_OF_MEMORY, \
"[Check][Param]Node:%s(%s) memory out of range, offset:%ld, size:%ld, exceed total size:%lu.", \
OP->GetName().c_str(), OP->GetType().c_str(), (OFFSET), (SIZE), (TOTAL_SIZE)); \
return {}; \
} \
} while (0)

namespace ge {
@@ -312,27 +321,30 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co
REPORT_INNER_ERROR("E19999", "Attr:%s, memory_type.size:%zu != input_desc.size:%zu, op:%s(%s), check invalid",
ATTR_NAME_INPUT_MEM_TYPE_LIST.c_str(), v_memory_type.size(), inputs_size,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "Fusion: check input size failed, op: %s, input v_memory_type size: %zu input numbers: %zu",
op_desc->GetName().c_str(), v_memory_type.size(), inputs_size);
GELOGE(PARAM_INVALID, "[Check][Param] Attr:%s, memory_type.size:%zu != input_desc.size:%zu, op:%s(%s)",
ATTR_NAME_INPUT_MEM_TYPE_LIST.c_str(), v_memory_type.size(), inputs_size,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return v_input_data_addr;
}
for (size_t i = 0; i < op_desc->GetAllInputsSize(); ++i) {
const GeTensorDescPtr tensor_desc = op_desc->MutableInputDesc(static_cast<uint32_t>(i));
GE_IF_BOOL_EXEC(tensor_desc == nullptr, GELOGD("Op: %s, Index: %zu, has no input", op_desc->GetName().c_str(), i);
continue;)
int64_t tensor_size = 0;
GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {});
if ((i < v_is_input_const.size()) && v_is_input_const[i]) {
// TBE: add weights address to input
int64_t tensor_size = 0;
GE_CHK_STATUS(TensorUtils::GetSize(*tensor_desc, tensor_size));
if (tensor_size) {
int64_t data_offset = 0;
GE_CHK_STATUS(TensorUtils::GetDataOffset(*tensor_desc, data_offset));
VALIDATE_MEM_RANGE(op_desc, model_param.weight_size, data_offset);
uint8_t *weight_addr = model_param.weight_base + data_offset;
v_input_data_addr.push_back(weight_addr);
GELOGI("[IMAS]GetInputDataAddrs graph_%u type[C] name[%s] input[%zu] memaddr[%p]", model_param.graph_id,
op_desc->GetName().c_str(), i, weight_addr);
}
// Add weights address to input
int64_t data_offset = 0;
GE_CHK_STATUS(TensorUtils::GetDataOffset(*tensor_desc, data_offset));
int64_t weight_size = 0;
// The reason why GetTensorSizeInBytes is used here is that the weight is allocated based on the size of
// TensorData in function AdjustConstWeightSize. and the size is zero when the tensor is empty.
GE_CHK_STATUS(TensorUtils::GetTensorSizeInBytes(*tensor_desc, weight_size));
VALIDATE_MEM_RANGE(op_desc, model_param.weight_size, data_offset, weight_size);
uint8_t *weight_addr = model_param.weight_base + data_offset;
v_input_data_addr.push_back(weight_addr);
GELOGI("[IMAS]GetInputDataAddrs graph_%u type[C] name[%s] input[%zu] memaddr[%p]", model_param.graph_id,
op_desc->GetName().c_str(), i, weight_addr);
non_const_index++;
continue;
}
@@ -341,9 +353,13 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co

int64_t input_offset = v_input_offset[non_const_index];
non_const_index++;
GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset),
int64_t inner_offset = 0;
(void)ge::AttrUtils::GetInt(op_desc->MutableInputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset);
GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset - inner_offset),
uint8_t *variable_addr = nullptr;
GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, input_offset, variable_addr), return {});
GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, input_offset - inner_offset,
tensor_size + inner_offset, variable_addr), return {});
variable_addr += inner_offset;
v_input_data_addr.push_back(variable_addr);
GELOGI("[IMAS]GetInputDataAddrs graph_%u type[V] name[%s] input[%lu] memaddr[%p]",
model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr);
@@ -357,9 +373,8 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co
mem_addr = reinterpret_cast<uint8_t *>(static_cast<intptr_t>(input_offset));
v_input_data_addr.push_back(mem_addr);
} else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) {
int64_t tensor_size = 0;
GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {});
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset);
// The input size and peer output size may be not consecutive, therefore, the tensor_size is not been checked.
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset, static_cast<int64_t>(0));
mem_addr = model_param.ts_mem_mall->Acquire(input_offset, static_cast<uint64_t>(tensor_size));
v_input_data_addr.push_back(mem_addr);
} else if (tensor_has_mem_type && mem_type == RT_MEMORY_P2P_DDR) {
@@ -369,7 +384,8 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co
op_desc->GetName().c_str(), i, p2p_mem_addr);
continue;
} else {
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset);
// The input size and peer output size may be not consecutive, therefore, the tensor_size is not been checked.
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, input_offset, static_cast<int64_t>(0));
mem_addr = model_param.mem_base + input_offset;
v_input_data_addr.push_back(mem_addr);
}
@@ -386,26 +402,25 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co
/// @return Status
///
Status ModelUtils::GetVarAddr(const RuntimeParam &model_param, const ConstOpDescPtr &op_desc, int64_t offset,
uint8_t *&var_addr) {
int64_t tensor_size, uint8_t *&var_addr) {
rtMemType_t mem_type = ge::VarManager::Instance(model_param.session_id)->GetVarMemType(offset);
switch (mem_type) {
case RT_MEMORY_RDMA_HBM:
if (offset < 0) {
REPORT_INNER_ERROR("E19999", "Param offset:%ld < 0, check invalid", offset);
GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p",
reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset)));
GELOGE(PARAM_INVALID, "[Check][Param] Param offset:%ld cannot be negative", offset);
return PARAM_INVALID;
}
var_addr = reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(offset));
break;
case RT_MEMORY_HBM:
VALIDATE_MEM_RANGE(op_desc, model_param.var_size, offset - model_param.logic_var_base);
VALIDATE_MEM_RANGE(op_desc, model_param.var_size, offset - model_param.logic_var_base, tensor_size);
var_addr = model_param.var_base + offset - model_param.logic_var_base;
break;
default:
REPORT_INNER_ERROR("E19999", "Get mem_type:%d for offset:%ld is unsupported, check invalid",
mem_type, offset);
GELOGE(PARAM_INVALID, "unsupported memory type %u", mem_type);
REPORT_INNER_ERROR("E19999", "Get mem_type:%d for offset:%ld is unsupported, check invalid", mem_type, offset);
GELOGE(PARAM_INVALID, "[Check][Param] Get mem_type:%d for offset:%ld is unsupported, check invalid",
mem_type, offset);
return PARAM_INVALID;
}
GE_CHECK_NOTNULL(var_addr);
@@ -433,9 +448,9 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C
REPORT_INNER_ERROR("E19999", "Attr:%s, memory_type.size:%zu != output_desc.size:%zu, op:%s(%s), check invalid",
ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), v_memory_type.size(), outputs_size,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID,
"Fusion: check output size failed, op: %s, output v_memory_type size: %lu output numbers: %zu",
op_desc->GetName().c_str(), v_memory_type.size(), outputs_size);
GELOGE(PARAM_INVALID, "[Check][Param] Attr:%s, memory_type.size:%zu != output_desc.size:%zu, op:%s(%s)",
ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), v_memory_type.size(), outputs_size,
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return v_output_data_addr;
}
for (size_t i = 0; i < outputs_size; ++i) {
@@ -451,9 +466,15 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C
GELOGD("%s is an optional output, the address don't need to be saved.", tensor_desc->GetName().c_str());
continue;
}
GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i]),
int64_t inner_offset = 0;
(void)ge::AttrUtils::GetInt(op_desc->MutableOutputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset);
int64_t tensor_size = 0;
GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {});
GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i] - inner_offset),
uint8_t *variable_addr = nullptr;
GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, v_output_offset[i], variable_addr), return {});
GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, v_output_offset[i] - inner_offset,
tensor_size + inner_offset, variable_addr), return {});
variable_addr += inner_offset;
v_output_data_addr.push_back(variable_addr);
GELOGI("[IMAS]GetOutputDataAddrs graph_%u type[V] name[%s] output[%zu] memaddr[%p]",
model_param.graph_id, op_desc->GetName().c_str(), i, variable_addr);
@@ -467,11 +488,7 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C
mem_addr = reinterpret_cast<uint8_t *>(static_cast<intptr_t>(v_output_offset[i]));
v_output_data_addr.push_back(mem_addr);
} else if (has_mem_type_attr && v_memory_type[i] == RT_MEMORY_TS_4G) {
const GeTensorDescPtr tensor_desc = op_desc->MutableOutputDesc(i);
GE_CHECK_NOTNULL_EXEC(tensor_desc, return {});
int64_t tensor_size = 0;
GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {});
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i]);
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i], tensor_size);
mem_addr = model_param.ts_mem_mall->Acquire(v_output_offset[i], static_cast<uint64_t>(tensor_size));
v_output_data_addr.push_back(mem_addr);
} else if (tensor_has_mem_type && mem_type == RT_MEMORY_P2P_DDR) {
@@ -481,7 +498,7 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C
op_desc->GetName().c_str(), i, p2p_mem_addr);
continue;
} else {
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i]);
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_output_offset[i], tensor_size);
mem_addr = static_cast<uint8_t *>(model_param.mem_base + v_output_offset[i]);
v_output_data_addr.push_back(mem_addr);
}
@@ -554,7 +571,7 @@ vector<void *> ModelUtils::GetWorkspaceDataAddrs(const RuntimeParam &model_param
GELOGI("[IMAS]GetWorkspaceDataAddrs graph_%u type[F] name[%s] workspace[%zu] offset[%ld] bytes[%ld] Null addr",
model_param.graph_id, op_desc->GetName().c_str(), i, v_workspace_offset[i], v_workspace_bytes[i]);
} else {
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_workspace_offset[i]);
VALIDATE_MEM_RANGE(op_desc, model_param.mem_size, v_workspace_offset[i], v_workspace_bytes[i]);
uint8_t *mem_addr = nullptr;
bool session_scope_memory = (has_workspace_no_reuse_scope) && (i < workspace_no_reuse_scope.size());
if (session_scope_memory) {
@@ -594,7 +611,7 @@ Status ModelUtils::GetRtAddress(const RuntimeParam &param, uintptr_t logic_addr,
} else if (logic_addr != 0) {
mem_addr = nullptr;
REPORT_INNER_ERROR("E19999", "Check param logic addr:0x%lx abnormal", logic_addr);
GELOGE(PARAM_INVALID, "The logic addr:0x%lx is abnormal", logic_addr);
GELOGE(PARAM_INVALID, "[Check][Param] The logic addr:0x%lx is abnormal", logic_addr);
return PARAM_INVALID;
}



+ 1
- 1
ge/graph/load/model_manager/model_utils.h View File

@@ -115,7 +115,7 @@ class ModelUtils {
/// @return Status
///
static Status GetVarAddr(const RuntimeParam &model_param, const ConstOpDescPtr &op_desc, int64_t offset,
uint8_t *&var_addr);
int64_t tensor_size, uint8_t *&var_addr);
};
} // namespace ge



+ 13
- 5
ge/graph/load/model_manager/task_info/kernel_ex_task_info.cc View File

@@ -195,7 +195,8 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin
return RT_ERROR_TO_GE_STATUS(rt_ret);)

SetIoAddrs(op_desc);
InitDumpTask(input_output_addr, op_desc);
InitDumpFlag(op_desc);
InitDumpArgs(input_output_addr, op_desc);
GELOGI("KernelExTaskInfo knonw node Init Success.");
return SUCCESS;
}
@@ -237,7 +238,8 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin
GELOGE(RT_FAILED, "[Call][RtMemcpy] failed, ret:0x%X, size:%lu", rt_ret, addrs_size);
return RT_ERROR_TO_GE_STATUS(rt_ret);)

InitDumpTask(input_output_addr_, op_desc);
InitDumpFlag(op_desc);
InitDumpArgs(input_output_addr_, op_desc);
}

uint64_t input_output_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(input_output_addr_));
@@ -269,10 +271,16 @@ Status KernelExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davin
return SUCCESS;
}

void KernelExTaskInfo::InitDumpTask(void *addr, const OpDescPtr &op_desc) {
if (davinci_model_->OpNeedDump(op_desc->GetName()) || davinci_model_->GetOpDugReg()) {
GELOGD("Op %s need dump in kernel ex task info", op_desc->GetName().c_str());
void KernelExTaskInfo::InitDumpFlag(const OpDescPtr &op_desc) {
if (davinci_model_->OpNeedDump(op_desc->GetName())) {
GELOGD("Op %s need init dump flag in kernel ex task info", op_desc->GetName().c_str());
dump_flag_ = RT_KERNEL_DUMPFLAG;
}
}

void KernelExTaskInfo::InitDumpArgs(void *addr, const OpDescPtr &op_desc) {
if (davinci_model_->OpNeedDump(op_desc->GetName())) {
GELOGD("Op %s need dump in kernel ex task info", op_desc->GetName().c_str());
dump_args_ = addr;
}
if (davinci_model_->GetOpDugReg()) {


+ 2
- 1
ge/graph/load/model_manager/task_info/kernel_ex_task_info.h View File

@@ -61,7 +61,8 @@ class KernelExTaskInfo : public TaskInfo {
Status CopyTaskInfo(const domi::KernelExDef &kernel_def, const RuntimeParam &rts_param, const OpDescPtr &op_desc);
void SetIoAddrs(const OpDescPtr &op_desc);

void InitDumpTask(void *addr, const OpDescPtr &op_desc);
void InitDumpFlag(const OpDescPtr &op_desc);
void InitDumpArgs(void *addr, const OpDescPtr &op_desc);
Status InitTaskExtInfo(const std::string &ext_info, const OpDescPtr &op_desc);

uint32_t task_id_;


+ 16
- 10
ge/graph/load/model_manager/task_info/kernel_task_info.cc View File

@@ -129,6 +129,7 @@ Status KernelTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci
ctx_.opIndex2[i] = context.origin_op_index(i);
}
ctx_.opCount = context.origin_op_index_size();
InitDumpFlag();
if (kernel_type_ == ccKernelType::TE) {
ctx_.opIndex = context.op_index();
uint16_t *args_offset_tmp = reinterpret_cast<uint16_t *>(const_cast<char *>(context.args_offset().data()));
@@ -660,7 +661,7 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne
if (davinci_model_->IsKnownNode()) {
args_ = l2_buffer_on_ ? davinci_model_->GetCurrentHybridArgsAddr(hybrid_args_offset_)
: davinci_model_->GetCurrentArgsAddr(args_offset_);
InitDumpTask(offset);
InitDumpArgs(offset);
return SUCCESS;
}

@@ -726,7 +727,7 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne
return FAILED;
}
skt_dump_args_ = static_cast<char *>(args_) + offset;
InitDumpTask(offset);
InitDumpArgs(offset);

vector<void *> virtual_io_addrs; // use virtual address for zero copy key.
virtual_io_addrs.insert(virtual_io_addrs.end(), input_data_addrs.begin(), input_data_addrs.end());
@@ -1022,7 +1023,7 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k

if (davinci_model_->IsKnownNode()) {
args_ = davinci_model_->GetCurrentHybridArgsAddr(hybrid_args_offset_);
InitDumpTask(sizeof(aicpu::AicpuParamHead));
InitDumpArgs(sizeof(aicpu::AicpuParamHead));
return SUCCESS;
}
const RuntimeParam &rts_param = davinci_model_->GetRuntimeParam();
@@ -1063,31 +1064,36 @@ Status KernelTaskInfo::InitAicpuTask(uint32_t op_index, const domi::KernelDef &k
op_desc->GetName().c_str(), op_desc->GetType().c_str(), args_size_, rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
InitDumpTask(sizeof(aicpu::AicpuParamHead));

if (kernel_type_ == ccKernelType::CUST_AI_CPU) {
dump_flag_ |= RT_KERNEL_CUSTOM_AICPU;
}
InitDumpArgs(sizeof(aicpu::AicpuParamHead));

davinci_model_->SetZeroCopyAddr(op_desc, io_addrs, args_addr.get(), args_, args_size_, sizeof(aicpu::AicpuParamHead));

return SUCCESS;
}

void KernelTaskInfo::InitDumpTask(uint32_t offset) {
void KernelTaskInfo::InitDumpFlag() {
if (davinci_model_->OpNeedDump(op_desc_->GetName())) {
GELOGD("Op %s need dump in task info", op_desc_->GetName().c_str());
GELOGD("Op %s init dump flag", op_desc_->GetName().c_str());
if (IsL1FusionOp(op_desc_)) {
dump_flag_ = RT_FUSION_KERNEL_DUMPFLAG;
} else {
dump_flag_ = RT_KERNEL_DUMPFLAG;
}
}
}

void KernelTaskInfo::InitDumpArgs(uint32_t offset) {
if (davinci_model_->OpNeedDump(op_desc_->GetName())) {
GELOGD("Op %s need dump in task info", op_desc_->GetName().c_str());
dump_args_ = static_cast<char *>(args_) + offset;
}
if (davinci_model_->GetOpDugReg()) {
GELOGD("Op debug is open in kernel task info");
dump_args_ = static_cast<char *>(args_) + offset;
}
if (kernel_type_ == ccKernelType::CUST_AI_CPU) {
dump_flag_ |= RT_KERNEL_CUSTOM_AICPU;
}
}

Status KernelTaskInfo::InitAicpuTaskExtInfo(const std::string &ext_info) {


+ 2
- 1
ge/graph/load/model_manager/task_info/kernel_task_info.h View File

@@ -128,7 +128,8 @@ class KernelTaskInfo : public TaskInfo {
Status SuperKernelDistribute();
bool IsL1FusionOp(const OpDescPtr &op_desc);
void SetIoAddrs(const OpDescPtr &op_desc);
void InitDumpTask(uint32_t offset);
void InitDumpFlag();
void InitDumpArgs(uint32_t offset);
void SetContinuousArgs(uint32_t args_size, DavinciModel *davinci_model);
void SetNoncontinuousArgs(uint32_t args_size, DavinciModel *davinci_model);
Status CopyNoncontinuousArgs(uint16_t offset);


+ 1
- 1
ge/graph/load/model_manager/task_info/task_info.cc View File

@@ -26,7 +26,7 @@ Status TaskInfo::SetStream(uint32_t stream_id, const std::vector<rtStream_t> &st
stream_ = stream_list[stream_id];
} else {
REPORT_INNER_ERROR("E19999", "stream_id:%u >= stream_list.size(): %zu, check invalid",
stream_id, stream_list.size());
stream_id, stream_list.size());
GELOGE(FAILED, "[Check][Param] index:%u >= stream_list.size():%zu.", stream_id, stream_list.size());
return FAILED;
}


+ 2
- 1
ge/graph/load/model_manager/task_info/task_info.h View File

@@ -49,7 +49,7 @@ struct RuntimeParam {
<< ", label_num:" << label_num << ", logic_mem_base:" << logic_mem_base
<< ", logic_weight_base:" << logic_weight_base << ", logic_var_base:" << logic_var_base
<< ", memory_size:" << mem_size << ", weight_size:" << weight_size << ", var_size:" << var_size
<< ", ex_memory_info:";
<< ", zero_copy_size:" << zero_copy_size << ", ex_memory_info:";
for (auto it : memory_infos) {
ss << "[memory_type:" << it.first << ", memory_size:" << it.second.memory_size << "]";
}
@@ -65,6 +65,7 @@ struct RuntimeParam {
uint64_t var_size = 0;
uint64_t logic_var_base = 0;
uint8_t *var_base = nullptr;
int64_t zero_copy_size = 0;
std::map<uint64_t, MemInfo> memory_infos;
uint32_t batch_num = 0;
uint32_t stream_num = 0;


+ 8
- 9
ge/graph/load/model_manager/tbe_handle_store.cc View File

@@ -24,7 +24,7 @@ namespace ge {
void TbeHandleInfo::used_inc(uint32_t num) {
if (used_ > std::numeric_limits<uint32_t>::max() - num) {
REPORT_INNER_ERROR("E19999", "Used:%u reach numeric max", used_);
GELOGE(INTERNAL_ERROR, "Used[%u] reach numeric max.", used_);
GELOGE(INTERNAL_ERROR, "[Check][Param] Used[%u] reach numeric max.", used_);
return;
}

@@ -34,7 +34,7 @@ void TbeHandleInfo::used_inc(uint32_t num) {
void TbeHandleInfo::used_dec(uint32_t num) {
if (used_ < std::numeric_limits<uint32_t>::min() + num) {
REPORT_INNER_ERROR("E19999", "Used:%u reach numeric min", used_);
GELOGE(INTERNAL_ERROR, "Used[%u] reach numeric min.", used_);
GELOGE(INTERNAL_ERROR, "[Check][Param] Used[%u] reach numeric min.", used_);
return;
}

@@ -107,9 +107,8 @@ void TBEHandleStore::ReferTBEHandle(const std::string &name) {
std::lock_guard<std::mutex> lock(mutex_);
auto it = kernels_.find(name);
if (it == kernels_.end()) {
REPORT_INNER_ERROR("E19999", "Kernel:%s not found in stored check invalid",
name.c_str());
GELOGE(INTERNAL_ERROR, "Kernel[%s] not found in stored.", name.c_str());
REPORT_INNER_ERROR("E19999", "Kernel:%s not found in stored check invalid", name.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Kernel[%s] not found in stored.", name.c_str());
return;
}

@@ -128,9 +127,8 @@ void TBEHandleStore::EraseTBEHandle(const std::map<std::string, uint32_t> &names
for (auto &item : names) {
auto it = kernels_.find(item.first);
if (it == kernels_.end()) {
REPORT_INNER_ERROR("E19999", "Kernel:%s not found in stored check invalid",
item.first.c_str());
GELOGE(INTERNAL_ERROR, "Kernel[%s] not found in stored.", item.first.c_str());
REPORT_INNER_ERROR("E19999", "Kernel:%s not found in stored check invalid", item.first.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Kernel[%s] not found in stored.", item.first.c_str());
continue;
}

@@ -142,7 +140,8 @@ void TBEHandleStore::EraseTBEHandle(const std::map<std::string, uint32_t> &names
if (rt_ret != RT_ERROR_NONE) {
REPORT_INNER_ERROR("E19999", "Call rtDevBinaryUnRegister failed for Kernel:%s fail, ret:0x%X",
item.first.c_str(), rt_ret);
GELOGE(INTERNAL_ERROR, "Kernel[%s] UnRegister handle fail:%u.", item.first.c_str(), rt_ret);
GELOGE(INTERNAL_ERROR, "[Call][RtDevBinaryUnRegister] Kernel[%s] UnRegister handle fail:%u.",
item.first.c_str(), rt_ret);
}
kernels_.erase(it);
}


+ 4
- 4
ge/graph/load/model_manager/ts_mem_mall.h View File

@@ -43,7 +43,7 @@ class TsMemMall {
for (auto it : mem_store_size_) {
rtError_t ret = rtFree(it.second);
if (ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rtFree failed, ret: 0x%X", ret);
GELOGE(RT_FAILED, "[Call][RtFree] failed, ret:0x%X", ret);
}
}
mem_store_size_.clear();
@@ -52,7 +52,7 @@ class TsMemMall {

void *Acquire(int64_t offset, uint64_t size) {
if (size == 0) {
GELOGE(RT_FAILED, "Acquire mem block failed, size: %lu", size);
GELOGE(RT_FAILED, "[Check][Param] Acquire mem block failed, size:%lu", size);
return nullptr;
}

@@ -71,7 +71,7 @@ class TsMemMall {
void *addr = nullptr;
rtError_t rt_ret = rtMalloc(&addr, bytes, mem_type_);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtMalloc] failed, size:%lu, ret:0x%X", bytes, rt_ret);
return nullptr;
}

@@ -94,7 +94,7 @@ class TsMemMall {
mem_store_addr_.erase(it);
rtError_t ret = rtFree(addr);
if (ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rtFree failed, ret: 0x%X", ret);
GELOGE(RT_FAILED, "[Call][RtFree] failed, ret:0x%X", ret);
}
}



+ 18
- 6
ge/graph/load/model_manager/zero_copy_offset.cc View File

@@ -38,8 +38,13 @@ Status ZeroCopyOffset::InitInputDataInfo(int64_t output_size, void *virtual_addr
op_name_ = op_desc->GetName();
(void)ge::AttrUtils::GetListInt(op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset_);
(void)ge::AttrUtils::GetListInt(op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset_);
GE_CHK_BOOL_EXEC(zero_copy_basic_offset_.size() == zero_copy_relative_offset_.size(), return PARAM_INVALID,
"basic_offset_size should be equal to relative_offset_size");
GE_CHK_BOOL_EXEC(zero_copy_basic_offset_.size() == zero_copy_relative_offset_.size(),
REPORT_INNER_ERROR("E19999", "basic_offset_size:%zu not equal to relative_offset_size:%zu, "
"check invalid", zero_copy_basic_offset_.size(),
zero_copy_relative_offset_.size());
return PARAM_INVALID,
"[Check][Param] basic_offset_size:%zu should be equal to relative_offset_size:%zu",
zero_copy_basic_offset_.size(), zero_copy_relative_offset_.size());
GELOGD("[ZCPY] zero_copy_basic_offset size is %zu", zero_copy_basic_offset_.size());

int64_t virtual_addr_offset = op_desc->GetOutputOffset().at(kDataIndex);
@@ -78,7 +83,8 @@ Status ZeroCopyOffset::InitOutputDataInfo(const vector<int64_t> &input_size_list
if (TensorUtils::GetTensorSizeInBytes(*tensor_desc, size) != GRAPH_SUCCESS) {
REPORT_INNER_ERROR("E19999", "Get input TensorSize in op:%s(%s) failed, input_index:%zu",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), idx);
GELOGE(FAILED, "GetTensorSizeInBytes failed!");
GELOGE(FAILED, "[Get][InputTensorSize] in op:%s(%s) failed, input_index:%zu",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), idx);
return FAILED;
}

@@ -88,8 +94,13 @@ Status ZeroCopyOffset::InitOutputDataInfo(const vector<int64_t> &input_size_list
op_name_ = op_desc->GetName();
(void)ge::AttrUtils::GetListInt(op_desc, ATTR_ZERO_COPY_BASIC_OFFSET, zero_copy_basic_offset_);
(void)ge::AttrUtils::GetListInt(op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset_);
GE_CHK_BOOL_EXEC(zero_copy_basic_offset_.size() == zero_copy_relative_offset_.size(), return PARAM_INVALID,
"basic_offset_size should be equal to relative_offset_size");
GE_CHK_BOOL_EXEC(zero_copy_basic_offset_.size() == zero_copy_relative_offset_.size(),
REPORT_INNER_ERROR("E19999", "basic_offset_size:%zu not equal to relative_offset_size:%zu, "
"check invalid",
zero_copy_basic_offset_.size(), zero_copy_relative_offset_.size());
return PARAM_INVALID,
"[Check][Param] basic_offset_size:%zu should be equal to relative_offset_size:%zu",
zero_copy_basic_offset_.size(), zero_copy_relative_offset_.size());
int64_t virtual_addr_offset = op_desc->GetInputOffset().at(idx);
IsL2Fusion(zero_copy_basic_offset_, virtual_addr_offset, fusion_flag);

@@ -194,7 +205,8 @@ void ZeroCopyOffset::SetOutsideAddrsValue(ZeroCopyTask &zero_copy_task, void *ou
for (uint32_t out_count = 0; out_count < GetAddrCount(); ++out_count) {
auto args_addrs = outside_addrs_[out_count].find(outside_addr);
if (args_addrs != outside_addrs_[out_count].end()) {
GE_CHK_STATUS(zero_copy_task.SetTaskArgsOffset(addr_val, offset), "Input args invalid.");
GE_CHK_STATUS(zero_copy_task.SetTaskArgsOffset(addr_val, offset),
"[Set][TaskArgsOffset] failed, Input args invalid, offset:%zu.", offset);
void *args_val = static_cast<uint8_t *>(args) + offset;
args_addrs->second.push_back(args_val);
GELOGD("[ZCPY] set copy input: virtual_addr: 0x%lx, task_addr: %p, args: %p, offset: %zu.", addr_val, args_val,


+ 5
- 6
ge/graph/load/model_manager/zero_copy_task.cc View File

@@ -36,9 +36,9 @@ ZeroCopyTask::~ZeroCopyTask() { args_addr_ = nullptr; }
*/
Status ZeroCopyTask::SetTaskArgsOffset(uintptr_t addr, size_t offset) {
if (offset + sizeof(uintptr_t) > args_size_) {
REPORT_INNER_ERROR("E19999", "Param offset:%zu + 8 > args_size_:%zu, check invalid",
offset, args_size_);
GELOGE(FAILED, "[ZCPY] %s set task args failed, args size: %zu, offset: %zu", name_.c_str(), args_size_, offset);
REPORT_INNER_ERROR("E19999", "Param offset:%zu + 8 > args_size_:%zu, check invalid", offset, args_size_);
GELOGE(FAILED, "[Check][Param] [ZCPY] %s set task args failed, args size:%zu, offset:%zu",
name_.c_str(), args_size_, offset);
return FAILED; // unexpected error, need fix.
}

@@ -118,9 +118,8 @@ Status ZeroCopyTask::DistributeParam(bool async_mode, rtStream_t stream) {
}

if (rt_err != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpyAsync or rtMemcpy failed, size:%zu, ret: 0x%X",
args_size_, rt_err);
GELOGE(RT_FAILED, "[ZCPY] %s distribute task param failed, error=0x%x", name_.c_str(), rt_err);
REPORT_CALL_ERROR("E19999", "Call rtMemcpyAsync or rtMemcpy failed, size:%zu, ret:0x%X", args_size_, rt_err);
GELOGE(RT_FAILED, "[Distribute][TaskParam] for %s failed, error = 0x%x", name_.c_str(), rt_err);
return RT_ERROR_TO_GE_STATUS(rt_err);
}



+ 17
- 23
ge/graph/manager/graph_caching_allocator.cc View File

@@ -112,7 +112,7 @@ Status CachingAllocator::Initialize(uint32_t device_id) {
auto bin_ptr = new (std::nothrow) BlockBin(BlockComparator);
if (bin_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New BlockBin fail, device_id:%u", device_id);
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Alloc BlockBin failed.");
GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "[Alloc][BlockBin] failed, device_id:%u", device_id);
return ACL_ERROR_GE_MEMORY_ALLOCATION;
}
free_block_bins_[i] = bin_ptr;
@@ -137,6 +137,7 @@ uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device
uint8_t *ptr = nullptr;
Block *block = FindFreeBlock(size, org_ptr, device_id);
if (block == nullptr) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (ge::SUCCESS == TryExtendCache(size, device_id)) {
block = FindFreeBlock(size, org_ptr, device_id);
if (block != nullptr) {
@@ -147,9 +148,8 @@ uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device
ptr = block->ptr;
}
if (ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "FindFreeBlock fail, size:%zu, device_id:%u",
size, device_id);
GELOGE(FAILED, "Malloc failed device id = %u, size= %zu", device_id, size);
REPORT_INNER_ERROR("E19999", "FindFreeBlock fail, size:%zu, device_id:%u", size, device_id);
GELOGE(FAILED, "[Check][Param] FindFreeBlock failed device id = %u, size= %zu", device_id, size);
}
return ptr;
}
@@ -157,18 +157,16 @@ uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device
Status CachingAllocator::Free(uint8_t *ptr, uint32_t device_id) {
GELOGI("Free device id = %u", device_id);
if (ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param ptr is nullptr, device_id:%u, check invalid",
device_id);
GELOGE(PARAM_INVALID, "Invalid memory pointer");
REPORT_INNER_ERROR("E19999", "Param ptr is nullptr, device_id:%u, check invalid", device_id);
GELOGE(PARAM_INVALID, "[Check][Param] Invalid memory pointer, device_id:%u", device_id);
return ge::PARAM_INVALID;
}

std::lock_guard<std::recursive_mutex> lock(mutex_);
auto it = allocated_blocks_.find(ptr);
if (it == allocated_blocks_.end()) {
REPORT_INNER_ERROR("E19999", "Param ptr not allocated before, device_id:%u, check invalid",
device_id);
GELOGE(PARAM_INVALID, "Invalid memory pointer: %p", ptr);
REPORT_INNER_ERROR("E19999", "Param ptr not allocated before, device_id:%u, check invalid", device_id);
GELOGE(PARAM_INVALID, "[Check][Param] Param ptr not allocated before, device_id:%u", device_id);
return ge::PARAM_INVALID;
}
Block *block = it->second;
@@ -225,9 +223,8 @@ Block *CachingAllocator::FindFreeBlock(size_t size, uint8_t *org_ptr, uint32_t d
Block key(device_id, size, org_ptr);
BlockBin *bin = GetBlockBin(size);
if (bin == nullptr) {
REPORT_INNER_ERROR("E19999", "GetBlockBin fail, size:%zu, device_id:%u",
size, device_id);
GELOGE(ge::FAILED, "Get block bin failed size = %zu", size);
REPORT_INNER_ERROR("E19999", "GetBlockBin fail, size:%zu, device_id:%u", size, device_id);
GELOGE(ge::FAILED, "[Get][BlockBin] failed, size:%zu, device_id:%u", size, device_id);
return nullptr;
}
std::lock_guard<std::recursive_mutex> lock(mutex_);
@@ -258,9 +255,8 @@ Block *CachingAllocator::SplitBlock(Block *block, size_t size, BlockBin &bin, ui
Block *remaining = block;
Block *new_block = new (std::nothrow) Block(device_id, size, &bin, block->ptr);
if (new_block == nullptr) {
REPORT_CALL_ERROR("E19999", "New Block fail, size:%zu, device_id:%u",
size, device_id);
GELOGE(ge::FAILED, "Alloc block failed size = %zu", size);
REPORT_CALL_ERROR("E19999", "New Block fail, size:%zu, device_id:%u", size, device_id);
GELOGE(ge::FAILED, "[Alloc][Block] failed, size:%zu, device_id:%u", size, device_id);
return block;
}
new_block->prev = remaining->prev;
@@ -285,7 +281,7 @@ Status CachingAllocator::TryExtendCache(size_t size, uint32_t device_id) {
size_t free_cached_memory_size = FreeCachedBlocks();
memory_addr = memory_allocator_->MallocMemory(purpose, memory_size, device_id);
if (memory_addr == nullptr) {
GELOGE(ge::FAILED, "TryExtendCache failed, no enough memory for size = %zu, device_id = %u", memory_size,
GELOGE(ge::FAILED, "[Malloc][Memory] failed, no enough memory for size = %zu, device_id = %u", memory_size,
device_id);
return ge::FAILED;
}
@@ -304,16 +300,14 @@ Status CachingAllocator::TryExtendCache(size_t size, uint32_t device_id) {
Status CachingAllocator::AddToBlockBin(uint8_t *ptr, size_t size, uint32_t device_id) {
BlockBin *bin = GetBlockBin(size);
if (bin == nullptr) {
REPORT_INNER_ERROR("E19999", "GetBlockBin fail, size:%zu, device_id:%u",
size, device_id);
GELOGE(ge::FAILED, "Get block bin failed size = %zu", size);
REPORT_INNER_ERROR("E19999", "GetBlockBin fail, size:%zu, device_id:%u", size, device_id);
GELOGE(ge::FAILED, "[Get][BlockBin] failed, size:%zu, device_id:%u", size, device_id);
return ge::FAILED;
}
Block *block = new (std::nothrow) Block(device_id, size, bin, nullptr);
if (block == nullptr) {
REPORT_CALL_ERROR("E19999", "New Block fail, size:%zu, device_id:%u",
size, device_id);
GELOGE(ge::FAILED, "Alloc block failed size = %zu", size);
REPORT_CALL_ERROR("E19999", "New Block fail, size:%zu, device_id:%u", size, device_id);
GELOGE(ge::FAILED, "[Alloc][Block] failed, size:%zu, device_id:%u", size, device_id);
return ge::FAILED;
}



+ 10
- 9
ge/graph/manager/graph_context.cc View File

@@ -33,7 +33,7 @@ GraphContext::GraphContext(const GraphNodePtr &graph_node) {
if (compute_graph_ == nullptr) {
std::shared_ptr<const ge::Graph> graph = graph_node->GetGraph();
if (graph == nullptr) {
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "compute_graph by graphNode is NULL!");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Get][Graph] failed, compute_graph by graphNode is NULL!");
return;
}

@@ -45,7 +45,7 @@ GraphContext::GraphContext(const GraphNodePtr &graph_node) {
Status GraphContext::SetComputeGraph(const GraphNodePtr &graph_node) {
if (graph_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph_node is nullptr, check invalid");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "graphNode is NULL!");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] graphNode is NULL!");
return GE_GRAPH_PARAM_NULLPTR;
}

@@ -56,7 +56,7 @@ Status GraphContext::SetComputeGraph(const GraphNodePtr &graph_node) {
std::shared_ptr<const ge::Graph> graph = graph_node->GetGraph();
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph in graph_node is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "compute_graph by graphNode is NULL!");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Get][Graph] failed, compute_graph by graphNode is NULL!");
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL;
}

@@ -73,14 +73,15 @@ Status GraphContext::Finalize() const { return SUCCESS; }
Status GraphContext::GetVariableTensor(const std::string &var_data_name, GeTensor &returned_tensor) {
if (var_data_name.empty()) {
REPORT_INNER_ERROR("E19999", "Param var_data_name is empty, check invalid");
GELOGE(GE_GRAPH_EMPTY_STRING_NAME, "Variable data name is empty!");
GELOGE(GE_GRAPH_EMPTY_STRING_NAME, "[Check][Param] Variable data name is empty!");
return GE_GRAPH_EMPTY_STRING_NAME;
}

if (GetVarNodeTensorTable().empty()) {
REPORT_INNER_ERROR("E19999", "VarNodeTensorTable is empty, var_data_name:%s, check invalid",
var_data_name.c_str());
GELOGE(GE_GRAPH_EMPTY_VARIABLE_TENSOR_TABLE, "VarNodeTensorTable is empty!");
GELOGE(GE_GRAPH_EMPTY_VARIABLE_TENSOR_TABLE, "[Check][Param] VarNodeTensorTable is empty, var_data_name:%s",
var_data_name.c_str());
return GE_GRAPH_EMPTY_VARIABLE_TENSOR_TABLE;
}
for (auto &var_record : GetVarNodeTensorTable()) {
@@ -88,9 +89,8 @@ Status GraphContext::GetVariableTensor(const std::string &var_data_name, GeTenso
returned_tensor.SetTensorDesc(var_record.second.GetTensorDesc());
auto ret = returned_tensor.SetData(var_record.second.GetData());
if (ret != SUCCESS) {
REPORT_INNER_ERROR("E19999", "SetData to tensor fail, var_data_name:%s",
var_data_name.c_str());
GELOGE(ret, "Set Tensor data failed!");
REPORT_INNER_ERROR("E19999", "SetData to tensor fail, var_data_name:%s", var_data_name.c_str());
GELOGE(ret, "[Set][Data] to Tensor failed, var_data_name:%s", var_data_name.c_str());
return ret;
}

@@ -100,7 +100,8 @@ Status GraphContext::GetVariableTensor(const std::string &var_data_name, GeTenso

REPORT_INNER_ERROR("E19999", "VarRecord with data_name:%s does not exist, check invalid",
var_data_name.c_str());
GELOGE(GE_GRAPH_VARIABLE_DOES_NOT_EXIST, "VarRecord with data_name %s does NOT exist!", var_data_name.c_str());
GELOGE(GE_GRAPH_VARIABLE_DOES_NOT_EXIST, "[Check][Param] VarRecord with data_name %s does NOT exist!",
var_data_name.c_str());

return GE_GRAPH_VARIABLE_DOES_NOT_EXIST;
}


+ 272
- 272
ge/graph/manager/graph_manager.cc
File diff suppressed because it is too large
View File


+ 9
- 6
ge/graph/manager/graph_manager_utils.cc View File

@@ -46,7 +46,7 @@ GraphNode::GraphNode(GraphId graph_id)
sem_(1) {
graph_run_async_listener_ = MakeShared<RunAsyncListener>();
if (graph_run_async_listener_ == nullptr) {
GELOGE(MEMALLOC_FAILED, "Make shared failed");
GELOGE(MEMALLOC_FAILED, "[New][RunAsyncListener] failed");
}
}

@@ -82,7 +82,8 @@ SubGraphInfo::~SubGraphInfo() {
rt_ret = rtFreeHost(buffer_addr);
buffer_addr = nullptr;
if (rt_ret != RT_ERROR_NONE) {
GELOGE(rt_ret, "[GraphManager] subgraph free buffer failed, modelId = %u", model_id_info_.model_id);
GELOGE(rt_ret, "[Call][RtFreeHost] subgraph free buffer failed, modelId = %u",
model_id_info_.model_id);
}
}
}
@@ -94,8 +95,8 @@ Status SubGraphInfo::FreeInOutBuffer() {
rtError_t rt_ret;
rt_ret = rtFreeHost(*iter);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtFreeHost fail");
GELOGE(rt_ret, "[GraphManager] subgraph free buffer failed, modelId = %u", model_id_info_.model_id);
REPORT_CALL_ERROR("E19999", "Call rtFreeHost fail, ret:%d", rt_ret);
GELOGE(rt_ret, "[Call][RtFreeHost] subgraph free buffer failed, modelId = %u", model_id_info_.model_id);
buffer_addr_.erase(buffer_addr_.begin(), iter);
return GE_GRAPH_FREE_FAILED;
}
@@ -131,7 +132,7 @@ Status GraphModelListener::OnComputeDone(uint32_t model_id, uint32_t task_id, ui
uint32_t GraphModelListener::GetResultCode() const {
if (!is_finished_) {
REPORT_CALL_ERROR("E19999", "Model not run finish");
GELOGE(INTERNAL_ERROR, "[GraphManager] model not run finish.");
GELOGE(INTERNAL_ERROR, "[Check][Param] model not run finish.");
return INTERNAL_ERROR;
}
return result_code_;
@@ -170,7 +171,9 @@ bool HasCalcOp(const ComputeGraphPtr &graph) {

for (const auto &node : graph->GetAllNodes()) {
OpDescPtr op_desc = node->GetOpDesc();
GE_IF_BOOL_EXEC(op_desc == nullptr, GELOGE(FAILED, "Node GetOpDesc is nullptr"); return false);
GE_IF_BOOL_EXEC(op_desc == nullptr,
REPORT_INNER_ERROR("E19999", "GetOpDesc failed, Node GetOpDesc is nullptr");
GELOGE(FAILED, "[Get][OpDesc] failed, Node GetOpDesc is nullptr"); return false);
if (calc_op_type.find(op_desc->GetType()) != calc_op_type.end()) {
return true;
}


+ 6
- 12
ge/graph/manager/graph_mem_allocator.cc View File

@@ -50,9 +50,7 @@ uint8_t *MemoryAllocator::MallocMemory(const string &purpose, size_t memory_size
if (rtMalloc(reinterpret_cast<void **>(&memory_addr), memory_size, memory_type_) != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, purpose:%s, size:%zu, device_id:%u",
purpose.c_str(), memory_size, device_id);
GELOGE(ge::INTERNAL_ERROR,
"MemoryAllocator::MallocMemory device_id = %u,"
" size= %lu",
GELOGE(ge::INTERNAL_ERROR, "[Malloc][Memory] failed, device_id = %u, size= %lu",
device_id, memory_size);

return nullptr;
@@ -68,7 +66,7 @@ Status MemoryAllocator::FreeMemory(uint8_t *memory_addr, uint32_t device_id) con
auto rtRet = rtFree(memory_addr);
if (rtRet != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtFree fail, device_id:%u", device_id);
GELOGE(rtRet, "MemoryAllocator::MallocMemory device_id = %u", device_id);
GELOGE(rtRet, "[Call][RtFree] failed, device_id = %u", device_id);
return RT_ERROR_TO_GE_STATUS(rtRet);
}
memory_addr = nullptr;
@@ -88,10 +86,8 @@ uint8_t *MemoryAllocator::MallocMemory(const string &purpose, const string &memo
if (memory_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "Malloc Memory fail, purpose:%s, memory_key:%s, memory_size:%zu, device_id:%u",
purpose.c_str(), memory_key.c_str(), memory_size, device_id);
GELOGE(ge::INTERNAL_ERROR,
"MemoryAllocator::MallocMemory failed,"
" memory_key[%s], size = %lu.",
memory_key.c_str(), memory_size);
GELOGE(ge::INTERNAL_ERROR, "[Malloc][Memory] failed, memory_key[%s], size = %lu, device_id:%u.",
memory_key.c_str(), memory_size, device_id);
return nullptr;
}

@@ -126,10 +122,8 @@ Status MemoryAllocator::FreeMemory(const string &memory_key, uint32_t device_id)
if (FreeMemory(it->second.memory_addr_, device_id) != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Free Memory fail, memory_key:%s, device_id:%u",
memory_key.c_str(), device_id);
GELOGE(ge::INTERNAL_ERROR,
"MemoryAllocator::FreeMemory rtFree failed,"
" memory_key[%s]",
memory_key.c_str());
GELOGE(ge::INTERNAL_ERROR, "[Free][Memory] failed, memory_key[%s], device_id:%u",
memory_key.c_str(), device_id);
return ge::INTERNAL_ERROR;
}



+ 50
- 37
ge/graph/manager/graph_var_manager.cc View File

@@ -40,7 +40,8 @@ ge::Status VarResource::GetVarAddr(const std::string &var_name, const ge::GeTens
if (dev_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param dev_ptr is nullptr, var_name:%s, session_id:%lu, "
"check invalid", var_name.c_str(), session_id_);
GELOGE(FAILED, "[GetVarAddr] dev_ptr is null!");
GELOGE(FAILED, "[Check][Param] Param dev_ptr is nullptr, var_name:%s, session_id:%lu",
var_name.c_str(), session_id_);
return FAILED;
}
std::string var_key = VarKey(var_name, tensor_desc);
@@ -51,7 +52,8 @@ ge::Status VarResource::GetVarAddr(const std::string &var_name, const ge::GeTens
REPORT_INNER_ERROR("E19999", "var_key:%s can't find in var_addr_mgr_map_, var_name:%s, session_id:%lu, "
"check invalid", var_key.c_str(), var_name.c_str(),
session_id_);
GELOGE(FAILED, "VarResource::GetVarAddr failed, var_key %s", var_key.c_str());
GELOGE(FAILED, "[Check][Param] var_key:%s can't find in var_addr_mgr_map_, var_name:%s, session_id:%lu",
var_key.c_str(), var_name.c_str(), session_id_);
return FAILED;
}

@@ -109,7 +111,8 @@ ge::Status VarResource::SaveVarAddr(const std::string &var_name, const ge::GeTen
REPORT_INNER_ERROR("E19999", "var_key:%s conflict in var_addr_mgr_map_, var_name:%s, session_id:%lu, "
"check invalid", var_key.c_str(), var_name.c_str(),
session_id_);
GELOGE(FAILED, "VarResource::SaveVarAddr, var_key %s save addr conflict", var_key.c_str());
GELOGE(FAILED, "[Check][Param] var_key:%s conflict in var_addr_mgr_map_, var_name:%s, session_id:%lu",
var_key.c_str(), var_name.c_str(), session_id_);
return FAILED;
}

@@ -145,14 +148,15 @@ ge::Status VarResource::RenewCurVarDesc(const std::string &var_name, const ge::O
if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc is nullptr, var_name:%s, session_id:%lu, check invalid",
var_name.c_str(), session_id_);
GELOGE(FAILED, "[RenewCurVarDesc] renew var desc fail! input opdesc is null!");
GELOGE(FAILED, "[Check][Param] input opdesc is nullptr, var_name:%s, session_id:%lu",
var_name.c_str(), session_id_);
return FAILED;
}

ge::GeTensorDesc curr_desc;
ge::Status ret = GetCurVarDesc(var_name, curr_desc);
if (ret != SUCCESS) {
GELOGE(FAILED, "[RenewCurVarDesc] Get var desc fail!");
GELOGE(FAILED, "[Get][CurVarDesc] fail, var_name:%s, session_id:%lu", var_name.c_str(), session_id_);
return FAILED;
}
std::string key = VarKey(var_name, curr_desc);
@@ -164,7 +168,8 @@ ge::Status VarResource::RenewCurVarDesc(const std::string &var_name, const ge::O
REPORT_INNER_ERROR("E19999", "var_key:%s can't find in var_addr_mgr_map_, var_name:%s, session_id:%lu, op:%s(%s), "
"check invalid", key.c_str(), var_name.c_str(),
session_id_, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "[RenewCurVarDesc] can't find ele with key [%s]", key.c_str());
GELOGE(FAILED, "[Check][Param] var_key:%s can't find in var_addr_mgr_map_, var_name:%s, session_id:%lu, op:%s(%s)",
key.c_str(), var_name.c_str(), session_id_, op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED;
}
auto val = iter->second;
@@ -285,14 +290,15 @@ Status HbmMemResource::AssignVarMem(const std::string &var_name, uint64_t size,
if (total_size_ < var_mem_size_) {
REPORT_INNER_ERROR("E19999", "VarMemMaxSize:%lu < var_mem_size_:%lu, var_size:%lu, var_name:%s, check invalid"
"", total_size_, var_mem_size_, size, var_name.c_str());
GELOGE(PARAM_INVALID, "total_size_: %lu is smaller than var_mem_size_: %lu", total_size_, var_mem_size_);
GELOGE(PARAM_INVALID, "[Check][Param] total_size_:%lu is smaller than var_mem_size_:%lu, var_name:%s",
total_size_, var_mem_size_, var_name.c_str());
return PARAM_INVALID;
}
uint64_t free_size = total_size_ - var_mem_size_;
if (free_size < (size + kSessionMemAlignSize * kSessionMemAlignUnit)) {
REPORT_INNER_ERROR("E19999", "free_size:%lu not enough, var_align_size:%lu, var_name:%s, check invalid",
free_size, size, var_name.c_str());
GELOGE(PARAM_INVALID, "Out of memory : current var size[%lu] exceeds total var size[%lu]",
GELOGE(PARAM_INVALID, "[Check][Param] Out of memory: current var size[%lu] exceeds total var size[%lu]",
size + kSessionMemAlignSize * kSessionMemAlignUnit + var_mem_size_, total_size_);
return PARAM_INVALID;
}
@@ -317,7 +323,7 @@ Status RdmaMemResource::AssignVarMem(const std::string &var_name, uint64_t size,
if (buffer == nullptr) {
REPORT_CALL_ERROR("E19999", "malloc rdma memory fail, var_size:%lu, var_name:%s",
size, var_name.c_str());
GELOGE(MEMALLOC_FAILED, "Failed to malloc rdma memory for node %s, size = %lu", var_name.c_str(), size);
GELOGE(MEMALLOC_FAILED, "[Malloc][RdmaMemory] for node %s failed, size = %lu", var_name.c_str(), size);
return MEMALLOC_FAILED;
}
address = static_cast<size_t>(reinterpret_cast<uintptr_t>(buffer));
@@ -468,7 +474,8 @@ int64_t VarManager::GetVarMemSize(rtMemType_t memory_type) {
if (mem_resource == nullptr) {
REPORT_INNER_ERROR("E19999", "Find no mem_resource in map, memory_type:%d, session_id:%lu",
memory_type, session_id_);
GELOGE(ge::INTERNAL_ERROR, "MemResource is invalid.");
GELOGE(ge::INTERNAL_ERROR, "[Check][Param] MemResource is invalid, memory_type:%d, session_id:%lu",
memory_type, session_id_);
return 0;
}
return mem_resource->GetVarMemSize();
@@ -482,8 +489,9 @@ Status VarManager::UpdateVarMemSize(rtMemType_t memory_type, int64_t mem_size) {
mem_resource = MemResource::BuildMemResourceFromType(memory_type);
if (mem_resource == nullptr) {
REPORT_CALL_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu",
memory_type, session_id_);
GELOGE(ge::INTERNAL_ERROR, "Alloc MemResource failed, memory_type = %u.", memory_type);
memory_type, session_id_);
GELOGE(ge::INTERNAL_ERROR, "[Alloc][MemResource] failed, memory_type:%u, session_id:%lu",
memory_type, session_id_);
return ge::INTERNAL_ERROR;
} else {
mem_resource_map_[memory_type] = mem_resource;
@@ -495,7 +503,8 @@ Status VarManager::UpdateVarMemSize(rtMemType_t memory_type, int64_t mem_size) {
if (mem_resource == nullptr) {
REPORT_INNER_ERROR("E19999", "MemResource is invalid, memory_type:%d, session_id:%lu",
memory_type, session_id_);
GELOGE(ge::INTERNAL_ERROR, "MemResource is invalid.");
GELOGE(ge::INTERNAL_ERROR, "[Check][Param] MemResource is invalid, memory_type:%u, session_id:%lu",
memory_type, session_id_);
return FAILED;
}
mem_resource->UpdateVarMemSize(mem_size);
@@ -515,7 +524,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
if (result != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get size from tensor fail, var_name:%s, memory_type:%d, session_id:%lu",
var_name.c_str(), memory_type, session_id_);
GELOGE(result, "get size from TensorDesc failed");
GELOGE(result, "[Get][Size] from tensor fail, var_name:%s, memory_type:%u, session_id:%lu",
var_name.c_str(), memory_type, session_id_);
return result;
}

@@ -526,7 +536,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
if (mem_resource == nullptr) {
REPORT_CALL_ERROR("E19999", "memory_type:%d invalid or New MemResource fail, session_id:%lu",
memory_type, session_id_);
GELOGE(ge::INTERNAL_ERROR, "Alloc MemResource failed, memory_type = %u.", memory_type);
GELOGE(ge::INTERNAL_ERROR, "[Alloc][MemResource] failed, memory_type:%u, session_id:%lu.",
memory_type, session_id_);
return ge::INTERNAL_ERROR;
} else {
mem_resource_map_[memory_type] = mem_resource;
@@ -538,7 +549,8 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
if (mem_resource == nullptr) {
REPORT_INNER_ERROR("E19999", "MemResource is invalid, memory_type:%d, session_id:%lu",
memory_type, session_id_);
GELOGE(ge::INTERNAL_ERROR, "MemResource is invalid, memory_type = %u.", memory_type);
GELOGE(ge::INTERNAL_ERROR, "[Check][Param] MemResource is invalid, memory_type:%u, session_id:%lu.",
memory_type, session_id_);
return ge::INTERNAL_ERROR;
}

@@ -567,14 +579,15 @@ ge::Status VarManager::AssignVarMem(const std::string &var_name, const ge::GeTen
if (can_not_reuse_old_memory) {
result = mem_resource->AssignVarMem(var_name, tensor_desc_size, session_id_, mem_offset);
if (result != SUCCESS) {
GELOGE(ge::INTERNAL_ERROR, "AssignVarMem by offset failed.");
GELOGE(ge::INTERNAL_ERROR, "[Assign][VarMem] by offset failed, session_id:%lu.", session_id_);
return ge::INTERNAL_ERROR;
}

result = var_resource_->SaveVarAddr(
var_name, tensor_desc, reinterpret_cast<uint8_t *>(static_cast<uintptr_t>(mem_offset)), memory_type);
if (result != SUCCESS) {
GELOGE(ge::INTERNAL_ERROR, "AssignVarMem by offset failed.");
GELOGE(ge::INTERNAL_ERROR, "[Save][VarAddr] by offset failed, memory type:%u, session_id:%lu.",
memory_type, session_id_);
return ge::INTERNAL_ERROR;
}
}
@@ -681,7 +694,8 @@ ge::Status VarManager::RenewCurVarDesc(const std::string &var_name, ge::OpDescPt
REPORT_INNER_ERROR("E19999", "VarManager has not been init, op:%s(%s), session_id:%lu, check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str(),
session_id_);
GELOGE(ge::INTERNAL_ERROR, "VarManager has not been init.");
GELOGE(ge::INTERNAL_ERROR, "[Check][Param] VarManager has not been init, op:%s(%s), session_id:%lu",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), session_id_);
return ge::INTERNAL_ERROR;
}
return var_resource_->RenewCurVarDesc(var_name, std::move(op_desc));
@@ -729,10 +743,8 @@ ge::Status VarManager::MallocVarMemory(size_t memory_size) {
const string purpose("variables and constant op memory in training network.");
var_mem_base = MemManager::Instance().MemInstance(RT_MEMORY_HBM).MallocMemory(purpose, memory_key, var_memory_size);
if (var_mem_base == nullptr) {
GELOGE(ge::INTERNAL_ERROR,
"VarManager::MallocVarMemory failed "
"session_id = %s",
memory_key.c_str());
GELOGE(ge::INTERNAL_ERROR, "[Malloc][VarMemory] failed, size:%zu, session_id:%s",
var_memory_size, memory_key.c_str());
return ge::INTERNAL_ERROR;
}
return SUCCESS;
@@ -812,7 +824,7 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {
string graph_memory_manager_malloc_max_size = it->second;
ge::Status ret = ParseMemoryMallocSize(graph_memory_manager_malloc_max_size, graph_mem_max_size_);
if (ret != SUCCESS) {
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "Parse graph memory manager malloc max size failed.");
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Call][ParseMemoryMallocSize] failed, session id:%lu.", session_id_);
return ge::GE_GRAPH_OPTIONS_INVALID;
}
GELOGI("The max size for graph mem is set to %zu", graph_mem_max_size_);
@@ -825,7 +837,7 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {
string memory_var_manager_malloc_size = it->second;
ge::Status ret = ParseMemoryMallocSize(memory_var_manager_malloc_size, var_mem_max_size_);
if (ret != SUCCESS) {
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "Parse memory var manager malloc size failed.");
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Call][ParseMemoryMallocSize] failed, session id:%lu.", session_id_);
return ge::GE_GRAPH_OPTIONS_INVALID;
}
}
@@ -834,8 +846,8 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {
if (var_mem_logic_base_ > kMaxMemorySize) {
REPORT_INNER_ERROR("E19999", "var_login_base:%zu can not exeed limit:%zu, session_id:%lu, check invalid",
var_mem_logic_base_, kMaxMemorySize, session_id_);
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "kMemoryVarLogicBase : %zu can not exceed max memory size : %zu.",
var_mem_logic_base_, kMaxMemorySize);
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Check][Param] kMemoryVarLogicBase:%zu can not exceed "
"max memory size:%zu, session_id:%lu.", var_mem_logic_base_, kMaxMemorySize, session_id_);
return ge::GE_GRAPH_OPTIONS_INVALID;
}

@@ -843,8 +855,8 @@ Status VarManager::SetMemoryMallocSize(const map<string, string> &options) {
if (use_max_mem_size_ > kMaxMemorySize) {
REPORT_INNER_ERROR("E19999", "all mem_use size:%zu can not exeed limit:%zu, session_id:%lu, check invalid",
use_max_mem_size_, kMaxMemorySize, session_id_);
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "kUseMaxMemorySize : %zu can not exceed max memory size : %zu.",
use_max_mem_size_, kMaxMemorySize);
GELOGE(ge::GE_GRAPH_OPTIONS_INVALID, "[Check][Param] kUseMaxMemorySize:%zu can not exceed "
"max memory size:%zu, session_id:%lu.", use_max_mem_size_, kMaxMemorySize, session_id_);
return ge::GE_GRAPH_OPTIONS_INVALID;
}
GELOGI("Set memory malloc size successfully");
@@ -855,7 +867,7 @@ Status VarManager::ParseMemoryMallocSize(string &memory_size, size_t &result) {
if (memory_size.empty()) {
REPORT_INNER_ERROR("E19999", "Param memory_size is empty, session_id:%lu, check invalid",
session_id_);
GELOGE(GE_GRAPH_OPTIONS_INVALID, "Memory malloc size input is empty.");
GELOGE(GE_GRAPH_OPTIONS_INVALID, "[Check][Param] Memory malloc size input is empty, session_id:%lu.", session_id_);
return GE_GRAPH_OPTIONS_INVALID;
}
// split string by '*'
@@ -882,7 +894,9 @@ Status VarManager::ParseMemoryMallocSize(string &memory_size, size_t &result) {
if (!isdigit(c)) {
REPORT_INNER_ERROR("E19999", "Param memory_size:%s contains non digit, session_id:%lu, check invalid",
memory_size.c_str(), session_id_);
GELOGE(GE_GRAPH_OPTIONS_INVALID, "Memory malloc size input contains non digit.");
GELOGE(GE_GRAPH_OPTIONS_INVALID,
"[Check][Param] Memory malloc size:%s input contains non digit, session_id:%lu.",
memory_size.c_str(), session_id_);
return GE_GRAPH_OPTIONS_INVALID;
}
}
@@ -891,13 +905,15 @@ Status VarManager::ParseMemoryMallocSize(string &memory_size, size_t &result) {
REPORT_INNER_ERROR("E19999", "Param memory_size:%s will overflow after multi all, session_id:%lu, "
"check invalid", memory_size.c_str(),
session_id_);
GELOGE(FAILED, "Input memory size is out of range.");
GELOGE(FAILED, "[Check][Param] Param memory_size:%s will overflow after multi all, session_id:%lu",
memory_size.c_str(), session_id_);
return FAILED);
if ((num > kMaxMemorySize) || (result * static_cast<size_t>(num) > kMaxMemorySize)) {
REPORT_INNER_ERROR("E19999", "Param memory_size:%s after multi will exceed limit:%lu, session_id:%lu, "
"check invalid", memory_size.c_str(), kMaxMemorySize,
session_id_);
GELOGE(FAILED, "Input memory size can not exceed max memory size : %zu.", kMaxMemorySize);
GELOGE(FAILED, "[Check][Param] Input memory size can not exceed max memory size:%zu, session_id:%lu.",
kMaxMemorySize, session_id_);
return FAILED;
}
result *= static_cast<size_t>(num);
@@ -1001,10 +1017,7 @@ VarManager *VarManagerPool::GetVarManager(uint64_t session_id) {
VarManager *var_manager = new (std::nothrow) VarManager(session_id);
if (var_manager == nullptr) {
REPORT_INNER_ERROR("E19999", "New VarManager fail, session_id:%lu", session_id);
GELOGE(INTERNAL_ERROR,
"VarManager::Instance find session by "
"session_id[%lu] failed.",
session_id);
GELOGE(INTERNAL_ERROR, "[New][VarManager] fail, session_id:%lu", session_id);
static VarManager new_var_manager(0);
return &new_var_manager;
}


+ 8
- 5
ge/graph/manager/host_mem_allocator.cc View File

@@ -21,7 +21,10 @@
namespace ge {
const void *HostMemAllocator::Malloc(const std::shared_ptr<AlignedPtr> &aligned_ptr, size_t size) {
if (aligned_ptr == nullptr) {
GELOGW("Insert a null aligned_ptr");
GELOGW("Insert a null aligned_ptr, size=%zu", size);
if (size == 0) {
allocated_blocks_[nullptr] = { size, nullptr };
}
return nullptr;
}
GELOGD("allocate existed host memory succ, size=%zu", size);
@@ -34,8 +37,8 @@ uint8_t *HostMemAllocator::Malloc(size_t size) {
std::lock_guard<std::mutex> lock(mutex_);
std::shared_ptr<AlignedPtr> aligned_ptr = MakeShared<AlignedPtr>(size);
if (aligned_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "New AlignedPtr fail");
GELOGE(INTERNAL_ERROR, "make shared_ptr for AlignedPtr failed");
REPORT_INNER_ERROR("E19999", "New AlignedPtr fail, size:%zu", size);
GELOGE(INTERNAL_ERROR, "[Call][MakeShared] for AlignedPtr failed, size:%zu", size);
return nullptr;
}
allocated_blocks_[aligned_ptr->Get()] = { size, aligned_ptr };
@@ -46,7 +49,7 @@ uint8_t *HostMemAllocator::Malloc(size_t size) {
Status HostMemAllocator::Free(const void *memory_addr) {
if (memory_addr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param memory_addr is nullptr, check invalid");
GELOGE(GE_GRAPH_FREE_FAILED, "Invalid memory pointer");
GELOGE(GE_GRAPH_FREE_FAILED, "[Check][Param] Invalid memory pointer");
return GE_GRAPH_FREE_FAILED;
}

@@ -54,7 +57,7 @@ Status HostMemAllocator::Free(const void *memory_addr) {
auto it = allocated_blocks_.find(memory_addr);
if (it == allocated_blocks_.end()) {
REPORT_INNER_ERROR("E19999", "Memory_addr is not alloc before, check invalid");
GELOGE(PARAM_INVALID, "Invalid memory pointer");
GELOGE(PARAM_INVALID, "[Check][Param] Invalid memory pointer:%p", memory_addr);
return PARAM_INVALID;
}
it->second.second.reset();


+ 9
- 13
ge/graph/manager/host_mem_manager.cc View File

@@ -39,9 +39,8 @@ Status SharedMemAllocator::Allocate(SharedMemInfo &mem_info) {
rtMallocHostSharedMemoryOut output_para;
rtError_t rt_ret = rtMallocHostSharedMemory(&input_para, &output_para);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMallocHostSharedMemory fail, ret:0x%X",
rt_ret);
GELOGE(RT_FAILED, "Call rt api(rtMallocHostSharedMemory) failed, devid:[%u].", device_id);
REPORT_CALL_ERROR("E19999", "Call rtMallocHostSharedMemory fail, ret:0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtMallocHostSharedMemory] failed, devid:[%u].", device_id);
return GE_GRAPH_MEMORY_ALLOC_FAILED;
}
mem_info.fd = output_para.fd;
@@ -60,9 +59,8 @@ Status SharedMemAllocator::DeAllocate(SharedMemInfo &mem_info) {
mem_info.host_aligned_ptr->MutableGet(), mem_info.device_address};
rtError_t rt_ret = rtFreeHostSharedMemory(&free_para);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtFreeHostSharedMemory fail, ret:0x%X",
rt_ret);
GELOGE(RT_FAILED, "Call rt api(rtFreeHostSharedMemory) failed, ret: 0x%X.", rt_ret);
REPORT_CALL_ERROR("E19999", "Call rtFreeHostSharedMemory fail, ret:0x%X", rt_ret);
GELOGE(RT_FAILED, "[Call][RtFreeHostSharedMemory] failed, ret:0x%X.", rt_ret);
return RT_FAILED;
}
return ge::SUCCESS;
@@ -78,7 +76,7 @@ Status HostMemManager::Initialize() {
allocator_ = std::unique_ptr<SharedMemAllocator>(new (std::nothrow) SharedMemAllocator());
if (allocator_ == nullptr) {
REPORT_CALL_ERROR("E19999", "New SharedMemAllocator fail");
GELOGE(GE_GRAPH_MALLOC_FAILED, "Shared memory allocator init failed!");
GELOGE(GE_GRAPH_MALLOC_FAILED, "[New][SharedMemAllocator] failed!");
return GE_GRAPH_MALLOC_FAILED;
}
return SUCCESS;
@@ -98,9 +96,8 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
auto iter = var_memory_base_map_.find(mem_info.op_name);
if (iter != var_memory_base_map_.end()) {
REPORT_INNER_ERROR("E19999", "MemInfo.op_name:%s can't find in var_memory_base_map_",
mem_info.op_name.c_str());
GELOGE(FAILED, "Host shared memory for op %s has been malloced", mem_info.op_name.c_str());
REPORT_INNER_ERROR("E19999", "Host shared memory for op %s has been malloced", mem_info.op_name.c_str());
GELOGE(FAILED, "[Check][Param] Host shared memory for op %s has been malloced", mem_info.op_name.c_str());
return FAILED;
}
mem_info.shm_name = OpNameToShmName(mem_info.op_name);
@@ -113,9 +110,8 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) {
Status HostMemManager::QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size) {
std::lock_guard<std::recursive_mutex> lock(mutex_);
if (var_memory_base_map_.find(op_name) == var_memory_base_map_.end()) {
REPORT_INNER_ERROR("E19999", "MemInfo.op_name:%s can't find in var_memory_base_map_",
op_name.c_str());
GELOGE(INTERNAL_ERROR, "Find host base base_addr failed,node name:%s!", op_name.c_str());
REPORT_INNER_ERROR("E19999", "MemInfo.op_name:%s can't find in var_memory_base_map_", op_name.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] Find host base base_addr failed, node name:%s!", op_name.c_str());
return INTERNAL_ERROR;
}
base_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(var_memory_base_map_[op_name].device_address));


+ 8
- 10
ge/graph/manager/memory_api.cc View File

@@ -50,9 +50,8 @@ Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info, rtMemType_t
path.append(file_name);
string canonical_path = RealPath(path.c_str());
if (canonical_path.empty()) {
REPORT_INNER_ERROR("E19999", "canonical_path:%s is empty, check invalid",
canonical_path.c_str());
GELOGE(FAILED, "Failed to get realpath of %s", path.c_str());
REPORT_INNER_ERROR("E19999", "canonical_path:%s is empty, check invalid", canonical_path.c_str());
GELOGE(FAILED, "[Call][RealPath] Failed to get realpath of %s", path.c_str());
return FAILED;
}
GELOGI("FileName:%s, Path:%s.", file_name.c_str(), canonical_path.c_str());
@@ -69,15 +68,14 @@ Status RdmaRemoteRegister(const std::vector<HostVarInfo> &var_info, rtMemType_t
if (hcom_remote_mem_register == nullptr) {
REPORT_CALL_ERROR("E19999", "Symbol HcomRegRemoteAccessMem can't find in %s, check invalid",
canonical_path.c_str());
GELOGE(FAILED, "Failed to invoke hcom_remote_mem_register function.");
GELOGE(FAILED, "[Check][Param] Symbol HcomRegRemoteAccessMem can't find in %s", canonical_path.c_str());
return FAILED;
}

HcclResult hccl_ret = hcom_remote_mem_register(reg_addrs.get(), table_len);
if (hccl_ret != HCCL_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Call hcom_remote_mem_register failed, ret:%d,",
hccl_ret);
GELOGE(HCCL_E_INTERNAL, "Rdma mem register failed, ret: 0x%X", hccl_ret);
REPORT_CALL_ERROR("E19999", "Call hcom_remote_mem_register failed, ret:%d,", hccl_ret);
GELOGE(HCCL_E_INTERNAL, "[Call][HcomRemoteMemRegister] Rdma mem register failed, ret:0x%X", hccl_ret);
return HCCL_E_INTERNAL;
}
return SUCCESS;
@@ -88,14 +86,14 @@ Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uin
uint32_t type_size = 0;
bool result = TypeUtils::GetDataTypeLength(tensor_info.data_type, type_size);
if (!result) {
GELOGE(GRAPH_FAILED, "GetDataTypeLength failed, data_type=(%s).",
GELOGE(GRAPH_FAILED, "[Get][DataTypeLength] failed, data_type=(%s).",
TypeUtils::DataTypeToSerialString(tensor_info.data_type).c_str());
return GRAPH_FAILED;
}
memory_size = type_size;
for (auto dim : tensor_info.dims) {
if (dim <= 0) {
GELOGE(GRAPH_FAILED, "Tensor dims should be positive");
GELOGE(GRAPH_FAILED, "[Check][Param] Tensor dims should be positive");
return GRAPH_FAILED;
}
memory_size *= dim;
@@ -103,7 +101,7 @@ Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uin
SharedMemInfo mem_info(tensor_info.var_name, memory_size);
Status ret = HostMemManager::Instance().MallocSharedMemory(mem_info);
if (ret != SUCCESS) {
GELOGE(GRAPH_FAILED, "MallocSharedMemory failed op name [%s]", tensor_info.var_name.c_str());
GELOGE(GRAPH_FAILED, "[Malloc][SharedMemory] failed, op name [%s]", tensor_info.var_name.c_str());
return GRAPH_FAILED;
}
dev_addr = reinterpret_cast<uint64_t>(reinterpret_cast<uintptr_t>(mem_info.device_address));


+ 1
- 1
ge/graph/manager/model_manager/event_manager.cc View File

@@ -45,7 +45,7 @@ Status EventManager::Init(size_t event_num) {
void EventManager::Release() noexcept {
for (size_t i = 0; i < this->event_list_.size(); ++i) {
rtError_t rt_ret = rtEventDestroy(this->event_list_[i]);
RETURN_IF_COND_NOT_MET(rt_ret == RT_ERROR_NONE, "Destroy event failed, idx is %zu, ret is 0x%x.", i, rt_ret);
RETURN_IF_COND_NOT_MET(rt_ret == RT_ERROR_NONE, "[Destroy][Event] failed, idx is %zu, ret is 0x%x.", i, rt_ret);
}
this->event_list_.clear();



+ 10
- 11
ge/graph/manager/rdma_pool_allocator.cc View File

@@ -82,8 +82,8 @@ Status RdmaPoolAllocator::InitMemory(size_t mem_size) {
auto device_id = GetContext().DeviceId();
GELOGD("Init Rdma Memory with size [%zu] for devid:[%u]", mem_size, device_id);
if (rdma_base_addr_ != nullptr) {
REPORT_INNER_ERROR("E19999", "Param rdma_base_addr_ is nullptr, check invalid");
GELOGE(GE_MULTI_INIT, "Rdma pool has been malloced");
REPORT_INNER_ERROR("E19999", "Param rdma_base_addr_ is not nullptr, devid:%u, check invalid", device_id);
GELOGE(GE_MULTI_INIT, "[Check][Param] Rdma pool has been malloced, devid:%u", device_id);
return GE_MULTI_INIT;
}
const std::string purpose = "Memory for rdma pool.";
@@ -95,15 +95,15 @@ Status RdmaPoolAllocator::InitMemory(size_t mem_size) {

rdma_base_addr_ = memory_allocator_->MallocMemory(purpose, mem_size, device_id);
if (rdma_base_addr_ == nullptr) {
GELOGE(GE_GRAPH_MALLOC_FAILED, "Rdma pool memory malloc failed");
GELOGE(GE_GRAPH_MALLOC_FAILED, "[Malloc][Memory] failed, size:%zu, device_id:%u", mem_size, device_id);
return GE_GRAPH_MALLOC_FAILED;
}
rdma_mem_size_ = mem_size;
// Init with a base block.
auto *base_block = new (std::nothrow) Block(device_id, mem_size, rdma_base_addr_);
if (base_block == nullptr) {
REPORT_CALL_ERROR("E19999", "New Block failed, device_id:%u", device_id);
GELOGE(GE_GRAPH_MALLOC_FAILED, "Block malloc failed");
REPORT_CALL_ERROR("E19999", "New Block failed, size:%zu, device_id:%u", mem_size, device_id);
GELOGE(GE_GRAPH_MALLOC_FAILED, "[New][Block] failed, size:%zu, device_id:%u", mem_size, device_id);
return GE_GRAPH_MALLOC_FAILED;
}
block_bin_.insert(base_block);
@@ -123,7 +123,7 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) {
if (block->ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Rdmapool memory address is nullptr, device_id:%u, check invalid",
device_id);
GELOGE(INTERNAL_ERROR, "Rdmapool memory address is nullptr.");
GELOGE(INTERNAL_ERROR, "[Check][Param] Rdmapool memory address is nullptr, device_id:%u", device_id);
return nullptr;
}
allocated_blocks_.emplace(block->ptr, block);
@@ -155,9 +155,8 @@ uint8_t *RdmaPoolAllocator::Malloc(size_t size, uint32_t device_id) {
Status RdmaPoolAllocator::Free(uint8_t *memory_addr, uint32_t device_id) {
GELOGI("Free rdma memory, device id = %u", device_id);
if (memory_addr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param memory_addr is nullptr, device_id:%u, check invalid",
device_id);
GELOGE(GE_GRAPH_FREE_FAILED, "Invalid memory pointer");
REPORT_INNER_ERROR("E19999", "Param memory_addr is nullptr, device_id:%u, check invalid", device_id);
GELOGE(GE_GRAPH_FREE_FAILED, "[Check][Param] Invalid memory pointer, device id:%u", device_id);
return GE_GRAPH_FREE_FAILED;
}

@@ -166,7 +165,7 @@ Status RdmaPoolAllocator::Free(uint8_t *memory_addr, uint32_t device_id) {
if (it == allocated_blocks_.end()) {
REPORT_INNER_ERROR("E19999", "Param memory_addr is not allocated before, device_id:%u, "
"check invalid", device_id);
GELOGE(PARAM_INVALID, "Invalid memory pointer");
GELOGE(PARAM_INVALID, "[Check][Param] Invalid memory pointer, device id:%u", device_id);
return PARAM_INVALID;
}

@@ -209,7 +208,7 @@ void RdmaPoolAllocator::MergeBlocks(Block *dst, Block *src) {
Status RdmaPoolAllocator::GetBaseAddr(uint64_t &base_addr, uint64_t &mem_size) {
if (rdma_base_addr_ == nullptr) {
REPORT_INNER_ERROR("E19999", "Param rdma_base_addr_ is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Rdma base addr is nullptr.");
GELOGE(INTERNAL_ERROR, "[Check][Param] Rdma base addr is nullptr.");
return INTERNAL_ERROR;
}
base_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(rdma_base_addr_));


+ 75
- 57
ge/graph/manager/trans_var_data_utils.cc View File

@@ -37,7 +37,8 @@ class RtContextSwitchGuard {
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxGetCurrent failed, device_id:%u, ret:0x%X,",
device_id, ret);
GELOGE(RT_FAILED, "Failed to get current context from rt, error-code %d", ret);
GELOGE(RT_FAILED, "[Call][RtCtxGetCurrent] Failed to get current context, device_id:%u, ret:0x%X",
device_id, ret);
return;
}

@@ -45,15 +46,14 @@ class RtContextSwitchGuard {
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxCreate failed, device_id:%u, ret:0x%X,",
device_id, ret);
GELOGE(RT_FAILED, "Failed to create new context for device %u, error-code %d", device_id, ret);
GELOGE(RT_FAILED, "[Call][RtCtxCreate] Failed to create new context for device:%u, ret:%d", device_id, ret);
return;
}

ret = rtCtxSetCurrent(current_);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, device_id:%u, ret:0x%X,",
device_id, ret);
GELOGE(RT_FAILED, "Failed to switch context to normal, context %p, device %u", current_, device_id);
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, device_id:%u, ret:0x%X", device_id, ret);
GELOGE(RT_FAILED, "[Call][RtCtxSetCurrent] failed, device_id:%u, ret:0x%X", device_id, ret);
return;
}
GELOGD("Create and switch rt context %p type %d for device %u, backup last %p.", current_, mode, device_id, last_);
@@ -80,7 +80,7 @@ int64_t CalcVarSizeInBytes(const GeTensorDesc &desc) {
if (var_size <= 0) {
REPORT_INNER_ERROR("E19999", "Data type:%s in desc, it's size:%ld < 0, check invalid",
TypeUtils::DataTypeToSerialString(desc.GetDataType()).c_str(), var_size);
GELOGE(PARAM_INVALID, "Failed to calc var data size from data type %s",
GELOGE(PARAM_INVALID, "[Calc][VarDataSize] by data type %s failed.",
TypeUtils::DataTypeToSerialString(desc.GetDataType()).c_str());
return -1;
}
@@ -99,7 +99,8 @@ Status CopyVarToDevice(const NodePtr &var, const formats::TransResult &trans_res
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, op:%s(%s), size:%lu, ret:0x%X,", var->GetName().c_str(),
var->GetType().c_str(), trans_result.length, ret);
GELOGE(RT_FAILED, "Failed to copy memory to device, size %zu", trans_result.length);
GELOGE(RT_FAILED, "[Call][RtMemcpy] failed, op:%s(%s), size:%lu, ret:0x%X,", var->GetName().c_str(),
var->GetType().c_str(), trans_result.length, ret);
return RT_FAILED;
}
return SUCCESS;
@@ -111,21 +112,17 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt
GE_CHECK_NOTNULL(var);
auto ret = VarManager::Instance(session_id)->GetVarAddr(var->GetName(), input_desc, &var_logic);
if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR,
"Failed to copy var %s from device, can not find it"
" from var manager %u",
var->GetName().c_str(), ret);
GELOGE(INTERNAL_ERROR, "[Get][VarAddr] failed, node:%s, session_id:%lu, ret:%d",
var->GetName().c_str(), session_id, ret);
return INTERNAL_ERROR;
}

uint8_t *var_addr = VarManager::Instance(session_id)->GetVarMemoryAddr(var_logic, RT_MEMORY_HBM);
if (var_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "Get variable memory addr failed, mem_type:%d, op:%s(%s), session_id:%lu,",
REPORT_CALL_ERROR("E19999", "Get variable memory addr failed, mem_type:%d, op:%s(%s), session_id:%lu",
RT_MEMORY_HBM, var->GetName().c_str(), var->GetType().c_str(), session_id);
GELOGE(INTERNAL_ERROR,
"Failed to copy var %s from device, cant not get "
"var addr from logic addr %p",
var->GetName().c_str(), var_logic);
GELOGE(INTERNAL_ERROR, "[Get][VarMemoryAddr] failed, mem_type:%d, op:%s(%s), session_id:%lu",
RT_MEMORY_HBM, var->GetName().c_str(), var->GetType().c_str(), session_id);
return INTERNAL_ERROR;
}

@@ -136,9 +133,10 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt

std::unique_ptr<uint8_t[]> var_host(new(std::nothrow) uint8_t[var_size_bytes]);
if (var_host == nullptr) {
REPORT_CALL_ERROR("E19999", "New host memory failed, size:%ld, op:%s(%s), session_id:%lu,",
REPORT_CALL_ERROR("E19999", "New host memory failed, size:%ld, op:%s(%s), session_id:%lu",
var_size_bytes, var->GetName().c_str(), var->GetType().c_str(), session_id);
GELOGE(OUT_OF_MEMORY, "Failed to malloc rt-host memory, size %ld", var_size_bytes);
GELOGE(OUT_OF_MEMORY, "[New][Memory] for rt-host failed, size:%ld, op:%s(%s), session_id:%lu",
var_size_bytes, var->GetName().c_str(), var->GetType().c_str(), session_id);
return OUT_OF_MEMORY;
}

@@ -147,10 +145,8 @@ Status CopyVarFromDevice(uint64_t session_id, const NodePtr &var, std::unique_pt
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%ld, op:%s(%s), session_id:%lu, ret:0x%X",
var_size_bytes, var->GetName().c_str(), var->GetType().c_str(), session_id, ret);
GELOGE(RT_FAILED,
"Failed to copy var memory from device, var %s, size %ld,"
" rt-error-code %u",
var->GetName().c_str(), var_size_bytes, ret);
GELOGE(RT_FAILED, "[Call][RtMemcpy] failed, size:%ld, op:%s(%s), session_id:%lu, ret:0x%X",
var_size_bytes, var->GetName().c_str(), var->GetType().c_str(), session_id, ret);
return RT_FAILED;
}

@@ -197,9 +193,7 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats
formats::ShapeToString(src_shape).c_str(),
formats::ShapeToString(dst_shape).c_str(),
TypeUtils::DataTypeToSerialString(data_type).c_str(), ret);
GELOGE(INTERNAL_ERROR,
"Failed to trans format from %s to %s, shape %s to %s, "
"data type %s error code %u",
GELOGE(INTERNAL_ERROR, "[Trans][Format] from %s to %s, shape %s to %s failed, data type %s error code %u",
TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(),
formats::ShapeToString(src_shape).c_str(), formats::ShapeToString(dst_shape).c_str(),
TypeUtils::DataTypeToSerialString(data_type).c_str(), ret);
@@ -221,7 +215,7 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats
TypeUtils::DataTypeToSerialString(src_data_type).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
formats::ShapeToString(input_shape).c_str(), src_data_size, ret);
GELOGE(INTERNAL_ERROR, "Failed to trans data type from %s to %s, input shape %s, data size %ld, error code %u",
GELOGE(INTERNAL_ERROR, "[Trans][DataType] from %s to %s failed, input shape %s, data size %ld, error code %u",
TypeUtils::DataTypeToSerialString(src_data_type).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(), formats::ShapeToString(input_shape).c_str(),
src_data_size, ret);
@@ -230,7 +224,7 @@ Status TransVarOnHost(uint8_t *var_data, const VarTransRoad &trans_road, formats
} else {
REPORT_INNER_ERROR("E19999", "Trans var data failed, the trans type %s does not supported, check invalid",
trans_info.node_type.c_str());
GELOGE(UNSUPPORTED, "Failed to trans var data, the trans type %s does not supported",
GELOGE(UNSUPPORTED, "[Trans][VarData] failed, the trans type %s does not supported",
trans_info.node_type.c_str());
return UNSUPPORTED;
}
@@ -255,10 +249,8 @@ Status ReAssignVarAddr(uint64_t session_id,
uint8_t *var_logic = nullptr;
Status ret = VarManager::Instance(session_id)->GetVarAddr(var_name, tensor_desc, &var_logic);
if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR,
"Failed to get var %s device addr, can not find it"
" from var manager %u",
var_name.c_str(), ret);
GELOGE(INTERNAL_ERROR, "[Get][VarAddr] failed, var name:%s, session_id:%lu, ret:%u",
var_name.c_str(), session_id, ret);
return INTERNAL_ERROR;
}

@@ -266,7 +258,8 @@ Status ReAssignVarAddr(uint64_t session_id,
if (var_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "Get variable memory addr failed, mem_type:%d, var_name:%s, session_id:%lu,",
RT_MEMORY_HBM, var_name.c_str(), session_id);
GELOGE(INTERNAL_ERROR, "Failed to convert var %s logic addr to real addr", var_name.c_str());
GELOGE(INTERNAL_ERROR, "[Get][VarMemoryAddr] failed, mem_type:%d, var_name:%s, session_id:%lu",
RT_MEMORY_HBM, var_name.c_str(), session_id);
return INTERNAL_ERROR;
}
*var_device = var_addr;
@@ -293,9 +286,8 @@ Status TransVarData(const NodePtr &var, const VarTransRoad &trans_road, uint64_t
// Sync var data from device
std::unique_ptr<uint8_t[]> var_data;
if (trans_road.empty()) {
REPORT_INNER_ERROR("E19999", "Param trans_road is empty, session_id:%lu, check invalid",
session_id);
GELOGE(INTERNAL_ERROR, "Failed to get trans_road, trans_road is empty.");
REPORT_INNER_ERROR("E19999", "Param trans_road is empty, session_id:%lu, check invalid", session_id);
GELOGE(INTERNAL_ERROR, "[Check][Param] trans_road is empty, session_id:%lu", session_id);
return INTERNAL_ERROR;
}
const GeTensorDesc &input_desc = trans_road.begin()->input;
@@ -307,7 +299,7 @@ Status TransVarData(const NodePtr &var, const VarTransRoad &trans_road, uint64_t
formats::TransResult trans_result{};
ret = TransVarOnHost(var_data.get(), trans_road, trans_result);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to trans var data on host, error code %u", ret);
GELOGE(ret, "[Call][TransVarOnHost] failed, session_id:%lu, ret:%u", session_id, ret);
return ret;
}

@@ -319,14 +311,15 @@ Status TransVarData(const NodePtr &var, const VarTransRoad &trans_road, uint64_t
/// TensorDesc needs to be removed. This change is large and needs to be performed step by step.
ret = ReAssignVarAddr(session_id, var->GetName(), trans_road.rbegin()->output, &var_device);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to re-assign memory on device, size %zu", trans_result.length);
GELOGE(ret, "[Call][ReAssignVarAddr] failed, session id:%lu, op:%s, ret:%u",
session_id, var->GetName().c_str(), ret);
return ret;
}

// sync new data to device
ret = CopyVarToDevice(var, trans_result, var_device);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to send var data to device");
GELOGE(ret, "[Call][CopyVarToDevice] failed, var:%s, ret:%u", var->GetName().c_str(), ret);
return ret;
}

@@ -350,7 +343,10 @@ Status TransTensor(uint8_t *var_data, const NodePtr &var_src, const NodePtr &var
TypeUtils::DataTypeToSerialString(src_data_datatype).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_datatype).c_str(),
src_data_shape_size, ret);
GELOGE(INTERNAL_ERROR, "trans var data on host failed");
GELOGE(INTERNAL_ERROR, "[Trans][DataType] from %s to %s failed, data size %ld, ret:%u",
TypeUtils::DataTypeToSerialString(src_data_datatype).c_str(),
TypeUtils::DataTypeToSerialString(dst_data_datatype).c_str(),
src_data_shape_size, ret);
return ret;
});
return SUCCESS;
@@ -366,9 +362,11 @@ Status CopyTensorFromSrcVarNode(const NodePtr &var_src,
/// need copy value from var_fp32 to var_fp16.
/// [opdesc of var_src and var_dst are checked before passed in, no need to check if they are nullptr]
GE_IF_BOOL_EXEC(var_src == nullptr || var_dst == nullptr,
REPORT_INNER_ERROR("E19999", "Param var_src or var_dst is empty, session_id:%lu, device_id:%u, "
REPORT_INNER_ERROR("E19999", "Param var_src or var_dst is nullptr, session_id:%lu, device_id:%u, "
"check invalid", session_id, device_id);
GELOGE(FAILED, "node var is nullptr"); return FAILED);
GELOGE(FAILED, "[Check][Param] Param var_src or var_dst is nullptr, session_id:%lu, device_id:%u",
session_id, device_id);
return FAILED);
// src_node output_desc (fp32)
GeTensorDesc output_desc = var_src->GetOpDesc()->GetOutputDesc(0);
auto src_data_type = output_desc.GetDataType();
@@ -390,31 +388,45 @@ Status CopyTensorFromSrcVarNode(const NodePtr &var_src,
RtContextSwitchGuard switch_context(RT_CTX_NORMAL_MODE, device_id);
// copy from src_node
auto ret = CopyVarFromDevice(session_id, var_src, var_src_data, output_desc);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(FAILED, "Copy Var From Device failed"); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(FAILED, "[Call][CopyVarFromDevice] failed, session id:%lu, var_src:%s",
session_id, var_src->GetName().c_str());
return ret);
// trans dtype
formats::TransResult trans_result{};
ret = TransTensor(var_src_data.get(), var_src, var_dst, trans_result);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(INTERNAL_ERROR, "trans var data on host failed"); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(INTERNAL_ERROR, "[Trans][Tensor] failed, var_src:%s, var_dst:%s",
var_src->GetName().c_str(), var_dst->GetName().c_str());
return ret);
// reset src value.
void *var_device = nullptr;
ret = ReAssignVarAddr(session_id, var_dst->GetName(), dst_tensor_desc, &var_device);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(INTERNAL_ERROR, "assign mem failed"); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(INTERNAL_ERROR, "[Call][ReAssignVarAddr] failed, session id:%lu, var_dst:%s",
session_id, var_dst->GetName().c_str());
return ret);
// copy to device
ret = CopyVarToDevice(var_dst, trans_result, var_device);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(ret, "Failed to send var data to device"); return ret);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(ret, "[Call][CopyVarToDevice] failed, var_dst:%s, ret:%u",
var_dst->GetName().c_str(), ret);
return ret);
return SUCCESS;
}
} // namespace
Status TransVarDataUtils::SyncVarData2BroadCast(const string &var_name, const ge::GeTensorDesc &src_tensor_desc,
uint8_t *dst_addr, int64_t dst_addr_size, uint64_t session_id) {
GE_CHK_BOOL_RET_STATUS(dst_addr != nullptr, FAILED, "dst addr is null. ");
GE_CHK_BOOL_RET_STATUS(dst_addr != nullptr, FAILED, "[Check][Param] dst addr is nullptr.");
uint8_t *src_host_addr = nullptr;
int64_t src_addr_size = 0;
GE_MAKE_GUARD_RTMEM(src_host_addr);
GE_CHK_STATUS_RET(SyncTensorToHost(var_name, src_tensor_desc, &src_host_addr, src_addr_size, session_id));

GELOGI("src_addr_size: %ld, dst_addr_size: %ld", src_addr_size, dst_addr_size);
GE_CHK_BOOL_RET_STATUS(src_addr_size == dst_addr_size, FAILED, "var data size is not equal broadcast ");
GE_CHK_BOOL_RET_STATUS(src_addr_size == dst_addr_size, FAILED,
"[Check][Param] src_addr_size:%ld not equal to dst_addr_size:%ld",
src_addr_size, dst_addr_size);

GE_CHK_RT_RET(rtMemcpy(dst_addr, dst_addr_size, src_host_addr, src_addr_size, RT_MEMCPY_HOST_TO_DEVICE));
return SUCCESS;
@@ -422,7 +434,7 @@ Status TransVarDataUtils::SyncVarData2BroadCast(const string &var_name, const ge

Status TransVarDataUtils::SyncBroadCastData2Var(uint8_t *src_addr, int64_t src_addr_size, const string &var_name,
const ge::GeTensorDesc &dst_tensor_desc, uint64_t session_id) {
GE_CHK_BOOL_RET_STATUS(src_addr != nullptr, FAILED, "src addr is null. ");
GE_CHK_BOOL_RET_STATUS(src_addr != nullptr, FAILED, "[Check][Param] src addr is nullptr. ");
uint8_t *host_addr = nullptr;
GE_MAKE_GUARD_RTMEM(host_addr);
GE_CHK_RT_RET(rtMallocHost(reinterpret_cast<void **>(&host_addr), src_addr_size));
@@ -436,7 +448,7 @@ Status TransVarDataUtils::SyncBroadCastData2Var(uint8_t *src_addr, int64_t src_a

Status TransVarDataUtils::SyncTensorToHost(const string &var_name, const ge::GeTensorDesc &src_tensor_desc,
uint8_t **host_addr, int64_t &src_tensor_size, uint64_t session_id) {
GE_CHK_STATUS_RET(ge::TensorUtils::GetSize(src_tensor_desc, src_tensor_size), "get size from TensorDesc failed");
GE_CHK_STATUS_RET(ge::TensorUtils::GetSize(src_tensor_desc, src_tensor_size), "[Get][Size] from TensorDesc failed");

uint8_t *src_addr = nullptr;
GE_CHK_STATUS_RET(VarManager::Instance(session_id)->GetVarAddr(var_name, src_tensor_desc, &src_addr));
@@ -493,7 +505,8 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtCtxSetCurrent failed, session_id:%lu, graph_id:%u, ret:0x%X,",
session_id, graph_id, rt_ret);
GELOGE(RT_FAILED, "Failed to set context, error_code is: 0x%X.", rt_ret);
GELOGE(RT_FAILED, "[Call][RtCtxSetCurrent] failed, session_id:%lu, graph_id:%u, ret:0x%X,",
session_id, graph_id, rt_ret);
return RT_ERROR_TO_GE_STATUS(rt_ret);
}
uint32_t allocated_graph_id = 0;
@@ -501,8 +514,8 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get allocated GraphId failed, session_id:%lu, graph_id:%u, ret:0x%X,",
session_id, graph_id, ret);
GELOGE(INTERNAL_ERROR, "var has not been allocated, node:%s, graph_id:%u.", node->GetName().c_str(),
graph_id);
GELOGE(INTERNAL_ERROR, "[Get][AllocatedGraphId] failed, node:%s, graph_id:%u.",
node->GetName().c_str(), graph_id);
return INTERNAL_ERROR;
}
uint32_t changed_graph_id = 0;
@@ -518,7 +531,8 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
}
ret = TransVarData(node, *trans_road, session_id);
if (ret != SUCCESS) {
GELOGE(INTERNAL_ERROR, "TransVarData failed, node:%s, graph_id:%u.", node->GetName().c_str(), graph_id);
GELOGE(INTERNAL_ERROR, "[Trans][VarData] failed, node:%s, graph_id:%u, session_id:%lu.",
node->GetName().c_str(), graph_id, session_id);
return INTERNAL_ERROR;
}
VarManager::Instance(session_id)->RemoveChangedGraphId(node->GetName());
@@ -527,7 +541,7 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
},
node, session_id, context, graph_id, ErrorManager::GetInstance().GetErrorManagerContext());
if (!f.valid()) {
GELOGE(FAILED, "Future is invalid");
GELOGE(FAILED, "[Check][Param] Future is invalid, session id:%lu, graph id:%u", session_id, graph_id);
return FAILED;
}
vector_future.push_back(std::move(f));
@@ -537,7 +551,7 @@ Status TransVarDataUtils::TransAllVarData(const vector<NodePtr> &variable_nodes,
for (size_t i = 0; i < vector_future.size(); ++i) {
ret_status = vector_future[i].get();
if (ret_status != SUCCESS) {
GELOGE(ret_status, "TransAllVarData:: trans %zu vardata failed", i);
GELOGE(ret_status, "[Check][Param] trans %zu vardata failed", i);
return ret_status;
}
}
@@ -550,7 +564,8 @@ Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, session_id:%lu, device_id:%u, check invalid",
session_id, device_id);
GELOGE(FAILED, "compute_graph is nullptr");
GELOGE(FAILED, "[Check][Param] compute_graph is nullptr, session_id:%lu, device_id:%u",
session_id, device_id);
return FAILED;
}

@@ -568,7 +583,10 @@ Status TransVarDataUtils::CopyVarData(const ComputeGraphPtr &compute_graph, uint
GELOGI("current_var_node__: [%s] copy_from_var_node__: [%s].", node->GetName().c_str(),
src_node->GetName().c_str());
auto ret = CopyTensorFromSrcVarNode(src_node, node, session_id, device_id);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(FAILED, "copy tensor failed!"); return FAILED);
GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(FAILED, "[Copy][Tensor] failed, src_node:%s, node:%s, session_id:%lu, device_id:%u",
src_node->GetName().c_str(), node->GetName().c_str(), session_id, device_id);
return FAILED);
// only copy once
(void) ge::AttrUtils::SetBool(node->GetOpDesc(), "_copy_value", true); // no need to check value
}


+ 4
- 6
ge/graph/manager/util/debug.cc View File

@@ -63,17 +63,15 @@ Status Debug::DumpDevMem(const char *file, const void *addr, int64_t size) {
uint8_t *host_addr = nullptr;
rtError_t ret = rtMallocHost(reinterpret_cast<void **>(&host_addr), size);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMallocHost failed, size:%zu, ret: 0x%X",
size, ret);
GELOGE(FAILED, "Call rt api rtMallocHost failed, ret: 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Call rtMallocHost failed, size:%zu, ret:0x%X", size, ret);
GELOGE(FAILED, "[Call][RtMallocHost] failed, size:%zu, ret:0x%X", size, ret);
return FAILED;
}
GE_MAKE_GUARD_RTMEM(host_addr);
ret = rtMemcpy(host_addr, size, addr, size, RT_MEMCPY_DEVICE_TO_HOST);
if (ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret: 0x%X",
size, ret);
GELOGE(FAILED, "Call rt api rtMemcpy failed, ret: 0x%X", ret);
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret:0x%X", size, ret);
GELOGE(FAILED, "[Call][RtMemcpy] failed, size:%zu, ret:0x%X", size, ret);
return FAILED;
}



+ 65
- 51
ge/graph/manager/util/hcom_util.cc View File

@@ -28,7 +28,8 @@ Status HcomOmeUtil::GetHcclDataType(const ge::ConstOpDescPtr &op_desc,
std::vector<GETaskKernelHcclInfo> &kernel_hccl_infos) {
GE_CHECK_NOTNULL(op_desc);
if (CheckKernelHcclInfo(op_desc, kernel_hccl_infos) != SUCCESS) {
GELOGE(PARAM_INVALID, "HcomOmeUtil:: the number of GETaskKernelHcclInfo is invalid.");
GELOGE(PARAM_INVALID, "[Check][KernelHcclInfo] failed, op:%s(%s).",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
GELOGI("GetHcclDataType start, node[%s], opType[%s].", op_desc->GetName().c_str(), op_desc->GetType().c_str());
@@ -40,10 +41,10 @@ Status HcomOmeUtil::GetHcclDataType(const ge::ConstOpDescPtr &op_desc,
if (op_desc->GetType() == HCOMRECEIVE) {
bool ret = ge::AttrUtils::GetDataType(op_desc, HCOM_ATTR_DATA_TYPE, src_data_type);
if (ret == false) {
REPORT_INNER_ERROR("E19999", "Get Attr:%s in op:%s(%s) fail",
HCOM_ATTR_DATA_TYPE.c_str(),
REPORT_INNER_ERROR("E19999", "Get Attr:%s in op:%s(%s) fail", HCOM_ATTR_DATA_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "op:HcomReceive, op desc no attr: dtype.");
GELOGE(PARAM_INVALID, "[Get][Attr] %s in op:%s(%s) fail", HCOM_ATTR_DATA_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
} else {
@@ -55,13 +56,11 @@ Status HcomOmeUtil::GetHcclDataType(const ge::ConstOpDescPtr &op_desc,
auto iter = kConstOpHcclDataType.find(static_cast<int64_t>(src_data_type));
if (iter == kConstOpHcclDataType.end()) {
REPORT_INNER_ERROR("E19999", "Attr:%s in op:%s(%s), value data_type:%s, not support in kConstOpHcclDataType now, "
"check invalid", HCOM_ATTR_DATA_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(),
ge::TypeUtils::DataTypeToSerialString(src_data_type).c_str());
GELOGE(PARAM_INVALID,
"HcomOmeUtil:: Node: %s Optype: %s HcomDataType cann't support! Current Davinci Data Type : %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str(),
ge::TypeUtils::DataTypeToSerialString(src_data_type).c_str());
"check invalid", HCOM_ATTR_DATA_TYPE.c_str(), op_desc->GetName().c_str(),
op_desc->GetType().c_str(), ge::TypeUtils::DataTypeToSerialString(src_data_type).c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Attr:%s in op:%s(%s), value data_type:%s, "
"not support in kConstOpHcclDataType now", HCOM_ATTR_DATA_TYPE.c_str(), op_desc->GetName().c_str(),
op_desc->GetType().c_str(), ge::TypeUtils::DataTypeToSerialString(src_data_type).c_str());
return PARAM_INVALID;
}

@@ -73,7 +72,7 @@ Status HcomOmeUtil::GetHcclDataType(const ge::ConstOpDescPtr &op_desc,
Status HcomOmeUtil::GetHcclTypeSize(HcclDataType data_type, int32_t &size) {
auto iter = kConstOpHcclDataTypeSize.find(data_type);
GE_CHK_BOOL_EXEC(iter != kConstOpHcclDataTypeSize.end(), return PARAM_INVALID,
"HcomOmeUtil::HcomDataTypeSize , No DataTypeSize!");
"[Check][Param] param data_type:%d not find", data_type);

size = iter->second;
return SUCCESS;
@@ -83,21 +82,22 @@ Status HcomOmeUtil::GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType
int &count) {
GE_CHECK_NOTNULL(op_desc);
if (!IsHCOMOp(op_desc->GetType())) {
REPORT_INNER_ERROR("E19999", "Op:%s(%s) is not hcom op, check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "HcomOmeUtil:: operator is not Hcom operator.");
REPORT_INNER_ERROR("E19999", "Op:%s(%s) is not hcom op, check invalid", op_desc->GetName().c_str(),
op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Op:%s(%s) is not hcom op", op_desc->GetName().c_str(),
op_desc->GetType().c_str());
return PARAM_INVALID;
}
int64_t total_size = 0;
int64_t align_size = 512;
int32_t size = 0;
GE_CHK_STATUS_RET(HcomOmeUtil::GetHcclTypeSize(data_type, size), "GetHcomCount: GetHcclTypeSize fail!");
GE_CHK_STATUS_RET(HcomOmeUtil::GetHcclTypeSize(data_type, size), "[Get][HcclTypeSize] fail, datatype:%d", data_type);
if (op_desc->GetType() == HCOMRECEIVE) {
for (size_t i = 0; i < op_desc->GetOutputsSize(); ++i) {
int64_t output_size = 0;
GE_CHECK_NOTNULL(op_desc->GetOutputDescPtr(i));
GE_CHK_STATUS_RET(ge::TensorUtils::GetSize(*op_desc->GetOutputDescPtr(i), output_size),
"Get size from TensorDesc failed, op: %s, output index: %zu.", op_desc->GetName().c_str(), i);
"[Get][Size] from TensorDesc failed, op:%s, output index:%zu.", op_desc->GetName().c_str(), i);
output_size = (output_size + align_size - 1) / align_size * align_size;
total_size += output_size;
}
@@ -107,42 +107,48 @@ Status HcomOmeUtil::GetHcomCount(const ge::ConstOpDescPtr &op_desc, HcclDataType
int64_t block_size = 0;
GE_CHECK_NOTNULL(op_desc->GetInputDescPtr(i));
GE_CHK_STATUS_RET(ge::TensorUtils::GetSize(*op_desc->GetInputDescPtr(i), input_size),
"get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i);
"[Get][Size] from TensorDesc failed, op:%s, input index:%zu", op_desc->GetName().c_str(), i);
// dynamic shape hccl op get size from output tensor desc
if (op_desc->HasAttr(ATTR_NAME_IS_UNKNOWN_SHAPE)) {
GE_CHECK_NOTNULL(op_desc->GetOutputDescPtr(i));
GE_CHK_STATUS_RET(ge::TensorUtils::GetSize(*op_desc->GetOutputDescPtr(i), input_size),
"get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i);
"[Get][Size] from TensorDesc failed, op:%s, input index:%zu", op_desc->GetName().c_str(), i);
}

GE_IF_BOOL_EXEC(
op_desc->GetType() == HCOMREDUCESCATTER, int32_t rank_size = 0;
GE_CHK_BOOL_RET_STATUS(ge::AttrUtils::GetInt(op_desc, HCOM_ATTR_RANK_SIZE, rank_size), PARAM_INVALID,
"get HCOM_ATTR_RANK_SIZE failed");
GE_CHK_BOOL_RET_STATUS(rank_size != 0, PARAM_INVALID, "rank size is zero");
int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize(); GE_CHK_STATUS_RET(
ge::CheckInt64Uint32MulOverflow(shape_size, size), "Product of shape size and size beyond INT64_MAX");
"[Get][Attr] %s in op:%s(%s) failed", HCOM_ATTR_RANK_SIZE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GE_CHK_BOOL_RET_STATUS(rank_size != 0, PARAM_INVALID, "[Check][Param] rank size is zero");
int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize();
GE_CHK_STATUS_RET(ge::CheckInt64Uint32MulOverflow(shape_size, size),
"[Check][Param] Product of shape size:%ld and size:%d beyond INT64_MAX, op:%s(%s)",
shape_size, size, op_desc->GetName().c_str(), op_desc->GetType().c_str());
block_size = (shape_size * size) / rank_size;
GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size), "Total size is beyond the INT64_MAX");
GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size),
"[Check][Param] Total size:%ld is beyond the INT64_MAX, op:%s(%s)",
total_size, op_desc->GetName().c_str(), op_desc->GetType().c_str());
total_size = total_size + block_size; continue;);

int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize();
GELOGD("hcom util node %s inputsize %ld, shapesize %ld, datasize %d.",
op_desc->GetName().c_str(), input_size, shape_size, size);
GE_CHK_STATUS_RET(ge::CheckInt64Int32MulOverflow(shape_size, size),
"Product of shape size and size beyond INT64_MAX");
"[Check][Param] Product of shape size:%ld and size:%d beyond INT64_MAX", shape_size, size);
GE_IF_BOOL_EXEC(is_allgather, block_size = shape_size * size;);
GE_IF_BOOL_EXEC(!is_allgather, block_size = (input_size + align_size - 1) / align_size * align_size;);
GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size), "Total size is beyond the INT64_MAX");
GE_CHK_STATUS_RET(ge::CheckInt64AddOverflow(total_size, block_size),
"[Check][Param] Total size:%ld is beyond the INT64_MAX", total_size);
total_size = total_size + block_size;
}
}

GE_CHK_BOOL_RET_STATUS(size != 0, PARAM_INVALID, "Size is zero");
GE_CHK_BOOL_RET_STATUS(size != 0, PARAM_INVALID, "[Check][Param] Size is zero");
count = static_cast<int>(total_size / size);

GE_CHK_BOOL_EXEC(total_size % size == 0, return PARAM_INVALID, "total_size:%ld is not divisiable by size:%d.",
total_size, size);
GE_CHK_BOOL_EXEC(total_size % size == 0, return PARAM_INVALID,
"[Check][Param] total_size:%ld is not divisiable by size:%d.", total_size, size);

return SUCCESS;
}
@@ -153,32 +159,34 @@ Status HcomOmeUtil::GetHorovodCount(const ge::ConstOpDescPtr &op_desc,
if (!IsHorovodOp(op_desc->GetType())) {
REPORT_INNER_ERROR("E19999", "Op:%s(%s) is not horovod op, check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "HcomOmeUtil:: operator is not Horovod operator.");
GELOGE(PARAM_INVALID, "[Call][IsHorovodOp] failed, Op:%s(%s) is not horovod op",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
int64_t align_size = 512;
int32_t size = 0;
for (size_t i = 0; i < op_desc->GetInputsSize(); i++) {
GE_CHK_STATUS_RET(HcomOmeUtil::GetHcclTypeSize(static_cast<HcclDataType>(kernel_hccl_infos[i].dataType), size),
"GetHorovodCount: GetHcclTypeSize fail!");
"[Call][GetHcclTypeSize] fail, op:%s(%s)",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
int64_t input_size = 0;
int64_t block_size = 0;
GE_CHECK_NOTNULL(op_desc->GetInputDescPtr(i));
GE_CHK_STATUS_RET(ge::TensorUtils::GetSize(*op_desc->GetInputDescPtr(i), input_size),
"get size from TensorDesc failed, op : %s, input index : %zu", op_desc->GetName().c_str(), i);
"[Get][Size] from TensorDesc failed, op:%s, input index:%zu", op_desc->GetName().c_str(), i);

int64_t shape_size = op_desc->GetInputDescPtr(i)->GetShape().GetShapeSize();
GE_CHK_STATUS_RET(ge::CheckInt64Int32MulOverflow(shape_size, size),
"Product of shape size and size beyond INT64_MAX");
"[Check][Param] Product of shape size:%ld and size:%d beyond INT64_MAX", shape_size, size);
if (kernel_hccl_infos[0].hccl_type == HVDCALLBACKALLGATHER) {
block_size = shape_size * size;
} else {
block_size = (input_size + align_size - 1) / align_size * align_size;
}

GE_CHK_BOOL_RET_STATUS(size != 0, PARAM_INVALID, "Size is zero");
GE_CHK_BOOL_EXEC(block_size % size == 0, return PARAM_INVALID, "block_size:%ld is not divisiable by size:%d.",
block_size, size);
GE_CHK_BOOL_RET_STATUS(size != 0, PARAM_INVALID, "[Check][Param] Size is zero");
GE_CHK_BOOL_EXEC(block_size % size == 0, return PARAM_INVALID,
"[Check][Param] block_size:%ld is not divisiable by size:%d.", block_size, size);
kernel_hccl_infos[i].count = static_cast<int>(block_size / size);
}

@@ -191,7 +199,8 @@ Status HcomOmeUtil::GetHcclCount(const ge::ConstOpDescPtr &op_desc,
Status ret;
ret = CheckKernelHcclInfo(op_desc, kernel_hccl_infos);
if (ret != SUCCESS) {
GELOGE(PARAM_INVALID, "HcomOmeUtil:: the number of GETaskKernelHcclInfo is invalid.");
GELOGE(PARAM_INVALID, "[Check][KernelHcclInfo] failed, the number of GETaskKernelHcclInfo is invalid, op:%s(%s).",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
GELOGI("GetHcclCount start, node[%s], opType[%s].", op_desc->GetName().c_str(), op_desc->GetType().c_str());
@@ -200,7 +209,7 @@ Status HcomOmeUtil::GetHcclCount(const ge::ConstOpDescPtr &op_desc,
ret = GetHcomCount(op_desc, static_cast<HcclDataType>(kernel_hccl_infos[0].dataType),
kernel_hccl_infos[0].hccl_type == HCOMALLGATHER, count);
if (ret != SUCCESS) {
GELOGE(ret, "HcomOmeUtil:: Node: %s Optype: %s get the Hcom operator hccl count fail.",
GELOGE(ret, "[Call][GetHcomCount] Node:%s Optype:%s get the Hcom operator hccl count fail.",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
@@ -210,7 +219,7 @@ Status HcomOmeUtil::GetHcclCount(const ge::ConstOpDescPtr &op_desc,
if (IsHorovodOp(op_desc->GetType())) {
ret = GetHorovodCount(op_desc, kernel_hccl_infos);
if (ret != SUCCESS) {
GELOGE(PARAM_INVALID, "HcomOmeUtil:: Node: %s Optype: %s get the Horovod hccl operator count fail.",
GELOGE(PARAM_INVALID, "[Call][GetHorovodCount] Node:%s Optype:%s get the Horovod hccl operator count fail.",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
@@ -225,11 +234,10 @@ Status HcomOmeUtil::GetHcclOperationType(const ge::ConstOpDescPtr &op_desc, Hccl
if (IsHCOMOp(op_desc->GetType())) {
std::string hcom_op_type;
GE_CHK_BOOL_EXEC(ge::AttrUtils::GetStr(op_desc, HCOM_ATTR_REDUCE_TYPE, hcom_op_type),
REPORT_INNER_ERROR("E19999", "Get Attr:%s in op:%s(%s) fail",
HCOM_ATTR_REDUCE_TYPE.c_str(),
REPORT_INNER_ERROR("E19999", "Get Attr:%s in op:%s(%s) fail", HCOM_ATTR_REDUCE_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID,
"HcomOmeUtil:: Node: %s Optype: %s Get HCOM_ATTR_REDUCE_TYPE fail, not support!",
"[Get][Attr] %s in op:%s(%s) fail", HCOM_ATTR_REDUCE_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());

if (hcom_op_type == "min") {
@@ -244,7 +252,9 @@ Status HcomOmeUtil::GetHcclOperationType(const ge::ConstOpDescPtr &op_desc, Hccl
REPORT_INNER_ERROR("E19999", "Attr:%s in Op:%s(%s), hcom_op_type value:%s is not support now, "
"check invalid", HCOM_ATTR_REDUCE_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), hcom_op_type.c_str());
GELOGE(PARAM_INVALID, "HcomOmeUtil::Get HCOM_ATTR_REDUCE_TYPE fail, [%s] not support!", hcom_op_type.c_str());
GELOGE(PARAM_INVALID, "[Check][Param] Attr:%s in Op:%s(%s), hcom_op_type value:%s is not support now",
HCOM_ATTR_REDUCE_TYPE.c_str(), op_desc->GetName().c_str(),
op_desc->GetType().c_str(), hcom_op_type.c_str());
return PARAM_INVALID;
}
}
@@ -256,7 +266,7 @@ Status HcomOmeUtil::GetHcclOperationType(const ge::ConstOpDescPtr &op_desc, Hccl
ATTR_HOROVOD_ATTR_REDUCE_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID,
"HcomOmeUtil:: Node: %s Optype: %s Get ATTR_HOROVOD_ATTR_REDUCE_TYPE fail, not support!",
"[Get][Attr] %s in op:%s(%s) fail", ATTR_HOROVOD_ATTR_REDUCE_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());

auto iter = kHorovodRedOpToHcclRedOp.find(static_cast<HorovodReduceOp>(horovod_op_type));
@@ -264,8 +274,9 @@ Status HcomOmeUtil::GetHcclOperationType(const ge::ConstOpDescPtr &op_desc, Hccl
REPORT_INNER_ERROR("E19999", "Attr:%s in Op:%s(%s), horovod_op_type value:%ld is not support now, "
"check invalid", ATTR_HOROVOD_ATTR_REDUCE_TYPE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), horovod_op_type);
GELOGE(PARAM_INVALID, "HcomOmeUtil:: Node: %s Optype: %s HcomOpType cann't support! Current HcomOpType : %ld",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), horovod_op_type);
GELOGE(PARAM_INVALID, "[Check][Param] Attr:%s in Op:%s(%s), horovod_op_type value:%ld is not support now",
ATTR_HOROVOD_ATTR_REDUCE_TYPE.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
horovod_op_type);
return PARAM_INVALID;
}
op_type = iter->second;
@@ -281,7 +292,7 @@ Status HcomOmeUtil::GetHcclRootId(const ge::ConstOpDescPtr &op_desc, int64_t &ro
HCOM_ATTR_ROOT_RANK.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID,
"HcomOmeUtil::Node %s Optype: %s Get HCOM_ATTR_ROOT_INDEX fail, not support!",
"[Get][Attr] %s in op:%s(%s) fail", HCOM_ATTR_ROOT_RANK.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());

return SUCCESS;
@@ -296,7 +307,7 @@ Status HcomOmeUtil::GetAllRootId(const ge::ConstOpDescPtr &op_desc,
int64_t root_id = 0;
Status dmrt = GetHcclRootId(op_desc, root_id);
if (dmrt != SUCCESS) {
GELOGE(FAILED, "davinci_model: GetHcomRootId fail! domi error: %u", dmrt);
GELOGE(FAILED, "[Get][HcclRootId] fail! domi error: %u", dmrt);
return FAILED;
}

@@ -324,7 +335,8 @@ Status HcomOmeUtil::CheckKernelHcclInfo(const ge::ConstOpDescPtr &op_desc,
REPORT_INNER_ERROR("E19999", "Op:%s(%s) is not hcom op or param kernel_hccl_infos.size:%zu != 1, "
"check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), kernel_hccl_infos.size());
GELOGE(PARAM_INVALID, "HcomOmeUtil:: in Hcom scenario, the number of GETaskKernelHcclInfo is invalid.");
GELOGE(PARAM_INVALID, "[Check][Param] Op:%s(%s) is not hcom op or param kernel_hccl_infos.size:%zu != 1",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), kernel_hccl_infos.size());
return PARAM_INVALID;
}

@@ -337,7 +349,9 @@ Status HcomOmeUtil::CheckKernelHcclInfo(const ge::ConstOpDescPtr &op_desc,
"in op:%s(%s), check invalid",
kernel_hccl_infos.size(), op_desc->GetInputsSize(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "HcomOmeUtil:: in Horovod scenario, the number of GETaskKernelHcclInfo is invalid.");
GELOGE(PARAM_INVALID, "Param kernel_hccl_infos.size:%zu is empty or not equal to "
"input_desc size:%zu in op:%s(%s)", kernel_hccl_infos.size(), op_desc->GetInputsSize(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
}
@@ -360,7 +374,7 @@ Status HcomOmeUtil::GetHorovodInputs(const ge::ConstOpDescPtr &op_desc,
}

if (CheckKernelHcclInfo(op_desc, kernel_hccl_infos) != SUCCESS) {
GELOGE(PARAM_INVALID, "HcomOmeUtil:: Node: %s Optype: %s the number of GETaskKernelHcclInfo is invalid.",
GELOGE(PARAM_INVALID, "[Check][KernelHcclInfo] Node:%s Optype:%s the number of GETaskKernelHcclInfo is invalid.",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}


+ 1
- 1
ge/graph/manager/util/variable_accelerate_ctrl.cc View File

@@ -54,7 +54,7 @@ void VarAccelerateCtrl::SetVarChanged(const std::string &var_name) {
void VarAccelerateCtrl::AddGraph(uint32_t graph_id, const ComputeGraphPtr &compute_graph) {
std::lock_guard<std::mutex> lock(mutex_);
if (compute_graph == nullptr) {
GELOGE(PARAM_INVALID, "Failed to add graph %u, the compute graph is null", graph_id);
GELOGE(PARAM_INVALID, "[Check][Param] Failed to add graph %u, the compute graph is null", graph_id);
return;
}
auto &var_names = graph_ids_to_var_names_[graph_id];


+ 86
- 27
ge/graph/optimize/graph_optimize.cc View File

@@ -38,7 +38,7 @@ GraphOptimize::GraphOptimize()
void AddNodeInputProperty(ComputeGraphPtr &compute_graph) {
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[AddNodeInputProperty]: compute_graph is nullptr.");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
return;
}
for (ge::NodePtr &node : compute_graph->GetDirectNode()) {
@@ -80,7 +80,7 @@ void AddNodeInputProperty(ComputeGraphPtr &compute_graph) {
Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std::string &engine_name) {
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeSubGraph]: compute_graph is nullptr.");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL;
}

@@ -89,8 +89,10 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std

std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GraphOptimzer: GE is not initialized");
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid, graph:%s",
compute_graph->GetName().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib] Gelib not init before, graph:%s",
compute_graph->GetName().c_str());
return GE_CLI_GE_NOT_INITIALIZED;
}

@@ -111,7 +113,8 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std
REPORT_INNER_ERROR("E19999", "Call OptimizeFusedGraphAfterGraphSlice failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, engine_name.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraphAfterGraphSlice]: graph optimize failed, ret:%d", ret);
GELOGE(ret, "[Call][OptimizeFusedGraphAfterGraphSlice] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, engine_name.c_str(), compute_graph->GetName().c_str());
return ret;
}
}
@@ -124,7 +127,8 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std
REPORT_INNER_ERROR("E19999", "Call OptimizeFusedGraph failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, engine_name.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeSubGraph][OptimizeFusedGraph]: graph optimize failed, ret:%d", ret);
GELOGE(ret, "[Optimize][FusedGraph] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, engine_name.c_str(), compute_graph->GetName().c_str());
return ret;
}
}
@@ -142,20 +146,22 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) {
}
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeOriginalGraph]: compute_graph is nullptr.");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL;
}

Status ret = SUCCESS;
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeOriginalGraph failed.");
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid, graph:%s.",
compute_graph->GetName().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib] Gelib not init before, graph:%s.",
compute_graph->GetName().c_str());
return GE_CLI_GE_NOT_INITIALIZED;
}

auto graph_optimizer = instance_ptr->OpsKernelManagerObj().GetAllGraphOptimizerObjsByPriority();
GELOGI("optimize by opskernel in original graph optimize phase. num of graph_optimizer is %lu.",
GELOGI("optimize by opskernel in original graph optimize phase. num of graph_optimizer is %zu.",
graph_optimizer.size());
string exclude_core_Type = (core_type_ == kVectorCore) ? kAicoreEngine : kVectorEngine;
GELOGD("[OptimizeOriginalGraph]: engine type will exclude: %s", exclude_core_Type.c_str());
@@ -169,7 +175,8 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) {
REPORT_INNER_ERROR("E19999", "Call OptimizeOriginalGraph failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, iter->first.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeOriginalGraph]: graph optimize failed, ret:%d", ret);
GELOGE(ret, "[Optimize][OriginalGraph] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, iter->first.c_str(), compute_graph->GetName().c_str());
return ret;
}
}
@@ -188,13 +195,15 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_
Status ret = SUCCESS;
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeOriginalGraph failed.");
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid, graph:%s",
compute_graph->GetName().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib] Gelib not init before, graph:%s",
compute_graph->GetName().c_str());
return GE_CLI_GE_NOT_INITIALIZED;
}

auto graph_optimizer = instance_ptr->OpsKernelManagerObj().GetAllGraphOptimizerObjsByPriority();
GELOGI("optimize by opskernel in original graph optimize phase. num of graph_optimizer is %lu.",
GELOGI("optimize by opskernel in judging insert phase. num of graph_optimizer is %zu.",
graph_optimizer.size());
string exclude_core_Type = (core_type_ == kVectorCore) ? kAicoreEngine : kVectorEngine;
if (graph_optimizer.size() != 0) {
@@ -209,7 +218,8 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_
REPORT_INNER_ERROR("E19999", "Call OptimizeOriginalGraphJudgeInsert failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, iter->first.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeOriginalGraphJudgeInsert]: graph optimize failed, ret:%d", ret);
GELOGE(ret, "[Call][OptimizeOriginalGraphJudgeInsert] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, iter->first.c_str(), compute_graph->GetName().c_str());
return ret;
}
}
@@ -220,14 +230,16 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_
Status GraphOptimize::OptimizeOriginalGraphForQuantize(ComputeGraphPtr &compute_graph) {
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeOriginalGraph]: compute_graph is nullptr.");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL;
}

std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeOriginalGraph failed.");
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid, graph:%s.",
compute_graph->GetName().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][Gelib] Gelib not init before, graph:%s.",
compute_graph->GetName().c_str());
return GE_CLI_GE_NOT_INITIALIZED;
}

@@ -247,7 +259,8 @@ Status GraphOptimize::OptimizeOriginalGraphForQuantize(ComputeGraphPtr &compute_
REPORT_INNER_ERROR("E19999", "Call OptimizeGraphPrepare failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, iter->first.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeOriginalGraphForQuantize]: graph optimize failed, ret:%u", ret);
GELOGE(ret, "[Call][OptimizeGraphPrepare] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, iter->first.c_str(), compute_graph->GetName().c_str());
return ret;
}
}
@@ -258,14 +271,16 @@ Status GraphOptimize::OptimizeOriginalGraphForQuantize(ComputeGraphPtr &compute_
Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_graph) {
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeGraphBeforeBuildForRts]: compute_graph is nullptr.");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL;
}

std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeGraphBeforeBuildForRts failed.");
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid, graph:%s.",
compute_graph->GetName().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib] Gelib not init before, graph:%s.",
compute_graph->GetName().c_str());
return GE_CLI_GE_NOT_INITIALIZED;
}

@@ -286,7 +301,48 @@ Status GraphOptimize::OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_gr
REPORT_INNER_ERROR("E19999", "Call OptimizeGraphBeforeBuild failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, iter->first.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeGraphBeforeBuildForRts]: graph optimize failed, ret:%u", ret);
GELOGE(ret, "[Call][OptimizeGraphBeforeBuild] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, iter->first.c_str(), compute_graph->GetName().c_str());
return ret;
}
}
}
return ret;
}

Status GraphOptimize::OptimizeAfterStage1(ComputeGraphPtr &compute_graph) {
GE_CHECK_NOTNULL(compute_graph);
GELOGD("OptimizeAfterStage1 in");
if (GetContext().GetHostExecFlag()) {
// graph exec on host, no need OptimizeAfterStage1
return SUCCESS;
}

Status ret = SUCCESS;
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeAfterStage1 failed.");
return GE_CLI_GE_NOT_INITIALIZED;
}

auto graph_optimizer = instance_ptr->OpsKernelManagerObj().GetAllGraphOptimizerObjsByPriority();
GELOGI("Optimize by ops kernel in after stage1 phase, num of graph_optimizer is %zu.", graph_optimizer.size());
string exclude_core_type = (core_type_ == kVectorCore) ? kAicoreEngine : kVectorEngine;
if (graph_optimizer.size() != 0) {
for (auto iter = graph_optimizer.begin(); iter != graph_optimizer.end(); ++iter) {
if (iter->first == exclude_core_type) {
GELOGI("[OptimizeAfterStage1]: engine type will exclude:%s.", exclude_core_type.c_str());
continue;
}
#ifndef ONLY_COMPILE_OPEN_SRC
GELOGI("Begin to optimize graph after stage1 by engine %s.", iter->first.c_str());
ret = (iter->second)->OptimizeAfterStage1(*compute_graph);
#endif
if (ret != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Call OptimizeAfterStage1 failed, ret:%d, engine_name:%s, "
"graph_name:%s.", ret, iter->first.c_str(), compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeAfterStage1]: graph optimize failed, ret:%d.", ret);
return ret;
}
}
@@ -373,14 +429,16 @@ Status GraphOptimize::IdentifyReference(ComputeGraphPtr &compute_graph) {
Status GraphOptimize::OptimizeWholeGraph(ComputeGraphPtr &compute_graph) {
if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[OptimizeWholeGraph]: compute_graph is nullptr.");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
return GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL;
}

std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "OptimizeWholeGraph failed.");
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid, graph:%s.",
compute_graph->GetName().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib] Gelib not init before, graph:%s.",
compute_graph->GetName().c_str());
return GE_CLI_GE_NOT_INITIALIZED;
}

@@ -401,7 +459,8 @@ Status GraphOptimize::OptimizeWholeGraph(ComputeGraphPtr &compute_graph) {
REPORT_INNER_ERROR("E19999", "Call OptimizeWholeGraph failed, ret:%d, engine_name:%s, "
"graph_name:%s", ret, iter.first.c_str(),
compute_graph->GetName().c_str());
GELOGE(ret, "[OptimizeWholeGraph]: graph optimize failed, ret:%u", ret);
GELOGE(ret, "[Call][OptimizeWholeGraph] failed, ret:%d, engine_name:%s, graph_name:%s",
ret, iter.first.c_str(), compute_graph->GetName().c_str());
return ret;
}
}


+ 3
- 0
ge/graph/optimize/graph_optimize.h View File

@@ -58,6 +58,9 @@ class GraphOptimize {
// for rts optimize before build to add attr and insert memcpy op
Status OptimizeGraphBeforeBuildForRts(ComputeGraphPtr &compute_graph);

// optimize whole graph, using after stage1
Status OptimizeAfterStage1(ComputeGraphPtr &graph);

// set options
Status SetOptions(const GraphManagerOptions &options);



+ 97
- 90
ge/graph/optimize/mem_rw_conflict_optimize.cc View File

@@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2020-2021 Huawei Technologies Co., Ltd
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -22,6 +22,7 @@
#include "graph/optimize/graph_optimize.h"
#include "graph/utils/graph_utils.h"
#include "graph/utils/node_utils.h"
#include "graph/utils/op_desc_utils.h"

namespace {
using namespace ge;
@@ -32,12 +33,14 @@ const int kCaseReadOnly = 0;
const int kCaseScopeWriteable = 2;
const int kCaseWriteable = 3;
const int kCaseInvalidRWType = 5;
// attr _input_mutable = true means node will modify its input in runtime
const char *const kModifyInput = "_input_mutable";

// rw type of input.
enum class InputRWType {
kReadOnly, // Normal op input only read
kWriteable, // Op like Assign/ApplyMomentum
kScopeWriteable, // Op like hcom_allreduce, it will modify input ,but not expect take effect on pre ouput
kScopeWriteable, // Op like hcom_allreduce/while, it will modify input ,but not expect take effect on pre ouput
kInvalidRWType
};
// rw type of output
@@ -154,38 +157,31 @@ bool IsSubgraphOutputNode(const NodePtr &node) {
return true;
}

NodePtr CreateIdentityAfterSrcNode(const Node &src_node, int out_anchor_idx) {
NodePtr AddIdentityToGraph(const Node &src_node, int out_anchor_idx) {
if (src_node.GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param src_node is invalid, which has no opdesc");
GELOGE(GRAPH_PARAM_INVALID, "[Get][OpDesc] failed, Param src_node opdesc is nullptr.");
return nullptr;
}
static std::atomic_long identity_num(0);
auto next_num = identity_num.fetch_add(1);
// 1. create new identity op desc
string identity_name = src_node.GetName() + "_" + IDENTITY + std::to_string(next_num);
auto identity_opdesc = MakeShared<OpDesc>(identity_name, IDENTITY);
if (identity_opdesc == nullptr) {
GELOGE(OUT_OF_MEMORY, "Failed to insert identity node, name %s", identity_name.c_str());
return nullptr;
}
OpDescBuilder op_desc_builder(identity_name, IDENTITY);
auto data_desc = src_node.GetOpDesc()->GetOutputDesc(out_anchor_idx);
// 2. add input_desc & output_desc for new identity
Status ret = identity_opdesc->AddInputDesc("x", data_desc);
if (ret != SUCCESS) {
GELOGE(ret, "Add Input desc failed for new identity %s.", identity_name.c_str());
return nullptr;
}
ret = identity_opdesc->AddOutputDesc("y", data_desc);
if (ret != SUCCESS) {
GELOGE(ret, "Add Output desc failed for new Identity %s.", identity_name.c_str());
return nullptr;
}
auto identity_op_desc = op_desc_builder.AddInput("x", data_desc)
.AddOutput("y", data_desc)
.Build();

GELOGI("Insert new Identity node %s.", identity_name.c_str());
auto graph = src_node.GetOwnerComputeGraph();
if (graph == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "Node %s owner compute graph is null.", src_node.GetName().c_str());
REPORT_INNER_ERROR("E19999", "Node %s owner compute graph is nullptr.", src_node.GetName().c_str());
GELOGE(GRAPH_PARAM_INVALID, "[Get][OwnerComputeGraph] failed, as Node %s owner compute graph is nullptr.",
src_node.GetName().c_str());
return nullptr;
}
return graph->AddNode(identity_opdesc);
return graph->AddNode(identity_op_desc);
}

OutputRWType GetOutputRWTypeByIndex(const Node &node, uint32_t index) {
@@ -274,8 +270,6 @@ InputRWType GetInputRWTypeByIndex(const Node &node, uint32_t index) {
// single node without sub graph
return GetSingleNodeInputRWTypeByIndex(node, index);
} else {
// node with sub graph
std::set<int> node_rw_type_set;
auto data_node_vec = NodeUtils::GetSubgraphDataNodesByIndex(node, index);
// get all input data node in subgraph
std::set<int> anchor_rw_type_set;
@@ -345,12 +339,24 @@ Status MarkRWTypeForSubgraph(const ComputeGraphPtr &sub_graph) {
auto parent_node = sub_graph->GetParentNode();
if (pre_output_rw_type == OutputRWType::kWriteable && parent_node->GetType() != PARTITIONEDCALL) {
// insert identity
auto identity_node = CreateIdentityAfterSrcNode(*pre_node, pre_out_anchor->GetIdx());
auto identity_node = AddIdentityToGraph(*pre_node, pre_out_anchor->GetIdx());
GE_CHECK_NOTNULL(identity_node);
auto ret = GraphUtils::InsertNodeBetweenDataAnchors(pre_out_anchor, in_data_anchor, identity_node);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to insert identity");
return ret;
if (GraphUtils::InsertNodeAfter(pre_out_anchor, {in_data_anchor}, identity_node) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Insert Identity node %s(%s) between %s(%s) -> %s(%s) failed.",
identity_node->GetName().c_str(),
identity_node->GetType().c_str(),
pre_node->GetName().c_str(),
pre_node->GetType().c_str(),
node->GetName().c_str(),
node->GetType().c_str());
GELOGE(FAILED, "[Insert][IdentityNode] %s(%s) between %s(%s) -> %s(%s) failed.",
identity_node->GetName().c_str(),
identity_node->GetType().c_str(),
pre_node->GetName().c_str(),
pre_node->GetType().c_str(),
node->GetName().c_str(),
node->GetType().c_str());
return FAILED;
}
GELOGI("InsertNode %s between %s and %s successfully.", identity_node->GetName().c_str(),
pre_node->GetName().c_str(), node->GetName().c_str());
@@ -484,12 +490,14 @@ Status RemoveNoUseIdentity(const NodePtr &node) {
GELOGI("No need insert Identity. Node %s need to remove.", node->GetName().c_str());
auto ret = GraphUtils::IsolateNode(node, {0});
if (ret != SUCCESS) {
GELOGE(ret, "Fail to isolate node %s.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Isolate Node:%s failed", node->GetName().c_str());
GELOGE(ret, "[Isolate][Node] %s failed.", node->GetName().c_str());
return ret;
}
ret = GraphUtils::RemoveNodeWithoutRelink(node->GetOwnerComputeGraph(), node);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to isolate node %s.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Call RemoveNodeWithoutRelink failed, node:%s", node->GetName().c_str());
GELOGE(ret, "[Call][RemoveNodeWithoutRelink] failed for node %s.", node->GetName().c_str());
return ret;
}
GELOGI("Pre node is %s and %dth output rw type is %s. Isolate and remove Identity node %s.",
@@ -505,34 +513,24 @@ Status SplitIdentityAlongAnchor(const OutDataAnchorPtr &out_data_anchor, const I
auto peer_in_data_node = peer_in_data_anchor->GetOwnerNode();
GE_CHECK_NOTNULL(peer_in_data_node);
auto input_rw_type = GetInputRWTypeByIndex(*peer_in_data_node, peer_in_data_anchor->GetIdx());
auto ret = out_data_anchor->Unlink(peer_in_data_anchor);
auto old_identity = out_data_anchor->GetOwnerNode();
if (ret != SUCCESS) {
GELOGE(ret, "Failed to unlink from %s %dth out to %s.", old_identity->GetName().c_str(), out_data_anchor->GetIdx(),
peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
return ret;
}
if (input_rw_type == InputRWType::kScopeWriteable || input_rw_type == InputRWType::kWriteable) {
auto new_identity = CreateIdentityAfterSrcNode(*pre_node, pre_out_data_anchor->GetIdx());
auto new_identity = AddIdentityToGraph(*pre_node, pre_out_data_anchor->GetIdx());
GE_CHECK_NOTNULL(new_identity);
if (GraphUtils::AddEdge(pre_out_data_anchor, new_identity->GetInDataAnchor(kIdentityAnchorIndex)) != SUCCESS
|| GraphUtils::AddEdge(new_identity->GetOutDataAnchor(kIdentityAnchorIndex), peer_in_data_anchor) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to insert Identity between node %s and %s",
pre_out_data_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
return INTERNAL_ERROR;
}

// 2. copy in-control-edge from dst to Identity
if (GraphUtils::CopyInCtrlEdges(peer_in_data_node, new_identity) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to copy in_control edges from node %s to %s", peer_in_data_node->GetName().c_str(),
new_identity->GetName().c_str());
return INTERNAL_ERROR;
auto ret = GraphUtils::InsertNodeBefore(peer_in_data_anchor, new_identity, kIdentityAnchorIndex,
kIdentityAnchorIndex);
if (ret != SUCCESS) {
GELOGE(ret, "[Insert][Identity] %s before %s %dth input failed.",
new_identity->GetName().c_str(),
peer_in_data_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_data_anchor->GetIdx());
return ret;
}
GELOGI("Node %s intput rw type is %s. Insert Identity between %s and %s.", peer_in_data_node->GetName().c_str(),
InputRWTypeToSerialString(input_rw_type).c_str(), pre_out_data_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_data_anchor->GetOwnerNode()->GetName().c_str());
} else {
(void) out_data_anchor->Unlink(peer_in_data_anchor);
// copy control edge to pre and peer node
if (GraphUtils::CopyInCtrlEdges(old_identity, peer_in_data_node) != SUCCESS
|| GraphUtils::CopyOutCtrlEdges(old_identity, pre_node) != SUCCESS) {
@@ -568,7 +566,8 @@ Status SplitIdentity(const NodePtr &node) {
for (const auto &peer_in_data_anchor : out_data_anchor->GetPeerInDataAnchors()) {
Status ret = SplitIdentityAlongAnchor(out_data_anchor, peer_in_data_anchor, pre_out_data_anchor, pre_node);
if (ret != SUCCESS) {
GELOGE(ret, "Split identity node along anchor failed.");
GELOGE(ret, "[Call][SplitIdentityAlongAnchor] failed, ret:%d, node:%s, pre_node:%s.",
ret, node->GetName().c_str(), pre_node->GetName().c_str());
return ret;
}
}
@@ -576,12 +575,15 @@ Status SplitIdentity(const NodePtr &node) {
if (node->GetOutDataNodesSize() == 0) {
Status ret = GraphUtils::IsolateNode(node, {});
if (ret != SUCCESS) {
GELOGE(FAILED, "IsolateAndDelete identity node %s.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "IsolateNode %s failed, ret:%d", node->GetName().c_str(), ret);
GELOGE(FAILED, "[Isolate][Node] %s failed, ret:%d", node->GetName().c_str(), ret);
return FAILED;
}
ret = GraphUtils::RemoveNodeWithoutRelink(node->GetOwnerComputeGraph(), node);
if (ret != SUCCESS) {
GELOGE(FAILED, "IsolateAndDelete identity node %s.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Call RemoveNodeWithoutRelink failed, node:%s", node->GetName().c_str());
GELOGE(FAILED, "[Call][RemoveNodeWithoutRelink] IsolateAndDelete identity node %s failed.",
node->GetName().c_str());
return FAILED;
}
GELOGI("IsolateAndDelete identity node %s.", node->GetName().c_str());
@@ -613,16 +615,14 @@ Status InsertIdentityAsNeeded(const NodePtr &node) {
GELOGD("No need insert Identity.");
continue;
case INSERT_IDENTITY:
auto identity_node = CreateIdentityAfterSrcNode(*node, out_data_anchor->GetIdx());
if (identity_node == nullptr) {
GELOGE(FAILED, "Create identity node failed.");
return FAILED;
}
auto ret = GraphUtils::InsertNodeBetweenDataAnchors(out_data_anchor, peer_in_data_anchor, identity_node);
if (ret != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Failed to insert reshape between node %s and %s", node->GetName().c_str(),
peer_in_node->GetName().c_str());
return INTERNAL_ERROR;
auto identity_node = AddIdentityToGraph(*node, out_data_anchor->GetIdx());
GE_CHECK_NOTNULL(identity_node);
auto ret = GraphUtils::InsertNodeBefore(peer_in_data_anchor, identity_node, kIdentityAnchorIndex,
kIdentityAnchorIndex);
if (ret != SUCCESS) {
GELOGE(ret, "[Insert][Node] %s before %s %dth input failed.", identity_node->GetName().c_str(),
peer_in_data_anchor->GetOwnerNode()->GetName().c_str(), peer_in_data_anchor->GetIdx());
return ret;
}
GELOGI("Insert Identity between %s and %s to handle memory conflict.", node->GetName().c_str(),
peer_in_node->GetName().c_str());
@@ -633,28 +633,35 @@ Status InsertIdentityAsNeeded(const NodePtr &node) {
return SUCCESS;
}
Status HandleAllreduceDuplicateInput(ComputeGraphPtr &compute_graph) {
for (const auto &node : compute_graph->GetDirectNode()) {
if (node->GetType() == HCOMALLREDUCE) {
std::set<OutDataAnchorPtr> pre_out_anchor_set;
for (const auto &in_data_anchor : node->GetAllInDataAnchors()) {
auto pre_out_anchor = in_data_anchor->GetPeerOutAnchor();
GE_CHECK_NOTNULL(pre_out_anchor);
if (pre_out_anchor_set.find(pre_out_anchor) == pre_out_anchor_set.end()) {
pre_out_anchor_set.emplace(pre_out_anchor);
continue;
}
// need insert identity
auto pre_node = pre_out_anchor->GetOwnerNode();
auto identity_node = CreateIdentityAfterSrcNode(*pre_node, pre_out_anchor->GetIdx());
GE_CHECK_NOTNULL(identity_node);
auto ret = GraphUtils::InsertNodeBetweenDataAnchors(pre_out_anchor, in_data_anchor, identity_node);
GE_CHK_STATUS_RET(ret, "Fail to insert identity.");
GELOGI("InsertNode %s between %s and %s successfully.", identity_node->GetName().c_str(),
pre_node->GetName().c_str(), node->GetName().c_str());
}
}
}
return SUCCESS;
for (const auto &node : compute_graph->GetDirectNode()) {
bool mutable_input_flag = false;
(void)AttrUtils::GetBool(node->GetOpDesc(), kModifyInput, mutable_input_flag);
if (!mutable_input_flag) {
continue;
}
std::set<OutDataAnchorPtr> pre_out_anchor_set;
for (const auto &in_data_anchor : node->GetAllInDataAnchors()) {
auto pre_out_anchor = in_data_anchor->GetPeerOutAnchor();
GE_CHECK_NOTNULL(pre_out_anchor);
if (pre_out_anchor_set.insert(pre_out_anchor).second) {
continue;
}
// need insert identity
auto pre_node = pre_out_anchor->GetOwnerNode();
auto identity_node = AddIdentityToGraph(*pre_node, pre_out_anchor->GetIdx());
GE_CHECK_NOTNULL(identity_node);
auto ret =
GraphUtils::InsertNodeBefore(in_data_anchor, identity_node, kIdentityAnchorIndex, kIdentityAnchorIndex);
if (ret != SUCCESS) {
GELOGE(ret, "[Insert][Node] %s before %s %dth input failed.", identity_node->GetName().c_str(),
node->GetName().c_str(), in_data_anchor->GetIdx());
return ret;
}
GELOGI("InsertNode %s between %s and %s successfully.", identity_node->GetName().c_str(),
pre_node->GetName().c_str(), node->GetName().c_str());
}
}
return SUCCESS;
}
} // namespace

@@ -669,7 +676,7 @@ Status GraphOptimize::CheckRWConflict(ComputeGraphPtr &compute_graph, bool &has_
// 1.loop all subgraph, mark rw type from inside to outside
Status ret = MarkRWTypeForAllSubgraph(sub_graph_vec);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to mark rw type for subgraph.");
GELOGE(ret, "[Call][MarkRWTypeForAllSubgraph] failed for %s.", compute_graph->GetName().c_str());
return ret;
}
has_conflict = false;
@@ -725,7 +732,7 @@ Status GraphOptimize::HandleMemoryRWConflict(ComputeGraphPtr &compute_graph) {
// 1.loop all subgraph, mark rw type from inside to outside
Status ret = MarkRWTypeForAllSubgraph(sub_graph_vec);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to mark rw type for subgraph.");
GELOGE(ret, "[Call][MarkRWTypeForAllSubgraph] failed for %s.", compute_graph->GetName().c_str());
return ret;
}
// 2.loop all node, including node in subgraph and handle memory rw conflict
@@ -752,20 +759,20 @@ Status GraphOptimize::HandleMemoryRWConflict(ComputeGraphPtr &compute_graph) {
// split identity
ret = SplitIdentity(node);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to split identity node %s.", node->GetName().c_str());
GELOGE(ret, "[Split][Identity] %s failed.", node->GetName().c_str());
return ret;
}
// remove no use identity
ret = RemoveNoUseIdentity(node);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to remove useless identity node %s.", node->GetName().c_str());
GELOGE(ret, "[Remove][Identity] %s failed.", node->GetName().c_str());
return ret;
}
}
// insert Identity
ret = InsertIdentityAsNeeded(node);
if (ret != SUCCESS) {
GELOGE(ret, "Fail to insert Identity node.");
GELOGE(ret, "[Insert][Identity] %s failed.", node->GetName().c_str());
return ret;
}
}


+ 20
- 8
ge/graph/optimize/summary_optimize.cc View File

@@ -32,16 +32,19 @@ namespace ge {
Status GraphOptimize::HandleSummaryOp(ComputeGraphPtr &compute_graph) {
GELOGI("[HandleSummaryOp] HandleSummaryOp start!");
if (summary_output_indexes_.size() >= kMaxMapSize) {
GELOGE(FAILED, "Map size out of range.");
REPORT_INNER_ERROR("E19999", "Map size:%zu out of range:%d, check invalid.",
summary_output_indexes_.size(), kMaxMapSize);
GELOGE(FAILED, "[Check][Param] Map size:%zu out of range:%d.", summary_output_indexes_.size(), kMaxMapSize);
return FAILED;
}
if (summary_output_indexes_.find(compute_graph->GetGraphID()) != summary_output_indexes_.end()) {
return SUCCESS;
}
if (compute_graph == nullptr) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "compute_graph is nullptr.");
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] compute_graph is nullptr.");
return GE_GRAPH_PARAM_NULLPTR;
}
if (summary_output_indexes_.find(compute_graph->GetGraphID()) != summary_output_indexes_.end()) {
return SUCCESS;
}
vector<NodePtr> del_nodes;
vector<NodePtr> front_nodes;
vector<uint8_t> out_index;
@@ -56,12 +59,18 @@ Status GraphOptimize::HandleSummaryOp(ComputeGraphPtr &compute_graph) {
compute_graph->SetSummaryFlag(true);
auto in = node_ptr->GetInDataAnchor(0);
if (in == nullptr) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "in is nullptr.");
REPORT_INNER_ERROR("E19999", "In data anchor(index:0) of node:%s is nullptr", node_ptr->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Get][InDataAnchor] of node:%s is nullptr, index:0",
node_ptr->GetName().c_str());
return GE_GRAPH_PARAM_NULLPTR;
}

auto peerin = in->GetPeerOutAnchor();
GE_IF_BOOL_EXEC(peerin == nullptr, GELOGE(GE_GRAPH_PARAM_NULLPTR, "peerin is nullptr.");
GE_IF_BOOL_EXEC(peerin == nullptr,
REPORT_INNER_ERROR("E19999", "peer out anchor is nullptr, node:%s, in anchor index:0",
node_ptr->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Get][PeerOutAnchor] of node:%s is nullptr, in anchor index:0",
node_ptr->GetName().c_str());
return GE_GRAPH_PARAM_NULLPTR);

auto ret = GraphUtils::RemoveEdge(peerin, in);
@@ -94,7 +103,10 @@ Status GraphOptimize::HandleSummaryOp(ComputeGraphPtr &compute_graph) {
for (auto &node_ptr : del_nodes) {
auto ret = GraphUtils::RemoveNodeWithoutRelink(compute_graph, node_ptr);
if (ret != SUCCESS) {
GELOGE(ret, "GraphUtils::RemoveNodeWithoutRelink failed.");
REPORT_CALL_ERROR("E19999", "Call RemoveNodeWithoutRelink failed, node:%s, graph:%s",
node_ptr->GetName().c_str(), compute_graph->GetName().c_str());
GELOGE(ret, "[Call][RemoveNodeWithoutRelink] failed, node:%s, graph:%s",
node_ptr->GetName().c_str(), compute_graph->GetName().c_str());
return ret;
}
// update Target list


+ 153
- 92
ge/graph/partition/dynamic_shape_partition.cc View File

@@ -36,6 +36,7 @@
#define REQUIRE(cond, ...) \
do { \
if (!(cond)) { \
REPORT_INNER_ERROR("E19999", __VA_ARGS__); \
GELOGE(FAILED, "[Dynamic shape partition]" __VA_ARGS__); \
return FAILED; \
} \
@@ -46,11 +47,6 @@
#define REQUIRE_GRAPH_SUCCESS(cond, ...) REQUIRE(((cond) == GRAPH_SUCCESS), __VA_ARGS__)

namespace ge {
namespace {
const std::set<std::string> kControlFlowOps{
STREAMACTIVE, STREAMSWITCH, STREAMMERGE, ENTER, REFENTER, LOOPCOND, NEXTITERATION, REFNEXTITERATION, EXIT, REFEXIT
};
}
using Cluster = DynamicShapePartitioner::Cluster;
using ClusterPtr = std::shared_ptr<Cluster>;

@@ -68,32 +64,32 @@ static bool IsSingleOpScene(const ComputeGraphPtr &root_graph) {
}

Status DynamicShapePartitioner::Partition() {
REQUIRE_NOT_NULL(root_graph_, "Graph is nullptr.");
REQUIRE_NOT_NULL(root_graph_, "[Check][Param] Graph is nullptr.");
if (IsSingleOpScene(root_graph_)) {
GELOGD("Skip dynamic shape partition as in single op scene.");
REQUIRE(AttrUtils::SetBool(*root_graph_, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, false),
"Failed set dynamic shape partitioned flag on root graph.");
"[Set][Attr] dynamic shape partitioned flag on root graph:%s failed.", root_graph_->GetName().c_str());
return SUCCESS;
}

GELOGD("Start dynamic shape partition graph %s.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(MarkUnknownShapeNodes(), "Failed mark unknown shape nodes, root grah name:%s.",
REQUIRE_SUCCESS(MarkUnknownShapeNodes(), "[Call][MarkUnknownShapeNodes] failed, root grah name:%s.",
root_graph_->GetName().c_str());
if (unknown_shape_nodes_.empty()) {
GELOGD("Skip dynamic shape partition of graph %s as all nodes are known shape.", root_graph_->GetName().c_str());
REQUIRE(AttrUtils::SetBool(*root_graph_, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, false),
"Failed set dynamic shape partitioned flag on root graph %s.", root_graph_->GetName().c_str());
"[Set][Attr] dynamic shape partitioned flag on root graph %s failed.", root_graph_->GetName().c_str());
return SUCCESS;
}
REQUIRE(AttrUtils::SetBool(*root_graph_, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, true),
"Failed set dynamic shape partitioned flag on root graph %s.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(CtrlEdgeTransfer(), "Failed do ctrl edge transfer!");
"[Set][Attr] dynamic shape partitioned flag on root graph %s failed.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(CtrlEdgeTransfer(), "[Call][CtrlEdgeTransfer] failed, graph:%s.", root_graph_->GetName().c_str());
DumpGraph("_Before_DSP");
auto status = PartitionImpl();
GELOGD("%s.", DebugString().c_str());
if (status != SUCCESS) {
GELOGE(status, "Failed dynamic shape partition graph: %s, status:\n %s", root_graph_->GetName().c_str(),
DebugString().c_str());
GELOGE(status, "[Call][PartitionImpl] Failed dynamic shape partition graph:%s, ret:%s",
root_graph_->GetName().c_str(), DebugString().c_str());
}
DumpGraph("_After_DSP");
GELOGD("Finish dynamic shape partition graph %s.", root_graph_->GetName().c_str());
@@ -128,13 +124,19 @@ Status DynamicShapePartitioner::CtrlEdgeTransfer() {
for (auto &in_control_node : n->GetInControlNodes()) {
GE_CHECK_NOTNULL(in_control_node);
GE_CHK_STATUS_RET(ge::GraphUtils::RemoveEdge(in_control_node->GetOutControlAnchor(),
n->GetInControlAnchor()), "remove edge failed");
n->GetInControlAnchor()),
"[Remove][Edge] between %s and %s failed",
in_control_node->GetOutControlAnchor()->GetOwnerNode()->GetName().c_str(),
n->GetName().c_str());
for (auto &out_node : n->GetOutNodes()) {
if (out_node == nullptr) {
continue;
}
GE_CHK_STATUS_RET(ge::GraphUtils::AddEdge(in_control_node->GetOutControlAnchor(),
out_node->GetInControlAnchor()), "add edge failed.");
out_node->GetInControlAnchor()),
"[Add][Edge] between %s and %s failed.",
in_control_node->GetOutControlAnchor()->GetOwnerNode()->GetName().c_str(),
out_node->GetName().c_str());
}
}
}
@@ -146,13 +148,16 @@ Status DynamicShapePartitioner::CtrlEdgeTransfer() {
}

Status DynamicShapePartitioner::PartitionImpl() {
REQUIRE_SUCCESS(root_graph_->TopologicalSorting(), "Graph topological sort failed.");
REQUIRE_SUCCESS(InitClusters(), "Failed init cluster nodes.");
REQUIRE_SUCCESS(MergeClusters(), "Failed merge clusters.");
REQUIRE_SUCCESS(root_graph_->TopologicalSorting(),
"[Call][TopologicalSorting] failed, graph:%s.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(InitClusters(), "[Init][Clusters] failed, graph:%s.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(MergeClusters(), "[Merge][Clusters] failed, graph:%s.", root_graph_->GetName().c_str());
PruneUniqueClusters();
REQUIRE_SUCCESS(BuildPartitionFrame(), "Failed build cluster partition frame.");
REQUIRE_SUCCESS(CombinePartitionFrame(), "Failed combine cluster partition frame.");
REQUIRE_SUCCESS(BuildPartitionSubgraph(), "Failed build cluster partition subgraph.");
REQUIRE_SUCCESS(BuildPartitionFrame(), "[Build][PartitionFrame] failed, graph:%s.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(CombinePartitionFrame(),
"[Combine][PartitionFrame] failed, graph:%s.", root_graph_->GetName().c_str());
REQUIRE_SUCCESS(BuildPartitionSubgraph(),
"[Build][PartitionSubgraph] failed, graph:%s.", root_graph_->GetName().c_str());
return SUCCESS;
}

@@ -174,21 +179,21 @@ void DynamicShapePartitioner::PruneUniqueClusters() {

Status DynamicShapePartitioner::BuildPartitionFrame() {
for (const auto &cluster : sorted_unique_clusters_) {
REQUIRE_SUCCESS(cluster->BuildFrame(), "Failed build frame of cluster[%lu].", cluster->Id());
REQUIRE_SUCCESS(cluster->BuildFrame(), "[Build][Frame] of cluster[%lu] failed.", cluster->Id());
}
return SUCCESS;
}

Status DynamicShapePartitioner::CombinePartitionFrame() {
for (const auto &cluster : sorted_unique_clusters_) {
REQUIRE_SUCCESS(cluster->CombinePartitionFrame(), "Failed combine frame of cluster[%lu].", cluster->Id());
REQUIRE_SUCCESS(cluster->CombinePartitionFrame(), "[Combine][Frame] of cluster[%lu] failed.", cluster->Id());
}
return SUCCESS;
}

Status DynamicShapePartitioner::BuildPartitionSubgraph() {
for (const auto &cluster : sorted_unique_clusters_) {
REQUIRE_SUCCESS(cluster->BuildPartitionSubgraph(), "Failed build subgraph of cluster[%lu].", cluster->Id());
REQUIRE_SUCCESS(cluster->BuildPartitionSubgraph(), "[Build][SubGraph] of cluster[%lu] failed.", cluster->Id());
}
return SUCCESS;
}
@@ -250,8 +255,8 @@ void DynamicShapePartitioner::ClearResource() {

Status DynamicShapePartitioner::MarkUnknownShapeNodes() {
for (auto &node : root_graph_->GetDirectNode()) {
REQUIRE_SUCCESS(CollectSpreadUnknownShapeNodes(node), "Failed collect spread unknown shape nodes %s.",
node->GetName().c_str());
REQUIRE_SUCCESS(CollectSpreadUnknownShapeNodes(node),
"[Call][CollectSpreadUnknownShapeNodes] for node:%s failed.", node->GetName().c_str());
}
return SUCCESS;
}
@@ -262,7 +267,7 @@ Status DynamicShapePartitioner::InitClusters() {
for (const auto &node : graph->GetDirectNode()) {
Cluster::Type type = Cluster::DATA;
bool is_input = ((node->GetType() == CONSTANT) || (node->GetType() == CONSTANTOP)) && node->GetInNodes().empty();
REQUIRE_NOT_NULL(node->GetOpDesc(), "op_desc is null");
REQUIRE_NOT_NULL(node->GetOpDesc(), "[Get][OpDesc] op_desc is null, graph:%s", graph->GetName().c_str());
if (node->GetType() == DATA) {
type = Cluster::DATA;
} else if (is_input) {
@@ -277,11 +282,19 @@ Status DynamicShapePartitioner::InitClusters() {
type = Cluster::KNOWN_SHAPE;
}
auto cluster = MakeShared<Cluster>(rank++, type, node, this);
REQUIRE_NOT_NULL(cluster, "Failed new memory for cluster.");
REQUIRE_NOT_NULL(cluster, "[New][Memory] for cluster failed.");
node_2_cluster_[node] = cluster;
if (cluster->IsUnknownShape() && !cluster->IsControlFlow()) {
if (cluster->IsUnknownShape()) {
ordered_cluster_.push_back(cluster);
}

int64_t group_index = -1;
if (AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_CONTROL_FLOW_GROUP, group_index)) {
GELOGD("[%s] is rts control flow Op, group index: %ld", node->GetName().c_str(), group_index);
auto &control_cluster = control_clusters_[group_index];
control_cluster.emplace_back(cluster);
}

// Already sorted topologically, so access to the parent cluster is safe
for (const auto &parent : node->GetInAllNodes()) {
cluster->AddInput(node_2_cluster_[parent]);
@@ -350,14 +363,41 @@ static std::string ToString(const std::vector<ClusterPtr> &clusters) {
}
}

void DynamicShapePartitioner::MergeClustersControlFlow() {
for (const auto &item : control_clusters_) {
const auto &control_cluster = item.second;
auto rit = control_cluster.rbegin();
if (rit == control_cluster.rend()) {
GELOGW("Invalid empty control flow cluster.");
continue;
}

const auto &cluster = *rit;
for (++rit; rit != control_cluster.rend(); ++rit) {
const auto &cluster_from = *rit;
auto merged_clusters = cluster->MergeAllPathFrom(cluster_from);
GELOGD("Merge all path cluster from %lu to %lu %s.", cluster_from->Id(), cluster->Id(),
ToString(merged_clusters).c_str());
for (const auto &merged_cluster : merged_clusters) {
for (const auto &node : merged_cluster->Nodes()) {
node_2_cluster_[node] = cluster;
}
}
}
}
}

void DynamicShapePartitioner::MergeClustersUnknownShape() {
// Merge unknown shape clusters
for (const auto &cluster : ordered_cluster_) {
if (cluster->IsIndependent() || cluster->IsControlFlow()) {
if (cluster->IsIndependent()) {
continue;
}
for (const auto &in_cluster : cluster->Inputs()) {
if (!in_cluster->IsUnknownShape() || in_cluster->IsControlFlow()) {
if (!in_cluster->IsUnknownShape()) {
continue;
}
if (!cluster->IsAdjoinNodes(in_cluster)) {
continue;
}
auto merged_clusters = cluster->MergeAllPathFrom(in_cluster);
@@ -419,8 +459,9 @@ void DynamicShapePartitioner::MergeClustersInputData() {
}

Status DynamicShapePartitioner::MergeClusters() {
MergeClustersControlFlow();
MergeClustersUnknownShape();
REQUIRE_SUCCESS(TopologicalSortClusters(), "Failed topological sort clusters after merge unknown shape clusters.");
REQUIRE_SUCCESS(TopologicalSortClusters(), "[TopologicalSort][Clusters] after merge unknown shape clusters failed.");
MergeClustersKnownShape();
MergeClustersInputData();
return SUCCESS;
@@ -446,7 +487,7 @@ Status DynamicShapePartitioner::CollectSpreadUnknownShapeNodes(NodePtr node) {
return SUCCESS;
}
auto opdesc = node->GetOpDesc();
REQUIRE_NOT_NULL(opdesc, "Opdesc is nullptr.");
REQUIRE_NOT_NULL(opdesc, "[Get][OpDesc] Opdesc is nullptr.");
// One can set 'ATTR_NAME_IS_UNKNOWN_SHAPE=true' on node so as to forcing the node flow into the unknown subgraph,
// ignore the actual shape.
if (JudgeUnknowShapeWithAttr(opdesc)) {
@@ -492,10 +533,11 @@ Status DynamicShapePartitioner::CollectSpreadUnknownShapeNodes(NodePtr node) {
auto graph = root_graph_;
for (const auto &subgraph_name : opdesc->GetSubgraphInstanceNames()) {
auto subgraph = graph->GetSubgraph(subgraph_name);
REQUIRE_NOT_NULL(subgraph, "Failed get subgraph %s of node %s on root graph.", subgraph_name.c_str(),
REQUIRE_NOT_NULL(subgraph, "[Get][Subgraph] %s of node %s on root graph failed.", subgraph_name.c_str(),
node->GetName().c_str());
bool is_graph_unknow = false;
REQUIRE_SUCCESS(IsUnknownShapeGraph(subgraph, is_graph_unknow), "Failed check subgraph %s shape of node %s.",
REQUIRE_SUCCESS(IsUnknownShapeGraph(subgraph, is_graph_unknow),
"[Call][IsUnknownShapeGraph] Failed check subgraph %s shape of node %s.",
subgraph_name.c_str(), node->GetName().c_str());
if (is_graph_unknow) {
GELOGD("Collect node %s as its subgraph %s is unknown.", node->GetName().c_str(), subgraph->GetName().c_str());
@@ -526,9 +568,10 @@ Status DynamicShapePartitioner::IsUnknownShapeNode(NodePtr node, bool &is_unknow
}
for (auto &subgraph_name : opdesc->GetSubgraphInstanceNames()) {
auto subgraph = graph->GetSubgraph(subgraph_name);
REQUIRE_NOT_NULL(subgraph, "Failed get subgraph %s of node %s on root graph.", subgraph_name.c_str(),
REQUIRE_NOT_NULL(subgraph, "[Get][Subgraph] %s of node %s on root graph failed.", subgraph_name.c_str(),
node->GetName().c_str());
REQUIRE_SUCCESS(IsUnknownShapeGraph(subgraph, is_unknown), "Failed check subgraph %s shape of node %s.",
REQUIRE_SUCCESS(IsUnknownShapeGraph(subgraph, is_unknown),
"[Call][IsUnknownShapeGraph] Failed check subgraph %s shape of node %s.",
subgraph_name.c_str(), node->GetName().c_str());
if (is_unknown) {
GELOGD("Mark node %s unknown as unknown subgraph.", node->GetName().c_str());
@@ -541,7 +584,8 @@ Status DynamicShapePartitioner::IsUnknownShapeNode(NodePtr node, bool &is_unknow

Status DynamicShapePartitioner::IsUnknownShapeGraph(ComputeGraphPtr graph, bool &is_unknown) {
for (auto &node : graph->GetDirectNode()) {
REQUIRE_SUCCESS(IsUnknownShapeNode(node, is_unknown), "Failed check node %s shape on graph %s.",
REQUIRE_SUCCESS(IsUnknownShapeNode(node, is_unknown),
"[Call][IsUnknownShapeNode]Failed check node %s shape on graph %s.",
node->GetName().c_str(), graph->GetName().c_str());
if (is_unknown) {
GELOGD("Mark graph %s unknown as contains unknown node %s.", graph->GetName().c_str(), node->GetName().c_str());
@@ -608,13 +652,6 @@ bool Cluster::IsRefVariable() const {
return false;
}

bool Cluster::IsControlFlow() const {
const auto &op_desc = nodes_[0]->GetOpDesc();
bool is_ctrl_flow = kControlFlowOps.count(op_desc->GetType()) > 0 && op_desc->HasAttr(ATTR_NAME_FORCE_UNKNOWN_SHAPE);
GELOGD("[%s] %s rts control flow Op ", op_desc->GetName().c_str(), is_ctrl_flow ? "Is" : "Not");
return is_ctrl_flow;
}

void Cluster::AddInput(ClusterPtr in) {
if (std::find(in_clusters_.begin(), in_clusters_.end(), in) != in_clusters_.end()) return;
in_clusters_.insert(in_clusters_.end(), in);
@@ -694,10 +731,7 @@ std::vector<ClusterPtr> Cluster::MergeAllPathFrom(ClusterPtr other) {
if (other->IsIndependent()) {
return path_clusters;
}
if (std::find(other->out_clusters_.begin(), other->out_clusters_.end(), shared_from_this()) ==
other->out_clusters_.end()) {
return path_clusters;
}

path_clusters.push_back(other);
forward_reached_queue.push(other);
backward_reached_queue.push(shared_from_this());
@@ -761,7 +795,7 @@ InControlAnchorPtr Cluster::GetFrameInControlAnchor() { return partition_node_->
OutControlAnchorPtr Cluster::GetFrameOutControlAnchor() { return partition_node_->GetOutControlAnchor(); };

Status Cluster::BuildFrame() {
if ((IsUnknownShape() || IsKnownShape() || IsInputNode()) && !IsControlFlow()) {
if (IsUnknownShape() || IsKnownShape() || IsInputNode()) {
return BuildPartitionFrame();
} else {
auto node = nodes_.front();
@@ -772,7 +806,7 @@ Status Cluster::BuildFrame() {
if (src_cluster->id_ != id_) {
REQUIRE_GRAPH_SUCCESS(
GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor),
"Failed remove edge from node %s index %d to node %s index %d.",
"[Remove][Edge] from node %s index %d to node %s failed, index %d.",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(peer_out_control_anchor),
in_control_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(in_control_anchor));
control_inputs_.insert(src_cluster);
@@ -802,20 +836,28 @@ Status Cluster::BuildPartitionFrame() {
string sub_graph_name_patten = (is_input ? "_input" : known_name);
std::string sub_graph_name = graph->GetName() + "_sub_" + std::to_string(unique_id_) + sub_graph_name_patten;
subgraph_ = MakeShared<ComputeGraph>(sub_graph_name);
REQUIRE_NOT_NULL(subgraph_, "Failed new memory for subgraph.");
REQUIRE_NOT_NULL(subgraph_, "[New][Memory] for subgraph failed, name:%s.", sub_graph_name.c_str());
auto partition_op = MakeShared<OpDesc>("PartitionedCall_" + std::to_string(unique_id_++), "PartitionedCall");
REQUIRE_NOT_NULL(partition_op, "Failed new memory for partition op.");
REQUIRE_NOT_NULL(partition_op, "[New][Memory] for partition op failed.");
REQUIRE(AttrUtils::SetBool(partition_op, ATTR_NAME_IS_UNKNOWN_SHAPE, is_unknown_shape),
"Failed set _is_unknown_shape flag on partitioned op %s.", partition_op->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(partition_op->AddSubgraphName(subgraph_->GetName()), "Failed add subgraph name.");
"[Set][Attr] _is_unknown_shape flag on partitioned op %s failed.", partition_op->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(partition_op->AddSubgraphName(subgraph_->GetName()),
"[Add][SubgraphName] %s for op:%s.",
subgraph_->GetName().c_str(), partition_op->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(partition_op->SetSubgraphInstanceName(0, subgraph_->GetName()),
"Failed set subgraph instance name.");
"[Call][SetSubgraphInstanceName] for op:%s failed, index:0, name:%s.",
partition_op->GetName().c_str(), subgraph_->GetName().c_str());
for (auto &node : nodes_) {
REQUIRE_NOT_NULL(subgraph_->AddNode(node), "Failed add node to subgraph.");
REQUIRE_NOT_NULL(subgraph_->AddNode(node),
"[Add][Node] %s to subgraph:%s failed.", node->GetName().c_str(), subgraph_->GetName().c_str());
REQUIRE(AttrUtils::SetBool(node->GetOpDesc(), ATTR_NAME_IS_UNKNOWN_SHAPE, is_unknown_shape),
"Failed set shape flag.");
REQUIRE_GRAPH_SUCCESS(GraphUtils::RemoveJustNode(graph, node), "Failed remove root graph node.");
REQUIRE_GRAPH_SUCCESS(node->SetOwnerComputeGraph(subgraph_), "Failed set owner graph.");
"[Set][Attr] %s to op:%s failed.", ATTR_NAME_IS_UNKNOWN_SHAPE.c_str(), node->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(GraphUtils::RemoveJustNode(graph, node),
"[Remove][JustNode] failed, graph:%s, node:%s.",
graph->GetName().c_str(), node->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(node->SetOwnerComputeGraph(subgraph_),
"[Set][OwnerComputeGraph] %s for node:%s failed.",
subgraph_->GetName().c_str(), node->GetName().c_str());
for (const auto &anchor : node->GetAllInDataAnchors()) {
auto peer_out_anchor = anchor->GetPeerOutAnchor();
if (peer_out_anchor == nullptr) {
@@ -825,7 +867,7 @@ Status Cluster::BuildPartitionFrame() {
if (src_cluster->id_ != id_) {
AddFrameInput(anchor);
REQUIRE_GRAPH_SUCCESS(partition_op->AddInputDesc(node->GetOpDesc()->GetInputDesc(anchor->GetIdx())),
"Failed add input desc.");
"[Add][InputDesc] to op:%s failed.", partition_op->GetName().c_str());
}
}
auto in_control_anchor = node->GetInControlAnchor();
@@ -838,7 +880,7 @@ Status Cluster::BuildPartitionFrame() {
if (src_cluster->id_ != id_) {
REQUIRE_GRAPH_SUCCESS(
GraphUtils::RemoveEdge(peer_out_control_anchor, in_control_anchor),
"Failed remove edge from %s:%d to %s:%d.", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
"[Remove][Edge] from %s:%d to %s:%d failed.", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetIdx(), node->GetName().c_str(), in_control_anchor->GetIdx());
control_inputs_.insert(src_cluster);
src_cluster->control_outputs_.insert(peer_out_control_anchor);
@@ -852,23 +894,28 @@ Status Cluster::BuildPartitionFrame() {
if (src_cluster->id_ != id_) {
AddFrameOutput(anchor);
REQUIRE_GRAPH_SUCCESS(partition_op->AddOutputDesc(node->GetOpDesc()->GetOutputDesc(anchor->GetIdx())),
"Failed add output desc.");
"[Add][OutputDesc] to op:%s failed.", partition_op->GetName().c_str());
break;
}
}
}
}
partition_node_ = graph->AddNode(partition_op);
REQUIRE_NOT_NULL(partition_node_, "Failed add partition node.");
REQUIRE_GRAPH_SUCCESS(partition_node_->SetOwnerComputeGraph(graph), "Failed set owner graph.");
REQUIRE_NOT_NULL(partition_node_,
"[Add][Node] %s to graph:%s failed.", partition_op->GetName().c_str(), graph->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(partition_node_->SetOwnerComputeGraph(graph),
"[Set][OwnerComputeGraph] %s for node:%s failed.",
graph->GetName().c_str(), partition_op->GetName().c_str());
subgraph_->SetParentNode(partition_node_);
subgraph_->SetParentGraph(graph);
REQUIRE_GRAPH_SUCCESS(graph->AddSubgraph(subgraph_), "Failed add subgraph to root graph.");
REQUIRE_GRAPH_SUCCESS(graph->AddSubgraph(subgraph_),
"[Add][Subgraph] %s to root graph:%s failed.",
subgraph_->GetName().c_str(), graph->GetName().c_str());
std::string session_graph_id;
REQUIRE(AttrUtils::GetStr(*graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id),
"Failed get ATTR_NAME_SESSION_GRAPH_ID on root graph.");
"[Get][Attr] %s on root graph:%s failed.", ATTR_NAME_SESSION_GRAPH_ID.c_str(), graph->GetName().c_str());
REQUIRE(AttrUtils::SetStr(*subgraph_, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id),
"Failed set ATTR_NAME_SESSION_GRAPH_ID on subgraph.");
"[Set][Attr] %s on subgraph:%s failed.", ATTR_NAME_SESSION_GRAPH_ID.c_str(), subgraph_->GetName().c_str());
return SUCCESS;
}

@@ -878,17 +925,17 @@ Status Cluster::CombinePartitionFrame() {
auto src_cluster = partitioner_->node_2_cluster_[peer_out_anchor->GetOwnerNode()];
auto src_anchor = src_cluster->GetFrameOutDataAnchor(peer_out_anchor);
auto dst_anchor = GetFrameInDataAnchor(anchor);
REQUIRE_GRAPH_SUCCESS(GraphUtils::RemoveEdge(peer_out_anchor, anchor), "Failed remove edge from %s:%d to %s:%d.",
REQUIRE_GRAPH_SUCCESS(GraphUtils::RemoveEdge(peer_out_anchor, anchor), "[Remove][Edge] from %s:%d to %s:%d fail.",
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetIdx(),
anchor->GetOwnerNode()->GetName().c_str(), anchor->GetIdx());
REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(src_anchor, dst_anchor), "Failed add edge from %s:%d to %s:%d.",
REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(src_anchor, dst_anchor), "[Add][Edge] from %s:%d to %s:%d failed.",
src_anchor->GetOwnerNode()->GetName().c_str(), src_anchor->GetIdx(),
dst_anchor->GetOwnerNode()->GetName().c_str(), dst_anchor->GetIdx());
}
for (const auto &src_cluster : control_inputs_) {
auto src_anchor = src_cluster->GetFrameOutControlAnchor();
auto dst_anchor = GetFrameInControlAnchor();
REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(src_anchor, dst_anchor), "Failed add edge from %s:%d to %s:%d.",
REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(src_anchor, dst_anchor), "[Add][Edge] from %s:%d to %s:%d failed.",
src_anchor->GetOwnerNode()->GetName().c_str(), src_anchor->GetIdx(),
dst_anchor->GetOwnerNode()->GetName().c_str(), dst_anchor->GetIdx());
}
@@ -896,62 +943,76 @@ Status Cluster::CombinePartitionFrame() {
}

Status Cluster::BuildPartitionSubgraph() {
if (IsData() || IsNetOutput() || IsIndependent() || IsControlFlow()) {
if (IsData() || IsNetOutput() || IsIndependent()) {
return SUCCESS;
}
int64_t parent_node_index = 0;
for (auto anchor : inputs_) {
auto data_op =
MakeShared<OpDesc>(subgraph_->GetName() + std::string("Data_") + std::to_string(parent_node_index), ge::DATA);
REQUIRE_NOT_NULL(data_op, "Failed new memory for data op.");
REQUIRE_NOT_NULL(data_op, "[New][Memory] for data op failed.");
auto input_desc = anchor->GetOwnerNode()->GetOpDesc()->GetInputDesc(anchor->GetIdx());
REQUIRE_GRAPH_SUCCESS(data_op->AddInputDesc(input_desc), "Failed add input desc.");
REQUIRE_GRAPH_SUCCESS(data_op->AddOutputDesc(input_desc), "Failed add output desc.");
REQUIRE_GRAPH_SUCCESS(data_op->AddInputDesc(input_desc),
"[Add][InputDesc] to op:%s failed.", data_op->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(data_op->AddOutputDesc(input_desc),
"[Add][OutputDesc] to op:%s failed.", data_op->GetName().c_str());
REQUIRE(AttrUtils::SetInt(data_op, ATTR_NAME_PARENT_NODE_INDEX, parent_node_index),
"Failed set parent_node_index on subgraph data node.");
"[Set][Attr] %s on subgraph data node:%s failed.",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), data_op->GetName().c_str());
bool is_unknown_shape = IsUnknownShape();
REQUIRE(AttrUtils::SetBool(data_op, ATTR_NAME_IS_UNKNOWN_SHAPE, is_unknown_shape),
"Failed set _is_unknown_shape flag on data op %s.", data_op->GetName().c_str());
"[Set][Attr] %s on data op %s failed.", ATTR_NAME_IS_UNKNOWN_SHAPE.c_str(), data_op->GetName().c_str());
auto data_node = subgraph_->AddNode(data_op);
REQUIRE_NOT_NULL(data_node, "Failed add data node to subgraph.");
REQUIRE_GRAPH_SUCCESS(data_node->SetOwnerComputeGraph(subgraph_), "Failed set owner graph of data node.");
REQUIRE_NOT_NULL(data_node,
"[Add][Node] %s to subgraph:%s failed.", data_op->GetName().c_str(), subgraph_->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(data_node->SetOwnerComputeGraph(subgraph_),
"[Set][OwnerGraph] %s of data node:%s failed.",
subgraph_->GetName().c_str(), data_op->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(data_node->GetOutDataAnchor(0), anchor),
"Faile add data input edge to %s:%d", anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetIdx());
"[Call][AddEdge] Failed add data input edge to %s:%d",
anchor->GetOwnerNode()->GetName().c_str(), anchor->GetIdx());
parent_node_index++;
}
if (outputs_.empty() && control_outputs_.empty()) {
return SUCCESS;
}
auto net_output_op = MakeShared<OpDesc>(subgraph_->GetName() + "_" + NODE_NAME_NET_OUTPUT, ge::NETOUTPUT);
REQUIRE_NOT_NULL(net_output_op, "Failed new memory for netoutput op.");
REQUIRE_NOT_NULL(net_output_op, "[New][Memory] for netoutput op failed.");
bool is_unknown_shape = IsUnknownShape();
REQUIRE(AttrUtils::SetBool(net_output_op, ATTR_NAME_IS_UNKNOWN_SHAPE, is_unknown_shape),
"Failed set _is_unknown_shape flag on net_output_op %s.", net_output_op->GetName().c_str());
"[Set][Attr] %s on op:%s failed.", ATTR_NAME_IS_UNKNOWN_SHAPE.c_str(), net_output_op->GetName().c_str());
for (size_t i = 0; i < outputs_.size(); ++i) {
GeTensorDesc input_desc;
REQUIRE_GRAPH_SUCCESS(net_output_op->AddInputDesc(input_desc), "Failed add input desc.");
REQUIRE_GRAPH_SUCCESS(net_output_op->AddInputDesc(input_desc),
"[Add][InputDesc] to op:%s failed.", net_output_op->GetName().c_str());
}
auto net_output_node = subgraph_->AddNode(net_output_op);
REQUIRE_NOT_NULL(net_output_node, "Failed add netoutput node to subgraph.");
REQUIRE_GRAPH_SUCCESS(net_output_node->SetOwnerComputeGraph(subgraph_), "Failed set owner graph of netoutput node.");
REQUIRE_NOT_NULL(net_output_node,
"[Call][AddNode] Failed add netoutput node:%s to subgraph:%s.",
net_output_op->GetName().c_str(), subgraph_->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(net_output_node->SetOwnerComputeGraph(subgraph_),
"[Set][OwnerGraph] %s of netoutput node:%s failed.",
subgraph_->GetName().c_str(), net_output_node->GetName().c_str());
parent_node_index = 0;
for (const auto &anchor : outputs_) {
auto output_desc = anchor->GetOwnerNode()->GetOpDesc()->GetOutputDesc(static_cast<uint32_t>(anchor->GetIdx()));
REQUIRE(AttrUtils::SetInt(output_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_node_index),
"Failed set parent_node_index on subgraph netoutput's input.");
"[Set][Attr] parent_node_index on subgraph node:%s netoutput's input failed.",
anchor->GetOwnerNode()->GetName().c_str());
REQUIRE_GRAPH_SUCCESS(net_output_op->UpdateInputDesc(parent_node_index, output_desc),
"Failed update input desc of netoutput node.");
"[Update][InputDesc] of netoutput node:%s failed.", net_output_op->GetName().c_str());

REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(anchor, net_output_node->GetInDataAnchor(parent_node_index)),
"Faile add edge from %s:%d to netoutput node.", anchor->GetOwnerNode()->GetName().c_str(),
anchor->GetIdx());
"[Add][Edge] from %s:%d to netoutput node:%s failed.",
anchor->GetOwnerNode()->GetName().c_str(), anchor->GetIdx(),
net_output_op->GetName().c_str());
parent_node_index++;
}
for (const auto &anchor : control_outputs_) {
REQUIRE_GRAPH_SUCCESS(GraphUtils::AddEdge(anchor, net_output_node->GetInControlAnchor()),
"Faile add control edge from %s:%d to netoutput node.",
anchor->GetOwnerNode()->GetName().c_str(), anchor->GetIdx());
"[Add][ControlEdge] from %s:%d to netoutput node:%s failed.",
anchor->GetOwnerNode()->GetName().c_str(), anchor->GetIdx(),
net_output_op->GetName().c_str());
}
return SUCCESS;
}


+ 10
- 3
ge/graph/partition/dynamic_shape_partition.h View File

@@ -47,7 +47,6 @@ class DynamicShapePartitioner {
bool IsUnknownShape() const;
bool IsIndependent() const;
bool IsNetOutput() const;
bool IsControlFlow() const;
std::vector<std::shared_ptr<Cluster>> Inputs() const;
std::vector<std::shared_ptr<Cluster>> Outputs() const;
bool IsInputNode() const;
@@ -81,6 +80,10 @@ class DynamicShapePartitioner {
Status BuildPartitionSubgraph();
// Clear resource and break circular dependency
void Clear();
bool IsAdjoinNodes(const std::shared_ptr<Cluster> &other) const {
const auto &out_clusters = other->out_clusters_;
return std::find(out_clusters.begin(), out_clusters.end(), shared_from_this()) != out_clusters.end();
}

private:
static thread_local size_t unique_id_;
@@ -126,13 +129,15 @@ class DynamicShapePartitioner {
// and there's only one path between the two clusters , merge the two clusters
// 3) Iterate through the INPUT_DATA clusters, merge all INPUT_DATA
Status MergeClusters();
// Merge clusters step0
void MergeClustersControlFlow();
// Merge clusters step1
void MergeClustersUnknownShape();
// Merge clusters step2
void MergeClustersKnownShape();
// Merge clusters step3
void MergeClustersInputData();
// Topological sort clusters after merge unknow shape clusters.
// Topological sort clusters after merge unknown shape clusters.
Status TopologicalSortClusters();
// Deduplicate merged clusters
void PruneUniqueClusters();
@@ -140,7 +145,7 @@ class DynamicShapePartitioner {
Status BuildPartitionFrame();
// Establish connection between corresponding partitioned of clusters
Status CombinePartitionFrame();
// Convert the nodes in cluster into a complete ComputeGraoh
// Convert the nodes in cluster into a complete ComputeGraph
Status BuildPartitionSubgraph();
// Clear resource and break circular dependency
void ClearResource();
@@ -155,6 +160,8 @@ class DynamicShapePartitioner {
Status CtrlEdgeTransfer();
ge::ComputeGraphPtr root_graph_; // The original graph to partition
std::unordered_map<NodePtr, std::shared_ptr<Cluster>> node_2_cluster_; // Record nodes and the cluster it belongs to
// V1 control flow cluster, need merge to one Graph.
std::unordered_map<int64_t, std::vector<std::shared_ptr<Cluster>>> control_clusters_;
// topological sorted clusters, this field will change with the splitting.
// When partitioning UNKNOWN_SHAPE cluster, it is a collection of all topological sorted UNKNOWN_SHAPE clusters
// When partitioning KNOWN_SHAPE cluster, it is a collection of all topological sorted KNOWN_SHAPE clusters


+ 9
- 6
ge/graph/partition/engine_place.cc View File

@@ -36,12 +36,14 @@ std::mutex check_support_cost_mutex;
}
Status EnginePlacer::Check() const {
if (compute_graph_ == nullptr) {
GELOGE(GE_GRAPH_NULL_INPUT, "compute_graph_ is null.");
REPORT_INNER_ERROR("E19999", "compute_graph_ is nullptr, check invalid.");
GELOGE(GE_GRAPH_NULL_INPUT, "[Check][Param] compute_graph_ is nullptr.");
return FAILED;
}
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Run enginePlacer failed");
REPORT_INNER_ERROR("E19999", "GELib instance is nullptr or it is not InitFlag, check invalid.");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib] Run enginePlacer failed, because GELib is invalid.");
return FAILED;
}
return SUCCESS;
@@ -87,13 +89,13 @@ Status EnginePlacer::Run() {
is_check_support_success = false;
ErrorManager::GetInstance().ATCReportErrMessage(
"E13003", {"opname", "optype"}, {op_desc->GetName(), op_desc->GetType()});
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Can not find engine of op type %s",
node_ptr->GetOpDesc()->GetType().c_str());
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] Can not find engine of op name %s type %s",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
continue;
}
}
if (AssignEngineAndLog(node_ptr, engine_name) != SUCCESS) {
GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "[GraphPartitioner]: AssignEngineAndLog FAILED");
GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "[Call][AssignEngineAndLog] FAILED, node:%s", op_desc->GetName().c_str());
return FAILED;
}
}
@@ -107,7 +109,8 @@ Status EnginePlacer::Run() {

Status EnginePlacer::AssignEngineAndLog(ge::ConstNodePtr node_ptr, const std::string &engine_name) {
if ((node_ptr == nullptr) || (node_ptr->GetOpDesc() == nullptr)) {
GELOGE(FAILED, "node_ptr is null.");
REPORT_INNER_ERROR("E19999", "Param node_ptr is nullptr or it's opdesc is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] node_ptr is nullptr.");
return FAILED;
}



+ 232
- 93
ge/graph/partition/graph_partition.cc View File

@@ -49,13 +49,18 @@ Status ge::GraphPartitioner::CheckIfEnd2PldEmpty(ge::ComputeGraphPtr &output_mer
if (graph_info_.partitions_.size() == kOneGraph) {
auto partition = (*graph_info_.partitions_.begin());
if (partition.first == nullptr) {
GELOGE(GE_GRAPH_EMPTY_PARTITION, "[GraphPartitioner]: partition.first is null, engine name is %s",
REPORT_INNER_ERROR("E19999", "partition.first is nullptr, check invalid, engine name is %s",
partition.second.c_str());
GELOGE(GE_GRAPH_EMPTY_PARTITION, "[Check][Param] partition.first is null, engine name is %s",
partition.second.c_str());
return FAILED;
}
output_merged_compute_graph = partition.first;
} else { // if placeholder to end map is empty, it should be an exception condition
GELOGE(GE_GRAPH_EMPTY_PARTITION, "[GraphPartitioner]: placeholder to end map is empty, partitions size is not 1.");
REPORT_INNER_ERROR("E19999", "partitions size:%zu is not 1, check invalid.", graph_info_.partitions_.size());
GELOGE(GE_GRAPH_EMPTY_PARTITION,
"[Check][Param] placeholder to end map is empty, partitions size:%zu is not 1.",
graph_info_.partitions_.size());
return FAILED;
}
return SUCCESS;
@@ -80,7 +85,8 @@ Status ge::GraphPartitioner::MergeAllSubGraph(ge::ComputeGraphPtr &output_merged
(void)AttrUtils::SetStr(node->GetOpDesc(), ATTR_NAME_STREAM_LABEL, temp_stream);
}
if (node->SetOwnerComputeGraph(output_merged_compute_graph) != GRAPH_SUCCESS) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "SetownerComputeGraph failed, node %s", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph for node:%s failed.", node->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Set][OwnerComputeGraph] failed, node %s", node->GetName().c_str());
return FAILED;
}
(void)output_merged_compute_graph->AddNode(node);
@@ -111,7 +117,8 @@ Status ge::GraphPartitioner::RemoveNodeAndEdgeBetweenEndPld(ge::ComputeGraphPtr
const std::vector<SubGraphInfoPtr> &sub_graph_list) {
if ((output_merged_compute_graph == nullptr) ||
(MergeAllSubGraph(output_merged_compute_graph, sub_graph_list) != SUCCESS)) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MergeAllSubGraph failed.");
REPORT_INNER_ERROR("E19999", "output_merged_compute_graph is nullptr or Call MergeAllSubGraph failed.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Merge][AllSubGraph] failed.");
return FAILED;
}
for (const auto &it : graph_info_.index_2_end_) {
@@ -127,19 +134,31 @@ Status ge::GraphPartitioner::RemoveNodeAndEdgeBetweenEndPld(ge::ComputeGraphPtr
: Anchor::DynamicAnchorCast<Anchor>(pld->GetOutDataAnchor(0));
auto src_anchor = end_in_anchor->GetFirstPeerAnchor(); // src_anchor should be only 1
if (GraphUtils::RemoveEdge(src_anchor, end_in_anchor) != GRAPH_SUCCESS) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: RemoveEdge failed. node_name:%s, graph_name:%s",
REPORT_CALL_ERROR("E19999", "RemoveEdge between %s and %s failed",
src_anchor->GetOwnerNode()->GetName().c_str(),
end_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Remove][Edge] between %s and %s failed. node_name:%s, graph_name:%s",
src_anchor->GetOwnerNode()->GetName().c_str(), end_in_anchor->GetOwnerNode()->GetName().c_str(),
end->GetName().c_str(), end->GetOwnerComputeGraph()->GetName().c_str());
return FAILED;
}
GE_CHECK_NOTNULL(pld_out_anchor);
for (const auto &peer_in_anchor : pld_out_anchor->GetPeerAnchors()) {
if (GraphUtils::RemoveEdge(pld_out_anchor, peer_in_anchor) != GRAPH_SUCCESS) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: RemoveEdge failed. node_name:%s, graph_name:%s",
REPORT_CALL_ERROR("E19999", "RemoveEdge between %s and %s failed",
pld_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Remove][Edge] between %s and %s failed. node_name:%s, graph_name:%s",
pld_out_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(),
pld->GetName().c_str(), pld->GetOwnerComputeGraph()->GetName().c_str());
return FAILED;
}
if (GraphUtils::AddEdge(src_anchor, peer_in_anchor) != GRAPH_SUCCESS) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "merge two subgraph fail.");
REPORT_CALL_ERROR("E19999", "AddEdge from %s to %s failed.",
src_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Add][Edge] from %s to %s failed.",
src_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
}
@@ -157,7 +176,7 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr
if (ret != SUCCESS) {
// even though failed, ensure all op do finish check support
real_ret = FAILED;
GELOGE(ret, "Graph merging Failed");
GELOGE(ret, "[Merge][SubGraph] Failed, ret:%d", ret);
}
GE_CHECK_NOTNULL(original_compute_graph);
// partition sub graph
@@ -166,7 +185,7 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr
ret = MergeSubGraph(merged_sub_graph, sub_graph);
if (ret != SUCCESS) {
real_ret = FAILED;
GELOGE(ret, "Sub graph merging Failed");
GELOGE(ret, "[Merge][SubGraph] Failed, ret:%d", ret);
continue;
}
// add sub graph
@@ -176,19 +195,32 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr
merged_sub_graph->SetOutputSize(sub_graph->GetOutputSize());
auto parent_node = sub_graph->GetParentNode();
GE_IF_BOOL_EXEC(parent_node == nullptr,
GELOGE(FAILED, "Parent node is null, graph name is %s", sub_graph->GetName().c_str());
REPORT_INNER_ERROR("E19999", "Parent node of graph:%s is nullptr.",
sub_graph->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Parent node is null, graph name is %s",
sub_graph->GetName().c_str());
return FAILED;)
auto original_graph = parent_node->GetOwnerComputeGraph();
GE_IF_BOOL_EXEC(graph_2_graph_partition_info_.find(original_graph) == graph_2_graph_partition_info_.end(),
GELOGE(FAILED, "Find graph info failed, graph name is %s", original_graph->GetName().c_str());
REPORT_INNER_ERROR("E19999", "graph:%s not find in graph_2_graph_partition_info_, check invalid.",
original_graph->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Find graph info failed, graph name is %s",
original_graph->GetName().c_str());
return FAILED;)
auto graph_info = graph_2_graph_partition_info_[original_graph];
GE_IF_BOOL_EXEC(graph_info.corresponding_node_in_partitions_.count(parent_node) == 0,
GELOGE(FAILED, "Find corresponding node failed, parent node name is %s", parent_node->GetName().c_str());
return FAILED;)
REPORT_INNER_ERROR("E19999", "node:%s not find in corresponding_node_in_partitions_, "
"check invalid", parent_node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Find corresponding node failed, parent node name is %s",
parent_node->GetName().c_str());
return FAILED;)
auto corresponding_node = graph_info.corresponding_node_in_partitions_[parent_node];
GE_IF_BOOL_EXEC(corresponding_node == nullptr, GELOGE(FAILED, "Get null node, node name is %s",
parent_node->GetName().c_str()); return FAILED;);
GE_IF_BOOL_EXEC(corresponding_node == nullptr,
REPORT_INNER_ERROR("E19999", "Get null node in corresponding_node_in_partitions_, "
"first node name is %s", parent_node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Get null node in corresponding_node_in_partitions_, "
"first node name is %s", parent_node->GetName().c_str());
return FAILED;);
merged_sub_graph->SetParentNode(corresponding_node);
auto subgraph_parent_graph = corresponding_node->GetOwnerComputeGraph();
merged_sub_graph->SetParentGraph(subgraph_parent_graph);
@@ -207,12 +239,17 @@ Status ge::GraphPartitioner::MergeAfterSubGraphOptimization(ge::ComputeGraphPtr
Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_compute_graph,
const ge::ComputeGraphPtr &original_compute_graph) {
if (original_compute_graph == nullptr) {
GELOGE(GE_GRAPH_NULL_INPUT, "[GraphPartitioner]: compute_graph is null.");
REPORT_INNER_ERROR("E19999", "Param original_compute_graph is nullptr, check invalid.");
GELOGE(GE_GRAPH_NULL_INPUT, "[Check][Param] original_compute_graph is nullptr.");
return FAILED;
}
if ((graph_2_graph_partition_info_.find(original_compute_graph) == graph_2_graph_partition_info_.end()) ||
(graph_2_subgraph_list_.find(original_compute_graph) == graph_2_subgraph_list_.end())) {
GELOGE(GE_GRAPH_NULL_INPUT, "[GraphPartitioner]: compute_graph is error.");
REPORT_INNER_ERROR("E19999", "original_compute_graph:%s is not find in graph_2_graph_partition_info_.",
original_compute_graph->GetName().c_str());
GELOGE(GE_GRAPH_NULL_INPUT,
"[Check][Param] original_compute_graph:%s is not find in graph_2_graph_partition_info_.",
original_compute_graph->GetName().c_str());
return FAILED;
}
GraphPartitionInfo &subgraph_info = graph_2_graph_partition_info_[original_compute_graph];
@@ -220,14 +257,16 @@ Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_co
graph_info_ = subgraph_info;

if (graph_info_.mode_ != kMerging) {
GELOGE(GE_GRAPH_UNSUPPORTED, "Cannot call merging in partition mode");
REPORT_INNER_ERROR("E19999", "Cannot call merging in partition mode, as mode != %d", kMerging);
GELOGE(GE_GRAPH_UNSUPPORTED, "[Check][Param] Cannot call merging in partition mode, as mode != %d", kMerging);
return FAILED;
}
GELOGD("Graph merge starts.");
// check input param
for (const auto &it : sub_graph_list) {
if (it == nullptr) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: merging sub-graphs failed, sub-graph is null");
REPORT_INNER_ERROR("E19999", "sub_graph is nullptr, check invalid.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] merging sub-graphs failed, sub-graph is nullptr");
return FAILED;
}
}
@@ -242,14 +281,16 @@ Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_co
output_merged_compute_graph = new_sub_graph;
GE_TIMESTAMP_START(MergeSubGraphRemoveNode);
if (RemoveNodeAndEdgeBetweenEndPld(output_merged_compute_graph, sub_graph_list) != ge::SUCCESS) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: merging sub-graphs failed");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Call][RemoveNodeAndEdgeBetweenEndPld] failed, graph:%s",
output_merged_compute_graph->GetName().c_str());
return FAILED;
}
GE_TIMESTAMP_END(MergeSubGraphRemoveNode, "GraphPartitioner::MergeGraphRemoveNodeAndEdge");
GE_TIMESTAMP_START(MergeSubGraphTopologicalSorting);
Status ret = output_merged_compute_graph->TopologicalSorting();
if (ret != SUCCESS) {
GELOGE(GE_GRAPH_TOPO_SORT_FAILED, "[GraphPartitioner]: output_merged_compute_graph->TopologicalSorting failed");
GELOGE(GE_GRAPH_TOPO_SORT_FAILED, "[Call][TopologicalSorting] for output_merged_compute_graph:%s failed",
output_merged_compute_graph->GetName().c_str());
return FAILED;
}
GE_TIMESTAMP_END(MergeSubGraphTopologicalSorting, "GraphPartitioner::MergeGraphTopologicalSorting");
@@ -257,7 +298,8 @@ Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_co
GE_TIMESTAMP_START(MergeSubGraphEnginePlacerRun);
graph_info_.engine_placer_.SetComputeGraph(output_merged_compute_graph);
if (graph_info_.engine_placer_.Run() != SUCCESS) {
GELOGE(GE_GRAPH_INIT_FAILED, "[GraphPartitioner]: engine_placer run failed");
GELOGE(GE_GRAPH_INIT_FAILED, "[Call][Run] engine_placer run failed, graph:%s",
output_merged_compute_graph->GetName().c_str());
return FAILED;
}
GE_TIMESTAMP_END(MergeSubGraphEnginePlacerRun, "GraphPartitioner::MergeGraphEnginePlacerRun");
@@ -267,17 +309,22 @@ Status ge::GraphPartitioner::MergeSubGraph(ge::ComputeGraphPtr &output_merged_co

Status ge::GraphPartitioner::UpdatePldOpDesc(const NodePtr &dst_node, int input_index, OpDescPtr &pld_op_desc) {
if ((dst_node == nullptr) || (pld_op_desc == nullptr) || (dst_node->GetOpDesc() == nullptr)) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param dst_node or pld_op_desc or op of dst_node is nullptr, check invalid");
GELOGE(FAILED, "[Check][Param] parameter ptr is null.");
return FAILED;
}
const auto &input_desc = dst_node->GetOpDesc()->GetInputDesc(static_cast<uint32_t>(input_index));
GE_IF_BOOL_EXEC(pld_op_desc->AddOutputDesc(input_desc) != GRAPH_SUCCESS, GELOGE(FAILED, "AddOutputDesc failed");
return FAILED;)
GE_IF_BOOL_EXEC(pld_op_desc->AddOutputDesc(input_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "AddOutputDesc to op:%s failed", pld_op_desc->GetName().c_str());
GELOGE(FAILED, "[Add][OutputDesc] to op:%s failed", pld_op_desc->GetName().c_str());
return FAILED;)
if (pld_op_desc->MutableOutputDesc(0) != nullptr) {
ge::TensorUtils::SetRealDimCnt(*(pld_op_desc->MutableOutputDesc(0).get()),
static_cast<uint32_t>(input_desc.GetShape().GetDims().size()));
} else {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: pld_op_desc is null.");
REPORT_INNER_ERROR("E19999", "output(0) of op:%s is nullptr, check invalid", pld_op_desc->GetName().c_str());
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[Check][Param] output(0) of op:%s is nullptr.",
pld_op_desc->GetName().c_str());
return FAILED;
}
return SUCCESS;
@@ -285,17 +332,22 @@ Status ge::GraphPartitioner::UpdatePldOpDesc(const NodePtr &dst_node, int input_

Status ge::GraphPartitioner::UpdateEndOpDesc(const NodePtr &src_node, int output_index, OpDescPtr &end_op_desc) {
if ((src_node == nullptr) || (end_op_desc == nullptr) || (src_node->GetOpDesc() == nullptr)) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param src_node or end_op_desc or op of src_node is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] parameter ptr is null.");
return FAILED;
}
const auto &output_desc = src_node->GetOpDesc()->GetOutputDesc(static_cast<uint32_t>(output_index));
GE_IF_BOOL_EXEC(end_op_desc->AddInputDesc(output_desc) != GRAPH_SUCCESS, GELOGE(FAILED, "AddInputDesc failed");
return FAILED;)
GE_IF_BOOL_EXEC(end_op_desc->AddInputDesc(output_desc) != GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "AddInputDesc to op:%s failed", end_op_desc->GetName().c_str());
GELOGE(FAILED, "[Add][InputDesc] to op:%s failed", end_op_desc->GetName().c_str());
return FAILED;)
if (end_op_desc->MutableInputDesc(0) != nullptr) {
ge::TensorUtils::SetRealDimCnt(*(end_op_desc->MutableInputDesc(0).get()),
static_cast<uint32_t>(output_desc.GetShape().GetDims().size()));
} else {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: pld_op_desc is null.");
REPORT_INNER_ERROR("E19999", "input(0) of op:%s is nullptr, check invalid.", end_op_desc->GetName().c_str());
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[Check][Param] input(0) of op:%s is nullptr.",
end_op_desc->GetName().c_str());
return FAILED;
}
return SUCCESS;
@@ -315,7 +367,8 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
string end_name = kEndType + std::to_string(graph_info_.num_of_pld_end_);
auto end_op_desc = MakeShared<OpDesc>(end_graph->GetName() + "_" + end_name, END);
if (end_op_desc == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "pld_op_desc is nullptr.");
REPORT_CALL_ERROR("E19999", "New Memory for OpDesc failed.");
GELOGE(GRAPH_PARAM_INVALID, "[New][Memory] for OpDesc failed, pld_op_desc is nullptr.");
return FAILED;
}
GE_IF_BOOL_EXEC(!AttrUtils::SetInt(end_op_desc, "peerIndex", graph_info_.num_of_pld_end_),
@@ -333,28 +386,40 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
bool is_need_update_desc = (output_index >= 0) && (graph_info_.mode_ == kPartitioning);
if (is_need_update_desc) {
if (UpdateEndOpDesc(src_node, output_index, end_op_desc) != SUCCESS) {
GELOGE(GRAPH_PARAM_INVALID, "UpdateEndOpDesc failed, input index %d", output_index);
GELOGE(GRAPH_PARAM_INVALID, "[Update][EndOpDesc] failed, input index:%d, end_op_desc:%s",
output_index, end_op_desc->GetName().c_str());
return FAILED;
}
} else {
GeTensorDesc input_desc;
if (end_op_desc->AddInputDesc(input_desc) != SUCCESS) {
GELOGE(GRAPH_PARAM_INVALID, "AddInputDesc failed, input index %d", output_index);
REPORT_CALL_ERROR("E19999", "add input desc to op:%s failed, input index:%d",
end_op_desc->GetName().c_str(), output_index);
GELOGE(GRAPH_PARAM_INVALID, "[Add][InputDesc] to op:%s failed, input index %d",
end_op_desc->GetName().c_str(), output_index);
return FAILED;
}
}
NodePtr new_end_node = end_graph->AddNode(end_op_desc);
if (new_end_node == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "new_end_node is nullptr.");
REPORT_CALL_ERROR("E19999", "add node:%s in graph:%s failed",
end_op_desc->GetName().c_str(), end_graph->GetName().c_str());
GELOGE(GRAPH_PARAM_INVALID, "[Add][Node] %s in graph:%s failed.",
end_op_desc->GetName().c_str(), end_graph->GetName().c_str());
return FAILED;
}
GE_IF_BOOL_EXEC(new_end_node->SetOwnerComputeGraph(end_graph) != GRAPH_SUCCESS,
GELOGE(GRAPH_PARAM_INVALID, "SetOwnerComputeGraph failed");
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph %s for node:%s failed",
end_graph->GetName().c_str(), new_end_node->GetName().c_str());
GELOGE(GRAPH_PARAM_INVALID, "[Set][OwnerComputeGraph] %s for node:%s failed",
end_graph->GetName().c_str(), new_end_node->GetName().c_str());
return FAILED;)
AnchorPtr end_dst_anchor = GetEndInAnchor(out_anchor, new_end_node);
if (GraphUtils::AddEdge(out_anchor, end_dst_anchor) != GRAPH_SUCCESS) {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "add end node : %s node %dth out-anchor --> end in %s subgraph fail.",
src_node->GetName().c_str(), AnchorUtils::GetIdx(out_anchor), end_graph->GetName().c_str());
REPORT_CALL_ERROR("E19999", "add edge from %s to %s failed", out_anchor->GetOwnerNode()->GetName().c_str(),
end_dst_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[Add][Edge] from %s to %s failed",
out_anchor->GetOwnerNode()->GetName().c_str(), end_dst_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
/// For fe, op id has been set in AddNode,
@@ -365,7 +430,8 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
const string pld_name = kPlaceHolderType + std::to_string(graph_info_.num_of_pld_end_);
auto pld_op_desc = MakeShared<OpDesc>(pld_graph->GetName() + "_" + pld_name, PLACEHOLDER);
if (pld_op_desc == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "pld_op_desc is nullptr.");
REPORT_CALL_ERROR("E19999", "New Memory for OpDesc failed.");
GELOGE(GRAPH_PARAM_INVALID, "[New][Memory] for OpDesc failed.");
return FAILED;
}
GE_IF_BOOL_EXEC(!AttrUtils::SetInt(pld_op_desc, "peerIndex", graph_info_.num_of_pld_end_),
@@ -401,30 +467,42 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
is_need_update_desc = (input_index >= 0) && (graph_info_.mode_ == kPartitioning);
if (is_need_update_desc) {
if (UpdatePldOpDesc(dst_node, input_index, pld_op_desc) != SUCCESS) {
GELOGE(GRAPH_PARAM_INVALID, "UpdateEndOpDesc failed, output index %d", input_index);
GELOGE(GRAPH_PARAM_INVALID, "[Update][PldOpDesc] failed, output index:%d, pld_op_desc:%s",
input_index, pld_op_desc->GetName().c_str());
return FAILED;
}
} else {
GeTensorDesc output_desc;
if (pld_op_desc->AddOutputDesc(output_desc) != SUCCESS) {
GELOGE(GRAPH_PARAM_INVALID, "AddOutputDesc failed, input index %d", input_index);
REPORT_CALL_ERROR("E19999", "AddOutputDesc to op:%s failed, input index %d",
pld_op_desc->GetName().c_str(), input_index);
GELOGE(GRAPH_PARAM_INVALID, "[Add][OutputDesc] to op:%s failed, input index %d",
pld_op_desc->GetName().c_str(), input_index);
return FAILED;
}
}
NodePtr new_pld_node = pld_graph->AddNode(pld_op_desc);
if (new_pld_node == nullptr) {
GELOGE(GRAPH_PARAM_INVALID, "new_pld_node is nullptr.");
REPORT_CALL_ERROR("E19999", "AddNode %s in graph:%s failed.",
pld_op_desc->GetName().c_str(), pld_graph->GetName().c_str());
GELOGE(GRAPH_PARAM_INVALID, "[Add][Node] %s in graph:%s failed.",
pld_op_desc->GetName().c_str(), pld_graph->GetName().c_str());
return FAILED;
}
GE_IF_BOOL_EXEC(new_pld_node->SetOwnerComputeGraph(pld_graph) != GRAPH_SUCCESS,
GELOGE(GRAPH_PARAM_INVALID, "SetOwnerComputeGraph failed");
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph for node:%s failed, graph:%s",
new_pld_node->GetName().c_str(), pld_graph->GetName().c_str());
GELOGE(GRAPH_PARAM_INVALID, "[Set][OwnerComputeGraph] for node:%s failed, graph:%s",
new_pld_node->GetName().c_str(), pld_graph->GetName().c_str());
return FAILED;)
AnchorPtr pld_src_anchor = GetPldOutAnchor(new_pld_node, peer_in_anchor);
// link placeHolder -> computeNode
if (GraphUtils::AddEdge(pld_src_anchor, peer_in_anchor) != GRAPH_SUCCESS) {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED,
"add placeholder node : placeholder --> %s node %dth in-anchor in %s subgraph fail.",
dst_node->GetName().c_str(), AnchorUtils::GetIdx(peer_in_anchor), pld_graph->GetName().c_str());
REPORT_CALL_ERROR("E19999", "AddEdge from %s to %s failed",
pld_src_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[Add][Edge] from %s to %s failed",
pld_src_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
graph_info_.index_2_end_[graph_info_.num_of_pld_end_] = new_end_node;
@@ -436,7 +514,8 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
Status ge::GraphPartitioner::LinkInput2EndRemoveOrginalLink(ge::NodePtr input_node, ge::ComputeGraphPtr src_graph,
ge::ComputeGraphPtr dst_graph) {
if ((input_node == nullptr) || (src_graph == nullptr) || (dst_graph == nullptr)) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param input_node or src_graph or dst_graph is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] parameter input_node or src_graph or dst_graph is nullptr.");
return FAILED;
}
// get the original anchors and remove the original link
@@ -444,27 +523,40 @@ Status ge::GraphPartitioner::LinkInput2EndRemoveOrginalLink(ge::NodePtr input_no
for (auto &peer_in_anchor : out_data_anchor->GetPeerAnchors()) {
if (peer_in_anchor->GetOwnerNode()->GetType() != kEndType) {
if (GraphUtils::RemoveEdge(out_data_anchor, peer_in_anchor) != GRAPH_SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: RemoveEdge() failed.");
REPORT_CALL_ERROR("E19999", "RemoveEdge between %s and %s failed.",
out_data_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] between %s and %s failed.",
out_data_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
// link input -> end
auto ret = AddPlaceHolderEndInSrcDstGraph(out_data_anchor, peer_in_anchor, src_graph, dst_graph);
if (ret != SUCCESS) {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: AddPlaceHolderEndInSrcDstGraph() failed.");
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[Call][AddPlaceHolderEndInSrcDstGraph] failed, ret:%d.", ret);
return ret;
}
} else {
auto end_node = peer_in_anchor->GetOwnerNode();
if (GraphUtils::RemoveJustNode(src_graph, end_node) != GRAPH_SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: RemoveJustNode() failed.");
REPORT_CALL_ERROR("E19999", "RemoveJustNode %s from graph:%s failed.",
end_node->GetName().c_str(), src_graph->GetName().c_str());
GELOGE(FAILED, "[Remove][JustNode] %s from graph:%s failed.",
end_node->GetName().c_str(), src_graph->GetName().c_str());
return FAILED;
}
if (end_node->SetOwnerComputeGraph(dst_graph) != GRAPH_SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: RemoveJustNode() failed.");
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph for node:%s failed, graph:%s.",
end_node->GetName().c_str(), dst_graph->GetName().c_str());
GELOGE(FAILED, "[Set][OwnerComputeGraph] to node:%s failed, graph:%s.",
end_node->GetName().c_str(), dst_graph->GetName().c_str());
return FAILED;
}
if (dst_graph->AddNode(end_node) == nullptr) {
GELOGE(FAILED, "[GraphPartitioner]: AddNode() failed.");
REPORT_CALL_ERROR("E19999", "AddNode %s in graph:%s failed.",
end_node->GetName().c_str(), dst_graph->GetName().c_str());
GELOGE(FAILED, "[Add][Node] %s in graph:%s failed.",
end_node->GetName().c_str(), dst_graph->GetName().c_str());
return FAILED;
}
}
@@ -476,27 +568,37 @@ Status ge::GraphPartitioner::LinkInput2EndRemoveOrginalLink(ge::NodePtr input_no
Status ge::GraphPartitioner::PutInputNodesInSubGraph(const ge::ComputeGraphPtr &src_graph,
const ge::ComputeGraphPtr &dst_graph) {
if ((src_graph == nullptr) || (dst_graph == nullptr)) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param src_graph or dst_graph is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] parameter src_graph or dst_graph is nullptr.");
return FAILED;
}
for (auto &input_node : src_graph->GetDirectNode()) {
if (IsDataLike(input_node)) {
if (input_node->SetOwnerComputeGraph(dst_graph) != GRAPH_SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: SetOwnerComputeGraph failed.");
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph for node:%s failed, graph:%s.",
input_node->GetName().c_str(), dst_graph->GetName().c_str());
GELOGE(FAILED, "[Set][OwnerComputeGraph] for node:%s failed, graph:%s.",
input_node->GetName().c_str(), dst_graph->GetName().c_str());
return FAILED;
}
// remove input node from src_graph
if (GraphUtils::RemoveJustNode(src_graph, input_node) != GRAPH_SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: RemoveJustNode() failed.");
REPORT_CALL_ERROR("E19999", "RemoveJustNode %s from graph:%s failed.",
input_node->GetName().c_str(), src_graph->GetName().c_str());
GELOGE(FAILED, "[Remove][JustNode] %s from graph:%s failed.",
input_node->GetName().c_str(), src_graph->GetName().c_str());
return FAILED;
}
// add input node to dst_graph
if (dst_graph->AddNode(input_node) == nullptr) {
GELOGE(FAILED, "[GraphPartitioner]: AddNode() failed.");
REPORT_CALL_ERROR("E19999", "AddNode %s in graph:%s failed.",
input_node->GetName().c_str(), src_graph->GetName().c_str());
GELOGE(FAILED, "[Add][Node] %s in graph:%s failed.",
input_node->GetName().c_str(), src_graph->GetName().c_str());
return FAILED;
}
if (LinkInput2EndRemoveOrginalLink(input_node, src_graph, dst_graph) != ge::SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: LinkInput2EndRemoveOrginalLink() failed.");
GELOGE(FAILED, "[Call][LinkInput2EndRemoveOrginalLink] failed.");
return FAILED;
}
}
@@ -519,7 +621,7 @@ bool ge::GraphPartitioner::IsDataLike(ge::NodePtr node) {

bool ge::GraphPartitioner::HasNoInput(ge::NodePtr node) {
if (node == nullptr) {
GELOGE(FAILED, "node_ptr is null.");
GELOGE(FAILED, "[Check][Param] node is nullptr.");
return true;
}
return node->GetInNodes().empty();
@@ -529,12 +631,13 @@ Status ge::GraphPartitioner::Initialize(ge::ComputeGraphPtr compute_graph) {
GELOGI("Initialize starts.");
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || compute_graph == nullptr) {
GELOGE(GE_GRAPH_NOT_INIT, "Graph partitioner initialize failed.");
REPORT_INNER_ERROR("E19999", "compute_graph or instance_ptr of GELib is nullptr, check invalid.");
GELOGE(GE_GRAPH_NOT_INIT, "[Check][Param] compute_graph or instance_ptr of GELib is nullptr.");
return FAILED;
}
graph_info_.engine_placer_.SetComputeGraph(compute_graph);
if (graph_info_.engine_placer_.Run() != SUCCESS) {
GELOGE(FAILED, "Engine placer run failed.");
GELOGE(FAILED, "[Call][Run] Engine placer run failed, graph:%s.", compute_graph->GetName().c_str());
return FAILED;
}
const NodeEngineMap *node_engine_map = graph_info_.engine_placer_.GetNodeEngineMap();
@@ -552,14 +655,16 @@ Status ge::GraphPartitioner::Initialize(ge::ComputeGraphPtr compute_graph) {
new_cluster = cluster;
} else {
if (node_engine_map->count(node) == 0) {
GELOGE(FAILED, "node[%s] does not owner engine!", node->GetName().c_str());
REPORT_INNER_ERROR("E19999", "node:%s not find in node_engine_map", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] node[%s] does not owner engine!", node->GetName().c_str());
return FAILED;
}
ClusterPtr cluster = MakeShared<Cluster>(temp_index, node_engine_map->at(node), temp_stream);
new_cluster = cluster;
}
if (new_cluster == nullptr) {
GELOGE(FAILED, "[GraphPartitioner]: failed to allocate new_cluster");
REPORT_CALL_ERROR("E19999", "Allocate Cluster failed, index:%zu", temp_index);
GELOGE(FAILED, "[Allocate][Cluster] failed, index:%zu", temp_index);
return FAILED;
}
new_cluster->nodes_.push_back(node);
@@ -570,11 +675,11 @@ Status ge::GraphPartitioner::Initialize(ge::ComputeGraphPtr compute_graph) {
if (parent_id < node_id) {
auto iter = graph_info_.node_2_cluster_.find(parent);
if (iter == graph_info_.node_2_cluster_.end()) {
GELOGE(FAILED,
"[GraphPartitioner]: node[%s]id[%ld]'s parent_node[%s]id[%ld]"
"should make cluster in advance",
node->GetOpDesc()->GetName().c_str(), node_id,
parent->GetOpDesc()->GetName().c_str(), parent_id);
REPORT_INNER_ERROR("E19999", "node[%s]id[%ld]'s parent_node[%s]id[%ld] should make cluster in advance",
node->GetOpDesc()->GetName().c_str(), node_id,
parent->GetOpDesc()->GetName().c_str(), parent_id);
GELOGE(FAILED, "[Check][Param] node[%s]id[%ld]'s parent_node[%s]id[%ld] should make cluster in advance",
node->GetOpDesc()->GetName().c_str(), node_id, parent->GetOpDesc()->GetName().c_str(), parent_id);
return FAILED;
}
new_cluster->in_clu_.insert(iter->second->index_);
@@ -603,7 +708,8 @@ Status ge::GraphPartitioner::AddPartitionsToGraphNode(vector<ge::SubGraphInfoPtr
// the output_subgraphs have topological order
for (const auto &sub_graph : graph_info_.rank_2_partitions_) {
if (graph_info_.partitions_.find(sub_graph) == graph_info_.partitions_.end()) {
GELOGE(GE_GRAPH_EMPTY_PARTITION, "[GraphPartitioner]: partition is null.");
REPORT_INNER_ERROR("E19999", "partition is null, subgraph:%s", sub_graph->GetName().c_str());
GELOGE(GE_GRAPH_EMPTY_PARTITION, "[Check][Param] partition is null, subgraph:%s", sub_graph->GetName().c_str());
return FAILED;
}
auto &engine_name = graph_info_.partitions_.at(sub_graph);
@@ -619,7 +725,8 @@ Status ge::GraphPartitioner::AddPartitionsToGraphNode(vector<ge::SubGraphInfoPtr
sub_graph->SetParentNode(compute_graph->GetParentNode());
auto sgi = MakeShared<SubGraphInfo>();
if (sgi == nullptr) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MakeShared sub graph info failed.");
REPORT_CALL_ERROR("E19999", "allocate memory for SubGraphInfo failed.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Allocate][Memory] for SubGraphInfo failed.");
return FAILED;
}
// set engine name
@@ -767,7 +874,8 @@ void ge::GraphPartitioner::MarkClusters() {
Status ge::GraphPartitioner::SplitSubGraphs(ge::ComputeGraphPtr compute_graph) {
GELOGD("SplitSubGraphs starts.");
if (compute_graph == nullptr) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(FAILED, "[Check][Param] parameter ptr is null.");
return FAILED;
}
// Create graphs for all clusters
@@ -785,7 +893,8 @@ Status ge::GraphPartitioner::SplitSubGraphs(ge::ComputeGraphPtr compute_graph) {
std::string graph_name = "new_sub_graph" + std::to_string(graph_info_.partitions_.size());
ComputeGraphPtr new_sub_graph = MakeShared<ge::ComputeGraph>(graph_name);
if (new_sub_graph == nullptr) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: MakeShared() failed.");
REPORT_CALL_ERROR("E19999", "allocate memory for ge::ComputeGraph failed.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Allocate][Memory] for ge::ComputeGraph failed.");
return FAILED;
}
AddNewGraphToPartition(new_sub_graph, child_cluster->engine_name_);
@@ -796,7 +905,10 @@ Status ge::GraphPartitioner::SplitSubGraphs(ge::ComputeGraphPtr compute_graph) {
// build node to corresponding node map
NodePtr corresponding_node = corresponding_graph->AddNode(node->GetOpDesc());
if (corresponding_node == nullptr) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[GraphPartitioner]: AddNode() failed.");
REPORT_CALL_ERROR("E19999", "add node:%s in graph:%s failed",
node->GetName().c_str(), corresponding_graph->GetName().c_str());
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Add][Node] %s in graph:%s failed.",
node->GetName().c_str(), corresponding_graph->GetName().c_str());
return FAILED;
}
graph_info_.corresponding_node_in_partitions_[node] = corresponding_node;
@@ -808,8 +920,12 @@ Status ge::GraphPartitioner::SplitSubGraphs(ge::ComputeGraphPtr compute_graph) {
// Normally, all nodes have a copy in corresponding_node_in_partitions_, so function at can not be exception
auto iter = graph_info_.corresponding_node_in_partitions_.find(peer_out_anchor->GetOwnerNode());
if (iter == graph_info_.corresponding_node_in_partitions_.end()) {
GELOGE(GRAPH_FAILED,
"[SpiltSubGraphs]: node[%s]id[%ld]'s parent_node[%s]id[%ld]"
REPORT_INNER_ERROR("E19999", "node[%s]id[%ld]'s parent_node[%s]id[%ld]"
"should make corresponding in advance",
node->GetOpDesc()->GetName().c_str(), node->GetOpDesc()->GetId(),
peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetId());
GELOGE(GRAPH_FAILED, "[Check][Param] node[%s]id[%ld]'s parent_node[%s]id[%ld]"
"should make corresponding in advance",
node->GetOpDesc()->GetName().c_str(), node->GetOpDesc()->GetId(),
peer_out_anchor->GetOwnerNode()->GetOpDesc()->GetName().c_str(),
@@ -827,13 +943,19 @@ Status ge::GraphPartitioner::SplitSubGraphs(ge::ComputeGraphPtr compute_graph) {
if (parent_cluster != child_cluster) {
GELOGD("Parent cluster is %zu, child_cluster is %zu", parent_cluster->index_, child_cluster->index_);
if (AddPlaceHolderEnd(peer_out_anchor, in_anchor) != ge::SUCCESS) {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: AddPlaceHolderEndInSrcDstGraph() failed.");
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED,
"[Call][AddPlaceHolderEnd] failed, out_anchor:%s index:%d, in_anchor:%s index:%d.",
peer_out_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(peer_out_anchor),
in_anchor->GetOwnerNode()->GetName().c_str(), AnchorUtils::GetIdx(in_anchor));
return FAILED;
}
} else { // parent and child in the same cluster, add edge
GELOGD("AddEdge from parent cluster %zu to child %zu", parent_cluster->index_, child_cluster->index_);
if (GraphUtils::AddEdge(src_anchor, dst_anchor) != GRAPH_SUCCESS) {
GELOGE(GRAPH_FAILED, "AddEdge fail, from %s to %s", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
REPORT_CALL_ERROR("E19999", "add edge from %s to %s failed",
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Add][Edge] from %s to %s failed", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
@@ -880,7 +1002,7 @@ Status ge::GraphPartitioner::Partition(ge::ComputeGraphPtr compute_graph, Mode m
auto real_ret = SUCCESS;
auto ret = PartitionSubGraph(compute_graph, mode);
if (ret != SUCCESS) {
GELOGE(ret, "Sub graph partition Failed");
GELOGE(ret, "[Partition][SubGraph] Failed, ret:%d", ret);
real_ret = ret;
}
GE_CHECK_NOTNULL(compute_graph);
@@ -888,7 +1010,7 @@ Status ge::GraphPartitioner::Partition(ge::ComputeGraphPtr compute_graph, Mode m
for (const auto &sub_graph : compute_graph->GetAllSubgraphs()) {
ret = PartitionSubGraph(sub_graph, mode);
if (ret != SUCCESS) {
GELOGE(ret, "Sub graph partition Failed");
GELOGE(ret, "[Partition][SubGraph] Failed, ret:%d", ret);
real_ret = ret;
}
}
@@ -903,7 +1025,8 @@ Status ge::GraphPartitioner::Partition(ge::ComputeGraphPtr compute_graph, Mode m

Status ge::GraphPartitioner::PartitionSubGraph(ge::ComputeGraphPtr compute_graph, Mode mode) {
if (compute_graph == nullptr) {
GELOGE(GE_GRAPH_NULL_INPUT, "[GraphPartitioner]: compute_graph is null.");
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid.");
GELOGE(GE_GRAPH_NULL_INPUT, "[Check][Param] compute_graph is nullptr.");
return FAILED;
}
// clear graph_info
@@ -912,18 +1035,24 @@ Status ge::GraphPartitioner::PartitionSubGraph(ge::ComputeGraphPtr compute_graph
graph_info_.output_size_ = compute_graph->GetOutputSize();
graph_info_.input_size_ = compute_graph->GetInputSize();
if (graph_info_.output_size_ == 0) {
GELOGE(GE_GRAPH_NULL_INPUT, "The output size need to be greater than 0.");
REPORT_INNER_ERROR("E19999", "the output size of graph:%s is 0, check invalid.",
compute_graph->GetName().c_str());
GELOGE(GE_GRAPH_NULL_INPUT, "[Check][Param] The output size:0 of graph:%s need to be greater than 0.",
compute_graph->GetName().c_str());
return FAILED;
}
GELOGI("Graph Partition starts, graph nodes size is %zu", compute_graph->GetDirectNodesSize());
Status ret = compute_graph->TopologicalSorting();
if (ret != SUCCESS) {
GELOGE(GE_GRAPH_TOPO_SORT_FAILED, "[GraphPartitioner]: subGraphPtr->TopologicalSorting failed");
REPORT_CALL_ERROR("E19999", "TopologicalSorting for graph:%s failed",
compute_graph->GetName().c_str());
GELOGE(GE_GRAPH_TOPO_SORT_FAILED, "[Call][TopologicalSorting] for subGraph:%s failed",
compute_graph->GetName().c_str());
return FAILED;
}
GE_TIMESTAMP_START(PartitionSubGraphInitialize);
if (Initialize(compute_graph) != SUCCESS) {
GELOGE(GE_GRAPH_INIT_FAILED, "[GraphPartitioner]: initialize failed");
GELOGE(GE_GRAPH_INIT_FAILED, "[Call][Initialize] for graph:%s failed", compute_graph->GetName().c_str());
return FAILED;
}
GE_TIMESTAMP_END(PartitionSubGraphInitialize, "GraphPartitioner::PartitionInitialize");
@@ -932,20 +1061,22 @@ Status ge::GraphPartitioner::PartitionSubGraph(ge::ComputeGraphPtr compute_graph
GE_TIMESTAMP_END(PartitionSubGraphMarkClusters, "GraphPartitioner::PartitionMarkClusters");
GE_TIMESTAMP_START(PartitionSubGraphSplitSubGraphs);
if (SplitSubGraphs(compute_graph) != SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: SplitSubGraphs failed");
GELOGE(FAILED, "[Split][SubGraphs] for graph:%s failed", compute_graph->GetName().c_str());
return FAILED;
}
GE_TIMESTAMP_END(PartitionSubGraphSplitSubGraphs, "GraphPartitioner::PartitionSplitSubGraphs");
GE_TIMESTAMP_START(PartitionSubGraphSortSubGraphs);
if (SortSubGraphs(compute_graph) != ge::SUCCESS) {
GELOGE(GE_GRAPH_TOPO_SORT_FAILED, "Graph Partition SortSubGraphs failed.");
GELOGE(GE_GRAPH_TOPO_SORT_FAILED, "[Sort][SubGraphs] for graph:%s failed.",
compute_graph->GetName().c_str());
return ge::FAILED;
}
GE_TIMESTAMP_END(PartitionSubGraphSortSubGraphs, "GraphPartitioner::PartitionSortSubGraphs");
GE_TIMESTAMP_START(PartitionSubGraphAddPartitionsToGraphNode);
vector<ge::SubGraphInfoPtr> output_subgraphs;
if (AddPartitionsToGraphNode(output_subgraphs, compute_graph) != ge::SUCCESS) {
GELOGE(GE_GRAPH_EMPTY_PARTITION, "Graph Partition AddPartitionsToGraphNode failed.");
GELOGE(GE_GRAPH_EMPTY_PARTITION, "[Add][Partitions] To GraphNode failed, graph:%s.",
compute_graph->GetName().c_str());
return ge::FAILED;
}
GE_TIMESTAMP_END(PartitionSubGraphAddPartitionsToGraphNode, "GraphPartitioner::PartitionAddPartitionsToGraphNode");
@@ -961,14 +1092,16 @@ Status ge::GraphPartitioner::PartitionSubGraph(ge::ComputeGraphPtr compute_graph
// all the inputs are the nodes and anchors in the original graph
Status ge::GraphPartitioner::AddPlaceHolderEnd(const AnchorPtr &out_anchor, const AnchorPtr &in_anchor) {
if ((out_anchor == nullptr) || (in_anchor == nullptr)) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "src_node or dst_node is null.");
REPORT_INNER_ERROR("E19999", "Param out_anchor or in_anchor is nullptr, check invalid.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] out_anchor or in_anchor is nullptr.");
return FAILED;
}
// nodes in original graph
const auto &src_node = out_anchor->GetOwnerNode();
const auto &dst_node = in_anchor->GetOwnerNode();
if ((src_node == nullptr) || (dst_node == nullptr)) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "src_node or dst_node is null.");
REPORT_INNER_ERROR("E19999", "in_anchor'node or out_anchor'node is nullptr. check invalid.");
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] src_node or dst_node is nullptr.");
return FAILED;
}
// All nodes have a copy in corresponding_node_in_partitions_, so function at can not be execption
@@ -977,7 +1110,10 @@ Status ge::GraphPartitioner::AddPlaceHolderEnd(const AnchorPtr &out_anchor, cons
auto dst_anchor =
graph_info_.corresponding_node_in_partitions_.at(dst_node)->GetInAnchor(AnchorUtils::GetIdx(in_anchor));
if ((src_anchor == nullptr) || (dst_anchor == nullptr)) {
GELOGE(GE_GRAPH_PARAM_NULLPTR, "src_anchor or dst_anchor is null.");
REPORT_INNER_ERROR("E19999", "src_anchor(index:%d) or dst_anchor(index:%d) is nullptr.",
AnchorUtils::GetIdx(out_anchor), AnchorUtils::GetIdx(in_anchor));
GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] src_anchor(index:%d) or dst_anchor(index:%d) is nullptr.",
AnchorUtils::GetIdx(out_anchor), AnchorUtils::GetIdx(in_anchor));
return FAILED;
}
// anchors in subGraph
@@ -986,7 +1122,7 @@ Status ge::GraphPartitioner::AddPlaceHolderEnd(const AnchorPtr &out_anchor, cons
// add end and pld node
auto ret = AddPlaceHolderEndInSrcDstGraph(src_anchor, dst_anchor, dst_subgraph, src_subgraph);
if (ret != SUCCESS) {
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[GraphPartitioner]: add placeholder end failed.");
GELOGE(GE_GRAPH_ADD_PLC_END_FAILED, "[Call][AddPlaceHolderEndInSrcDstGraph] failed, ret:%d.", ret);
return ret;
}
return SUCCESS;
@@ -996,7 +1132,8 @@ Status ge::GraphPartitioner::SortSubGraphs(const ge::ComputeGraphPtr &compute_gr
uint32_t rank = kRankOne; // rank 0 for data graph
ComputeGraphPtr new_input_nodes_sub_graph = MakeShared<ComputeGraph>("inputNodeGraph");
if ((new_input_nodes_sub_graph == nullptr) || (compute_graph == nullptr)) {
GELOGE(FAILED, "[GraphPartitioner]: new_input_nodes_sub_graph or compute_graph is null.");
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr or Allocate Memory for ComputeGraph failed.");
GELOGE(FAILED, "[Check][Param] new_input_nodes_sub_graph or compute_graph is nullptr.");
return FAILED;
}
for (const auto &node : compute_graph->GetDirectNode()) {
@@ -1009,7 +1146,7 @@ Status ge::GraphPartitioner::SortSubGraphs(const ge::ComputeGraphPtr &compute_gr
rank++;
} else if (graph_info_.partitions_[sub_graph] == kEngineDefaultData) { // merge data graph
if (PutInputNodesInSubGraph(sub_graph, new_input_nodes_sub_graph) != SUCCESS) {
GELOGE(FAILED, "[GraphPartitioner]: putInputNodesInSubGraph failed.");
GELOGE(FAILED, "[Call][putInputNodesInSubGraph] failed.");
return FAILED;
}
auto to_be_del = graph_info_.partitions_.find(sub_graph);
@@ -1038,7 +1175,8 @@ Status ge::GraphPartitioner::SortSubGraphs(const ge::ComputeGraphPtr &compute_gr

AnchorPtr ge::GraphPartitioner::GetEndInAnchor(const AnchorPtr &src_anchor, const NodePtr &end_node) {
if ((src_anchor == nullptr) || (end_node == nullptr)) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param src_anchor or end_node is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] parameter src_anchor or end_node is nullptr.");
return nullptr;
}
AnchorPtr end_in_anchor;
@@ -1052,7 +1190,8 @@ AnchorPtr ge::GraphPartitioner::GetEndInAnchor(const AnchorPtr &src_anchor, cons

AnchorPtr ge::GraphPartitioner::GetPldOutAnchor(const NodePtr &pld_node, const AnchorPtr &dst_anchor) {
if ((pld_node == nullptr) || (dst_anchor == nullptr)) {
GELOGE(FAILED, "parameter ptr is null.");
REPORT_INNER_ERROR("E19999", "Param pld_node or dst_anchor is nullptr, check invalid.");
GELOGE(FAILED, "[Check][Param] parameter pld_node or dst_anchor is nullptr.");
return nullptr;
}
AnchorPtr pld_out_anchor;
@@ -1066,7 +1205,7 @@ AnchorPtr ge::GraphPartitioner::GetPldOutAnchor(const NodePtr &pld_node, const A

void ge::GraphPartitioner::AddEndPldInformationToSubGraphInfo(ge::SubGraphInfoPtr &subgraph_info) {
if (subgraph_info == nullptr) {
GELOGE(FAILED, "parameter ptr is null.");
GELOGE(FAILED, "[Check][Param] parameter subgraph_info is nullptr.");
return;
}
auto subgraph = subgraph_info->GetSubGraph();


+ 63
- 24
ge/graph/partition/stage_partition.cc View File

@@ -54,12 +54,12 @@ Status StagePartitioner::Partition() {

GE_DUMP(root_graph_, "BeforeStagePartition");
if (SplitStageLevel() != SUCCESS) {
GELOGE(FAILED, "Split graph-stage for graph %s failed.", root_graph_->GetName().c_str());
GELOGE(FAILED, "[Split][GraphStage] for graph %s failed.", root_graph_->GetName().c_str());
return FAILED;
}

if (StagePartition() != SUCCESS) {
GELOGE(FAILED, "Stage partition for graph %s failed.", root_graph_->GetName().c_str());
GELOGE(FAILED, "[Stage][Partition] for graph %s failed.", root_graph_->GetName().c_str());
return FAILED;
}

@@ -71,7 +71,7 @@ Status StagePartitioner::Partition() {
return a_level < b_level;
});
if (root_graph_->TopologicalSorting() != GRAPH_SUCCESS) {
GELOGE(FAILED, "Topological sort for graph %s after stage partition failed, "
GELOGE(FAILED, "[Call][TopologicalSorting] for graph %s after stage partition failed, "
"maybe stage_level was not set correctly.", root_graph_->GetName().c_str());
return FAILED;
}
@@ -103,7 +103,10 @@ Status StagePartitioner::SplitStageLevel() {
continue;
}
if (!AttrUtils::SetInt(in_node->GetOpDesc(), ATTR_STAGE_LEVEL, cur_stage_level)) {
GELOGE(INTERNAL_ERROR, "Set attr ATTR_STAGE_LEVEL on node %s failed.", in_node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Set Attr %s on node %s failed.",
ATTR_STAGE_LEVEL.c_str(), in_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s on node %s failed.",
ATTR_STAGE_LEVEL.c_str(), in_node->GetName().c_str());
return INTERNAL_ERROR;
}
GELOGD("Mark stage_level node %s, stage_level=%u", in_node->GetName().c_str(), cur_stage_level);
@@ -131,23 +134,26 @@ Status StagePartitioner::StagePartition() {
std::string subgraph_name = "Subgraph_Level_" + std::to_string(stage.first);
NodePtr graph_node = BuildSubgraphNode(subgraph_name, stage_info);
if (graph_node == nullptr) {
GELOGE(FAILED, "Build PartitionedCall node for stage %u failed.", stage.first);
GELOGE(FAILED, "[Build][SubgraphNode] for stage %u failed, graph name:%s.", stage.first, subgraph_name.c_str());
return FAILED;
}

ComputeGraphPtr subgraph = BuildStageGraph(graph_node, stage_info);
if (subgraph == nullptr) {
GELOGE(FAILED, "Build subgraph for stage %u failed.", stage.first);
GELOGE(FAILED, "[Build][StageGraph] %s for stage %u failed.", graph_node->GetName().c_str(), stage.first);
return FAILED;
}
if (root_graph_->AddSubgraph(subgraph) != GRAPH_SUCCESS) {
GELOGE(FAILED, "Add subgraph of stage %u failed.", stage.first);
REPORT_CALL_ERROR("E19999", "add subgraph:%s in root graph:%s of stage %u failed.",
subgraph->GetName().c_str(), root_graph_->GetName().c_str(), stage.first);
GELOGE(FAILED, "[Add][SubGraph] %s in root graph:%s of stage %u failed.",
subgraph->GetName().c_str(), root_graph_->GetName().c_str(), stage.first);
return FAILED;
}

if ((RelinkDataEdges(graph_node, stage_info) != SUCCESS) ||
(RelinkCtrlEdges(graph_node, stage_info) != SUCCESS)) {
GELOGE(FAILED, "Relink edges for stage %u failed.", stage.first);
GELOGE(FAILED, "[ReLink][Edges] for stage %u failed, graph_node:%s.", stage.first, graph_node->GetName().c_str());
return FAILED;
}

@@ -214,7 +220,7 @@ NodePtr StagePartitioner::BuildSubgraphNode(const std::string &graph_name, const
for (size_t i = 0; i < input_num; i++) {
auto input_desc = stage_info.data_inputs[i].second->GetOwnerNode()->GetOpDesc();
if (input_desc == nullptr) {
GELOGE(PARAM_INVALID, "op_desc is null, node: %s",
GELOGE(PARAM_INVALID, "[Check][Param] op_desc is null, node:%s",
stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str());
return nullptr;
}
@@ -225,7 +231,7 @@ NodePtr StagePartitioner::BuildSubgraphNode(const std::string &graph_name, const
for (size_t i = 0; i < output_num; i++) {
auto output_desc = stage_info.data_outputs[i].first->GetOwnerNode()->GetOpDesc();
if (output_desc == nullptr) {
GELOGE(PARAM_INVALID, "op_desc is null, node: %s",
GELOGE(PARAM_INVALID, "[Check][Param] op_desc is null, node:%s",
stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str());
return nullptr;
}
@@ -235,7 +241,7 @@ NodePtr StagePartitioner::BuildSubgraphNode(const std::string &graph_name, const

OpDescPtr op_desc = op_desc_builder.Build();
if (op_desc == nullptr) {
GELOGE(FAILED, "Create op_desc for subgraph node failed, name:%s.", graph_name.c_str());
GELOGE(FAILED, "[Create][OpDesc] for subgraph node failed, name:%s.", graph_name.c_str());
return nullptr;
}

@@ -243,17 +249,23 @@ NodePtr StagePartitioner::BuildSubgraphNode(const std::string &graph_name, const
op_desc->SetSubgraphInstanceName(0, graph_name);

if (!AttrUtils::SetInt(op_desc, ATTR_STAGE_LEVEL, stage_info.stage_level)) {
GELOGE(INTERNAL_ERROR, "Set attr ATTR_STAGE_LEVEL on node %s failed", op_desc->GetName().c_str());
REPORT_CALL_ERROR("E19999", "set attr %s on node %s failed", ATTR_STAGE_LEVEL.c_str(), op_desc->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s on node %s failed", ATTR_STAGE_LEVEL.c_str(), op_desc->GetName().c_str());
return nullptr;
}

NodePtr subgraph_node = root_graph_->AddNode(op_desc);
if (subgraph_node == nullptr) {
GELOGE(FAILED, "Add node %s failed.", graph_name.c_str());
REPORT_CALL_ERROR("E19999", "add node:%s in graph:%s failed.",
op_desc->GetName().c_str(), root_graph_->GetName().c_str());
GELOGE(FAILED, "[Add][Node] %s in graph:%s failed.", op_desc->GetName().c_str(), root_graph_->GetName().c_str());
return nullptr;
}
if (subgraph_node->SetOwnerComputeGraph(root_graph_) != GRAPH_SUCCESS) {
GELOGE(FAILED, "Set owner graph for node %s failed.", subgraph_node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "SetOwnerComputeGraph for node %s failed, grpah:%s.",
subgraph_node->GetName().c_str(), root_graph_->GetName().c_str());
GELOGE(FAILED, "[Set][OwnerGraph] for node %s failed, grpah:%s.",
subgraph_node->GetName().c_str(), root_graph_->GetName().c_str());
return nullptr;
}

@@ -314,11 +326,13 @@ ComputeGraphPtr StagePartitioner::BuildStageGraph(const NodePtr &subgraph_node,
std::string error_msg;
ComputeGraphPtr subgraph = graph_builder.Build(error_code, error_msg);
if (subgraph == nullptr) {
GELOGE(error_code, "Build subgraph %s failed: %s.", subgraph_node->GetName().c_str(), error_msg.c_str());
GELOGE(error_code, "[Build][Subgraph] %s failed:%s.", subgraph_node->GetName().c_str(), error_msg.c_str());
return nullptr;
}
if (!AttrUtils::SetInt(subgraph, ATTR_STAGE_LEVEL, stage_info.stage_level)) {
GELOGE(FAILED, "Set ATTR_STAGE_LEVEL on graph %s failed.", subgraph->GetName().c_str());
REPORT_CALL_ERROR("E19999", "set attr %s on graph %s failed.",
ATTR_STAGE_LEVEL.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s on graph %s failed.", ATTR_STAGE_LEVEL.c_str(), subgraph->GetName().c_str());
return nullptr;
}

@@ -329,7 +343,12 @@ Status StagePartitioner::RelinkDataEdges(const NodePtr &subgraph_node, const Sta
// in data nodes
for (size_t i = 0; i < stage_info.data_inputs.size(); i++) {
if (stage_info.data_inputs[i].first->Unlink(stage_info.data_inputs[i].second) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Remove data edge %s:%d->%s:%d failed.",
REPORT_CALL_ERROR("E19999", "remove data edge from %s:%d to %s:%d failed",
stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(),
stage_info.data_inputs[i].first->GetIdx(),
stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str(),
stage_info.data_inputs[i].second->GetIdx());
GELOGE(INTERNAL_ERROR, "[Remove][DataEdge] %s:%d->%s:%d failed.",
stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(),
stage_info.data_inputs[i].first->GetIdx(),
stage_info.data_inputs[i].second->GetOwnerNode()->GetName().c_str(),
@@ -337,7 +356,11 @@ Status StagePartitioner::RelinkDataEdges(const NodePtr &subgraph_node, const Sta
return INTERNAL_ERROR;
}
if (stage_info.data_inputs[i].first->LinkTo(subgraph_node->GetInDataAnchor(i)) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add data edge %s:%d->%s:%zu failed.",
REPORT_CALL_ERROR("E19999", "add data edge from %s:%d to %s:%zu failed.",
stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(),
stage_info.data_inputs[i].first->GetIdx(),
subgraph_node->GetName().c_str(), i);
GELOGE(INTERNAL_ERROR, "[Add][DataEdge] %s:%d->%s:%zu failed.",
stage_info.data_inputs[i].first->GetOwnerNode()->GetName().c_str(),
stage_info.data_inputs[i].first->GetIdx(),
subgraph_node->GetName().c_str(), i);
@@ -350,14 +373,20 @@ Status StagePartitioner::RelinkDataEdges(const NodePtr &subgraph_node, const Sta
GE_CHECK_NOTNULL(out_data_anchor);
for (const auto &peer_in_anchor : stage_info.data_outputs[i].second) {
if (stage_info.data_outputs[i].first->Unlink(peer_in_anchor) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Remove data edge %s:%d->%s:%d failed.",
REPORT_CALL_ERROR("E19999", "Remove data edge from %s:%d to %s:%d failed.",
stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str(),
stage_info.data_outputs[i].first->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "[Remove][DataEdge] %s:%d->%s:%d failed.",
stage_info.data_outputs[i].first->GetOwnerNode()->GetName().c_str(),
stage_info.data_outputs[i].first->GetIdx(),
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
return INTERNAL_ERROR;
}
if (out_data_anchor->LinkTo(peer_in_anchor) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add data edge %s:%zu->%s:%d failed.", subgraph_node->GetName().c_str(), i,
REPORT_CALL_ERROR("E19999", "Add data edge from %s:%zu to %s:%d failed.", subgraph_node->GetName().c_str(), i,
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "[Add][DataEdge] %s:%zu->%s:%d failed.", subgraph_node->GetName().c_str(), i,
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
return INTERNAL_ERROR;
}
@@ -371,13 +400,18 @@ Status StagePartitioner::RelinkCtrlEdges(const NodePtr &subgraph_node, const Sta
// in ctrl nodes
for (const auto &ctrl_input : stage_info.ctrl_inputs) {
if (ctrl_input.first->Unlink(ctrl_input.second) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Remove ctrl edge %s->%s failed.",
REPORT_CALL_ERROR("E19999", "Remove ctrl edge %s->%s failed.",
ctrl_input.first->GetOwnerNode()->GetName().c_str(),
ctrl_input.second->GetOwnerNode()->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][CtrlEdge] %s->%s failed.",
ctrl_input.first->GetOwnerNode()->GetName().c_str(), ctrl_input.second->GetOwnerNode()->GetName().c_str());
return INTERNAL_ERROR;
}
if (!ctrl_input.first->IsLinkedWith(subgraph_node->GetInControlAnchor())) {
if (ctrl_input.first->LinkTo(subgraph_node->GetInControlAnchor()) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add ctrl edge %s->%s failed.",
REPORT_CALL_ERROR("E19999", "Add ctrl edge %s->%s failed.",
ctrl_input.first->GetOwnerNode()->GetName().c_str(), subgraph_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][CtrlEdge] %s->%s failed.",
ctrl_input.first->GetOwnerNode()->GetName().c_str(), subgraph_node->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -386,14 +420,19 @@ Status StagePartitioner::RelinkCtrlEdges(const NodePtr &subgraph_node, const Sta
// out ctrl nodes
for (const auto &ctrl_output : stage_info.ctrl_outputs) {
if (ctrl_output.first->Unlink(ctrl_output.second) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Remove ctrl edge %s->%s failed.",
REPORT_CALL_ERROR("E19999", "Remove ctrl edge %s->%s failed.",
ctrl_output.first->GetOwnerNode()->GetName().c_str(),
ctrl_output.second->GetOwnerNode()->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Remove][CtrlEdge] %s->%s failed.",
ctrl_output.first->GetOwnerNode()->GetName().c_str(),
ctrl_output.second->GetOwnerNode()->GetName().c_str());
return INTERNAL_ERROR;
}
if (!subgraph_node->GetOutControlAnchor()->IsLinkedWith(ctrl_output.second)) {
if (subgraph_node->GetOutControlAnchor()->LinkTo(ctrl_output.second) != GRAPH_SUCCESS) {
GELOGE(INTERNAL_ERROR, "Add ctrl edge %s->%s failed.",
REPORT_CALL_ERROR("E19999", "Add ctrl edge %s->%s failed.",
subgraph_node->GetName().c_str(), ctrl_output.second->GetOwnerNode()->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][CtrlEdge] %s->%s failed.",
subgraph_node->GetName().c_str(), ctrl_output.second->GetOwnerNode()->GetName().c_str());
return INTERNAL_ERROR;
}


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

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

if (node->GetType() == ADDN) {
if (node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Param [node] op desc is null.");
GELOGE(PARAM_INVALID, "[Get][OpDesc] Param [node] op desc is null.");
return PARAM_INVALID;
}
// AddN with single input can be optimized


+ 44
- 41
ge/graph/passes/aicpu_constant_folding_pass.cc View File

@@ -123,7 +123,7 @@ Status AicpuConstantFoldingPass::GetInputAddrs(const vector<ConstGeTensorPtr> &w
vector<AddrAndType> &input_addrs) {
if (weight_vec.empty()) {
REPORT_INNER_ERROR("E19999", "Param weight_vec is empty, check invalid");
GELOGE(FAILED, "Weight is null");
GELOGE(FAILED, "[Check][Param] Weight is null");
return FAILED;
}
for (const ConstGeTensorPtr &weight : weight_vec) {
@@ -135,7 +135,7 @@ Status AicpuConstantFoldingPass::GetInputAddrs(const vector<ConstGeTensorPtr> &w
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X",
weight->GetData().size(), rt_ret);
GELOGE(rt_ret, "rtMemcpy error");
GELOGE(rt_ret, "[Call][RtMemcpy] failed, size:%zu, ret = 0x%X", weight->GetData().size(), rt_ret);
GE_CHK_RT(rtFree(input_addr));
return FAILED;
}
@@ -150,7 +150,8 @@ Status AicpuConstantFoldingPass::GetOutputAddrs(const OpDescPtr &node_desc, vect
if (node_desc->GetOutputsSize() == 0) {
REPORT_INNER_ERROR("E19999", "Ouput desc size of op:%s(%s) is 0, check invalid",
node_desc->GetName().c_str(), node_desc->GetType().c_str());
GELOGE(FAILED, "Output size is 0 ");
GELOGE(FAILED, "[Get][OutputsSize] Ouput desc size of op:%s(%s) is 0",
node_desc->GetName().c_str(), node_desc->GetType().c_str());
return FAILED;
}
for (size_t i = 0; i < node_desc->GetOutputsSize(); ++i) {
@@ -178,7 +179,7 @@ Status AicpuConstantFoldingPass::GenerateDataPtrInfo(const vector<uint64_t> &out
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc failed, size:%lu, ret = 0x%X",
result_summary.shape_data_size, rt_ret);
GELOGE(rt_ret, "rtMalloc error");
GELOGE(rt_ret, "[Call][RtMalloc] failed, size:%lu, ret = 0x%X", result_summary.shape_data_size, rt_ret);
GE_CHK_RT(rtFree(raw_data_addr));
return FAILED;
}
@@ -208,7 +209,7 @@ Status AicpuConstantFoldingPass::UpdateWorkSpaceAddr(string &task_info, STR_FWK_
// Update the workspace_addr
if (task_info.empty()) {
REPORT_INNER_ERROR("E19999", "Param task_info is empty, check invalid");
GELOGE(FAILED, "task_info is empty ");
GELOGE(FAILED, "[Check][Param] task_info is empty ");
return FAILED;
}
void *workspace_addr = nullptr;
@@ -218,7 +219,7 @@ Status AicpuConstantFoldingPass::UpdateWorkSpaceAddr(string &task_info, STR_FWK_
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X",
task_info.size(), rt_ret);
GELOGE(rt_ret, "rtMemcpy error");
GELOGE(rt_ret, "[Call][RtMemcpy] failed, size:%zu, ret = 0x%X", task_info.size(), rt_ret);
GE_CHK_RT(rtFree(workspace_addr));
return FAILED;
}
@@ -232,7 +233,7 @@ Status AicpuConstantFoldingPass::UpdateInputAndOutputAddr(const vector<uint64_t>
auto addrs_size = sizeof(uint64_t) * (io_addrs.size());
if (addrs_size <= 0) {
REPORT_INNER_ERROR("E19999", "Param io_addrs size is 0, check invalid");
GELOGE(FAILED, "addrs_size is less than 1 ");
GELOGE(FAILED, "[Check][Param] addrs_size is less than 1 ");
return FAILED;
}
void *input_output_addr = nullptr;
@@ -241,7 +242,7 @@ Status AicpuConstantFoldingPass::UpdateInputAndOutputAddr(const vector<uint64_t>
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X",
addrs_size, rt_ret);
GELOGE(rt_ret, "rtMemcpy error");
GELOGE(rt_ret, "[Call][RtMemcpy] failed, size:%zu, ret = 0x%X", addrs_size, rt_ret);
GE_CHK_RT(rtFree(input_output_addr));
return FAILED;
}
@@ -264,12 +265,12 @@ Status AicpuConstantFoldingPass::UpdateSingleOpAddr(string &task_info, const vec

Status ret = UpdateInputAndOutputAddr(io_addrs, task);
if (ret != SUCCESS) {
GELOGE(ret, "UpdateInputAndOutputAddr error");
GELOGE(ret, "[Update][InputAndOutputAddr] failed, ret:%d", ret);
return ret;
}
ret = UpdateWorkSpaceAddr(task_info, task);
if (ret != SUCCESS) {
GELOGE(ret, "UpdateWorkSpaceAddr error");
GELOGE(ret, "[Update][WorkSpaceAddr] failed, ret:%d", ret);
return ret;
}
return SUCCESS;
@@ -299,7 +300,7 @@ Status AicpuConstantFoldingPass::UpdateMemCopyAddr(string &task_info, const vect
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X",
data_size, rt_ret);
GELOGE(rt_ret, "rtMemcpy error");
GELOGE(rt_ret, "[Call][RtMemcpy] failed, size:%zu, ret = 0x%X", data_size, rt_ret);
GE_CHK_RT(rtFree(input_addr_ptr));
return FAILED;
}
@@ -311,12 +312,12 @@ Status AicpuConstantFoldingPass::UpdateMemCopyAddr(string &task_info, const vect

Status ret = UpdateInputAndOutputAddr(io_addrs, task);
if (ret != SUCCESS) {
GELOGE(ret, "UpdateInputAndOutputAddr error");
GELOGE(ret, "[Update][InputAndOutputAddr] failed, ret:%d", ret);
return ret;
}
ret = UpdateWorkSpaceAddr(task_info, task);
if (ret != SUCCESS) {
GELOGE(ret, "UpdateWorkSpaceAddr error");
GELOGE(ret, "[Update][WorkSpaceAddr] failed, ret:%d", ret);
return ret;
}
return SUCCESS;
@@ -328,14 +329,14 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons
auto instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] GE is not initialized");
return GE_CLI_GE_NOT_INITIALIZED;
}
auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName);
if (kernel_builder == nullptr) {
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed",
kKernelLibName);
GELOGE(FAILED, "Get op kernel info store failed");
GELOGE(FAILED, "[Get][OpsKernelBuilder] by name:%s failed", kKernelLibName);
return FAILED;
}
STR_FWK_OP_KERNEL aicpu_task;
@@ -364,17 +365,17 @@ Status AicpuConstantFoldingPass::LaunchSingleOpRunTask(const NodePtr &node, cons

ret = UpdateSingleOpAddr(task_info, input_addrs, output_addrs, aicpu_task);
if (ret != SUCCESS) {
GELOGE(ret, "UpdateSingleOpAddr error");
GELOGE(ret, "[Update][SingleOpAddr] failed, ret:%d", ret);
return ret;
}
ret = GenerateTaskForLaunch(aicpu_task, task_buf);
if (ret != SUCCESS) {
GELOGE(ret, "GenerateTaskForLaunch error");
GELOGE(ret, "[Generate][Task] For Launch failed, ret:%d", ret);
return ret;
}
ret = KernelLaunch(task_buf);
if (ret != SUCCESS) {
GELOGE(ret, "KernelLaunch error");
GELOGE(ret, "[Call][KernelLaunch] failed, ret:%d", ret);
return ret;
}

@@ -386,14 +387,14 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector<uint64_t> &data_
auto instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] GE is not initialized");
return GE_CLI_GE_NOT_INITIALIZED;
}
auto kernel_builder = OpsKernelBuilderManager::Instance().GetOpsKernelBuilder(kKernelLibName);
if (kernel_builder == nullptr) {
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed",
kKernelLibName);
GELOGE(FAILED, "Get op kernel info store failed");
GELOGE(FAILED, "[Get][OpsKernelBuilder] by name:%s failed", kKernelLibName);
return FAILED;
}
STR_FWK_OP_KERNEL aicpu_task;
@@ -427,17 +428,17 @@ Status AicpuConstantFoldingPass::LaunchMemCopyTask(const vector<uint64_t> &data_

ret = UpdateMemCopyAddr(task_info, data_infos, internal_addrs, aicpu_task);
if (ret != SUCCESS) {
GELOGE(ret, "UpdateMemCopyAddr error");
GELOGE(ret, "[Update][MemCopyAddr] failed, ret:%d", ret);
return ret;
}
ret = GenerateTaskForLaunch(aicpu_task, task_buf);
if (ret != SUCCESS) {
GELOGE(ret, "GenerateTaskForLaunch error");
GELOGE(ret, "[Generate][Task] For Launch failed, ret:%d", ret);
return ret;
}
ret = KernelLaunch(task_buf);
if (ret != SUCCESS) {
GELOGE(ret, "KernelLaunch error");
GELOGE(ret, "[Call][KernelLaunch] failed, ret:%d", ret);
return ret;
}
return SUCCESS;
@@ -451,7 +452,7 @@ Status AicpuConstantFoldingPass::GenerateTaskForLaunch(STR_FWK_OP_KERNEL &aicpu_
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMemcpy failed, size:%zu, ret = 0x%X",
sizeof(STR_FWK_OP_KERNEL), rt_ret);
GELOGE(rt_ret, "rtMemcpy error");
GELOGE(rt_ret, "[Call][RtMemcpy] failed, size:%zu, ret = 0x%X", sizeof(STR_FWK_OP_KERNEL), rt_ret);
GE_CHK_RT(rtFree(task_buf));
return FAILED;
}
@@ -482,56 +483,56 @@ Status AicpuConstantFoldingPass::KernelLaunch(void *task_buf) {
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtModelCreate failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "create model failed.");
GELOGE(rt_ret, "[Create][Model] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtStreamCreate(&stream, 0);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtStreamCreate failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "create stream failed.");
GELOGE(rt_ret, "[Create][Stream] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtModelBindStream(model, stream, 0);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtModelBindStream failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "rtModelBindStream failed.");
GELOGE(rt_ret, "[Call][RtModelBindStream] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtKernelLaunchEx(task_buf, sizeof(STR_FWK_OP_KERNEL), 0, stream);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtModelBindStream failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "rtKernelLaunchEx failed.");
GELOGE(rt_ret, "[Call][RtModelBindStream] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtModelLoadComplete(model);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtModelLoadComplete failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "rtModelLoadComplete failed.");
GELOGE(rt_ret, "[Call][RtModelLoadComplete] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtStreamCreate(&stream_run, 0);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtStreamCreate failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "create run stream failed.");
GELOGE(rt_ret, "[Call][RtStreamCreate] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtModelExecute(model, stream_run, 0);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtModelExecute failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "rtModelExecute failed.");
GELOGE(rt_ret, "[Call][RtModelExecute] failed, ret = 0x%X", rt_ret);
return FAILED;
}
rt_ret = rtStreamSynchronize(stream_run);
if (rt_ret != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtStreamSynchronize failed, ret = 0x%X",
rt_ret);
GELOGE(rt_ret, "rtStreamSynchronize failed.");
GELOGE(rt_ret, "[Call][RtStreamSynchronize] failed, ret = 0x%X", rt_ret);
return FAILED;
}
return SUCCESS;
@@ -543,7 +544,8 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co
REPORT_INNER_ERROR("E19999", "Output desc size:%zu of op:%s(%s), after multi 2, not equal to data_vec.size:%zu, "
"check invalid", node_desc->GetOutputsSize(),
node_desc->GetName().c_str(), node_desc->GetType().c_str(), data_vec.size());
GELOGE(FAILED, "node[%s] something wrong with output size", node_desc->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Output desc size:%zu of op:%s(%s), after multi 2, not equal to data_vec.size:%zu",
node_desc->GetOutputsSize(), node_desc->GetName().c_str(), node_desc->GetType().c_str(), data_vec.size());
return FAILED;
}

@@ -552,7 +554,7 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co
GeTensorPtr output_ptr = MakeShared<GeTensor>(output_tensor_desc);
if (output_ptr == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "node[%s] something wrong with construct GeTensor", node_desc->GetName().c_str());
GELOGE(FAILED, "[New][GeTensor] failed");
return FAILED;
}
const DataPtrInfo &raw_data_info = data_vec.at(i * kDouble);
@@ -561,14 +563,14 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co
if (data_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "New Buffer failed, size:%lu",
raw_data_size);
GELOGE(MEMALLOC_FAILED, "new data_addr failed");
GELOGE(MEMALLOC_FAILED, "[New][Buffer] failed, size:%lu", raw_data_size);
return INTERNAL_ERROR;
}
GE_CHK_RT_RET(rtMemcpy(data_addr.get(), raw_data_size,
reinterpret_cast<void *>(reinterpret_cast<uintptr_t>(raw_data_info.dst_ptr)), raw_data_size,
RT_MEMCPY_DEVICE_TO_HOST));
GE_IF_BOOL_EXEC(output_ptr->SetData(data_addr.get(), raw_data_size) != GRAPH_SUCCESS,
GELOGE(FAILED, "set data failed");
GELOGE(FAILED, "[Set][Data] for node:%s output[%zu] failed", node_desc->GetName().c_str(), i);
return FAILED);
GELOGD("GenerateGeTensor: raw_data_size %lu", raw_data_size);

@@ -586,7 +588,7 @@ Status AicpuConstantFoldingPass::GenerateGeTensor(const OpDescPtr &node_desc, co
if (shape_addr == nullptr) {
REPORT_CALL_ERROR("E19999", "New Buffer failed, size:%lu",
dim_num);
GELOGE(MEMALLOC_FAILED, "new shape_addr failed");
GELOGE(MEMALLOC_FAILED, "[New][Buffer] failed, size:%lu", dim_num);
return INTERNAL_ERROR;
}
GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), shape_data_size,
@@ -632,22 +634,23 @@ bool AicpuConstantFoldingPass::IsSkipFold(const ge::NodePtr &node) {
auto instance_ptr = ge::GELib::GetInstance();
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) {
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] GE is not initialized");
return true;
}
OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName);
if (kernel_info == nullptr) {
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed",
kKernelLibName);
GELOGE(FAILED, "Get op kernel info store failed");
GELOGE(FAILED, "[Get][OpsKernelInfoStore] by name:%s failed", kKernelLibName);
return true;
}
std::string check_result;
kernel_info->opsFlagCheck(*node, check_result);
if (check_result.empty()) {
REPORT_CALL_ERROR("E19999", "Call opsFlagCheck faled, ops kernel name:%s, op:%s(%s)",
REPORT_CALL_ERROR("E19999", "Call opsFlagCheck failed, ops kernel name:%s, op:%s(%s)",
kKernelLibName, node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Get op check_result failed");
GELOGE(FAILED, "[Call][OpsFlagCheck] failed, ops kernel name:%s, op:%s(%s)",
kKernelLibName, node->GetName().c_str(), node->GetType().c_str());
return true;
}
return check_result.substr(0, kOpsFlag) == kNotSupported;


+ 6
- 4
ge/graph/passes/assert_pass.cc View File

@@ -36,7 +36,7 @@ Status AssertPass::Run(NodePtr &node) {
}
if (node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [node] [opDesc] must not be null.");
GELOGE(PARAM_INVALID, "[Get][OpDesc] param [node] [opDesc] must not be null.");
return PARAM_INVALID;
}
std::string op_type = node->GetOpDesc()->GetType();
@@ -49,7 +49,7 @@ Status AssertPass::Run(NodePtr &node) {
// remove unused node
Status status = RemoveUnusedNode(nodes_unused);
if (status != SUCCESS) {
GELOGE(status, "remove unused node failed.");
GELOGE(status, "[Remove][UnusedNode] failed, ret:%d.", status);
return status;
}
}
@@ -95,8 +95,10 @@ Status AssertPass::RemoveUnusedNode(std::vector<NodePtr> &nodes_unused) {
}

if (IsolateAndDeleteNode(node, assert_io_map) != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Isolate and delete node:%s(%s) faild",
node->GetName().c_str(), node->GetType().c_str());
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Call][IsolateAndDeleteNode] for node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
}


+ 24
- 10
ge/graph/passes/assign_remove_pass.cc View File

@@ -33,13 +33,13 @@ Status AssignRemovePass::Run(NodePtr &node) {
GELOGD("AssignRemovePass running");

if (TransformAttr(node) != SUCCESS) {
GELOGE(FAILED, "Transform assign_var_name attr failed, node=%s", node->GetName().c_str());
GELOGE(FAILED, "[Call][TransformAttr] Transform assign_var_name attr failed, node=%s", node->GetName().c_str());
return FAILED;
}

if (node->GetType() == ASSIGN) {
if (OptimizedAssignNode(node) != SUCCESS) {
GELOGE(FAILED, "Optimize for assign_node %s failed", node->GetName().c_str());
GELOGE(FAILED, "[Call][Optimize] for assign_node %s failed", node->GetName().c_str());
return FAILED;
}
}
@@ -60,7 +60,9 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
REPORT_INNER_ERROR("E19999", "Index %d or %d input anchor of node:%s(%s) is nullptr, check invalid",
kAssignRefInputIndex, kAssignValueInputIndex,
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "In data anchor is null, node:%s", assign_node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Index %d or %d input anchor of node:%s(%s) is nullptr",
kAssignRefInputIndex, kAssignValueInputIndex,
assign_node->GetName().c_str(), assign_node->GetType().c_str());
return FAILED;
}
const auto &ref_peer_anchor = ref_in_anchor->GetPeerOutAnchor();
@@ -69,7 +71,9 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
REPORT_INNER_ERROR("E19999", "Index %d or %d input anchor of node:%s(%s), peer anchor is nullptr, check invalid",
kAssignRefInputIndex, kAssignValueInputIndex,
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "Peer data anchor is null, node:%s", assign_node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Index %d or %d input anchor of node:%s(%s), peer anchor is nullptr",
kAssignRefInputIndex, kAssignValueInputIndex,
assign_node->GetName().c_str(), assign_node->GetType().c_str());
return FAILED;
}

@@ -87,7 +91,7 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
if (IsolateAndDeleteNode(assign_node, {kAssignRefInputIndex}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "Isolate and delete assign_node %s failed.", assign_node->GetName().c_str());
GELOGE(FAILED, "[IsolateAndDelete][Node] %s failed.", assign_node->GetName().c_str());
return FAILED;
}

@@ -97,7 +101,9 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
REPORT_INNER_ERROR("E19999", "Input index %d or %d of node:%s(%s), peer op is nullptr, check invalid",
kAssignRefInputIndex, kAssignValueInputIndex,
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "value input is null");
GELOGE(FAILED, "[Check][Param] Input index %d or %d of node:%s(%s), peer op is nullptr",
kAssignRefInputIndex, kAssignValueInputIndex,
assign_node->GetName().c_str(), assign_node->GetType().c_str());
return FAILED;
}

@@ -105,7 +111,8 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
if (ref_input->UpdateInputDesc(0, value_input->GetOutputDesc(value_peer_anchor->GetIdx())) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Input index %d of node:%s(%s), update it's peer op input:0 desc failed",
kAssignRefInputIndex, assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "Update input_desc for variable %s failed.", ref_input->GetName().c_str());
GELOGE(FAILED, "[Update][InputDesc] Input index %d of node:%s(%s), update it's peer op input:0 desc failed",
kAssignRefInputIndex, assign_node->GetName().c_str(), assign_node->GetType().c_str());
return FAILED;
}
if (GraphUtils::AddEdge(value_peer_anchor, ref_peer_anchor->GetOwnerNode()->GetInDataAnchor(0)) != GRAPH_SUCCESS) {
@@ -114,7 +121,10 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
value_peer_anchor->GetOwnerNode()->GetType().c_str(), value_peer_anchor->GetIdx(),
ref_peer_anchor->GetOwnerNode()->GetName().c_str(),
ref_peer_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(FAILED, "Add data edge %s->%s failed", value_input->GetName().c_str(), ref_input->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(out_index:%d) and op:%s(%s)(in_index:0) failed",
value_peer_anchor->GetOwnerNode()->GetName().c_str(),
value_peer_anchor->GetOwnerNode()->GetType().c_str(), value_peer_anchor->GetIdx(),
ref_peer_anchor->GetOwnerNode()->GetName().c_str(), ref_peer_anchor->GetOwnerNode()->GetType().c_str());
return FAILED;
}

@@ -125,7 +135,9 @@ Status AssignRemovePass::OptimizedAssignNode(NodePtr &assign_node) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%d desc of node:%s(%s) failed",
ASSIGN_VAR_NAME.c_str(), value_peer_anchor->GetIdx(),
value_input->GetName().c_str(), value_input->GetType().c_str());
GELOGE(FAILED, "Set attr ASSIGN_VAR_NAME failed.");
GELOGE(FAILED, "[Set][Attr] %s to output:%d desc of node:%s(%s) failed",
ASSIGN_VAR_NAME.c_str(), value_peer_anchor->GetIdx(),
value_input->GetName().c_str(), value_input->GetType().c_str());
return FAILED;
}
auto value_node = value_peer_anchor->GetOwnerNode();
@@ -160,7 +172,9 @@ Status AssignRemovePass::TransformAttr(NodePtr &node) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%d desc of node:%s(%s) failed",
ASSIGN_VAR_NAME.c_str(), peer_data_anchor->GetIdx(),
in_node->GetName().c_str(), in_node->GetType().c_str());
GELOGE(FAILED, "Set attr ASSIGN_VAR_NAME failed.");
GELOGE(FAILED, "[Set][Attr] %s to output:%d desc of node:%s(%s) failed",
ASSIGN_VAR_NAME.c_str(), peer_data_anchor->GetIdx(),
in_node->GetName().c_str(), in_node->GetType().c_str());
return FAILED;
}
AddRePassNode(in_node);


+ 31
- 24
ge/graph/passes/atomic_addr_clean_pass.cc View File

@@ -159,7 +159,8 @@ Status AtomicAddrCleanPass::HandleLoopGraph(ComputeGraphPtr &graph, const vector
// Insert atomic clean op
NodePtr clean_addr_node = InsertAtomicAddrCleanNode(graph);
if (clean_addr_node == nullptr) {
GELOGE(FAILED, "Insert AtomicAddrClean node failed. Ignore atomicAddrClean pass.");
GELOGE(FAILED, "[Insert][AtomicAddrCleanNode] to graph:%s failed. Ignore atomicAddrClean pass.",
graph->GetName().c_str());
return FAILED;
}

@@ -173,7 +174,9 @@ Status AtomicAddrCleanPass::HandleLoopGraph(ComputeGraphPtr &graph, const vector

auto ret = LinkToAtomicNode(node, clean_addr_node);
if (ret != SUCCESS) {
GELOGE(ret, "Link control anchor failed from atomic node to atomic_addr_clean node.");
GELOGE(ret,
"[Call][LinkToAtomicNode] Link control anchor failed from atomic node:%s to atomic_addr_clean:%s node.",
node->GetName().c_str(), clean_addr_node->GetName().c_str());
return ret;
}
index++;
@@ -188,7 +191,7 @@ Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vect
vector<NodePtr> dispersed_atomic_nodes;
auto ret = HandleDispersedAtomicNodes(graph, atomic_node_vec, common_atomic_nodes, dispersed_atomic_nodes);
if (ret != SUCCESS) {
GELOGE(ret, "Handle dispersed atomic nodes failed, graph name is %s.", graph->GetName().c_str());
GELOGE(ret, "[Call][HandleDispersedAtomicNodes] failed, graph name is %s.", graph->GetName().c_str());
return ret;
}

@@ -200,13 +203,15 @@ Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vect
// not loop graph , insert only one clean node in graph
NodePtr clean_addr_node = InsertAtomicAddrCleanNode(graph);
if (clean_addr_node == nullptr) {
GELOGE(FAILED, "Insert AtomicAddrClean node failed. Ignore atomicAddrClean pass.");
GELOGE(FAILED, "[Insert][AtomicAddrCleanNode] in graph:%s failed. Ignore atomicAddrClean pass.",
graph->GetName().c_str());
return FAILED;
}
for (const auto &node : common_atomic_nodes) {
ret = LinkToAtomicNode(node, clean_addr_node);
if (ret != SUCCESS) {
GELOGE(ret, "Link control anchor failed from atomic node to atomic_addr_clean node.");
GELOGE(ret, "[Link][ControlAnchor] failed from atomic node:%s to atomic_addr_clean node:%s.",
node->GetName().c_str(), clean_addr_node->GetName().c_str());
return ret;
}
}
@@ -218,7 +223,8 @@ Status AtomicAddrCleanPass::HandleNormalGraph(ComputeGraphPtr &graph, const vect
NodePtr peer_in_node = in_anchor->GetPeerOutAnchor()->GetOwnerNode();
ret = LinkToAtomicNode(peer_in_node, clean_addr_node);
if (ret != SUCCESS) {
GELOGE(ret, "Link failed, %s : %s", peer_in_node->GetName().c_str(), clean_addr_node->GetName().c_str());
GELOGE(ret, "[Link][ControlAnchor] from node:%s to node:%s failed",
peer_in_node->GetName().c_str(), clean_addr_node->GetName().c_str());
return ret;
}
}
@@ -276,7 +282,8 @@ Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph,
if (!node_anchors_connect_netoutput.empty()) {
NodePtr dispersed_clean_addr_node = InsertAtomicAddrCleanNode(graph);
if (dispersed_clean_addr_node == nullptr) {
GELOGE(FAILED, "Insert AtomicAddrClean node failed. Ignore atomicAddrClean pass.");
GELOGE(FAILED, "[Insert][AtomicAddrCleanNode] in graph:%s failed. Ignore atomicAddrClean pass.",
graph->GetName().c_str());
return FAILED;
}

@@ -291,7 +298,7 @@ Status AtomicAddrCleanPass::HandleDispersedAtomicNodes(ComputeGraphPtr &graph,
++index;
Status ret = LinkToAtomicNode(node, dispersed_clean_addr_node);
if (ret != SUCCESS) {
GELOGE(ret, "Link control anchor failed from atomic node: %s to atomic_addr_clean node: %s.",
GELOGE(ret, "[Link][ControlAnchor] failed from atomic node:%s to atomic_addr_clean node:%s.",
node->GetName().c_str(), dispersed_clean_addr_node->GetName().c_str());
return ret;
}
@@ -308,7 +315,7 @@ NodePtr AtomicAddrCleanPass::InsertAtomicAddrCleanNode(ComputeGraphPtr &graph) {
OpDescPtr op_desc = MakeShared<OpDesc>(NODE_NAME_ATOMIC_ADDR_CLEAN, ATOMICADDRCLEAN);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(INTERNAL_ERROR, "Make shared atomic addr clean op failed.");
GELOGE(INTERNAL_ERROR, "[New][OpDesc] failed.");
return nullptr;
}
string session_graph_id;
@@ -336,7 +343,7 @@ Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr
GE_IF_BOOL_EXEC(atomic_node == nullptr || atomic_clean_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param atomic_node or atomic_clean_node is nullptr, "
"check invalid");
DOMI_LOGE("param [atomic_node][atomic_clean_node] must not be null.");
DOMI_LOGE("[Check][Param] param [atomic_node][atomic_clean_node] must not be null.");
return PARAM_INVALID);
InControlAnchorPtr in_ctrl_anchor = atomic_node->GetInControlAnchor();
OutControlAnchorPtr out_ctrl_anchor = atomic_clean_node->GetOutControlAnchor();
@@ -345,9 +352,9 @@ Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr
"check invalid",
atomic_node->GetName().c_str(), atomic_node->GetType().c_str(),
atomic_clean_node->GetName().c_str(), atomic_clean_node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Get control anchor faild, dst node: %s.",
atomic_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] in_ctrl_anchor of op:%s(%s) or out_ctrl_anchor of op:%s(%s) is nullptr.",
atomic_node->GetName().c_str(), atomic_node->GetType().c_str(),
atomic_clean_node->GetName().c_str(), atomic_clean_node->GetType().c_str());
return INTERNAL_ERROR;
}

@@ -358,9 +365,9 @@ Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr
out_ctrl_anchor->GetOwnerNode()->GetType().c_str(),
in_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Graph add cleanAddrNode op out ctrl edge fail, dst node: %s.",
atomic_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
out_ctrl_anchor->GetOwnerNode()->GetName().c_str(), out_ctrl_anchor->GetOwnerNode()->GetType().c_str(),
in_ctrl_anchor->GetOwnerNode()->GetName().c_str(), in_ctrl_anchor->GetOwnerNode()->GetType().c_str());
return INTERNAL_ERROR;
}
GELOGD("Graph add cleanAddrNode op out ctrl edge, dst node: %s.", atomic_node->GetName().c_str());
@@ -375,7 +382,7 @@ Status AtomicAddrCleanPass::LinkToAtomicNode(const NodePtr &atomic_node, NodePtr
}

bool AtomicAddrCleanPass::IsAtomicOp(const NodePtr &node) {
GE_IF_BOOL_EXEC(node == nullptr, GELOGE(FAILED, "node is null."); return false);
GE_IF_BOOL_EXEC(node == nullptr, GELOGE(FAILED, "[Check][Param] node is nullptr."); return false);
OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
return false;
@@ -416,7 +423,7 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector<NodePtr> &atomic_
std::shared_ptr<GELib> instance = ge::GELib::GetInstance();
if ((instance == nullptr) || !instance->InitFlag()) {
REPORT_INNER_ERROR("E19999", "GeLib is not init before, check invalid");
GELOGE(ge::GE_CLI_GE_NOT_INITIALIZED, "CompileSingleOp failed.");
GELOGE(ge::GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] GeLib is not init before.");
return ge::GE_CLI_GE_NOT_INITIALIZED;
}

@@ -428,10 +435,10 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector<NodePtr> &atomic_
}
string kernel_lib_name = op_desc->GetOpKernelLibName();
if (kernel_lib_name.empty()) {
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed",
kernel_lib_name.c_str());
GELOGE(ge::INTERNAL_ERROR, "Get atomic node:%s(%s) kernel lib failed.", atomic_node->GetName().c_str(),
atomic_node->GetType().c_str());
REPORT_INNER_ERROR("E19999", "Find ops kernel by name of op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(ge::INTERNAL_ERROR, "[Get][OpKernelLibName] of op:%s(%s) failed.", op_desc->GetName().c_str(),
op_desc->GetType().c_str());
return ge::INTERNAL_ERROR;
}

@@ -451,8 +458,8 @@ Status AtomicAddrCleanPass::CompileUnknownGraphOp(const vector<NodePtr> &atomic_
GE_TIMESTAMP_ADD(UnknownGraphCompileOp);
if (ret != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Call CompileOp failed, kernel_lib_name:%s, ret:%d",
kernel_lib_name.c_str(), ret);
GELOGE(ret, "Compile atomic op failed, kernel lib name is %s", kernel_lib_name.c_str());
kernel_lib_name.c_str(), ret);
GELOGE(ret, "[Compile][AtomicOp] failed, kernel lib name is %s", kernel_lib_name.c_str());
return ret;
}
}


+ 22
- 23
ge/graph/passes/attach_stream_label_pass.cc View File

@@ -29,9 +29,11 @@ Status AttachStreamLabelPass::Run(ComputeGraphPtr graph) {
std::map<NodePtr, NodePtr> branch_head_nodes;
FindNodes(graph, need_label_nodes, enter_nodes, branch_head_nodes);
for (const auto &node : need_label_nodes) {
GE_CHK_STATUS_RET(UpdateCondBranch(node, branch_head_nodes), "Update cond branch failed, start node:%s.", node->GetName().c_str());
GE_CHK_STATUS_RET(UpdateCondBranch(node, branch_head_nodes), "[Update][CondBranch] failed, start node:%s.",
node->GetName().c_str());
}
GE_CHK_STATUS_RET(UpdateEnterNode(enter_nodes), "UpdateEnterNode failed.");
GE_CHK_STATUS_RET(UpdateEnterNode(enter_nodes),
"[Update][EnterNode] in graph:%s failed.", graph->GetName().c_str());

GELOGD("AttachStreamLabelPass Leave.");
return SUCCESS;
@@ -83,7 +85,7 @@ Status AttachStreamLabelPass::UpdateCondBranch(const NodePtr &node,
const std::map<NodePtr, NodePtr> &branch_head_nodes) {
std::string stream_label;
if (AttachFlag(node, stream_label) != SUCCESS) {
GELOGE(FAILED, "Attach flag for node %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Attach][Flag] for node %s failed.", node->GetName().c_str());
return FAILED;
}

@@ -119,9 +121,8 @@ Status AttachStreamLabelPass::UpdateCondBranch(const NodePtr &node,
GELOGD("Attach label %s to node: %s.", stream_label.c_str(), tmp_node->GetName().c_str());
auto status = SetStreamLabel(tmp_node, stream_label);
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
stream_label.c_str(), tmp_node->GetName().c_str(), tmp_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed.",
stream_label.c_str(), tmp_node->GetName().c_str(), tmp_node->GetType().c_str());
return status;
}
}
@@ -141,7 +142,7 @@ Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &strea
if (node->GetInDataNodes().empty()) {
REPORT_INNER_ERROR("E19999", "In data nodes is empty of op:%s(%s), check invalid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "node %s has no input_data_node.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][InDataNodes] node %s has no input_data_node.", node->GetName().c_str());
return INTERNAL_ERROR;
}
stream_label = node->GetInDataNodes().at(0)->GetName();
@@ -153,22 +154,21 @@ Status AttachStreamLabelPass::AttachFlag(const NodePtr &node, std::string &strea
ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED,
"StreamSwitch get attr TRUE_BRANCH_STREAM failed.");
"[Get][Attr] %s of op:%s(%s) failed", ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
stream_label += (value ? "_t" : "_f");
auto status = SetActiveLabelList(node, {stream_label});
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
stream_label.c_str(), node->GetName().c_str(), node->GetType().c_str());
GELOGE(status, "set active_label_list failed.");
GELOGE(status, "[Set][ActiveLabelList] %s to op:%s(%s) failed.",
stream_label.c_str(), node->GetName().c_str(), node->GetType().c_str());
return status;
}
} else if (type == STREAMMERGE) {
stream_label = node->GetName();
auto status = SetStreamLabel(node, stream_label);
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
stream_label.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.",
stream_label.c_str(), node->GetName().c_str(), node->GetType().c_str());
return status;
}
}
@@ -198,7 +198,7 @@ Status AttachStreamLabelPass::UpdateEnterNode(const std::vector<NodePtr> &enter_

for (const auto &pair : enter_active_map) {
if (SetEnterLabel(pair.second, pair.first) != SUCCESS) {
GELOGE(FAILED, "Set stream_label for enter_nodes failed.");
GELOGE(FAILED, "[Set][EnterLabel] for enter_nodes failed.");
return FAILED;
}

@@ -211,7 +211,8 @@ Status AttachStreamLabelPass::UpdateEnterNode(const std::vector<NodePtr> &enter_
REPORT_CALL_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed",
ATTR_NAME_ACTIVE_LABEL_LIST.c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ACTIVE_LABEL_LIST failed, node: %s.", active_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][Attr] %s of op:%s(%s) failed.", ATTR_NAME_ACTIVE_LABEL_LIST.c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return INTERNAL_ERROR;
}

@@ -220,7 +221,7 @@ Status AttachStreamLabelPass::UpdateEnterNode(const std::vector<NodePtr> &enter_
nodes.emplace(enter_node);
}
if (UpdateLoopBranch(nodes, active_label_list[0]) != SUCCESS) {
GELOGE(FAILED, "Update stream_label for loop_branch failed.");
GELOGE(FAILED, "[Update][StreamLabel] %s for loop_branch failed.", active_label_list[0].c_str());
return FAILED;
}
}
@@ -246,9 +247,8 @@ Status AttachStreamLabelPass::SetEnterLabel(const std::vector<NodePtr> &enter_no
for (const auto &enter_node : enter_nodes) {
auto status = SetStreamLabel(enter_node, stream_label);
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
stream_label.c_str(), enter_node->GetName().c_str(), enter_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed.",
stream_label.c_str(), enter_node->GetName().c_str(), enter_node->GetType().c_str());
return status;
}
}
@@ -281,9 +281,8 @@ Status AttachStreamLabelPass::UpdateLoopBranch(const std::stack<NodePtr> &enter_
GELOGD("Attach label %s to node: %s.", stream_label.c_str(), out_node->GetName().c_str());
auto status = SetStreamLabel(out_node, stream_label);
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
stream_label.c_str(), out_node->GetName().c_str(), out_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed.",
stream_label.c_str(), out_node->GetName().c_str(), out_node->GetType().c_str());
return status;
}
nodes.push(out_node);


+ 22
- 14
ge/graph/passes/base_pass.cc View File

@@ -142,13 +142,14 @@ void PushToRePassIfSeen(NodePtr &node, const std::pair<std::string, BaseNodePass

Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, DuringPassNodeSets &during_pass_node_set) {
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;
}
GELOGD("Begin to run pass for node %s", node->GetName().c_str());
for (const auto &name_to_pass : names_to_passes) {
if (name_to_pass.second == nullptr) {
GELOGE(INTERNAL_ERROR, "There is null pointer in passes(%s), skip it", name_to_pass.first.c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] There is null pointer in passes(%s), skip it", name_to_pass.first.c_str());
continue;
}

@@ -156,8 +157,9 @@ Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, DuringPassNo
name_to_pass.second->init();
auto result = name_to_pass.second->Run(node);
if (result != SUCCESS) {
GELOGE(INTERNAL_ERROR,
"Failed to process pass %s on node %s, result "
REPORT_CALL_ERROR("E19999", "process pass %s on node:%s failed, ret:%u",
name_to_pass.first.c_str(), node->GetName().c_str(), result);
GELOGE(INTERNAL_ERROR, "[Process][Pass] %s on node %s failed, result "
"%u, the passes will be terminated immediately.",
name_to_pass.first.c_str(), node->GetName().c_str(), result);
return result;
@@ -201,26 +203,31 @@ void ClearOption(NamesToPass names_to_pass) {

Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map) {
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;
}
GELOGI("Prepare to isolate and delete node, name:%s, type:%s.", node->GetName().c_str(),
node->GetType().c_str());
ComputeGraphPtr graph = node->GetOwnerComputeGraph();
if (graph == nullptr) {
GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str());
REPORT_INNER_ERROR("E19999", "The owner graph of node:%s must not be null.", node->GetName().c_str());
GELOGE(FAILED, "[Get][OwnerComputeGraph] failed, The owner graph of node:%s must not be null.",
node->GetName().c_str());
return FAILED;
}

AddRePassNodesWithInOut(node);

if (GraphUtils::IsolateNode(node, io_map) != GRAPH_SUCCESS) {
GELOGE(FAILED, "[%s] IsolateNode failed.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "Isolate Node:%s failed", node->GetName().c_str());
GELOGE(FAILED, "[Isolate][Node] %s failed.", node->GetName().c_str());
return FAILED;
}

if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != SUCCESS) {
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str());
REPORT_CALL_ERROR("E19999", "call RemoveNodeWithoutRelink for node:%s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Call][RemoveNodeWithoutRelink] for node:%s failed.", node->GetName().c_str());
return FAILED;
}

@@ -230,7 +237,8 @@ Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector<int>

Status GEPass::Run(const NamesToPass &names_to_passes) {
if (graph_ == nullptr) {
GELOGE(INTERNAL_ERROR, "The graph is null");
REPORT_INNER_ERROR("E19999", "graph_ is nullptr, check invalid.");
GELOGE(INTERNAL_ERROR, "[Check][Param] The graph is nullptr");
return INTERNAL_ERROR;
}
if (names_to_passes.empty()) {
@@ -240,7 +248,7 @@ Status GEPass::Run(const NamesToPass &names_to_passes) {

if (depth_ > kMaxRecursiveDepth) {
GELOGE(PARAM_INVALID,
"The pass for root graph %s will be terminated because too many nesting"
"[Check][Param] The pass for root graph %s will be terminated because too many nesting"
" levels(%d) of subgraphs, last subgraph is %s",
root_graph_->GetName().c_str(), depth_, graph_->GetName().c_str());
return PARAM_INVALID;
@@ -284,7 +292,7 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) {

auto ret = RunPasses(node, names_to_passes, during_pass_node_set);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u",
GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code:%u",
node->GetName().c_str(), node->GetType().c_str(), ret);
return ret;
}
@@ -292,7 +300,7 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) {
bool has_sub_graph = false;
ret = RunPassesOnSubGraph(node, names_to_passes, has_sub_graph);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to run passes on the sub graph of node %s", node->GetName().c_str());
GELOGE(ret, "[Run][Passes] on the sub graph of node %s failed", node->GetName().c_str());
return ret;
}

@@ -301,7 +309,7 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) {
SetFlagOption(kOptimizeAfterSubGraph, names_to_passes);
ret = RunPasses(node, names_to_passes, during_pass_node_set);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u",
GELOGE(ret, "[Process][Passes] on node %s type %s failed, error code: %u",
node->GetName().c_str(), node->GetType().c_str(), ret);
return ret;
}
@@ -347,7 +355,7 @@ Status GEPass::RunPassesOnSubGraph(const NodePtr &node, const NamesToPass &names
GEPass pass(graph, root_graph_, depth_ + 1);
auto ret = pass.Run(names_to_passes);
if (ret != SUCCESS) {
GELOGE(ret, "Failed to run passes for sub graph %s from node %s", name.c_str(), node->GetName().c_str());
GELOGE(ret, "[Run][Passes] for sub graph:%s from node:%s failed", name.c_str(), node->GetName().c_str());
return ret;
}
}


+ 34
- 17
ge/graph/passes/bitcast_pass.cc View File

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

@@ -44,6 +44,7 @@ Status BitcastPass::Run(NodePtr &node) {
OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "[Get][OpDesc] failed, op_desc of node is nullptr");
return PARAM_INVALID;
}
ge::DataType dst_data_type;
@@ -62,22 +63,25 @@ Status BitcastPass::CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_

if (!ge::AttrUtils::GetDataType(op_desc, kAttrNameType, dst_data_type)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s of op:%s(%s) failed",
kAttrNameType, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "Node failed to get attribute type.");
kAttrNameType, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "[Get][Attr] %s of op:%s(%s) failed",
kAttrNameType, op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
if (dst_data_type >= ge::DT_UNDEFINED) {
REPORT_INNER_ERROR("E19999", "Param dst_data_type:%d check invalid, op:%s(%s)",
dst_data_type, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "dst_data_type[%s] is not valid.",
TypeUtils::DataTypeToSerialString(dst_data_type).c_str());
GELOGE(PARAM_INVALID, "[Check][Param] dst_data_type[%s] is not valid, op:%s(%s)",
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}

if (op_desc->GetOutputDescPtr(0) == nullptr) {
REPORT_INNER_ERROR("E19999", "Index 0 ouput desc of op:%s(%s) not exist, check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "Bitcast node outputDesc is null.");
GELOGE(PARAM_INVALID, "[Get][OutputDescPtr] Index 0 ouput desc of op:%s(%s) not exist.",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
if (op_desc->GetOutputDescPtr(0)->GetDataType() != dst_data_type) {
@@ -85,9 +89,10 @@ Status BitcastPass::CheckDstDataType(const OpDescPtr op_desc, ge::DataType &dst_
"check invalid", op_desc->GetName().c_str(), op_desc->GetType().c_str(),
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
TypeUtils::DataTypeToSerialString(op_desc->GetOutputDescPtr(0)->GetDataType()).c_str());
GELOGE(PARAM_INVALID, "dst_data_type[%s] is not equal to output_data_type[%s].",
GELOGE(PARAM_INVALID, "[Check][Param] dst_data_type[%s] is not equal to output_data_type[%s], op:%s(%s).",
TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
TypeUtils::DataTypeToSerialString(op_desc->GetOutputDescPtr(0)->GetDataType()).c_str());
TypeUtils::DataTypeToSerialString(op_desc->GetOutputDescPtr(0)->GetDataType()).c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}
return SUCCESS;
@@ -99,7 +104,8 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType
if (input_tensor_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Index 0 input desc of op:%s(%s) not exist, check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "input_tensor_desc must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] input_tensor_desc(index:0) of op:%s(%s) must not be null.",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}

@@ -109,8 +115,9 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType
REPORT_INNER_ERROR("E19999", "ori_data_type:%d of index 0 input desc in op:%s(%s), "
"check invalid",
ori_data_type, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(PARAM_INVALID, "ori_data_type[%s] is not valid.",
TypeUtils::DataTypeToSerialString(ori_data_type).c_str());
GELOGE(PARAM_INVALID, "[Check][Param] ori_data_type[%s] of input desc(index 0) in op:%s(%s) is not valid.",
TypeUtils::DataTypeToSerialString(ori_data_type).c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return PARAM_INVALID;
}

@@ -121,7 +128,7 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType

BitcastPass::kVecInt64 dim_vec(input_tensor_desc->GetShape().GetDims());
if (CalcAndUpdateShape(dim_vec, ori_data_type, dst_data_type) != SUCCESS) {
GELOGE(PARAM_INVALID, "CalcAndUpdateShape failed.");
GELOGE(PARAM_INVALID, "[Call][CalcAndUpdateShape] failed.");
return PARAM_INVALID;
}

@@ -130,7 +137,9 @@ Status BitcastPass::CheckOutputShape(const OpDescPtr op_desc, const ge::DataType
"check invalid",
formats::JoinToString(output_tensor_desc->GetShape().GetDims()).c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), formats::JoinToString(dim_vec).c_str());
GELOGE(PARAM_INVALID, "out_put_shape is different from expectations.");
GELOGE(PARAM_INVALID, "[Check][Param] Shape:%s of index 0 output desc in op:%s(%s), different from expect shape:%s",
formats::JoinToString(output_tensor_desc->GetShape().GetDims()).c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str(), formats::JoinToString(dim_vec).c_str());
return PARAM_INVALID;
}

@@ -141,7 +150,7 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data
ge::DataType dst_data_type) {
if (dim_vec.size() == 0) {
REPORT_INNER_ERROR("E19999", "Param dim_vec is empty, check invalid");
GELOGE(PARAM_INVALID, "Pre node shape size is zero.");
GELOGE(PARAM_INVALID, "[Check][Param] Param dim_vec is empty.");
return PARAM_INVALID;
}
int64_t ori_data_size = GetSizeByDataType(ori_data_type);
@@ -155,7 +164,10 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data
"check invalid",
ori_data_size, TypeUtils::DataTypeToSerialString(ori_data_type).c_str(),
dst_data_size, TypeUtils::DataTypeToSerialString(dst_data_type).c_str());
GELOGE(PARAM_INVALID, "ori_data_size is not divisible by dst_data_size.");
GELOGE(PARAM_INVALID,
"[Check][Param] size:%ld of ori_data_type:%s is not divisible by size:%ld of dst_data_type:%s.",
ori_data_size, TypeUtils::DataTypeToSerialString(ori_data_type).c_str(),
dst_data_size, TypeUtils::DataTypeToSerialString(dst_data_type).c_str());
return PARAM_INVALID;
}
dim_vec.push_back(ori_data_size / dst_data_size);
@@ -166,7 +178,10 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data
"check invalid",
dst_data_size, TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
ori_data_size, TypeUtils::DataTypeToSerialString(ori_data_type).c_str());
GELOGE(PARAM_INVALID, "dst_data_size is not divisible by ori_data_size.");
GELOGE(PARAM_INVALID,
"[Check][Param] size:%ld of dst_data_type:%s is not divisible by size:%ld of ori_data_type:%s.",
dst_data_size, TypeUtils::DataTypeToSerialString(dst_data_type).c_str(),
ori_data_size, TypeUtils::DataTypeToSerialString(ori_data_type).c_str());
return PARAM_INVALID;
}

@@ -174,7 +189,9 @@ Status BitcastPass::CalcAndUpdateShape(BitcastPass::kVecInt64 &dim_vec, ge::Data
REPORT_INNER_ERROR("E19999", "The last dim:%ld in param dim_vec is not equal to "
"dst_data_size:%ld / ori_data_size:%ld, check invalid",
dim_vec[dim_vec.size() - 1], dst_data_size, ori_data_size);
GELOGE(PARAM_INVALID, "The last dim is not equal to dst_data_size / ori_data_size.");
GELOGE(PARAM_INVALID, "[Check][Param] The last dim:%ld in param dim_vec is not equal to "
"dst_data_size:%ld / ori_data_size:%ld",
dim_vec[dim_vec.size() - 1], dst_data_size, ori_data_size);
return PARAM_INVALID;
}
dim_vec.pop_back();


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

@@ -26,13 +26,13 @@ namespace ge {
Status CastRemovePass::Run(NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "Param [node] must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] Param [node] must not be null.");
return PARAM_INVALID;
}
OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "OpDesc of param [node] must not be null.");
GELOGE(PARAM_INVALID, "[Get][OpDesc] OpDesc of param [node] must not be null.");
return PARAM_INVALID;
}

@@ -49,7 +49,7 @@ Status CastRemovePass::Run(NodePtr &node) {
OpDescPtr end_op_desc = end_node->GetOpDesc();
if (end_op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "op_desc of end_node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "OpDesc of end node must not be null.");
GELOGE(PARAM_INVALID, "[Get][OpDesc] OpDesc of end node must not be null.");
return PARAM_INVALID;
}

@@ -104,7 +104,7 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to
if (IsolateAndDeleteNode(node, {0}) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "IsolateAndDeleteNode %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[IsolateAndDelete][Node] %s failed.", node->GetName().c_str());
return FAILED;
}
}
@@ -120,7 +120,7 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to
OpDescPtr op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "Find nullptr op_desc in node, check invalid");
GELOGE(FAILED, "OpDesc must not be null.");
GELOGE(FAILED, "[Get][OpDesc] OpDesc must not be null.");
return FAILED;
}

@@ -132,7 +132,8 @@ Status CastRemovePass::RemoveCast(DataType &type, std::vector<NodePtr> &nodes_to
REPORT_CALL_ERROR("E19999", "Set Attr:%s of op:%s(%s) failed",
ATTR_NEED_COMPILE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Set ATTR_NEED_COMPILE Attr fail.");
GELOGE(FAILED, "[Set][Attr] %s of op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED;
}
auto in_desc = op_desc->MutableInputDesc(0);


+ 11
- 5
ge/graph/passes/cast_translate_pass.cc View File

@@ -33,7 +33,7 @@
namespace ge {
bool CastTranslatePass::CheckInAndOutDataAnchor(NodePtr &node) const {
if (node == nullptr) {
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
return false;
}
if (node->GetOpDesc() == nullptr) {
@@ -191,7 +191,7 @@ bool CastTranslatePass::IsOpSupportedOptimize(NodePtr &cast_node, NodePtr &trans
}

bool CastTranslatePass::CheckOpSupportOptimize(NodePtr &node, bool &is_src_cast) {
GE_IF_BOOL_EXEC(node == nullptr, GELOGE(FAILED, "node is null."); return false);
GE_IF_BOOL_EXEC(node == nullptr, GELOGE(FAILED, "[Check][Param] node is nullptr."); return false);
auto out_node = node->GetOutDataNodes().at(0);
// N dst nodes have the same datatype and format, check the first node
if (is_src_cast) {
@@ -249,14 +249,19 @@ Status CastTranslatePass::FuseDstNTranslates(NodePtr &node) {
GE_CHECK_NOTNULL(out_data_node);
AddRePassNodesWithInOut(out_data_node);
// Has checked nodes only has one in data anchor one out data anchor
GE_CHK_GRAPH_STATUS_RET(NodeUtils::MoveOutputEdges(out_data_node, base_node), "move out put edge failed");
GE_CHK_GRAPH_STATUS_RET(NodeUtils::MoveOutputEdges(out_data_node, base_node),
"[Move][OutputEdges] failed, out data node:%s, index:0",
base_node->GetName().c_str());

// Relink in control anchor, delete in data anchor
auto in_ctr_anchor = out_data_node->GetInControlAnchor();
GE_CHECK_NOTNULL(in_ctr_anchor);
for (const auto &peer_anchor : in_ctr_anchor->GetPeerOutControlAnchors()) {
GE_CHECK_NOTNULL(base_node->GetInControlAnchor());
GE_CHK_GRAPH_STATUS_RET(base_node->GetInControlAnchor()->LinkFrom(peer_anchor), "link from peer anchor failed");
GE_CHK_GRAPH_STATUS_RET(base_node->GetInControlAnchor()->LinkFrom(peer_anchor),
"[Add][Edge] between %s and %s failed",
base_node->GetInControlAnchor()->GetOwnerNode()->GetName().c_str(),
peer_anchor->GetOwnerNode()->GetName().c_str());
}
in_ctr_anchor->UnlinkAll();
out_data_node->GetAllInDataAnchors().at(0)->UnlinkAll();
@@ -266,7 +271,8 @@ Status CastTranslatePass::FuseDstNTranslates(NodePtr &node) {
if (GraphUtils::RemoveNodeWithoutRelink(graph, out_data_node) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
out_data_node->GetName().c_str(), out_data_node->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", out_data_node->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed",
out_data_node->GetName().c_str(), out_data_node->GetType().c_str(), graph->GetName().c_str());
return FAILED;
}
AddNodeDeleted(out_data_node);


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

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

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



+ 11
- 12
ge/graph/passes/compile_nodes_pass.cc View File

@@ -42,7 +42,7 @@ graphStatus CompileNodesPass::Run(ComputeGraphPtr graph) {
std::shared_ptr<GELib> instance = ge::GELib::GetInstance();
if (instance == nullptr || !instance->InitFlag()) {
REPORT_INNER_ERROR("E19999", "Gelib not init before, check invalid");
GELOGE(ge::GE_CLI_GE_NOT_INITIALIZED, "Run CompileNodesPass failed.");
GELOGE(ge::GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] Gelib not init before.");
return ge::GE_CLI_GE_NOT_INITIALIZED;
}
std::unordered_map<string, vector<NodePtr>> kernel_to_compile_nodes;
@@ -71,7 +71,7 @@ graphStatus CompileNodesPass::Run(ComputeGraphPtr graph) {
kernel_to_compile_nodes.insert(std::make_pair(kernel_lib_name, node_vec));
}
} else {
GELOGE(GRAPH_FAILED, "Get node:%s, type:%s supported kernel failed.", node->GetName().c_str(),
GELOGE(GRAPH_FAILED, "[Get][SupportedKernel] for node:%s(%s) failed.", node->GetName().c_str(),
node->GetType().c_str());
return GRAPH_FAILED;
}
@@ -79,7 +79,7 @@ graphStatus CompileNodesPass::Run(ComputeGraphPtr graph) {
// compile node follow different kernel, currently only TBE kernel
auto result = CompileNodes(instance, kernel_to_compile_nodes);
if (result != GRAPH_SUCCESS) {
GELOGE(result, "Compile op failed.");
GELOGE(result, "[Compile][Op] failed, ret:%u.", result);
return result;
}
GELOGD("[CompileNodesPass]: Optimize success.");
@@ -91,7 +91,7 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std:
string &kernel_lib_name) {
auto op_desc = node->GetOpDesc();
if (op_desc == nullptr) {
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "Get op %s opdesc failed", node->GetName().c_str());
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "[Get][OpDesc] failed, op of param node is nullptr.");
return ge::GE_GRAPH_PARAM_NULLPTR;
}
// reset op kernel lib, find supported kernel
@@ -102,7 +102,7 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std:
if (kernel_lib_name.empty()) {
REPORT_INNER_ERROR("E19999", "kernel_lib_name in op:%s(%s) is empty, check invalid",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(GRAPH_FAILED, "Get node:%s, type:%s kernel lib failed.", node->GetName().c_str(),
GELOGE(GRAPH_FAILED, "[Get][OpKernelLib] for node:%s(%s) failed.", node->GetName().c_str(),
op_desc->GetType().c_str());
return GRAPH_FAILED;
}
@@ -111,7 +111,7 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std:
if (kernel_info == nullptr) {
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed for op:%s(%s)",
kernel_lib_name.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "Get op %s ops kernel info store failed", node->GetName().c_str());
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "[Get][OpsKernelInfoStore] for op:%s failed", node->GetName().c_str());
return ge::GE_GRAPH_PARAM_NULLPTR;
}

@@ -144,13 +144,13 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std:
REPORT_INPUT_ERROR("E13002", std::vector<std::string>({"optype", "opskernel", "reason"}),
std::vector<std::string>({op_desc->GetType(), it.first, it.second}));
GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED,
"CheckAccuracySupport:Op type %s of ops kernel %s is unsupported, reason:%s",
"[Call][CheckAccuracySupport] for Op type %s of ops kernel %s is unsupported, reason:%s",
op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str());
}

REPORT_INPUT_ERROR("E13003", std::vector<std::string>({"opname", "optype"}),
std::vector<std::string>({op_desc->GetName(), op_desc->GetType()}));
GELOGE(GRAPH_FAILED, "Cannot find kernel lib support node:%s, type:%s , get kernel lib failed.",
GELOGE(GRAPH_FAILED, "[Check][Param] Cannot find kernel lib support node:%s, type:%s , get kernel lib failed.",
node->GetName().c_str(), op_desc->GetType().c_str());
return GRAPH_FAILED;
}
@@ -173,9 +173,8 @@ graphStatus CompileNodesPass::CompileNodes(const std::shared_ptr<GELib> instance
for (auto &kernel_nodes : kernel_to_compile_nodes) {
kernel_info = instance->OpsKernelManagerObj().GetOpsKernelInfoStore(kernel_nodes.first);
if (kernel_info == nullptr) {
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed",
kernel_nodes.first.c_str());
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "Get op %s ops kernel info store failed", kernel_nodes.first.c_str());
REPORT_INNER_ERROR("E19999", "Find ops kernel by name:%s failed", kernel_nodes.first.c_str());
GELOGE(ge::GE_GRAPH_PARAM_NULLPTR, "[Get][OpsKernelInfoStore] for op %s failed", kernel_nodes.first.c_str());
return ge::GE_GRAPH_PARAM_NULLPTR;
}
string reason;
@@ -192,7 +191,7 @@ graphStatus CompileNodesPass::CompileNodes(const std::shared_ptr<GELib> instance
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Call CompileOp failed, kernel_lib_name:%s, ret:%d",
kernel_nodes.first.c_str(), ret);
GELOGE(ret, "Compile op failed, kernel name is %s", kernel_nodes.first.c_str());
GELOGE(ret, "[Compile][Op] failed, kernel name is %s", kernel_nodes.first.c_str());
return GRAPH_FAILED;
}
}


+ 38
- 28
ge/graph/passes/cond_pass.cc View File

@@ -32,7 +32,7 @@ Status CondPass::Run(NodePtr &node) {
if (ret == NOT_CHANGED) {
return SUCCESS;
} else if (ret != SUCCESS) {
GELOGE(FAILED, "Get cond_info for node %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Get][CondInfo] for node %s failed.", node->GetName().c_str());
return FAILED;
}

@@ -48,19 +48,19 @@ Status CondPass::Run(NodePtr &node) {
if (cond_tensor.MutableShape().GetDim(0) == UNKNOWN_DIM_NUM) {
GELOGI("Output tensor rank of Cond is unknown.");
if (cond_tensor.GetDataType() == DT_STRING) {
GE_CHK_STATUS_RET(HandleStringCond(graph, peer_out_anchor, cond_in_anchor), "HandleStringCond for %s failed.",
op_desc->GetName().c_str())
GE_CHK_STATUS_RET(HandleStringCond(graph, peer_out_anchor, cond_in_anchor),
"[Handle][StringCond] for op:%s failed.", op_desc->GetName().c_str())
}
return SUCCESS;
}
if (!cond_tensor.GetShape().IsScalar()) {
GE_CHK_STATUS_RET(HandleNonScalarCond(graph, peer_out_anchor, cond_in_anchor), "HandleNonScalarCond for %s failed.",
op_desc->GetName().c_str())
GE_CHK_STATUS_RET(HandleNonScalarCond(graph, peer_out_anchor, cond_in_anchor),
"[Handle][NonScalarCond] for op:%s failed.", op_desc->GetName().c_str())
} else {
switch (cond_tensor.GetDataType()) {
case DT_STRING:
GE_CHK_STATUS_RET(HandleStringCond(graph, peer_out_anchor, cond_in_anchor), "HandleStringCond for %s failed.",
op_desc->GetName().c_str())
GE_CHK_STATUS_RET(HandleStringCond(graph, peer_out_anchor, cond_in_anchor),
"[Handle][StringCond] for op:%s failed.", op_desc->GetName().c_str())
break;
case DT_BOOL:
case DT_FLOAT:
@@ -70,7 +70,7 @@ Status CondPass::Run(NodePtr &node) {
case DT_INT8:
case DT_INT64:
GE_CHK_STATUS_RET(HandleScalarCond(graph, peer_out_anchor, cond_in_anchor, cond_tensor.GetDataType()),
"HandleScalarCond for %s failed.", op_desc->GetName().c_str())
"[Handle][ScalarCond] for op:%s failed.", op_desc->GetName().c_str())
break;
case DT_INT32:
break;
@@ -79,7 +79,9 @@ Status CondPass::Run(NodePtr &node) {
"data_type:%d of index:%d input tensor in op:%s(%s) check invalid",
cond_tensor.GetDataType(), cond_in_anchor->GetIdx(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "UpdateInputDesc for node %s failed.", op_desc->GetName().c_str());
GELOGE(FAILED, "[Check][Param] data_type:%d of index:%d input tensor in op:%s(%s) is invalid",
cond_tensor.GetDataType(), cond_in_anchor->GetIdx(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED;
}
}
@@ -91,7 +93,8 @@ Status CondPass::Run(NodePtr &node) {
if (op_desc->UpdateInputDesc(cond_in_anchor->GetIdx(), cond_tensor) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Update input desc of op:%s(%s) failed, index:%d",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), cond_in_anchor->GetIdx());
GELOGE(FAILED, "UpdateInputDesc for node %s failed.", op_desc->GetName().c_str());
GELOGE(FAILED, "[Update][InputDesc] for op:%s(%s) failed, index:%d",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), cond_in_anchor->GetIdx());
return FAILED;
}

@@ -112,12 +115,12 @@ Status CondPass::GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph, OutDat
std::string type = node->GetType();
if (kIfOpTypes.count(type) != 0) {
if (GetCondInfoForIf(node, graph, peer_out_anchor, cond_in_anchor) != SUCCESS) {
GELOGE(FAILED, "Get cond_info for if node failed.");
GELOGE(FAILED, "[Get][CondInfo] for if node:%s failed.", node->GetName().c_str());
return FAILED;
}
} else if (kWhileOpTypes.count(type) != 0) {
if (GetCondInfoForWhile(node, graph, peer_out_anchor, cond_in_anchor) != SUCCESS) {
GELOGE(FAILED, "Get cond_info for while node failed.");
GELOGE(FAILED, "[Get][CondInfo] for while node:%s failed.", node->GetName().c_str());
return FAILED;
}
} else {
@@ -166,8 +169,9 @@ Status CondPass::GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph
if (iter == subgraph_names_to_index.end()) {
REPORT_INNER_ERROR("E19999", "subgraph name:%s not exist in SubgraphNameIndexes map of op:%s(%s), "
"check invalid", ATTR_NAME_WHILE_COND.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Get cond_graph index failed, while_node:%s.", node->GetName().c_str());
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "subgraph name:%s not exist in SubgraphNameIndexes map of op:%s(%s)", ATTR_NAME_WHILE_COND.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED;
}
std::string cond_graph_instance_name = op_desc->GetSubgraphInstanceName(iter->second);
@@ -181,7 +185,7 @@ Status CondPass::GetCondInfoForWhile(const NodePtr &node, ComputeGraphPtr &graph
if (output_num != 1) {
REPORT_INNER_ERROR("E19999", "Input data anchor num:%u of op:%s(%s) not equal to 1, check invalid",
output_num, op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.",
GELOGE(FAILED, "[Check][Param] output size of cond_graph is invalid, expect 1 but %u exactly, while_node:%s.",
output_num, node->GetName().c_str());
return FAILED;
}
@@ -239,7 +243,7 @@ Status CondPass::HandleScalarCond(const ComputeGraphPtr &graph, const OutDataAnc
std::string cast_name = cond_in_anchor->GetOwnerNode()->GetName() + "_Cast";
NodePtr cast_node = AddCastNode(graph, cast_name, tensor, src_type, DT_INT32);
if (cast_node == nullptr) {
GELOGE(FAILED, "Add Cast node failed, name:%s.", cast_name.c_str());
GELOGE(FAILED, "[Add][CastNode] failed, name:%s.", cast_name.c_str());
return FAILED;
}

@@ -250,7 +254,7 @@ Status CondPass::HandleScalarCond(const ComputeGraphPtr &graph, const OutDataAnc
peer_out_anchor->GetOwnerNode()->GetType().c_str(),
cond_in_anchor->GetOwnerNode()->GetName().c_str(),
cond_in_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(FAILED, "Insert Cast node %s between %s->%s failed.",
GELOGE(FAILED, "[Insert][CastNode] %s between %s->%s failed.",
cast_node->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
cond_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
@@ -287,14 +291,16 @@ Status CondPass::InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Create op_desc:%s(%s) failed",
(in_data_anchor->GetOwnerNode()->GetName() + "_" + type).c_str(), type.c_str());
GELOGE(FAILED, "Create op_desc failed.");
GELOGE(FAILED, "[Create][OpDesc] %s(%s) failed.",
(in_data_anchor->GetOwnerNode()->GetName() + "_" + type).c_str(), type.c_str());
return FAILED;
}
NodePtr new_node = graph->AddNode(op_desc);
if (new_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "Create %s node failed.", type.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 FAILED;
}
AddRePassNode(new_node);
@@ -306,9 +312,10 @@ Status CondPass::InsertNode(const ComputeGraphPtr &graph, const OutDataAnchorPtr
peer_out_anchor->GetOwnerNode()->GetType().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(FAILED, "Insert %s node %s between %s->%s failed.", type.c_str(),
new_node->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(FAILED, "[Insert][Node] %s(%s) between %s(%s)->%s(%s) failed",
new_node->GetName().c_str(), new_node->GetType().c_str(),
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(),
in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str());
return FAILED;
}

@@ -337,20 +344,22 @@ NodePtr CondPass::AddCastNode(const ComputeGraphPtr &graph, const std::string &n
OpDescBuilder op_desc_builder(name, CAST);
OpDescPtr cast_desc = op_desc_builder.AddInput("x", in_tensor).AddOutput("y", out_tensor).Build();
if (cast_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Create op_desc:%s(%s) failed",
name.c_str(), CAST);
GELOGE(FAILED, "Create cast op_desc failed, name: %s.", name.c_str());
REPORT_CALL_ERROR("E19999", "Create op_desc:%s(%s) failed", name.c_str(), CAST);
GELOGE(FAILED, "[Create][OpDesc] failed, name:%s(%s).", name.c_str(), CAST);
return nullptr;
}
if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, src) &&
AttrUtils::SetInt(cast_desc, CAST_ATTR_DSTT, dst) &&
AttrUtils::SetInt(cast_desc, CAST_ATTR_DST_TYPE, dst) &&
AttrUtils::SetBool(cast_desc, CAST_ATTR_TRUNCATE, false))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s,%s,%s,%s to node:%s(%s) not all success",
REPORT_CALL_ERROR("E19999", "Set Attr:%s, %s, %s, %s to node:%s(%s) not all success",
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(),
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(),
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
GELOGE(FAILED, "Set CAST_ATTR failed, node: %s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s, %s, %s, %s to node:%s(%s) not all success",
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;
}

@@ -358,7 +367,8 @@ NodePtr CondPass::AddCastNode(const ComputeGraphPtr &graph, const std::string &n
if (cast_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "Add cast node failed, name: %s.", name.c_str());
GELOGE(FAILED, "[Add][Node] %s(%s) to graph:%s failed",
cast_desc->GetName().c_str(), cast_desc->GetType().c_str(), graph->GetName().c_str());
return nullptr;
}
AddRePassNode(cast_node);


+ 11
- 11
ge/graph/passes/cond_remove_pass.cc View File

@@ -41,7 +41,7 @@ Status CondRemovePass::Run(NodePtr &node) {
if (ret == NOT_CHANGED) {
return SUCCESS;
} else if (ret != SUCCESS) {
GELOGE(FAILED, "Get cond_info for node %s failed.", node->GetName().c_str());
GELOGE(FAILED, "[Get][CondInfo] for node %s failed.", node->GetName().c_str());
return FAILED;
}
int32_t cond_index = 0;
@@ -90,7 +90,7 @@ Status CondRemovePass::RemoveDeadCondLink(const int32_t index, const NodePtr &no
peerout_anchor->GetOwnerNode()->GetType().c_str(), peerout_anchor->GetIdx(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx());
GELOGE(FAILED, "Remove edge from node %s index %d to node %s index %d.",
GELOGE(FAILED, "[Remove][Edge] from node %s index %d to node %s index %d.",
peerout_anchor->GetOwnerNode()->GetName().c_str(), peerout_anchor->GetIdx(),
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx());
return FAILED;
@@ -105,7 +105,7 @@ Status CondRemovePass::GetCaseChosenBranch(const NodePtr &node, const uint32_t c
if (subgraph_names_size == 0) {
REPORT_INNER_ERROR("E19999", "subgraph size of op:%s(%s) is 0, check invavlid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Node %s has none subgraph.", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Node %s has none subgraph.", node->GetName().c_str());
return ge::FAILED;
}
// If cond index is over the maimum subgraph number, choose the last subgraph
@@ -116,7 +116,7 @@ Status CondRemovePass::GetCaseChosenBranch(const NodePtr &node, const uint32_t c
if (chosen_branch_name.empty()) {
REPORT_INNER_ERROR("E19999", "Get subgraph name from op:%s(%s) by index:%u failed",
node->GetName().c_str(), node->GetType().c_str(), cond_index_new);
GELOGE(FAILED, "Node %s has no subgraph, index is %u.", node->GetName().c_str(), cond_index_new);
GELOGE(FAILED, "[Get][SubGraph] Node %s has no subgraph, index is %u.", node->GetName().c_str(), cond_index_new);
return ge::FAILED;
}
auto chosen_graph = GraphUtils::FindRootGraph(node->GetOwnerComputeGraph())->GetSubgraph(chosen_branch_name);
@@ -132,7 +132,7 @@ Status CondRemovePass::GetIfChosenBranch(const NodePtr &node, const uint32_t con
if (subgraph_names_size == 0) {
REPORT_INNER_ERROR("E19999", "subgraph size of op:%s(%s) is 0, check invavlid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Node %s has none subgraph.", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Node %s has none subgraph.", node->GetName().c_str());
return ge::FAILED;
}
// If cond is false, else branch
@@ -143,7 +143,7 @@ Status CondRemovePass::GetIfChosenBranch(const NodePtr &node, const uint32_t con
if (chosen_branch_name.empty()) {
REPORT_INNER_ERROR("E19999", "Get subgraph name from op:%s(%s) by index:%u failed",
node->GetName().c_str(), node->GetType().c_str(), cond_index_new);
GELOGE(FAILED, "Node %s has no subgraph, index is %u.", node->GetName().c_str(), cond_index_new);
GELOGE(FAILED, "[Get][SubGraph] Node %s has no subgraph, index is %u.", node->GetName().c_str(), cond_index_new);
return ge::FAILED;
}
auto chosen_graph = GraphUtils::FindRootGraph(node->GetOwnerComputeGraph())->GetSubgraph(chosen_branch_name);
@@ -151,7 +151,7 @@ Status CondRemovePass::GetIfChosenBranch(const NodePtr &node, const uint32_t con
REPORT_INNER_ERROR("E19999",
"Find subgraph by name:%s from node:%s(%s)'s root_graph failed",
chosen_branch_name.c_str(), node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Can not find branch %s in node %s's parent graph %s.", chosen_branch_name.c_str(),
GELOGE(FAILED, "[Check][Param] Can not find branch %s in node %s's parent graph %s.", chosen_branch_name.c_str(),
node->GetName().c_str(), node->GetOwnerComputeGraph()->GetName().c_str());
return ge::FAILED;
}
@@ -263,7 +263,7 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c
peerout_anchor->GetOwnerNode()->GetType().c_str(), peerout_anchor->GetIdx(),
partitioncall_node->GetName().c_str(),
partitioncall_node->GetType().c_str(), input_anchor->GetIdx());
GELOGE(FAILED, "Add edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu",
GELOGE(FAILED, "[Add][Edge] failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu",
peerout_anchor->GetOwnerNode()->GetName().c_str(), peerout_anchor->GetIdx(),
partitioncall_node->GetName().c_str(), input_anchor->GetIdx(), input_desc_size,
output_desc_size);
@@ -280,7 +280,7 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c
node->GetName().c_str(), node->GetType().c_str(), output_anchor->GetIdx(),
peerin_anchor->GetOwnerNode()->GetName().c_str(),
peerin_anchor->GetOwnerNode()->GetType().c_str(), peerin_anchor->GetIdx());
GELOGE(FAILED, "Remove edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu",
GELOGE(FAILED, "[Remove][Edge] failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu",
node->GetName().c_str(), output_anchor->GetIdx(), peerin_anchor->GetOwnerNode()->GetName().c_str(),
peerin_anchor->GetIdx(), input_desc_size, output_desc_size);
return FAILED;
@@ -292,7 +292,7 @@ Status CondRemovePass::ReplaceIfCaseNodeWithPartitioncall(const NodePtr &node, c
partitioncall_node->GetType().c_str(), output_anchor->GetIdx(),
peerin_anchor->GetOwnerNode()->GetName().c_str(),
peerin_anchor->GetOwnerNode()->GetType().c_str(), peerin_anchor->GetIdx());
GELOGE(FAILED, "Add edge failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu",
GELOGE(FAILED, "[Add][Edge] failed, from node:%s idx:%d to node:%s idx:%d, input num:%zu, output num:%zu",
partitioncall_node->GetName().c_str(), output_anchor->GetIdx(),
peerin_anchor->GetOwnerNode()->GetName().c_str(), peerin_anchor->GetIdx(), input_desc_size,
output_desc_size);
@@ -370,7 +370,7 @@ Status CondRemovePass::GetCondInfo(const NodePtr &node, ComputeGraphPtr &graph,
std::string type = node->GetType();
if ((kIfOpTypes.count(type) != 0) || (kCaseOpTypes.count(type) != 0)) {
if (GetCondInfoForIfCase(node, graph, cond_out_anchor, cond_in_anchor) != SUCCESS) {
GELOGE(FAILED, "Get cond_info for if/case node failed.");
GELOGE(FAILED, "[Get][CondInfo] for if/case node:%s failed.", node->GetName().c_str());
return FAILED;
}
} else {


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

@@ -33,12 +33,12 @@ Status RunOpKernelWithCheck(NodePtr &node,
std::vector<GeTensorPtr> &outputs) {
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance();
if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) {
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized or is finalized.");
GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Check][Param] GE is not initialized or is finalized.");
return UNSUPPORTED;
}
OpsKernelInfoStorePtr kernel_info = instance_ptr->OpsKernelManagerObj().GetOpsKernelInfoStore(kKernelLibName);
if (kernel_info == nullptr) {
GELOGE(FAILED, "Get op kernel info store %s failed", kKernelLibName.c_str());
GELOGE(FAILED, "[Get][OpsKernelInfoStore] %s failed", kKernelLibName.c_str());
return UNSUPPORTED;
}

@@ -110,7 +110,7 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) {
}
REPORT_CALL_ERROR("E19999", "Calculate for node %s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Calculate for node %s failed in constant folding", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Call][Calculate] for node %s failed in constant folding", node->GetName().c_str());
return ret;
}
GELOGI("Node %s type %s, constant folding compute success.", node->GetName().c_str(), node->GetType().c_str());
@@ -129,10 +129,8 @@ Status ConstantFoldingPass::Run(ge::NodePtr &node) {
if (outputs.empty()) {
REPORT_INNER_ERROR("E19999", "After calculate for node %s(%s), output weight is empty, check invalid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Failed to constant folding on node %s,"
" no output weight",
node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] After calculate for node %s(%s), output weight is empty",
node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
}



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

@@ -58,7 +58,7 @@ void GetOutDataNodeToIndexMap(NodePtr &node, std::map<string, InDataAnchorPtr> &
Status ConstantFuseSamePass::Run(ge::ComputeGraphPtr graph) {
if (graph == nullptr) {
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;
}
GELOGI("ConstantFuseSamePass in.");
@@ -160,13 +160,14 @@ Status ConstantFuseSamePass::MoveOutDataEdges(NodePtr &src_node, NodePtr &dst_no
}
auto ret = dst_out_data_anchor->LinkTo(it->second);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:0 link to op:%s(%s) in index:%d failed",
REPORT_CALL_ERROR("E19999", "Op:%s(%s) out index:0 link to op:%s(%s) in index:%d failed",
dst_node->GetName().c_str(), dst_node->GetType().c_str(),
it->second->GetOwnerNode()->GetName().c_str(), it->second->GetOwnerNode()->GetType().c_str(),
it->second->GetIdx());
GELOGE(FAILED, "Failed to move out data edge from %s to %s", src_node->GetName().c_str(),
dst_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] Op:%s(%s) out index:0 link to op:%s(%s) in index:%d failed",
dst_node->GetName().c_str(), dst_node->GetType().c_str(),
it->second->GetOwnerNode()->GetName().c_str(), it->second->GetOwnerNode()->GetType().c_str(),
it->second->GetIdx());
return FAILED;
}
}
@@ -193,7 +194,8 @@ Status ConstantFuseSamePass::FuseConstNodes(ComputeGraphPtr &graph,
if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str());
GELOGE(FAILED, "[Remove][Node] %s(%s) Without Relink in graph:%s failed.",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
return FAILED;
}
}


+ 57
- 36
ge/graph/passes/control_trigger_pass.cc View File

@@ -30,7 +30,7 @@ Status ControlTriggerPass::Run(ComputeGraphPtr graph) {
auto in_ctrl_nodes = node->GetInControlNodes();
for (NodePtr &in_ctrl_node : in_ctrl_nodes) {
if (HandleDynamicCtrlEdges(graph, node, in_ctrl_node) != SUCCESS) {
GELOGE(FAILED, "HandleDynamicCtrlEdges for %s->%s fail.", in_ctrl_node->GetName().c_str(),
GELOGE(FAILED, "[Handle][DynamicCtrlEdges] for node:%s->node:%s failed.", in_ctrl_node->GetName().c_str(),
node->GetName().c_str());
return FAILED;
}
@@ -55,7 +55,7 @@ Status ControlTriggerPass::HandleDynamicCtrlEdges(ComputeGraphPtr &graph, NodePt
NodePtr switch_node = nullptr;
bool branch_flag = false;
if (FindSwitchNode(in_ctrl_node, switch_node, branch_flag) != SUCCESS) {
GELOGE(FAILED, "FindSwitchNode fail.");
GELOGE(FAILED, "[Find][SwitchNode] failed, in_ctrl_node:%s.", in_ctrl_node->GetName().c_str());
return FAILED;
}

@@ -76,8 +76,9 @@ Status ControlTriggerPass::HandleDynamicCtrlEdges(ComputeGraphPtr &graph, NodePt
node->GetName().c_str(), node->GetType().c_str(),
in_ctrl_node->GetName().c_str(), in_ctrl_node->GetType().c_str(),
constant->GetName().c_str(), constant->GetType().c_str());
GELOGE(FAILED, "Replace ctrl edge fail, %s->%s, %s->%s.", in_ctrl_node->GetName().c_str(),
node->GetName().c_str(), in_ctrl_node->GetName().c_str(), constant->GetName().c_str());
GELOGE(FAILED, "[Replace][CtrlEdge] failed, remove edge:%s->%s, add edge:%s->%s.",
in_ctrl_node->GetName().c_str(), node->GetName().c_str(),
in_ctrl_node->GetName().c_str(), constant->GetName().c_str());
return FAILED;
}

@@ -87,7 +88,8 @@ Status ControlTriggerPass::HandleDynamicCtrlEdges(ComputeGraphPtr &graph, NodePt
}

if (InsertOppositeBranch(graph, node, in_ctrl_node, switch_node, branch_flag) != SUCCESS) {
GELOGE(FAILED, "InsertOppositeBranch fail.");
GELOGE(FAILED, "[Insert][OppositeBranch] failed, node:%s, in_ctrl_node:%s.",
node->GetName().c_str(), in_ctrl_node->GetName().c_str());
return FAILED;
}

@@ -145,7 +147,7 @@ Status ControlTriggerPass::FindSwitchNode(const NodePtr &node, NodePtr &switch_n
case kNotControlOp:
break;
default:
GELOGE(FAILED, "invalid type");
GELOGE(FAILED, "[Check][Param] invalid node type");
return FAILED;
}

@@ -167,6 +169,12 @@ Status ControlTriggerPass::FindSwitchNode(const NodePtr &node, NodePtr &switch_n
/// @return ControlNodeType
///
ControlNodeType ControlTriggerPass::TransferNodeType(const NodePtr &node, uint32_t index) {
OpDescPtr merge_desc = node->GetOpDesc();
if (merge_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "op_desc in merge node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, merge_desc is nullptr.");
return kInvalidType;
}
const std::string type = node->GetType();
if ((type == SWITCH) || (type == REFSWITCH)) {
if ((index != SWITCH_TRUE_OUTPUT) && (index != SWITCH_FALSE_OUTPUT)) {
@@ -175,7 +183,7 @@ ControlNodeType ControlTriggerPass::TransferNodeType(const NodePtr &node, uint32
}

if (FindPredInput(node) != SUCCESS) {
GELOGE(INTERNAL_ERROR, "FindPredInput fail, switch_node: %s.", node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Find][PredInput] failed, switch_node:%s.", node->GetName().c_str());
return kInvalidType;
}

@@ -189,12 +197,6 @@ ControlNodeType ControlTriggerPass::TransferNodeType(const NodePtr &node, uint32
return branch_flag ? kLoopSwitchT : kLoopSwitchF;
}
} else if ((type == MERGE) || (type == REFMERGE)) {
OpDescPtr merge_desc = node->GetOpDesc();
if (merge_desc == nullptr) {
REPORT_INNER_ERROR("E19999", "op_desc in merge node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "FindPredInput fail, merge_desc is null, merge_node: %s.", node->GetName().c_str());
return kInvalidType;
}
if (!merge_desc->HasAttr(ATTR_NAME_NEXT_ITERATION)) {
return kCondMerge;
}
@@ -248,14 +250,16 @@ Status ControlTriggerPass::InsertOppositeBranch(ComputeGraphPtr &graph, NodePtr

NodePtr merge_node = InsertMergeNode(graph, node, in_ctrl_node, data_desc);
if (merge_node == nullptr) {
GELOGE(FAILED, "InsertMergeNode fail.");
GELOGE(FAILED, "[Insert][MergeNode] failed, node:%s, in_ctrl_node:%s.",
node->GetName().c_str(), in_ctrl_node->GetName().c_str());
return FAILED;
}

NodePtr const_f = InsertConstNode(graph, merge_node, data_desc, false);
NodePtr const_t = InsertConstNode(graph, merge_node, data_desc, true);
if ((const_f == nullptr) || (const_t == nullptr)) {
GELOGE(FAILED, "InsertConstNode fail.");
GELOGE(FAILED, "[Insert][ConstNode] failed, graph:%s, merge_node:%s.",
graph->GetName().c_str(), merge_node->GetName().c_str());
return FAILED;
}

@@ -266,7 +270,8 @@ Status ControlTriggerPass::InsertOppositeBranch(ComputeGraphPtr &graph, NodePtr
const std::string identity_name = switch_desc->GetName() + "_" + IDENTITY;
NodePtr identity_node = InsertIdentityNode(graph, identity_name, switch_desc->GetOutputDesc(new_idx));
if (identity_node == nullptr) {
GELOGE(FAILED, "InsertIdentityNode fail.");
GELOGE(FAILED, "[Insert][IdentityNode] name:%s failed, graph:%s.",
identity_name.c_str(), graph->GetName().c_str());
return FAILED;
}

@@ -274,21 +279,25 @@ Status ControlTriggerPass::InsertOppositeBranch(ComputeGraphPtr &graph, NodePtr
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
in_ctrl_node->GetName().c_str(), in_ctrl_node->GetType().c_str(),
orig_const->GetName().c_str(), orig_const->GetType().c_str());
GELOGE(FAILED, "Add in ctrl edge fail, %s->%s.", in_ctrl_node->GetName().c_str(), orig_const->GetName().c_str());
GELOGE(FAILED, "[Add][CtrlEdge] failed, %s->%s.", in_ctrl_node->GetName().c_str(), orig_const->GetName().c_str());
return FAILED;
}
if (GraphUtils::AddEdge(switch_node->GetOutDataAnchor(new_idx), identity_node->GetInDataAnchor(0)) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%u) and op:%s(%s)(index:0) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), new_idx,
identity_node->GetName().c_str(), identity_node->GetType().c_str());
GELOGE(FAILED, "Add in data edge fail, %s->%s.", switch_desc->GetName().c_str(), identity_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:%u) and op:%s(%s)(index:0) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(), new_idx,
identity_node->GetName().c_str(), identity_node->GetType().c_str());
return FAILED;
}
if (GraphUtils::AddEdge(identity_node->GetOutControlAnchor(), new_const->GetInControlAnchor()) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
identity_node->GetName().c_str(), identity_node->GetType().c_str(),
new_const->GetName().c_str(), new_const->GetType().c_str());
GELOGE(FAILED, "Add in ctrl edge fail, %s->%s.", identity_node->GetName().c_str(), new_const->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
identity_node->GetName().c_str(), identity_node->GetType().c_str(),
new_const->GetName().c_str(), new_const->GetType().c_str());
return FAILED;
}

@@ -299,7 +308,7 @@ Status ControlTriggerPass::InsertOppositeBranch(ComputeGraphPtr &graph, NodePtr
} else {
if (!iter->second.insert(pred_const).second) {
REPORT_INNER_ERROR("E19999", "Insert to control_trigger_map_ failed");
GELOGE(FAILED, "control_trigger_map_ insert failed.");
GELOGE(FAILED, "[Check][Param] control_trigger_map_ insert failed.");
return FAILED;
}
}
@@ -321,7 +330,7 @@ NodePtr ControlTriggerPass::InsertMergeNode(ComputeGraphPtr &graph, NodePtr &nod
OpDescPtr op_desc = MakeShared<OpDesc>(name, MERGE);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create Merge op %s: create op_desc fail.", name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed");
return nullptr;
}

@@ -329,7 +338,8 @@ NodePtr ControlTriggerPass::InsertMergeNode(ComputeGraphPtr &graph, NodePtr &nod
(op_desc->AddOutputDesc(data_desc) != GRAPH_SUCCESS) || (op_desc->AddOutputDesc(data_desc) != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Add input or ouput desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Merge op %s: add input/output desc fail.", name.c_str());
GELOGE(INTERNAL_ERROR, "[Add][GeTensorDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr;
}

@@ -338,7 +348,8 @@ NodePtr ControlTriggerPass::InsertMergeNode(ComputeGraphPtr &graph, NodePtr &nod
if (merge_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Create Merge op %s fail.", 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;
}

@@ -350,7 +361,8 @@ NodePtr ControlTriggerPass::InsertMergeNode(ComputeGraphPtr &graph, NodePtr &nod
node->GetName().c_str(), node->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Replace ctrl edge fail, %s->%s, %s->%s", in_ctrl_node->GetName().c_str(), node->GetName().c_str(),
GELOGE(FAILED, "[Replace][CtrlEdge] failed, remove edge:%s->%s, add edge:%s->%s",
in_ctrl_node->GetName().c_str(), node->GetName().c_str(),
merge_node->GetName().c_str(), node->GetName().c_str());
return nullptr;
}
@@ -372,7 +384,7 @@ NodePtr ControlTriggerPass::InsertConstNode(ComputeGraphPtr &graph, NodePtr &mer
OpDescPtr op_desc = MakeShared<OpDesc>(name, CONSTANT);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create Const op %s: create op_desc fail.", name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr;
}

@@ -380,20 +392,22 @@ NodePtr ControlTriggerPass::InsertConstNode(ComputeGraphPtr &graph, NodePtr &mer
GeTensorPtr const_value = MakeShared<GeTensor>(data_desc, reinterpret_cast<uint8_t *>(&value), sizeof(int32_t));
if (const_value == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "Create tensor fail.");
GELOGE(FAILED, "[New][GeTensor] failed.");
return nullptr;
}
if (!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_value)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Const op %s: set attr ATTR_NAME_WEIGHTS fail.", name.c_str());
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 nullptr;
}

if (op_desc->AddOutputDesc(data_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Const op %s: add output desc fail.", name.c_str());
GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr;
}

@@ -402,7 +416,8 @@ NodePtr ControlTriggerPass::InsertConstNode(ComputeGraphPtr &graph, NodePtr &mer
if (const_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Create Const op %s fail.", 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;
}

@@ -411,7 +426,9 @@ NodePtr ControlTriggerPass::InsertConstNode(ComputeGraphPtr &graph, NodePtr &mer
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%u) failed",
const_node->GetName().c_str(), const_node->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str(), out_idx);
GELOGE(FAILED, "Add in data edge fail, %s->%s", const_node->GetName().c_str(), merge_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%u) failed",
const_node->GetName().c_str(), const_node->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str(), out_idx);
return nullptr;
}

@@ -430,14 +447,15 @@ NodePtr ControlTriggerPass::InsertIdentityNode(ComputeGraphPtr &graph, const std
OpDescPtr op_desc = MakeShared<OpDesc>(name, IDENTITY);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create Identity op %s: create op_desc fail.", name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed");
return nullptr;
}

if ((op_desc->AddInputDesc(data_desc) != GRAPH_SUCCESS) || (op_desc->AddOutputDesc(data_desc) != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Add input or output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Identity op %s: add input/output desc fail.", name.c_str());
GELOGE(INTERNAL_ERROR, "[Add][GeTensorDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr;
}

@@ -446,7 +464,8 @@ NodePtr ControlTriggerPass::InsertIdentityNode(ComputeGraphPtr &graph, const std
if (identity_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Create Identity op %s fail.", 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;
}

@@ -463,7 +482,7 @@ NodePtr ControlTriggerPass::InsertIdentityNode(ComputeGraphPtr &graph, const std
Status ControlTriggerPass::FindPredInput(const NodePtr &switch_node) {
if (switch_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param switch_node is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "switch_node is null");
GELOGE(INTERNAL_ERROR, "[Check][Param] switch_node is nullptr");
return INTERNAL_ERROR;
}

@@ -472,7 +491,8 @@ Status ControlTriggerPass::FindPredInput(const NodePtr &switch_node) {
REPORT_INNER_ERROR("E19999", "Index:%d in anchor of switch_node:%s(%s) is nullptr, check invalid",
SWITCH_PRED_INPUT,
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "in_cond_anchor is nullptr, node: %s.", switch_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][InDataAnchor] Index:%d in anchor of switch_node:%s(%s) is nullptr",
SWITCH_PRED_INPUT, switch_node->GetName().c_str(), switch_node->GetType().c_str());
return INTERNAL_ERROR;
}
OutDataAnchorPtr pred_cond_anchor = in_cond_anchor->GetPeerOutAnchor();
@@ -480,7 +500,8 @@ Status ControlTriggerPass::FindPredInput(const NodePtr &switch_node) {
REPORT_INNER_ERROR("E19999", "Index:%d in anchor of switch_node:%s(%s), it's peer anchor is nullptr, "
"check invalid", SWITCH_PRED_INPUT,
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "pred_cond_anchor is nullptr, node: %s.", switch_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Index:%d in anchor of switch_node:%s(%s), it's peer anchor is nullptr",
SWITCH_PRED_INPUT, switch_node->GetName().c_str(), switch_node->GetType().c_str());
return INTERNAL_ERROR;
}



+ 6
- 2
ge/graph/passes/ctrl_edge_transfer_pass.cc View File

@@ -65,13 +65,17 @@ Status CtrlEdgeTransferPass::Run(ge::ComputeGraphPtr graph) {
for (auto &in_control_node : n->GetInControlNodes()) {
GE_CHECK_NOTNULL(in_control_node);
GE_CHK_GRAPH_STATUS_RET(ge::GraphUtils::RemoveEdge(in_control_node->GetOutControlAnchor(),
n->GetInControlAnchor()), "remove edge failed");
n->GetInControlAnchor()),
"[Remove][ControlEdge] between %s and %s failed",
in_control_node->GetName().c_str(), n->GetName().c_str());
for (auto &out_node : n->GetOutNodes()) {
if (out_node == nullptr) {
continue;
}
GE_CHK_GRAPH_STATUS_RET(ge::GraphUtils::AddEdge(in_control_node->GetOutControlAnchor(),
out_node->GetInControlAnchor()), "add edge failed.");
out_node->GetInControlAnchor()),
"[Add][ControlEdge] between %s and %s failed.",
in_control_node->GetName().c_str(), out_node->GetName().c_str());
}
}
}


+ 11
- 8
ge/graph/passes/data_pass.cc View File

@@ -32,7 +32,8 @@ Status MappingSubgraphInput(const ComputeGraphPtr &graph, const std::function<in
if (!AttrUtils::GetInt(node->GetOpDesc(), "index", index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", "index",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Failed to get index from data[%s]", node->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] index from op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}

@@ -42,7 +43,8 @@ Status MappingSubgraphInput(const ComputeGraphPtr &graph, const std::function<in
if (!AttrUtils::SetInt(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(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Failed to set parent index for node %s", node->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
}
@@ -72,7 +74,8 @@ Status MappingSubgraphOutput(const ComputeGraphPtr &graph, const std::function<i
REPORT_CALL_ERROR("E19999", "Set Attr:%s to tensor of op:%s(%s) input:%zu failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(),
index);
GELOGE(FAILED, "Failed to set parent index for graph %s", graph->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to tensor of op:%s(%s) input:%zu failed",
ATTR_NAME_PARENT_NODE_INDEX.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str(), index);
return FAILED;
}
}
@@ -87,12 +90,12 @@ Status MappingSubgraphIndex(const ComputeGraphPtr &graph,
GE_CHECK_NOTNULL(input);
GE_CHECK_NOTNULL(output);
if (MappingSubgraphInput(graph, input) != SUCCESS) {
GELOGE(FAILED, "Failed to mapping subgraph input for graph: %s", graph->GetName().c_str());
GELOGE(FAILED, "[Call][MappingSubgraphInput] for graph:%s failed", graph->GetName().c_str());
return FAILED;
}

if (MappingSubgraphOutput(graph, output) != SUCCESS) {
GELOGE(FAILED, "Failed to mapping subgraph output for graph: %s", graph->GetName().c_str());
GELOGE(FAILED, "[Call][MappingSubgraphOutput] for graph:%s failed", graph->GetName().c_str());
return FAILED;
}

@@ -149,7 +152,7 @@ Status DataPass::PostParseSubgraph(const ComputeGraphPtr &graph, const string &i
if (post_func_it == subgraph_handle.end()) {
REPORT_INNER_ERROR("E19999", "The subgraph post func for node %s type %s is null, check invalid",
parent_node->GetName().c_str(), parent_node->GetType().c_str());
GELOGE(FAILED, "The subgraph post func for node %s type %s is null.",
GELOGE(FAILED, "[Check][Param] The subgraph post func for node %s type %s is null.",
parent_node->GetName().c_str(), parent_node->GetType().c_str());
return FAILED;
}
@@ -157,7 +160,7 @@ Status DataPass::PostParseSubgraph(const ComputeGraphPtr &graph, const string &i
if (post_func_it->second(ir_name, graph) != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Post process subgraph %s on node %s type %s failed",
graph->GetName().c_str(), parent_node->GetName().c_str(), parent_node->GetType().c_str());
GELOGE(FAILED, "Failed to post process subgraph %s on node %s type %s",
GELOGE(FAILED, "[Call][PostFunc] Failed to post process subgraph %s on node %s type %s",
graph->GetName().c_str(), parent_node->GetName().c_str(), parent_node->GetType().c_str());
return FAILED;
}
@@ -188,7 +191,7 @@ Status DataPass::Run(ComputeGraphPtr compute_graph) {
GE_CHECK_NOTNULL(parent_node->GetOpDesc());
auto func_desc = parent_node->GetOpDesc();
GE_CHK_STATUS_RET(func_desc->GetSubgraphNameByInstanceName(compute_graph->GetName(), subgraph_name),
"Subgraph: %s get subgraph name failed.", compute_graph->GetName().c_str());
"[Get][SubGraphName] for Graph:%s failed.", compute_graph->GetName().c_str());

GELOGI("Post process for subgraph %s, Subgraph name: %s, Parent name: %s, Parent type: %s.",
compute_graph->GetName().c_str(), subgraph_name.c_str(), parent_node->GetName().c_str(),


+ 12
- 10
ge/graph/passes/dimension_adjust_pass.cc View File

@@ -30,14 +30,14 @@ const int kRemoveInputIndex = 1;
Status DimensionAdjustPass::Run(ge::NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "node is nullptr.");
GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr.");
return PARAM_INVALID;
}

OpDescPtr op_desc_ptr = node->GetOpDesc();
if (op_desc_ptr == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc of node is nullptr, check invalid");
GELOGE(PARAM_INVALID, "GetOpDesc return nullptr.");
GELOGE(PARAM_INVALID, "[Get][OpDesc] return nullptr.");
return PARAM_INVALID;
}

@@ -46,7 +46,7 @@ Status DimensionAdjustPass::Run(ge::NodePtr &node) {
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(ret, "DimensionAdjustPass get originnal type fail.");
GELOGE(ret, "[Get][OriginalType] of op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str());
return ret;
}

@@ -75,7 +75,7 @@ Status DimensionAdjustPass::Run(ge::NodePtr &node) {
}
REPORT_CALL_ERROR("E19999", "kernel compute for op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(ret, "DimensionAdjustPass compute failed");
GELOGE(ret, "[Call][Compute] for op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str());
return ret;
}
// Need to handle axis_input of node like ExpandDims
@@ -88,21 +88,22 @@ Status DimensionAdjustPass::Run(ge::NodePtr &node) {
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Unlink op:%s(%s) data input:%u with control edge copy failed",
node->GetName().c_str(), node->GetType().c_str(), kRemoveInputIndex);
GELOGE(ret, "DimensionAdjustPass unlink node with control copy fail.");
GELOGE(ret, "[Unlink][Op] %s(%s) data input:%u with control edge copy failed",
node->GetName().c_str(), node->GetType().c_str(), kRemoveInputIndex);
return ret;
}
// 2.Remove const axis node without any output
if ((axis_node->GetType() == CONSTANT || axis_node->GetType() == CONSTANTOP) &&
axis_node->GetOutDataNodesSize() == 0) {
ret = IsolateAndDeleteNode(axis_node, {});
GE_CHK_GRAPH_STATUS_RET(ret, "Fail to remove node %s.", axis_node->GetName().c_str());
GE_CHK_GRAPH_STATUS_RET(ret, "[Remove][Node] %s failed.", axis_node->GetName().c_str());
GELOGI("Remove useless axis input const %s", axis_node->GetName().c_str());
}
}

ret = DealWithInNodes(node);
if (ret != SUCCESS) {
GELOGE(ret, "DealWithInNodes of %s failed.", node->GetName().c_str());
GELOGE(ret, "[DealWith][InNodes] of node:%s failed.", node->GetName().c_str());
return ret;
}

@@ -147,14 +148,14 @@ NodePtr DimensionAdjustPass::AddIdentityNodeToGraph(const string &name, const Ge
ComputeGraphPtr &graph) {
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Comput graph ptr is null in creating identity node.");
GELOGE(INTERNAL_ERROR, "[Check][Param] Comput graph ptr is nullptr in creating identity node.");
return nullptr;
}

OpDescPtr desc = MakeShared<OpDesc>("", "");
if (desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(MEMALLOC_FAILED, "Failed to create op desc.");
GELOGE(MEMALLOC_FAILED, "[New][OpDesc] failed.");
return nullptr;
}

@@ -165,7 +166,8 @@ NodePtr DimensionAdjustPass::AddIdentityNodeToGraph(const string &name, const Ge
if ((ret != GRAPH_SUCCESS) || (ret2 != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Add input or ouput desc to op:%s(%s) failed",
desc->GetName().c_str(), desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add input/output desc in creating identity.");
GELOGE(INTERNAL_ERROR, "[Add][GeTensorDesc] to op:%s(%s) failed",
desc->GetName().c_str(), desc->GetType().c_str());
return nullptr;
}



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

@@ -41,7 +41,7 @@ Status DimensionComputePass::Run(ge::NodePtr &node) {
} else {
REPORT_CALL_ERROR("E19999", "kernel compute for op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(ret, "DimensionComputePass Compute failed");
GELOGE(ret, "[Call][Compute] for op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str());
return ret;
}
}
@@ -49,10 +49,8 @@ Status DimensionComputePass::Run(ge::NodePtr &node) {
if (outputs.empty()) {
REPORT_INNER_ERROR("E19999", "After compute for node %s(%s), output weight is empty, check invalid",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Failed to compute dims for node %s,"
" no output weight",
node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] After compute for node %s(%s), output weight is empty",
node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
}



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

@@ -32,12 +32,12 @@ Status DropOutPass::Run(NodePtr &node) {
GELOGD("DropOutPass running");
if (node == nullptr) {
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;
}
if (node->GetOpDesc() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param op_desc of node 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;
}
std::string op_type = node->GetOpDesc()->GetType();


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

@@ -27,7 +27,7 @@ namespace ge {
Status EndOfSequenceAddControlPass::Run(ComputeGraphPtr graph) {
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(PARAM_INVALID, "param [graph] must not be null.");
GELOGE(PARAM_INVALID, "[Check][Param] param [graph] must not be null.");
return PARAM_INVALID;
}
if (graph->GetParentGraph() != nullptr) {
@@ -67,7 +67,8 @@ Status EndOfSequenceAddControlPass::Run(ComputeGraphPtr graph) {
// Insert control edge
Status status = AddControlEdge(end_of_sequence, target_nodes);
if (status != SUCCESS) {
GELOGE(FAILED, "Graph add EndOfSequence op out ctrl edge fail.");
GELOGE(FAILED, "[Add][ControlEdge] Graph add EndOfSequence op:%s out ctrl edge failed.",
end_of_sequence->GetName().c_str());
return FAILED;
}
GELOGI("EndOfSequenceAddControlPass end.");
@@ -83,11 +84,12 @@ Status EndOfSequenceAddControlPass::AddControlEdge(NodePtr &end_of_sequence, std
}
Status status = GraphUtils::AddEdge(out_ctrl_anchor, in_ctrl_anchor);
if (status != 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",
end_of_sequence->GetName().c_str(), end_of_sequence->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "Graph add EndOfSequence op out ctrl edge fail, dst node: %s.", node->GetName().c_str());
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
end_of_sequence->GetName().c_str(), end_of_sequence->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}
GELOGI("Graph add EndOfSequence op out ctrl edge, dst node: %s.", node->GetName().c_str());


+ 6
- 5
ge/graph/passes/enter_pass.cc View File

@@ -38,7 +38,7 @@ Status EnterPass::Run(NodePtr &node) {
// enter node has only one input
if (node->GetInDataNodes().empty()) {
REPORT_INNER_ERROR("E19999", "Param node in data nodes is empty, check invalid");
GELOGE(PARAM_INVALID, "enter_node %s has no input", node->GetName().c_str());
GELOGE(PARAM_INVALID, "[Check][Param] enter_node %s has no input", node->GetName().c_str());
return PARAM_INVALID;
}
NodePtr in_node = node->GetInDataNodes().at(0);
@@ -62,18 +62,19 @@ Status EnterPass::Run(NodePtr &node) {
REPORT_CALL_ERROR("E19999", "Remove control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
out_ctrl_node->GetName().c_str(), out_ctrl_node->GetType().c_str());
GELOGE(FAILED, "Remove Enter ctrl output fail, %s->%s", node->GetName().c_str(),
out_ctrl_node->GetName().c_str());
GELOGE(FAILED, "[Remove][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
out_ctrl_node->GetName().c_str(), out_ctrl_node->GetType().c_str());
return FAILED;
}
}
} else {
if (OptimizeEnterWithOnlyDataOut(node, in_node) != SUCCESS) {
GELOGE(FAILED, "Optimize enter node[%s] with only out data node failed.", node->GetName().c_str());
GELOGE(FAILED, "[Optimize][EnterNode] [%s] with only out data node failed.", node->GetName().c_str());
return FAILED;
}
if (UnlinkCtrlEdgeBeforeConst(node) != SUCCESS) {
GELOGE(FAILED, "Unlink control edge before const of node[%s]'s out nodes failed.", node->GetName().c_str());
GELOGE(FAILED, "[Unlink][ControlEdge] before const of node[%s]'s out nodes failed.", node->GetName().c_str());
return FAILED;
}
}


+ 133
- 90
ge/graph/passes/flow_ctrl_pass.cc View File

@@ -52,7 +52,8 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) {
// Add big cycle
Status ret = AddFpBpIteratorCtrl(compute_graph, node);
if (ret != SUCCESS) {
GELOGE(ret, "AddFpBpIteratorCtrl fail, node: %s.", node->GetName().c_str());
GELOGE(ret, "[Add][FpBpIteratorCtrl] failed, node:%s, graph:%s.",
node->GetName().c_str(), compute_graph->GetName().c_str());
return ret;
}
graph_change = true;
@@ -74,7 +75,8 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) {
if (is_found && need_cycle_flag) {
Status ret = AddSpecialNodeIteratorCtrl(compute_graph, node);
if (ret != SUCCESS) {
GELOGE(ret, "AddSpecialNodeIteratorCtrl fail, node: %s.", node->GetName().c_str());
GELOGE(ret, "[Add][SpecialNodeIteratorCtrl] failed, node:%s, graph:%s.",
node->GetName().c_str(), compute_graph->GetName().c_str());
return ret;
}
graph_change = true;
@@ -116,7 +118,7 @@ NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &nod
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, node_type);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Make OpDesc failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str());
GELOGE(FAILED, "[New][OpDesc] failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str());
return nullptr;
}

@@ -125,7 +127,7 @@ NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &nod
if (graph_status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Add node:%s intput desc failed, error=%u.", node_name.c_str(), graph_status);
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed", op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr;
}
}
@@ -135,20 +137,22 @@ NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &nod
if (graph_status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Add node:%s output desc failed, error=%u.", node_name.c_str(), graph_status);
GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr;
}
}

GE_IF_BOOL_EXEC(compute_graph == nullptr,
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
DOMI_LOGE("compute_graph is nullptr");
DOMI_LOGE("[Check][Param] compute_graph is nullptr");
return nullptr);
NodePtr node = compute_graph->AddNode(op_desc);
if (node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), compute_graph->GetName().c_str());
GELOGE(FAILED, "add node failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str());
GELOGE(FAILED, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), compute_graph->GetName().c_str());
return nullptr;
}

@@ -159,21 +163,19 @@ NodePtr FlowCtrlPass::InsertOp(ComputeGraphPtr &compute_graph, const string &nod
NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const string &switch_name,
const NodePtr &loop_cond, const NodePtr &iter_per_loop) {
GE_IF_BOOL_EXEC(loop_cond == nullptr || loop_cond->GetOpDesc() == nullptr,
REPORT_INNER_ERROR("E19999", "Param loop_cond or its op_desc is nullptr, "
"check invalid");
GELOGE(FAILED, "loop_cond is null");
REPORT_INNER_ERROR("E19999", "Param loop_cond or its op_desc is nullptr, check invalid");
GELOGE(FAILED, "[Check][Param] Param loop_cond or its op_desc is nullptr");
return nullptr);
GE_IF_BOOL_EXEC(iter_per_loop == nullptr || iter_per_loop->GetOpDesc() == nullptr,
REPORT_INNER_ERROR("E19999", "Param iter_per_loop or its op_desc is nullptr, "
"check invalid");
GELOGE(FAILED, "iter_per_loop is nullptr");
REPORT_INNER_ERROR("E19999", "Param iter_per_loop or its op_desc is nullptr, check invalid");
GELOGE(FAILED, "[Check][Param] Param iter_per_loop or its op_desc is nullptr");
return nullptr);
std::vector<GeTensorDesc> input_desc_list = {loop_cond->GetOpDesc()->GetOutputDesc(0),
iter_per_loop->GetOpDesc()->GetOutputDesc(0)};
std::vector<GeTensorDesc> output_desc_list;
NodePtr stream_switch = InsertOp(compute_graph, STREAMSWITCH, switch_name, input_desc_list, output_desc_list);
if (stream_switch == nullptr) {
GELOGE(FAILED, "InsertStreamSwitchOp failed, name:%s.", switch_name.c_str());
GELOGE(FAILED, "[Insert][StreamSwitchOp] failed, name:%s.", switch_name.c_str());
return nullptr;
}

@@ -183,7 +185,9 @@ NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
loop_cond->GetName().c_str(), loop_cond->GetType().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "Add loop_cond_node to switch_node:%s edge failed, ret = %u.", switch_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
loop_cond->GetName().c_str(), loop_cond->GetType().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
return nullptr;
}

@@ -193,17 +197,20 @@ NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:1) failed",
iter_per_loop->GetName().c_str(), iter_per_loop->GetType().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "Add iter_per_loop_node to switch_node:%s edge failed, ret = %u.", switch_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:1) failed",
iter_per_loop->GetName().c_str(), iter_per_loop->GetType().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
return nullptr;
}

// stream switch op need switch cond by attr.
GE_IF_BOOL_EXEC(!AttrUtils::SetInt(stream_switch->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND,
static_cast<int64_t>(RT_LESS)),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_STREAM_SWITCH_COND.c_str(),
static_cast<int64_t>(RT_LESS)),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_STREAM_SWITCH_COND.c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
DOMI_LOGE("set ATTR_NAME_STREAM_SWITCH_COND failed"); return nullptr);
DOMI_LOGE("[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_STREAM_SWITCH_COND.c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
return nullptr);

return stream_switch;
}
@@ -211,7 +218,7 @@ NodePtr FlowCtrlPass::InsertStreamSwitchOp(ComputeGraphPtr &compute_graph, const
NodePtr FlowCtrlPass::AddVariableNode(ComputeGraphPtr &compute_graph, const string &name) {
GE_IF_BOOL_EXEC(compute_graph == nullptr,
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
DOMI_LOGE("compute_graph is nullptr");
DOMI_LOGE("[Check][Param] compute_graph is nullptr");
return nullptr);
NodePtr exist_node = compute_graph->FindNode(name);
if (exist_node != nullptr) {
@@ -221,15 +228,14 @@ NodePtr FlowCtrlPass::AddVariableNode(ComputeGraphPtr &compute_graph, const stri
// fetch and set tensor desc
GeTensorDesc tensor_desc;
if (ge::VarManager::Instance(compute_graph->GetSessionID()) == nullptr) {
REPORT_INNER_ERROR("E19999", "Get VarManager by session_id:%lu failed",
compute_graph->GetSessionID());
REPORT_INNER_ERROR("E19999", "Get VarManager by session_id:%lu failed", compute_graph->GetSessionID());
return nullptr;
}
Status ret = ge::VarManager::Instance(compute_graph->GetSessionID())->GetCurVarDesc(name, tensor_desc);
if (ret != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Get var tensor from VarManager by name:%s failed, session_id:%lu",
name.c_str(), compute_graph->GetSessionID());
GELOGE(FAILED, "Get var desc fail, name:%s", name.c_str());
GELOGE(FAILED, "[Get][CurVarDesc] failed, name:%s, session_id:%lu", name.c_str(), compute_graph->GetSessionID());
return nullptr;
}
std::vector<GeTensorDesc> input_desc_list;
@@ -263,7 +269,7 @@ Status FlowCtrlPass::AddGlobalStepVariableNode(ComputeGraphPtr &compute_graph) {
NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP,
input_desc_list, output_desc_list);
if (global_step == nullptr) {
GELOGE(FAILED, "Add global_step node failed, global_step is null.");
GELOGE(FAILED, "[Insert][Op] in graph:%s failed, global_step is null.", compute_graph->GetName().c_str());
return FAILED;
}

@@ -273,7 +279,9 @@ Status FlowCtrlPass::AddGlobalStepVariableNode(ComputeGraphPtr &compute_graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
global_step->GetName().c_str(), global_step->GetType().c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
GELOGE(FAILED, "Add global_step to netoutput edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
global_step->GetName().c_str(), global_step->GetType().c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
return FAILED;
}
GELOGD("Add global_step to netoutput edge in graph %u success", compute_graph->GetGraphID());
@@ -284,9 +292,9 @@ NodePtr FlowCtrlPass::InsertAssignOp(ge::ComputeGraphPtr &compute_graph, const s
const string &node_name, const NodePtr &ref_node, const NodePtr &value_node) {
GE_IF_BOOL_EXEC(ref_node == nullptr || value_node == nullptr ||
ref_node->GetOpDesc() == nullptr || value_node->GetOpDesc() == nullptr,
REPORT_INNER_ERROR("E19999", "Param ref_node or value_node or their op_desc has nullptr, "
REPORT_INNER_ERROR("E19999", "Param ref_node or value_node or their op_desc is nullptr, "
"check invalid");
GELOGE(FAILED, "ref node or value node is null");
GELOGE(FAILED, "[Check][Param] Param ref_node or value_node or their op_desc is nullptr");
return nullptr);
GeTensorDesc ref_tensor_desc = ref_node->GetOpDesc()->GetOutputDesc(0);
GeTensorDesc val_tensor_desc = value_node->GetOpDesc()->GetOutputDesc(0);
@@ -294,7 +302,7 @@ NodePtr FlowCtrlPass::InsertAssignOp(ge::ComputeGraphPtr &compute_graph, const s
std::vector<GeTensorDesc> output_desc_list = {ref_tensor_desc};
NodePtr assign_node = InsertOp(compute_graph, node_type, node_name, input_desc_list, output_desc_list);
if (assign_node == nullptr) {
GELOGE(FAILED, "Insert node %s(%s) failed.", node_name.c_str(), node_type.c_str());
GELOGE(FAILED, "[Insert][node] %s(%s) failed.", node_name.c_str(), node_type.c_str());
return nullptr;
}
// assign node input 0 = ref_node
@@ -303,7 +311,9 @@ NodePtr FlowCtrlPass::InsertAssignOp(ge::ComputeGraphPtr &compute_graph, const s
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
ref_node->GetName().c_str(), ref_node->GetType().c_str(),
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "Add ref_node to %s edge failed, add_ret=%u.", node_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
ref_node->GetName().c_str(), ref_node->GetType().c_str(),
assign_node->GetName().c_str(), assign_node->GetType().c_str());
return nullptr;
}
// assign input 1 = value_node
@@ -312,7 +322,9 @@ NodePtr FlowCtrlPass::InsertAssignOp(ge::ComputeGraphPtr &compute_graph, const s
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:1) failed",
value_node->GetName().c_str(), value_node->GetType().c_str(),
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "Add value_node to %s edge failed, add_ret=%u.", node_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:1) failed",
value_node->GetName().c_str(), value_node->GetType().c_str(),
assign_node->GetName().c_str(), assign_node->GetType().c_str());
return nullptr;
}
(void)ge::AttrUtils::SetBool(assign_node->GetOpDesc(), ATTR_NEED_COMPILE, true);
@@ -335,7 +347,7 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co
assign_add_node_in_fpbp_loop_ =
InsertAssignOp(compute_graph, ASSIGNADD, NODE_NAME_FLOWCTRL_LOOP_ASSIGNADD, loop_cond_node, loop_inc_node);
if (assign_add_node_in_fpbp_loop_ == nullptr || switch_node == nullptr) {
GELOGE(PARAM_INVALID, "assign add node or switch node is null");
GELOGE(PARAM_INVALID, "[Check][Param] assign add node or switch node is null");
return FAILED;
}

@@ -346,7 +358,9 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
active_name.c_str(), assign_add_node_in_fpbp_loop_->GetName().c_str(),
assign_add_node_in_fpbp_loop_->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
active_name.c_str(), assign_add_node_in_fpbp_loop_->GetName().c_str(),
assign_add_node_in_fpbp_loop_->GetType().c_str());
return status;
}

@@ -355,28 +369,31 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
active_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(status, "set active_label_list failed.");
GELOGE(status, "[Set][ActiveLabelList] %s to op:%s(%s) failed",
active_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
return status;
}

// 2. Insert active node
NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {});
if (active_node == nullptr) {
GELOGE(FAILED, "Insert stream active node:%s for IterCtrlTrueStream failed.", active_name.c_str());
GELOGE(FAILED, "[Insert][StreamActiveNode] %s for IterCtrlTrueStream failed.", active_name.c_str());
return FAILED;
}
status = SetStreamLabel(active_node, active_name);
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
active_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
active_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return status;
}
GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_IS_LOOP_ACTIVE.c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed");
DOMI_LOGE("[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_IS_LOOP_ACTIVE.c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED);

// add ctrl edges
@@ -387,7 +404,9 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co
switch_node->GetName().c_str(), switch_node->GetType().c_str(),
assign_add_node_in_fpbp_loop_->GetName().c_str(),
assign_add_node_in_fpbp_loop_->GetType().c_str());
GELOGE(FAILED, "Add switch_node to assign_add_node ctrl edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(),
assign_add_node_in_fpbp_loop_->GetName().c_str(), assign_add_node_in_fpbp_loop_->GetType().c_str());
return FAILED;
}

@@ -398,7 +417,9 @@ Status FlowCtrlPass::CreateIterCtrlTrueBranch(ComputeGraphPtr &compute_graph, co
assign_add_node_in_fpbp_loop_->GetName().c_str(),
assign_add_node_in_fpbp_loop_->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(FAILED, "Add assign_add_node to active_node ctrl edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
assign_add_node_in_fpbp_loop_->GetName().c_str(), assign_add_node_in_fpbp_loop_->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED;
}

@@ -421,7 +442,7 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
NodePtr assign_node =
InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node);
if (assign_node == nullptr || switch_node == nullptr) {
GELOGE(PARAM_INVALID, "assign_node or switch node is null.");
GELOGE(PARAM_INVALID, "[Check][Param] assign_node or switch node is null.");
return FAILED;
}

@@ -429,7 +450,8 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
switch_node->GetName().c_str(), assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
switch_node->GetName().c_str(), assign_node->GetName().c_str(), assign_node->GetType().c_str());
return status;
}

@@ -438,7 +460,9 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(),
assign_node->GetName().c_str(), assign_node->GetType().c_str());
GELOGE(FAILED, "Add switch_node to assign_node ctrl edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(),
assign_node->GetName().c_str(), assign_node->GetType().c_str());
return FAILED;
}

@@ -448,25 +472,28 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
string active_name = switch_node->GetName() + "_StreamExitActive";
NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {});
if (active_node == nullptr) {
GELOGE(FAILED, "Insert stream active node:%s for IterCtrlTrueStream failed.", active_name.c_str());
GELOGE(FAILED, "[Insert][StreamActiveNode] %s for IterCtrlTrueStream failed.", active_name.c_str());
return FAILED;
}
status = SetStreamLabel(active_node, switch_node->GetName());
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
switch_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed", switch_node->GetName().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed", switch_node->GetName().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return status;
}
GE_CHK_STATUS_RET(SetSwitchBranchNodeLabel(active_node, switch_node->GetName()),
"set switch branch node label failed.");
"[Set][SwitchBranchNodeLabel] %s to op:%s(%s) failed", switch_node->GetName().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());

string model_exit_name = switch_node->GetName() + "_ModelExit";
status = SetActiveLabelList(active_node, { model_exit_name });
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
model_exit_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "set active_label_list failed.");
GELOGE(status, "[Set][ActiveLabelList] %s to op:%s(%s) failed",
model_exit_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return status;
}

@@ -475,14 +502,16 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
assign_node->GetName().c_str(), assign_node->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(FAILED, "Add assign_node to active_node ctrl edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
assign_node->GetName().c_str(), assign_node->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED;
}

// 3. Insert model exit node and add ctrl edge
NodePtr model_exit_node = InsertOp(compute_graph, MODELEXIT, model_exit_name, {}, {});
if (model_exit_node == nullptr) {
GELOGE(FAILED, "Insert model_exit node:%s for IterCtrlTrueStream failed.", model_exit_name.c_str());
GELOGE(FAILED, "[Insert][ModelExitNode] %s for IterCtrlTrueStream failed.", model_exit_name.c_str());
return FAILED;
}
status = SetStreamLabel(model_exit_node, model_exit_name);
@@ -490,7 +519,8 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
model_exit_name.c_str(), model_exit_node->GetName().c_str(),
model_exit_node->GetType().c_str());
GELOGE(status, "Set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed", model_exit_name.c_str(),
model_exit_node->GetName().c_str(), model_exit_node->GetType().c_str());
return status;
}

@@ -499,7 +529,9 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
active_node->GetName().c_str(), assign_node->GetType().c_str(),
model_exit_node->GetName().c_str(), model_exit_node->GetType().c_str());
GELOGE(FAILED, "Add active_node to model_exit_node ctrl edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
active_node->GetName().c_str(), assign_node->GetType().c_str(),
model_exit_node->GetName().c_str(), model_exit_node->GetType().c_str());
return FAILED;
}
}
@@ -509,28 +541,28 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c
}

Status FlowCtrlPass::AddFpBpIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr &pre_node) {
GE_IF_BOOL_EXEC(pre_node == nullptr, DOMI_LOGE("pre_node is nullptr."); return FAILED);
GE_IF_BOOL_EXEC(pre_node == nullptr, DOMI_LOGE("[Check][Param] pre_node is nullptr."); return FAILED);
string pre_node_name = pre_node->GetName();
GELOGI("Add FpBp Iterator ctrl, pre node:%s.", pre_node_name.c_str());
// 1. Get or add variables
NodePtr loop_cond_node = AddVariableNode(compute_graph, NODE_NAME_FLOWCTRL_LOOP_COND);
if (loop_cond_node == nullptr) {
GELOGE(FAILED, "Add variable:%s failed.", NODE_NAME_FLOWCTRL_LOOP_COND.c_str());
GELOGE(FAILED, "[Add][Variable] %s failed.", NODE_NAME_FLOWCTRL_LOOP_COND.c_str());
return FAILED;
}
NodePtr loop_inc_node = AddVariableNode(compute_graph, NODE_NAME_FLOWCTRL_LOOP_INCREMENT);
if (loop_inc_node == nullptr) {
GELOGE(FAILED, "Add variable:%s failed.", NODE_NAME_FLOWCTRL_LOOP_INCREMENT.c_str());
GELOGE(FAILED, "[Add][Variable] %s failed.", NODE_NAME_FLOWCTRL_LOOP_INCREMENT.c_str());
return FAILED;
}
NodePtr loop_reset_node = AddVariableNode(compute_graph, NODE_NAME_FLOWCTRL_LOOP_RESETVALUE);
if (loop_reset_node == nullptr) {
GELOGE(FAILED, "Add variable:%s failed.", NODE_NAME_FLOWCTRL_LOOP_RESETVALUE.c_str());
GELOGE(FAILED, "[Add][Variable] %s failed.", NODE_NAME_FLOWCTRL_LOOP_RESETVALUE.c_str());
return FAILED;
}
NodePtr iter_per_loop_node = AddVariableNode(compute_graph, NODE_NAME_FLOWCTRL_LOOP_PER_ITER);
if (iter_per_loop_node == nullptr) {
GELOGE(FAILED, "Add variable:%s failed.", NODE_NAME_FLOWCTRL_LOOP_PER_ITER.c_str());
GELOGE(FAILED, "[Add][Variable] %s failed.", NODE_NAME_FLOWCTRL_LOOP_PER_ITER.c_str());
return FAILED;
}

@@ -538,14 +570,15 @@ Status FlowCtrlPass::AddFpBpIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr
string switch_name = pre_node_name + "_" + NODE_NAME_STREAM_SWITCH;
NodePtr switch_node = InsertStreamSwitchOp(compute_graph, switch_name, loop_cond_node, iter_per_loop_node);
if (switch_node == nullptr) {
GELOGE(FAILED, "InsertStreamSwitchOp:%s failed.", switch_name.c_str());
GELOGE(FAILED, "[Insert][StreamSwitchOp] %s failed.", switch_name.c_str());
return FAILED;
}
auto status = SetStreamLabel(switch_node, switch_name);
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed",
switch_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(status, "set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
switch_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
return status;
}

@@ -554,15 +587,16 @@ Status FlowCtrlPass::AddFpBpIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(FAILED, "Add pre node:%s to switch_node:%s ctrl edge failed, ret = %u.", pre_node_name.c_str(),
switch_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
return FAILED;
}

// 3. Create switch false branch: return results and reset the loopCond
Status ret = CreateIterCtrlFalseBranch(compute_graph, loop_cond_node, loop_reset_node, switch_node);
if (ret != SUCCESS) {
GELOGE(ret, "CreateIterCtrlFalseBranch fail, pre node:%s.", pre_node_name.c_str());
GELOGE(ret, "[Create][IterCtrlFalseBranch] fail, pre node:%s.", pre_node_name.c_str());
return ret;
}

@@ -570,7 +604,7 @@ Status FlowCtrlPass::AddFpBpIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr
// active train streams and increase the loopCond
ret = CreateIterCtrlTrueBranch(compute_graph, loop_cond_node, loop_inc_node, switch_node);
if (ret != SUCCESS) {
GELOGE(ret, "CreateIterCtrlTrueBranch fail, pre node:%s.", pre_node_name.c_str());
GELOGE(ret, "[Create][IterCtrlTrueBranch] fail, pre node:%s.", pre_node_name.c_str());
return ret;
}
return SUCCESS;
@@ -594,15 +628,15 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
* itersPerLoop loopCond
*/
GE_IF_BOOL_EXEC(loop_after_node == nullptr || compute_graph == nullptr,
REPORT_INNER_ERROR("E19999", "Param loop_after_node or compute_graph is nullptr, "
"check invalid");
DOMI_LOGE("loop after node or compute graph is null.");
REPORT_INNER_ERROR("E19999", "Param loop_after_node or compute_graph is nullptr, check invalid");
DOMI_LOGE("[Check][Param] loop after node or compute graph is null.");
return FAILED);
InDataAnchorPtr in_anchor = loop_after_node->GetInDataAnchor(0);
if (in_anchor == nullptr || in_anchor->GetPeerOutAnchor() == nullptr) {
REPORT_INNER_ERROR("E19999", "Param loop_after_node:%s(%s) no in data node, check invalid",
loop_after_node->GetName().c_str(), loop_after_node->GetType().c_str());
GELOGE(FAILED, "Find %s in data anchor failed.", loop_after_node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Param loop_after_node:%s(%s) no in data node.",
loop_after_node->GetName().c_str(), loop_after_node->GetType().c_str());
return FAILED;
}
NodePtr loop_pre_node = in_anchor->GetPeerOutAnchor()->GetOwnerNode();
@@ -612,28 +646,30 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
if (loop_cond_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s not found in graph:%s, check invalid",
NODE_NAME_FLOWCTRL_LOOP_COND.c_str(), compute_graph->GetName().c_str());
GELOGE(FAILED, "Find node :%s failed.", NODE_NAME_FLOWCTRL_LOOP_COND.c_str());
GELOGE(FAILED, "[Check][Param] Node:%s not found in graph:%s.",
NODE_NAME_FLOWCTRL_LOOP_COND.c_str(), compute_graph->GetName().c_str());
return FAILED;
}
NodePtr iter_per_loop_node = compute_graph->FindNode(NODE_NAME_FLOWCTRL_LOOP_PER_ITER);
if (iter_per_loop_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Node:%s not found in graph:%s, check invalid",
NODE_NAME_FLOWCTRL_LOOP_PER_ITER.c_str(), compute_graph->GetName().c_str());
GELOGE(FAILED, "Find node :%s failed.", NODE_NAME_FLOWCTRL_LOOP_PER_ITER.c_str());
GELOGE(FAILED, "[Check][Param] Node:%s not found in graph:%s.",
NODE_NAME_FLOWCTRL_LOOP_PER_ITER.c_str(), compute_graph->GetName().c_str());
return FAILED;
}

// 2. Add StreamSwitch and edges to switch_node.
GE_IF_BOOL_EXEC(loop_pre_node == nullptr,
REPORT_INNER_ERROR("E19999", "Param loop_after_node:%s(%s) no in data node, "
"check invalid", loop_after_node->GetName().c_str(),
loop_after_node->GetType().c_str());
DOMI_LOGE("loop pre node is null.");
REPORT_INNER_ERROR("E19999", "Param loop_after_node:%s(%s) no in data node, check invalid",
loop_after_node->GetName().c_str(), loop_after_node->GetType().c_str());
DOMI_LOGE("[Check][Param] Param loop_after_node:%s(%s) no in data node",
loop_after_node->GetName().c_str(), loop_after_node->GetType().c_str());
return FAILED);
string switch_name = loop_pre_node->GetName() + "_" + NODE_NAME_STREAM_SWITCH;
NodePtr switch_node = InsertStreamSwitchOp(compute_graph, switch_name, loop_cond_node, iter_per_loop_node);
if (switch_node == nullptr) {
GELOGE(FAILED, "InsertStreamSwitchOp:%s failed.", switch_name.c_str());
GELOGE(FAILED, "[Insert][StreamSwitchOp] %s failed.", switch_name.c_str());
return FAILED;
}

@@ -641,7 +677,8 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed",
switch_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(status, "set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
switch_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
return status;
}

@@ -650,8 +687,9 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
loop_pre_node->GetName().c_str(), loop_pre_node->GetType().c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(FAILED, "Add loop_pre_node:%s to switch_node:%s ctrl edge failed, ret = %u.",
loop_pre_node->GetName().c_str(), switch_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
loop_pre_node->GetName().c_str(), loop_pre_node->GetType().c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
return FAILED;
}
add_ret = GraphUtils::AddEdge(loop_after_node->GetOutControlAnchor(), switch_node->GetInControlAnchor());
@@ -659,8 +697,9 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
loop_after_node->GetName().c_str(), loop_after_node->GetType().c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(FAILED, "Add node:%s to switch_node:%s ctrl edge failed, ret = %u.", loop_after_node->GetName().c_str(),
switch_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
loop_after_node->GetName().c_str(), loop_after_node->GetType().c_str(),
switch_node->GetName().c_str(), switch_node->GetType().c_str());
return FAILED;
}

@@ -668,7 +707,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
string active_name = switch_name + "_StreamActive";
NodePtr active_node = InsertOp(compute_graph, STREAMACTIVE, active_name, {}, {});
if (active_node == nullptr) {
GELOGE(FAILED, "Insert stream active node:%s for SpecialNodeIteratorCtrl failed.", active_name.c_str());
GELOGE(FAILED, "[Insert][StreamActiveNode] %s for SpecialNodeIteratorCtrl failed.", active_name.c_str());
return FAILED;
}

@@ -676,15 +715,16 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream label:%s to op:%s(%s) failed",
active_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "set stream label failed.");
GELOGE(status, "[Set][StreamLabel] %s to op:%s(%s) failed",
active_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return status;
}

GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_IS_LOOP_ACTIVE.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_IS_LOOP_ACTIVE.c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed");
DOMI_LOGE("[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_IS_LOOP_ACTIVE.c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED);

add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), active_node->GetInControlAnchor());
@@ -692,8 +732,9 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(FAILED, "Add switch_node:%s to active_node:%s ctrl edge failed, ret = %u.", switch_name.c_str(),
active_name.c_str(), add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
switch_node->GetName().c_str(), switch_node->GetType().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED;
}

@@ -702,15 +743,17 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph,
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
active_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(status, "set active_label_list failed.");
GELOGE(status, "[Set][ActiveLabelList] %s to op:%s(%s) failed",
active_name.c_str(), switch_node->GetName().c_str(), switch_node->GetType().c_str());
return status;
}
// used for stream assign to find active stream
status = SetActiveLabelList(active_node, { loop_pre_node->GetName() });
if (status != ge::SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
loop_pre_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "set active_label_list failed.");
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed", loop_pre_node->GetName().c_str(),
active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(status, "[Set][ActiveLabelList] %s to op:%s(%s) failed",
loop_pre_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return status;
}
active_nodes_in_iter_loop_.push_back(active_node);


+ 42
- 40
ge/graph/passes/folding_pass.cc View File

@@ -36,7 +36,7 @@ namespace folding_pass {
shared_ptr<Kernel> GetKernelByType(const NodePtr &node) {
if (node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid");
GELOGE(FAILED, "parameter is null.");
GELOGE(FAILED, "[Check][Param] parameter node is nullptr.");
return nullptr;
}
KernelFactory &factory = KernelFactory::Instance();
@@ -84,7 +84,7 @@ NodePtr AddConstNodeToGraph(GeTensorPtr &tensor, ComputeGraphPtr &graph) {
auto const_desc = OpDescUtils::CreateConstOp(tensor);
if (const_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Create Const op failed");
GELOGE(OUT_OF_MEMORY, "Failed to get const desc from tensor");
GELOGE(OUT_OF_MEMORY, "[Create][ConstOp] failed");
return nullptr;
}

@@ -96,14 +96,14 @@ NodePtr AddConstNodeToGraph(GeTensorPtr &tensor, ComputeGraphPtr &graph) {
NodePtr AddIdentityNodeToGraph(const std::string &name, const GeTensorDesc &tensor, ComputeGraphPtr &graph) {
if (graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid");
GELOGE(INTERNAL_ERROR, "Compute graph ptr is null in creating identity node.");
GELOGE(INTERNAL_ERROR, "[Check][Param] Compute graph ptr is null in creating identity node.");
return nullptr;
}

OpDescPtr desc = MakeShared<OpDesc>("", "");
if (desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(MEMALLOC_FAILED, "Failed to create op desc.");
GELOGE(MEMALLOC_FAILED, "[New][OpDesc] failed.");
return nullptr;
}

@@ -114,7 +114,8 @@ NodePtr AddIdentityNodeToGraph(const std::string &name, const GeTensorDesc &tens
if ((ret != GRAPH_SUCCESS) || (ret2 != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Add input or output desc to op:%s(%s) failed",
desc->GetName().c_str(), desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add input/output desc in creating Identity.");
GELOGE(INTERNAL_ERROR, "[Add][GeTensorDesc] to op:%s(%s) failed",
desc->GetName().c_str(), desc->GetType().c_str());
return nullptr;
}

@@ -146,9 +147,9 @@ Status FoldingPass::Folding(NodePtr &node, vector<GeTensorPtr> &outputs) {
auto in_data_nodes = node->GetInDataNodes();
std::unordered_set<NodePtr> in_data_nodes_set(in_data_nodes.begin(), in_data_nodes.end());
if (IsolateAndDeleteNode(node, {}) != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Isolate and delete node:%s(%s) faild",
REPORT_INNER_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to isolate and delete node %s, type %s.",
GELOGE(INTERNAL_ERROR, "[IsolateAndDelete][Node] %s(%s) failed.",
node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
}
@@ -160,9 +161,9 @@ Status FoldingPass::Folding(NodePtr &node, vector<GeTensorPtr> &outputs) {
continue;
}
if (IsolateAndDeleteNode(pre_node, {}) != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Isolate and delete node:%s(%s) faild",
REPORT_INNER_ERROR("E19999", "Isolate and delete node:%s(%s) failed",
pre_node->GetName().c_str(), pre_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to isolate and delete in data node %s, type %s.",
GELOGE(INTERNAL_ERROR, "[IsolateAndDelete][Node] %s(%s) failed.",
pre_node->GetName().c_str(), pre_node->GetType().c_str());
return INTERNAL_ERROR;
}
@@ -190,11 +191,10 @@ Status FoldingPass::DealWithInNodes(NodePtr &node) {
GELOGI("The in_node name is %s, and node type is %s.", in_node->GetName().c_str(), in_node->GetType().c_str());
auto ret = in_node_anchor->Unlink(in_data_anchor);
if (ret != SUCCESS) {
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",
in_node->GetName().c_str(), in_node->GetType().c_str(), in_node_anchor->GetIdx(),
node->GetName().c_str(), node->GetType().c_str(), in_data_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "Failed to unlink anchor between const node %s to constant-folding-node %s, type %s.",
GELOGE(INTERNAL_ERROR, "[Unlink][Anchor] between const node:%s and constant-folding-node:%s(%s) failed.",
in_node->GetName().c_str(), node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
}
@@ -204,16 +204,18 @@ Status FoldingPass::DealWithInNodes(NodePtr &node) {
auto identity =
AddIdentityNodeToGraph(identity_name, node->GetOpDesc()->GetInputDesc(in_data_anchor->GetIdx()), graph);
if (identity == nullptr) {
GELOGE(INTERNAL_ERROR, "Failed to add identity node to graph.");
GELOGE(INTERNAL_ERROR, "[Add][IdentityNode] %s to graph:%s failed.",
identity_name.c_str(), graph->GetName().c_str());
return INTERNAL_ERROR;
}
ret = GraphUtils::AddEdge(in_node_anchor, identity->GetInDataAnchor(0));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(inde:0) failed",
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
in_node->GetName().c_str(), in_node->GetType().c_str(), in_node_anchor->GetIdx(),
identity->GetName().c_str(), identity->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add edge, from node %s to node %s.", in_node->GetName().c_str(),
identity->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
in_node->GetName().c_str(), in_node->GetType().c_str(), in_node_anchor->GetIdx(),
identity->GetName().c_str(), identity->GetType().c_str());
return INTERNAL_ERROR;
}
GELOGI("Create new identity node success.");
@@ -222,8 +224,9 @@ Status FoldingPass::DealWithInNodes(NodePtr &node) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
identity->GetName().c_str(), identity->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add edge, from node %s to node %s.", in_node->GetName().c_str(),
node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
identity->GetName().c_str(), identity->GetType().c_str(),
node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
}
}
@@ -236,7 +239,7 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
std::vector<GeTensorPtr> &v_weight) {
if (node == nullptr) {
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 FAILED;
}
auto graph = node->GetOwnerComputeGraph();
@@ -245,24 +248,23 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
if (index >= v_weight.size()) {
REPORT_INNER_ERROR("E19999", "Index:%lu in param index_to_anchors >= param v_weight.size:%zu, "
"check invalid", index, v_weight.size());
GELOGE(INTERNAL_ERROR,
"Failed to constant fold on node %s type %s, "
GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to constant fold on node %s type %s, "
"the out nodes num %lu calculated is less than the node out anchor index %zu",
node->GetName().c_str(), node->GetType().c_str(), v_weight.size(), index);
return INTERNAL_ERROR;
}
GeTensorPtr weight = v_weight[index];
if (weight == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%lu in param v_weight is nullptr check invalid",
index);
GELOGE(INTERNAL_ERROR, "Failed to constant fold on node %s type %s, the %lust node calculated is null",
REPORT_INNER_ERROR("E19999", "Index:%lu in param v_weight is nullptr check invalid", index);
GELOGE(INTERNAL_ERROR,
"[Check][Param] Failed to constant fold on node %s type %s, the %lust node calculated is null",
node->GetName().c_str(), node->GetType().c_str(), index);
return INTERNAL_ERROR;
}

auto const_node = AddConstNodeToGraph(weight, graph);
if (const_node == nullptr) {
GELOGE(INTERNAL_ERROR, "Failed to add dynamic const node, node name:%s, index:%zu.",
GELOGE(INTERNAL_ERROR, "[Add][ConstNode] To Graph failed, node name:%s, index:%zu.",
node->GetName().c_str(), index);
return INTERNAL_ERROR;
}
@@ -273,7 +275,8 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
if (in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%lu in param index_to_anchors has nullptr member in_anchor, "
"check invalid", index);
GELOGE(INTERNAL_ERROR, "In anchor is nullptr.");
GELOGE(INTERNAL_ERROR,
"[Check][Param] Index:%lu in param index_to_anchors has nullptr member in_anchor", index);
return INTERNAL_ERROR;
}
auto ret = ConnectNodeToInAnchor(in_anchor, const_node, 0);
@@ -287,7 +290,7 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
node->GetName().c_str(), node->GetType().c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to add control edge, from node %s to const node %s.", node->GetName().c_str(),
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] failed, from node %s to const node %s.", node->GetName().c_str(),
const_node->GetName().c_str());
return INTERNAL_ERROR;
}
@@ -296,11 +299,10 @@ Status FoldingPass::AddConstNode(NodePtr &node, IndexsToAnchors indexes_to_ancho
if (AttrUtils::GetStr(node->GetOpDesc(), ATTR_NAME_STREAM_LABEL, stream_label)) {
GE_CHECK_NOTNULL(const_node->GetOpDesc());
if (!AttrUtils::SetStr(const_node->GetOpDesc(), ATTR_NAME_STREAM_LABEL, stream_label)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_STREAM_LABEL.c_str(),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_STREAM_LABEL.c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to set stream label on dynamic const node %s, with stream label:%s.",
const_node->GetName().c_str(), stream_label.c_str());
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_STREAM_LABEL.c_str(),
const_node->GetName().c_str(), const_node->GetType().c_str());
return INTERNAL_ERROR;
}
}
@@ -317,7 +319,7 @@ Status FoldingPass::RemoveNodeKeepingCtrlEdges(NodePtr &node) {
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) in graph failed",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Failed to isolate the folding-node %s type %s", node->GetName().c_str(),
GELOGE(INTERNAL_ERROR, "[Isolate][Node] %s type %s failed", node->GetName().c_str(),
node->GetType().c_str());
return INTERNAL_ERROR;
}
@@ -327,7 +329,8 @@ Status FoldingPass::RemoveNodeKeepingCtrlEdges(NodePtr &node) {
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "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;
}
AddNodeDeleted(node);
@@ -338,7 +341,7 @@ Status FoldingPass::ConnectNodeToInAnchor(InDataAnchorPtr &in_anchor, NodePtr &n
// the origin edge must be removed before add
if (in_anchor == nullptr || node == nullptr) {
REPORT_INNER_ERROR("E19999", "Param node or in_anchor is nullptr, check invalid");
GELOGE(PARAM_INVALID, "in anchor or node is null");
GELOGE(PARAM_INVALID, "[Check][Param] in anchor or node is null");
return PARAM_INVALID;
}
auto peer_out_anchor = in_anchor->GetPeerOutAnchor();
@@ -352,8 +355,7 @@ Status FoldingPass::ConnectNodeToInAnchor(InDataAnchorPtr &in_anchor, NodePtr &n
if (new_out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param out index:%d data anchor of node:%s(%s) is nullptr, check invalid",
node_index, node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR,
"Failed to add node to in anchor,"
GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to add node to in anchor,"
" the index %d for node %s, type %s is invalid",
node_index, node->GetName().c_str(), node->GetType().c_str());
return INTERNAL_ERROR;
@@ -363,10 +365,10 @@ Status FoldingPass::ConnectNodeToInAnchor(InDataAnchorPtr &in_anchor, NodePtr &n
node->GetName().c_str(), node->GetType().c_str(), node_index,
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR,
"Failed to add edge between anchors,"
" new node %s, type %s",
node->GetName().c_str(), node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
node->GetName().c_str(), node->GetType().c_str(), node_index,
in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(),
in_anchor->GetIdx());
return INTERNAL_ERROR;
}
AddRePassNodesWithInOut(node);


+ 47
- 36
ge/graph/passes/for_pass.cc View File

@@ -56,17 +56,18 @@ Status ForPass::Run(NodePtr &node) {

ForInfo for_info;
GE_CHK_STATUS_RET(BuildForInfo(root_graph, node, for_info),
"Build ForInfo failed, node:%s.", node->GetName().c_str());
"[Build][ForInfo] failed, node:%s.", node->GetName().c_str());

WhileInfo while_info;
GE_CHK_STATUS_RET(TranWhileInfo(graph, for_info, while_info),
"Transfer WhileInfo from ForInfo failed, node:%s.", node->GetName().c_str());
"[Transfer][WhileInfo] from ForInfo failed, node:%s.", node->GetName().c_str());

ComputeGraphPtr cond_graph = BuildCondGraph(while_info);
if ((cond_graph == nullptr) || (root_graph->AddSubgraph(cond_graph) != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Build cond graph failed or add cond subgraph to root_graph:%s failed",
root_graph->GetName().c_str());
GELOGE(FAILED, "Add while_cond_graph failed, node:%s.", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Build cond graph failed or add cond subgraph to root_graph:%s failed.",
root_graph->GetName().c_str());
return FAILED;
}

@@ -74,12 +75,13 @@ Status ForPass::Run(NodePtr &node) {
if ((body_graph == nullptr) || (root_graph->AddSubgraph(body_graph) != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Build body graph failed or add body subgraph to root_graph:%s failed",
root_graph->GetName().c_str());
GELOGE(FAILED, "Add while_body_graph failed, node:%s.", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Build body graph failed or add body subgraph to root_graph:%s failed",
root_graph->GetName().c_str());
return FAILED;
}

GE_CHK_STATUS_RET(UpdateForBodyInputMapping(while_info),
"Update InputMapping for for-body-graph failed, node:%s.", node->GetName().c_str());
"[Update][InputMapping] for for-body-graph failed, node:%s.", node->GetName().c_str());

// for node has and only has one subgraph
GE_CHECK_NOTNULL(node->GetOpDesc());
@@ -107,7 +109,9 @@ Status ForPass::BuildForInfo(const ComputeGraphPtr &root_graph, const NodePtr &n
"in data anchor of op:%s(%s) lack, check invalid",
FOR_START_INPUT, FOR_LIMIT_INPUT, FOR_DELTA_INPUT,
node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "BuildForInfo for %s failed: start/limit/delta is NULL.", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] FOR_START_INPUT index:%d or FOR_LIMIT_INPUT index:%d or FOR_DELTA_INPUT index:%d "
"in data anchor of op:%s(%s) lack",
FOR_START_INPUT, FOR_LIMIT_INPUT, FOR_DELTA_INPUT, node->GetName().c_str(), node->GetType().c_str());
return FAILED;
}

@@ -116,7 +120,7 @@ Status ForPass::BuildForInfo(const ComputeGraphPtr &root_graph, const NodePtr &n
std::vector<OutControlAnchorPtr> ctrl_inputs;
std::vector<InControlAnchorPtr> ctrl_outputs;
if (FindInputsAndOutputs(node, data_inputs, data_outputs, ctrl_inputs, ctrl_outputs) != SUCCESS) {
GELOGE(FAILED, "BuildForInfo for %s failed: find inputs/outputs failed.", node->GetName().c_str());
GELOGE(FAILED, "[Find][InputsAndOutputs] in node:%s failed.", node->GetName().c_str());
return FAILED;
}
NodeUtils::UnlinkAll(*node);
@@ -128,14 +132,16 @@ Status ForPass::BuildForInfo(const ComputeGraphPtr &root_graph, const NodePtr &n
if (for_body_name.empty()) {
REPORT_INNER_ERROR("E19999", "Get subgraph name from op:%s(%s) by index 0 failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "BuildForInfo for %s failed: sub_graph_name is empty.", node->GetName().c_str());
GELOGE(FAILED, "[Get][SubGraphName] from op:%s(%s) by index 0 failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED;
}
ComputeGraphPtr for_body = root_graph->GetSubgraph(for_body_name);
if (for_body == nullptr) {
REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed",
root_graph->GetName().c_str(), for_body_name.c_str());
GELOGE(FAILED, "BuildForInfo for %s failed: for_body_graph is NULL.", node->GetName().c_str());
GELOGE(FAILED, "[Get][SubGraph] from graph:%s by name:%s failed",
root_graph->GetName().c_str(), for_body_name.c_str());
return FAILED;
}

@@ -162,13 +168,14 @@ Status ForPass::BuildForInfo(const ComputeGraphPtr &root_graph, const NodePtr &n
///
OutDataAnchorPtr ForPass::FindInputWithIndex(const NodePtr &node, uint32_t index) {
if (node == nullptr) {
GELOGE(FAILED, "FindInputWithIndex failed: node is NULL.");
GELOGE(FAILED, "[Check][Param] node is nullptr.");
return nullptr;
}

InDataAnchorPtr in_data_anchor = node->GetInDataAnchor(index);
if (in_data_anchor == nullptr) {
GELOGE(FAILED, "FindInputWithIndex %s:%u failed: in_data_anchor is NULL.", node->GetName().c_str(), index);
GELOGE(FAILED, "[Get][InDataAnchor] failed, In Data Anchor index:%u in node:%s is nullptr.",
index, node->GetName().c_str());
return nullptr;
}

@@ -234,9 +241,8 @@ Status ForPass::TranWhileInfo(const ComputeGraphPtr &graph, const ForInfo &for_i
std::string i_name = for_name + "_i";
NodePtr i_node = graph->AddNode(CreateConstDesc(i_name, 0));
if (i_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(Const) to graph:%s failed",
i_name.c_str(), graph->GetName().c_str());
GELOGE(FAILED, "TranWhileInfo failed: create i_node failed.");
REPORT_CALL_ERROR("E19999", "Add node:%s(Const) to graph:%s failed", i_name.c_str(), graph->GetName().c_str());
GELOGE(FAILED, "[Add][Node] %s(Const) to graph:%s failed", i_name.c_str(), graph->GetName().c_str());
return FAILED;
}
AddRePassNode(i_node);
@@ -249,7 +255,9 @@ Status ForPass::TranWhileInfo(const ComputeGraphPtr &graph, const ForInfo &for_i
REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
i_node->GetName().c_str(), i_node->GetType().c_str(),
identity_node->GetName().c_str(), identity_node->GetType().c_str());
GELOGE(FAILED, "TranWhileInfo failed: Add data-edge %s:0->%s:0 failed.", i_name.c_str(), identity_name.c_str());
GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed",
i_node->GetName().c_str(), i_node->GetType().c_str(),
identity_node->GetName().c_str(), identity_node->GetType().c_str());
return FAILED;
}
AddRePassNode(identity_node);
@@ -259,21 +267,22 @@ Status ForPass::TranWhileInfo(const ComputeGraphPtr &graph, const ForInfo &for_i
if (i_input == nullptr) {
REPORT_INNER_ERROR("E19999", "Out data anchor index:0 in op:%s(%s) is nullptr, check invalid",
identity_node->GetName().c_str(), identity_node->GetType().c_str());
GELOGE(FAILED, "TranWhileInfo failed: i_input is NULL.");
GELOGE(FAILED, "[Get][OutDataAnchor] failed, Out data anchor index:0 in op:%s(%s) is nullptr",
identity_node->GetName().c_str(), identity_node->GetType().c_str());
return FAILED;
}

OutDataAnchorPtr range_input = nullptr;
OutDataAnchorPtr abs_delta_input = nullptr;
if (CreateLoopInput(graph, for_info, range_input, abs_delta_input) != SUCCESS) {
GELOGE(FAILED, "TranWhileInfo failed: create loop input failed.");
GELOGE(FAILED, "[Create][LoopInput] failed, graph:%s.", graph->GetName().c_str());
return FAILED;
}

BuildWhileInfo(for_info, i_input, range_input, abs_delta_input, while_info);

if (InsertWhileNode(graph, for_name + "_While", while_info) != SUCCESS) {
GELOGE(FAILED, "TranWhileInfo failed: insert while node failed.");
GELOGE(FAILED, "[Insert][WhileNode] in graph:%s failed.", graph->GetName().c_str());
return FAILED;
}

@@ -292,7 +301,7 @@ OpDescPtr ForPass::CreateConstDesc(const std::string &name, int32_t value) {
OpDescPtr const_op_desc = MakeShared<OpDesc>(name, CONSTANT);
if (const_op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, const:%s.", name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr;
}

@@ -300,21 +309,23 @@ OpDescPtr ForPass::CreateConstDesc(const std::string &name, int32_t value) {
GeTensorPtr const_value = MakeShared<GeTensor>(data_desc, reinterpret_cast<uint8_t *>(&value), sizeof(int32_t));
if (const_value == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "Create tensor failed, const:%s.", name.c_str());
GELOGE(FAILED, "[New][GeTensor] failed");
return nullptr;
}

if (!AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
GELOGE(FAILED, "Set ATTR_NAME_WEIGHTS failed, const:%s.", name.c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return nullptr;
}

if (const_op_desc->AddOutputDesc("y", data_desc) != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed, name:y",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
GELOGE(FAILED, "Add output desc failed, const:%s.", name.c_str());
GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed, name:y",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return nullptr;
}

@@ -360,7 +371,7 @@ Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for
std::string error_msg;
if ((graph_builder.Build(error_code, error_msg) == nullptr) || (error_code != GRAPH_SUCCESS)) {
REPORT_CALL_ERROR("E19999", "Add loop input node to graph:%s failed", graph->GetName().c_str());
GELOGE(FAILED, "Create loop_count node failed: error_code:%u, error_msg:%s.", error_code, error_msg.c_str());
GELOGE(FAILED, "[Create][LoopInputNode] failed: error_code:%u, error_msg:%s.", error_code, error_msg.c_str());
return FAILED;
}

@@ -373,7 +384,7 @@ Status ForPass::CreateLoopInput(const ComputeGraphPtr &graph, const ForInfo &for
NodePtr loop_count_node = graph_builder.GetNode(abs_name_1);
if ((abs_delta_node == nullptr) || (loop_count_node == nullptr)) {
REPORT_CALL_ERROR("E19999", "Add loop input node to graph:%s failed", graph->GetName().c_str());
GELOGE(FAILED, "Create loop node failed: node is NULL.");
GELOGE(FAILED, "[Create][LoopNode] failed: node is nullptr, graph:%s.", graph->GetName().c_str());
return FAILED;
}

@@ -467,14 +478,15 @@ Status ForPass::InsertWhileNode(const ComputeGraphPtr &graph, const std::string
if (while_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(FAILED, "Create while node failed, name:%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 FAILED;
}
AddRePassNode(while_node);

while_info.while_node = while_node;
if (BuildWhileLink(while_info) != SUCCESS) {
GELOGE(FAILED, "Build while link-edge failed, name:%s.", name.c_str());
GELOGE(FAILED, "[Build][WhileLink] failed, node:%s.", while_node->GetName().c_str());
return FAILED;
}

@@ -500,7 +512,7 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) {
continue;
}
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_data_anchor),
"Add data-edge %s:%d->%s:%zu failed.",
"[Add][DataEdge] %s:%d->%s:%zu failed.",
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetIdx(),
while_node->GetName().c_str(), i);
}
@@ -511,7 +523,7 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) {
GE_CHECK_NOTNULL(out_data_anchor);
for (auto &peer_in_anchor : while_info.data_outputs[i]) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_data_anchor, peer_in_anchor),
"Add data-edge %s:%zu->%s:%d failed.",
"[Add][DataEdge] %s:%zu->%s:%d failed.",
while_node->GetName().c_str(), i + kWhileOutputIndex,
peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetIdx());
}
@@ -521,7 +533,7 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) {
GE_CHECK_NOTNULL(in_ctrl_anchor);
for (auto &peer_out_anchor : while_info.ctrl_inputs) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(peer_out_anchor, in_ctrl_anchor),
"Add ctrl-edge %s->%s failed.",
"[Add][CtrlEdge] %s->%s failed.",
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
in_ctrl_anchor->GetOwnerNode()->GetName().c_str());
}
@@ -530,7 +542,7 @@ Status ForPass::BuildWhileLink(const WhileInfo &while_info) {
GE_CHECK_NOTNULL(out_ctrl_anchor);
for (auto &peer_in_anchor : while_info.ctrl_outputs) {
GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_ctrl_anchor, peer_in_anchor),
"Add ctrl-edge %s->%s failed.",
"[Add][CtrlEdge] %s->%s failed.",
out_ctrl_anchor->GetOwnerNode()->GetName().c_str(),
peer_in_anchor->GetOwnerNode()->GetName().c_str());
}
@@ -585,7 +597,7 @@ ComputeGraphPtr ForPass::BuildCondGraph(WhileInfo &while_info) {
ComputeGraphPtr cond_graph = graph_builder.Build(error_code, error_msg);
if (cond_graph == nullptr) {
REPORT_CALL_ERROR("E19999", "Build graph:%s failed", cond_name.c_str());
GELOGE(FAILED, "Build cond_graph failed: error_code:%u, error_msg:%s.", error_code, error_msg.c_str());
GELOGE(FAILED, "[Build][CondGraph] failed: error_code:%u, error_msg:%s.", error_code, error_msg.c_str());
return nullptr;
}

@@ -667,13 +679,13 @@ ComputeGraphPtr ForPass::BuildBodyGraph(WhileInfo &while_info) {
std::string error_msg;
ComputeGraphPtr body_graph = graph_builder.Build(error_code, error_msg);
if (body_graph == nullptr) {
GELOGE(FAILED, "Build body_graph failed: error_code:%u, error_msg:%s.", error_code, error_msg.c_str());
GELOGE(FAILED, "[Build][BodyGraph] failed: error_code:%u, error_msg:%s.", error_code, error_msg.c_str());
return nullptr;
}

NodePtr sub_graph_node = graph_builder.GetNode(sub_graph_node_name);
if (sub_graph_node == nullptr) {
GELOGE(FAILED, "Get sub_graph_node failed: name:%s.", sub_graph_node_name.c_str());
GELOGE(FAILED, "[Get][Node] by name:%s failed.", sub_graph_node_name.c_str());
return nullptr;
}
while_info.sub_graph_node = sub_graph_node;
@@ -699,9 +711,8 @@ OpDescPtr ForPass::CreateSubgraphOpDesc(const std::string &name, uint32_t input_

OpDescPtr op_desc = op_desc_builder.Build();
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Build op_desc:%s(%s) failed",
name.c_str(), PARTITIONEDCALL);
GELOGE(FAILED, "Create op_desc for subgraph node failed, name:%s.", name.c_str());
REPORT_CALL_ERROR("E19999", "Build op_desc:%s(%s) failed", name.c_str(), PARTITIONEDCALL);
GELOGE(FAILED, "[Build][OpDesc] %s(%s) failed", name.c_str(), PARTITIONEDCALL);
return nullptr;
}



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

@@ -35,14 +35,14 @@ namespace ge {
Status FuseDataNodesWithCommonInputPass::Run(ge::ComputeGraphPtr graph) {
if (graph == nullptr) {
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;
}
GELOGD("FuseDataNodesWithCommonInputPass in.");
// key: subgraph, value:--key: peer out anchor to parent node, --value: parent indexes to parent node
map<ComputeGraphPtr, map<OutDataAnchorPtr, set<uint32_t>>> subgraphs_to_need_fuse_nodes_info;
if (InitNeedFuseNodesInfo(graph, subgraphs_to_need_fuse_nodes_info) != SUCCESS) {
GELOGE(FAILED, "InitNeedFuseNodesInfo failed.");
GELOGE(FAILED, "[Init][NeedFuseNodesInfo] for graph:%s failed.", graph->GetName().c_str());
return FAILED;
}
return FuseDataNodes(subgraphs_to_need_fuse_nodes_info);
@@ -116,7 +116,8 @@ Status FuseDataNodesWithCommonInputPass::FuseDataNodes(
if (GraphUtils::RemoveNodeWithoutRelink(subgraph, node) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed",
node->GetName().c_str(), node->GetType().c_str(), subgraph->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(), subgraph->GetName().c_str());
return FAILED;
}
}


+ 19
- 10
ge/graph/passes/get_original_format_pass.cc View File

@@ -37,7 +37,8 @@ using domi::SUCCESS;
namespace ge {
Status GetOriginalFormatPass::Run(ge::ComputeGraphPtr graph) {
GE_CHECK_NOTNULL(graph);
GE_RETURN_WITH_LOG_IF_ERROR(SetOriginalFormat(graph), "SetOriginalFormat failed");
GE_RETURN_WITH_LOG_IF_ERROR(SetOriginalFormat(graph),
"[Set][OriginalFormat] for graph:%s failed", graph->GetName().c_str());

return SUCCESS;
}
@@ -54,7 +55,8 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_INFERRED_FORMAT.c_str(),
node_ptr->GetName().c_str(), node_ptr->GetType().c_str());
GELOGE(FAILED, "set ATTR_NAME_INFERRED_FORMAT failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INFERRED_FORMAT.c_str(),
node_ptr->GetName().c_str(), node_ptr->GetType().c_str());
return FAILED);
}

@@ -70,13 +72,15 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_FORMAT.c_str(),
desc_ptr->GetName().c_str(), desc_ptr->GetType().c_str());
GELOGE(FAILED, "set ATTR_NAME_FORMAT failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_FORMAT.c_str(),
desc_ptr->GetName().c_str(), desc_ptr->GetType().c_str());
return FAILED);
GE_IF_BOOL_EXEC(!AttrUtils::SetInt(desc_ptr, ATTR_NAME_INFERRED_FORMAT, ori_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_INFERRED_FORMAT.c_str(),
desc_ptr->GetName().c_str(), desc_ptr->GetType().c_str());
GELOGE(FAILED, "set ATTR_NAME_INFERRED_FORMAT failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INFERRED_FORMAT.c_str(),
desc_ptr->GetName().c_str(), desc_ptr->GetType().c_str());
return FAILED);
continue;
}
@@ -142,7 +146,8 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_IGNORE_PRED_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
GELOGE(FAILED, "remove edge failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_IGNORE_PRED_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
return FAILED);
}

@@ -152,23 +157,27 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
GELOGE(FAILED, "set ATTR_NAME_FORMAT failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
return FAILED);
GE_IF_BOOL_EXEC(!AttrUtils::SetInt(tmp_op_ptr, ATTR_NAME_INFERRED_FORMAT, ori_format),
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_INFERRED_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
GELOGE(FAILED, "set ATTR_NAME_INFERRED_FORMAT failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INFERRED_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
return FAILED);
} else {
int64_t existingFormat = 0;
GE_RETURN_WITH_LOG_IF_FALSE(AttrUtils::GetInt(tmp_op_ptr, ATTR_NAME_FORMAT, existingFormat),
"Get existing_format attr failed");
"[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
if (!AttrUtils::SetInt(tmp_op_ptr, ATTR_NAME_INFERRED_FORMAT, existingFormat)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed",
ATTR_NAME_INFERRED_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
GELOGE(FAILED, "set ATTR_NAME_INFERRED_FORMAT failed");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INFERRED_FORMAT.c_str(),
tmp_op_ptr->GetName().c_str(), tmp_op_ptr->GetType().c_str());
return FAILED;
}
}
@@ -177,7 +186,7 @@ Status GetOriginalFormatPass::SetOriginalFormat(const ge::ComputeGraphPtr &graph
}

bool GetOriginalFormatPass::IsFormatTranspose(const ge::OpDescPtr op_ptr, int32_t ori_format) {
GE_CHK_BOOL_EXEC(op_ptr != nullptr, return false, "opdef is nullptr");
GE_CHK_BOOL_EXEC(op_ptr != nullptr, return false, "[Check][Param] op_ptr is nullptr");
if (op_ptr->GetType() == PERMUTE) {
vector<int32_t> index_list;
GE_IF_BOOL_EXEC(!AttrUtils::GetListInt(op_ptr, PERMUTE_ATTR_ORDER, index_list), return false);


+ 12
- 7
ge/graph/passes/global_step_insert_pass.cc View File

@@ -41,7 +41,7 @@ NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph,
OpDescPtr op_desc = MakeShared<OpDesc>(node_name, node_type);
GE_IF_BOOL_EXEC(op_desc == nullptr,
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED,"Make OpDesc failed");
GELOGE(FAILED,"[New][OpDesc] failed");
return nullptr);

for (auto &input_desc : input_list) {
@@ -49,7 +49,8 @@ NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph,
if (graph_status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Add node:%s intput desc failed, error=%u.", node_name.c_str(), graph_status);
GELOGE(FAILED, "[Add][InputDesc] to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return nullptr;
}
}
@@ -59,17 +60,19 @@ NodePtr GlobalStepInsertPass::InsertOp(ComputeGraphPtr &compute_graph,
if (graph_status != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Add node:%s output desc failed, error=%u.", node_name.c_str(), graph_status);
GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed, ret:%u.",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph_status);
return nullptr;
}
}

GE_IF_BOOL_EXEC(compute_graph == nullptr, GELOGE(FAILED,"compute_graph is nullptr"); return nullptr);
GE_IF_BOOL_EXEC(compute_graph == nullptr, GELOGE(FAILED,"[Check][Param] compute_graph is nullptr"); return nullptr);
NodePtr node = compute_graph->AddNode(op_desc);
GE_IF_BOOL_EXEC(node == nullptr,
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), compute_graph->GetName().c_str());
GELOGE(FAILED, "add node failed, name:%s, type:%s.", node_name.c_str(), node_type.c_str());
GELOGE(FAILED, "[Add][Node] %s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), compute_graph->GetName().c_str());
return nullptr);

GELOGI("Insert op success, name:%s, type:%s.", node_name.c_str(), node_type.c_str());
@@ -107,7 +110,7 @@ Status GlobalStepInsertPass::Run(ComputeGraphPtr compute_graph) {
NodePtr global_step = InsertOp(compute_graph, VARIABLE, NODE_NAME_GLOBAL_STEP,
input_desc_list, output_desc_list);
if (global_step == nullptr) {
GELOGE(FAILED, "Add global_step node failed, global_step is null.");
GELOGE(FAILED, "[Insert][Op] to graph:%s failed.", compute_graph->GetName().c_str());
return FAILED;
}

@@ -117,7 +120,9 @@ Status GlobalStepInsertPass::Run(ComputeGraphPtr compute_graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
global_step->GetName().c_str(), global_step->GetType().c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
GELOGE(FAILED, "Add global_step to netoutput edge failed, add_ret=%u.", add_ret);
GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
global_step->GetName().c_str(), global_step->GetType().c_str(),
output_node->GetName().c_str(), output_node->GetType().c_str());
return FAILED;
}
GELOGD("Add global_step to netoutput edge in graph %u success", compute_graph->GetGraphID());


+ 10
- 8
ge/graph/passes/guarantee_const_pass.cc View File

@@ -36,19 +36,20 @@ Status GuaranteeConstPass::Run(NodePtr &node) {
string type;
Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Get original type for node:%s failed",
node->GetName().c_str());
GELOGE(status_ret, "GuaranteeConstPass get original type fail.");
REPORT_CALL_ERROR("E19999", "Get original type for node:%s failed", node->GetName().c_str());
GELOGE(status_ret, "[Get][OriginalType] for node:%s failed", node->GetName().c_str());
return status_ret;
}
if (type != GUARANTEECONST) {
return SUCCESS;
}
if (node->GetOpDesc()->GetAllInputsDesc().size() != kGuaranteeConstInputsSize) {
REPORT_CALL_ERROR("E19999", "Num:%zu of input desc node:%s(%s) not equal to %u, "
REPORT_CALL_ERROR("E19999", "Num:%zu of input desc in node:%s(%s) not equal to %u, "
"check invalid", node->GetOpDesc()->GetAllInputsDesc().size(),
node->GetName().c_str(), node->GetType().c_str(), kGuaranteeConstInputsSize);
GELOGE(PARAM_INVALID, "input size error. Input size:%zu", node->GetOpDesc()->GetAllInputsDesc().size());
GELOGE(PARAM_INVALID, "[Check][Param] Num:%zu of input desc in node:%s(%s) not equal to %u",
node->GetOpDesc()->GetAllInputsDesc().size(),
node->GetName().c_str(), node->GetType().c_str(), kGuaranteeConstInputsSize);
return PARAM_INVALID;
}
// [Cascade pointer]
@@ -57,12 +58,13 @@ Status GuaranteeConstPass::Run(NodePtr &node) {
// Input tensor cannot be a resource variable handle.
const DataType &input_dtype = in_desc->GetDataType();
if (input_dtype == DT_RESOURCE) {
REPORT_CALL_ERROR("E19999",
"Data type:%s of op:%s(%s) input0 tensor not equal to %s, check invalid",
REPORT_CALL_ERROR("E19999", "Data type:%s of op:%s(%s) input0 tensor not equal to %s, check invalid",
TypeUtils::DataTypeToSerialString(input_dtype).c_str(),
node->GetName().c_str(), node->GetType().c_str(),
TypeUtils::DataTypeToSerialString(DT_RESOURCE).c_str());
GELOGE(FAILED, "Input tensor cannot be a resource variable handle in [%s].", node->GetName().c_str());
GELOGE(FAILED, "[Check][Param] Data type:%s of op:%s(%s) input0 tensor not equal to %s",
TypeUtils::DataTypeToSerialString(input_dtype).c_str(),
node->GetName().c_str(), node->GetType().c_str(), TypeUtils::DataTypeToSerialString(DT_RESOURCE).c_str());
return FAILED;
}



+ 24
- 67
ge/graph/passes/hccl_continuous_memcpy_pass.cc View File

@@ -1,5 +1,5 @@
/**
* Copyright 2020 Huawei Technologies Co., Ltd
* Copyright 2021 Huawei Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,11 +24,12 @@
#include "common/ge/ge_util.h"
#include "framework/common/types.h"
#include "graph/utils/graph_utils.h"
#include "graph/utils/op_desc_utils.h"

namespace {
const int kAnchorNum = 0;
const int32_t kAnchorAssignRefIndex = 0;
const int32_t kAnchorAssignValueIndex = 1;
const int32_t kAnchorIdentityIndex = 0;
} // namespace
namespace ge {
Status HcclContinuousMemcpyPass::Run(ge::ComputeGraphPtr graph) {
@@ -161,41 +162,23 @@ NodePtr HcclContinuousMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &grap

std::string node_name = pre_node->GetName() + "_" + IDENTITY;
node_name = CheckDuplicateName(node_name);
OpDescPtr op_desc = MakeShared<OpDesc>(node_name.c_str(), IDENTITY);
if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(INTERNAL_ERROR, "Create Identity op: MakeShared op_desc fail.");
return nullptr;
}
GELOGI("Create Identity op:%s.", op_desc->GetName().c_str());

graphStatus ret = op_desc->AddInputDesc("x", pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx()));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Identity op: add input desc fail.");
return nullptr;
}

ret = op_desc->AddOutputDesc("y", pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx()));
if (ret != GRAPH_SUCCESS) {
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Create Identity op: add output desc fail.");
OpDescBuilder op_desc_builder(node_name, IDENTITY);
auto data_desc = pre_op_desc->GetOutputDesc(out_data_anchor->GetIdx());
auto identity_op_desc = op_desc_builder.AddInput("x", data_desc).AddOutput("y", data_desc).Build();
if (identity_op_desc == nullptr) {
return nullptr;
}
// because history reason ,this pass can not do work after constant fold so mark it
(void)AttrUtils::SetBool(op_desc, ATTR_NO_NEED_CONSTANT_FOLDING, false);
(void)AttrUtils::SetBool(identity_op_desc, ATTR_NO_NEED_CONSTANT_FOLDING, false);

NodePtr memcpy_node = graph->AddNode(op_desc);
if (memcpy_node == nullptr) {
NodePtr identity_node = graph->AddNode(identity_op_desc);
if (identity_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str());
identity_node->GetName().c_str(), identity_node->GetType().c_str(), graph->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Insert Identity node fail.");
return nullptr;
}

return memcpy_node;
return identity_node;
}

///
@@ -256,50 +239,24 @@ Status HcclContinuousMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &gra
Status HcclContinuousMemcpyPass::InsertIdentityBeforeHccl(const ComputeGraphPtr &graph,
const OutDataAnchorPtr &src_out_anchor,
const InDataAnchorPtr &hccl_in_anchor) {
GELOGI("Between op %s and op %s need insert memcpy async op.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
GELOGI("Between op %s and op %s need insert identity op.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str());
NodePtr memcpy_node = CreateIdentityNode(graph, src_out_anchor);
GE_CHECK_NOTNULL(memcpy_node);
NodePtr identity_node = CreateIdentityNode(graph, src_out_anchor);
GE_CHECK_NOTNULL(identity_node);

Status ret1 = src_out_anchor->Unlink(hccl_in_anchor);
if (ret1 != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d unlink from op:%s(%s) in index:%d failed",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetType().c_str(),
hccl_in_anchor->GetIdx());
GELOGE(INTERNAL_ERROR, "The op %s Unlink anchor %s fail.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}
auto out_data_anchor_0 = memcpy_node->GetOutDataAnchor(kAnchorNum);
GE_CHECK_NOTNULL(out_data_anchor_0);
ret1 = out_data_anchor_0->LinkTo(hccl_in_anchor);
if (ret1 != SUCCESS) {
auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex);
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d link to op:%s(%s) in index:%d failed",
out_data_anchor_0->GetOwnerNode()->GetName().c_str(),
out_data_anchor_0->GetOwnerNode()->GetType().c_str(), out_data_anchor_0->GetIdx(),
"Op:Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
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->GetIdx());
GELOGE(INTERNAL_ERROR, "The op %s link anchor %s fail.", memcpy_node->GetName().c_str(),
hccl_in_anchor->GetOwnerNode()->GetName().c_str());
return FAILED;
}

Status ret = src_out_anchor->LinkTo(memcpy_node->GetInDataAnchor(kAnchorNum));
if (ret != SUCCESS) {
REPORT_CALL_ERROR("E19999",
"Op:%s(%s) out index:%d link to op:%s(%s) in index:%u failed",
src_out_anchor->GetOwnerNode()->GetName().c_str(),
src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(),
memcpy_node->GetName().c_str(), memcpy_node->GetType().c_str(),
kAnchorNum);
GELOGE(INTERNAL_ERROR, "The op %s link anchor %s fail.", src_out_anchor->GetOwnerNode()->GetName().c_str(),
memcpy_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "Fail to insert %s(%s) before %s(%s) on index:%d input anchor.",
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->GetIdx());
return FAILED;
}
return SUCCESS;


Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save