Browse Source

!1798 code_sync_0617

Merge pull request !1798 from code_sync_0617
tags/v1.3.0
zhangzhenghai Gitee 4 years ago
parent
commit
f71c51e18c
100 changed files with 2165 additions and 1421 deletions
  1. +119
    -107
      CMakeLists.txt
  2. +31
    -3
      build.sh
  3. +1
    -7
      ge/CMakeLists.txt
  4. +0
    -5
      ge/common/auth/file_saver.cc
  5. +4
    -5
      ge/common/ge/plugin_manager.cc
  6. +1
    -2
      ge/common/helper/model_cache_helper.cc
  7. +7
    -9
      ge/common/helper/model_helper.cc
  8. +4
    -19
      ge/common/model_parser/model_parser.cc
  9. +1
    -2
      ge/common/model_parser/model_parser.h
  10. +2
    -2
      ge/common/model_saver.cc
  11. +3
    -0
      ge/common/profiling/ge_profiling.cc
  12. +17
    -5
      ge/common/profiling/profiling_manager.cc
  13. +2
    -0
      ge/common/profiling/profiling_manager.h
  14. +3
    -0
      ge/common/types.cc
  15. +70
    -51
      ge/common/util.cc
  16. +12
    -16
      ge/engine_manager/dnnengine_manager.cc
  17. +1
    -6
      ge/executor/CMakeLists.txt
  18. +3
    -5
      ge/executor/ge_executor.cc
  19. +4
    -0
      ge/ge_local_engine/engine/host_cpu_engine.cc
  20. +3
    -0
      ge/ge_local_engine/engine/host_cpu_engine.h
  21. +2
    -1
      ge/ge_runtime/runtime_model.cc
  22. +1
    -1
      ge/ge_runtime/task/aicpu_task.cc
  23. +3
    -6
      ge/ge_runtime/task/hccl_task.cc
  24. +42
    -0
      ge/ge_runtime/task/label_goto_task.cc
  25. +28
    -2
      ge/ge_runtime/task/label_switch_task.cc
  26. +5
    -7
      ge/generator/ge_generator.cc
  27. +71
    -59
      ge/graph/build/memory/graph_mem_assigner.cc
  28. +3
    -0
      ge/graph/build/memory/graph_mem_assigner.h
  29. +2
    -1
      ge/graph/build/stream_allocator.cc
  30. +7
    -1
      ge/graph/build/task_generator.cc
  31. +12
    -2
      ge/graph/common/omg_util.cc
  32. +8
    -0
      ge/graph/common/omg_util.h
  33. +4
    -10
      ge/graph/load/graph_loader.cc
  34. +1
    -2
      ge/graph/load/graph_loader.h
  35. +29
    -26
      ge/graph/load/model_manager/davinci_model.cc
  36. +1
    -1
      ge/graph/load/model_manager/davinci_model.h
  37. +9
    -36
      ge/graph/load/model_manager/model_manager.cc
  38. +4
    -2
      ge/graph/load/model_manager/model_utils.cc
  39. +8
    -8
      ge/graph/manager/graph_manager.cc
  40. +7
    -8
      ge/graph/manager/host_mem_manager.cc
  41. +1
    -1
      ge/graph/manager/host_mem_manager.h
  42. +9
    -2
      ge/graph/manager/memory_api.cc
  43. +9
    -8
      ge/graph/optimize/graph_optimize.cc
  44. +2
    -4
      ge/graph/optimize/mem_rw_conflict_optimize.cc
  45. +4
    -10
      ge/graph/partition/graph_partition.cc
  46. +19
    -9
      ge/graph/passes/base_pass.cc
  47. +2
    -2
      ge/graph/passes/flow_ctrl_pass.cc
  48. +51
    -39
      ge/graph/passes/hccl_continuous_memcpy_pass.cc
  49. +46
    -29
      ge/graph/passes/hccl_memcpy_pass.cc
  50. +4
    -3
      ge/graph/passes/hccl_tailing_optimization_pass.cc
  51. +6
    -7
      ge/graph/passes/identity_pass.cc
  52. +7
    -5
      ge/graph/passes/infershape_pass.cc
  53. +3
    -1
      ge/graph/passes/inplace_support_check_pass.cc
  54. +18
    -21
      ge/graph/passes/input_output_connection_identify_pass.cc
  55. +87
    -59
      ge/graph/passes/iterator_op_pass.cc
  56. +7
    -3
      ge/graph/passes/link_gen_mask_nodes_pass.cc
  57. +1
    -1
      ge/graph/passes/mark_agnostic_pass.cc
  58. +2
    -1
      ge/graph/passes/mark_force_unknown_for_cond_pass.cc
  59. +1
    -1
      ge/graph/passes/mark_graph_unknown_status_pass.cc
  60. +85
    -58
      ge/graph/passes/memcpy_addr_async_pass.cc
  61. +21
    -10
      ge/graph/passes/merge_input_memcpy_pass.cc
  62. +21
    -14
      ge/graph/passes/merge_pass.cc
  63. +42
    -23
      ge/graph/passes/merge_to_stream_merge_pass.cc
  64. +224
    -134
      ge/graph/passes/multi_batch_clone_pass.cc
  65. +118
    -72
      ge/graph/passes/multi_batch_pass.cc
  66. +78
    -51
      ge/graph/passes/net_output_pass.cc
  67. +54
    -49
      ge/graph/passes/next_iteration_pass.cc
  68. +0
    -1
      ge/graph/passes/next_iteration_pass.h
  69. +5
    -4
      ge/graph/passes/no_use_reshape_remove_pass.cc
  70. +7
    -5
      ge/graph/passes/parallel_concat_start_op_pass.cc
  71. +3
    -3
      ge/graph/passes/pass_manager.cc
  72. +51
    -29
      ge/graph/passes/pass_utils.cc
  73. +8
    -5
      ge/graph/passes/permute_pass.cc
  74. +1
    -1
      ge/graph/passes/placeholder_with_default_pass.cc
  75. +1
    -1
      ge/graph/passes/prevent_gradient_pass.cc
  76. +2
    -2
      ge/graph/passes/print_op_pass.cc
  77. +2
    -2
      ge/graph/passes/prune_pass.cc
  78. +18
    -11
      ge/graph/passes/ref_identity_delete_op_pass.cc
  79. +5
    -3
      ge/graph/passes/remove_same_const_pass.cc
  80. +30
    -13
      ge/graph/passes/replace_transshape_pass.cc
  81. +2
    -2
      ge/graph/passes/replace_with_empty_const_pass.cc
  82. +13
    -3
      ge/graph/passes/reshape_recovery_pass.cc
  83. +3
    -3
      ge/graph/passes/resource_pair_add_control_pass.cc
  84. +3
    -3
      ge/graph/passes/resource_pair_remove_control_pass.cc
  85. +95
    -34
      ge/graph/passes/same_transdata_breadth_fusion_pass.cc
  86. +5
    -2
      ge/graph/passes/save_pass.cc
  87. +38
    -26
      ge/graph/passes/set_input_output_offset_pass.cc
  88. +4
    -1
      ge/graph/passes/shape_operate_op_remove_pass.cc
  89. +4
    -2
      ge/graph/passes/snapshot_pass.cc
  90. +3
    -2
      ge/graph/passes/stop_gradient_pass.cc
  91. +49
    -27
      ge/graph/passes/subexpression_migration_pass.cc
  92. +67
    -41
      ge/graph/passes/subgraph_const_migration_pass.cc
  93. +2
    -0
      ge/graph/passes/subgraph_const_migration_pass.h
  94. +31
    -20
      ge/graph/passes/subgraph_pass.cc
  95. +23
    -21
      ge/graph/passes/switch_data_edges_bypass.cc
  96. +15
    -6
      ge/graph/passes/switch_dead_branch_elimination.cc
  97. +16
    -10
      ge/graph/passes/switch_logic_remove_pass.cc
  98. +159
    -80
      ge/graph/passes/switch_to_stream_switch_pass.cc
  99. +7
    -4
      ge/graph/passes/transop_breadth_fusion_pass.cc
  100. +36
    -20
      ge/graph/passes/transop_depth_fusion_pass.cc

+ 119
- 107
CMakeLists.txt View File

@@ -39,7 +39,7 @@ set(ATLAS_MS_RUNTIME_PATH ${ATLAS_RUNTIME_DIR} ${ATLAS_ACL_DIR} ${ATLAS_ATC_DIR}


option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE) option(ENABLE_OPEN_SRC "Enable graphengine compile in opensource." FALSE)


if (ENABLE_OPEN_SRC)
if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST)
set(HI_PYTHON python3) set(HI_PYTHON python3)


include(cmake/external_libs/protobuf_shared.cmake) include(cmake/external_libs/protobuf_shared.cmake)
@@ -51,119 +51,131 @@ if (ENABLE_OPEN_SRC)
include(cmake/external_libs/json.cmake) include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake) include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake) include(cmake/intf_pub_linux.cmake)

# if D_LINK_PATH is set in environment variables, search libraries in given path
if(DEFINED ENV{D_LINK_PATH})
# D_LINK_PATH is set
set(GE_LIB_PATH $ENV{D_LINK_PATH})
set(GE_SYS_ARCH "")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
# x86 ubuntu
set(GE_SYS_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
# arm euleros
set(GE_SYS_ARCH "aarch64")
add_subdirectory(tests)
else ()
if (ENABLE_OPEN_SRC)
set(HI_PYTHON python3)

include(cmake/external_libs/protobuf_shared.cmake)
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/gflags.cmake)
include(cmake/external_libs/gtest.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)

# if D_LINK_PATH is set in environment variables, search libraries in given path
if(DEFINED ENV{D_LINK_PATH})
# D_LINK_PATH is set
set(GE_LIB_PATH $ENV{D_LINK_PATH})
set(GE_SYS_ARCH "")
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "x86_64")
# x86 ubuntu
set(GE_SYS_ARCH "x86_64")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "aarch64")
# arm euleros
set(GE_SYS_ARCH "aarch64")
else()
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated")
endif()
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH})
set(STATIC_ACL_LIB ${GE_LIB_PATH})
find_module(slog libalog.so ${GE_LIB_PATH})
find_module(static_mmpa libmmpa.a ${GE_LIB_PATH})
find_module(msprofiler_ext libmsprofiler.a ${GE_LIB_PATH})
find_module(hccl libhccl.so ${GE_LIB_PATH})
find_module(adump_server libadump_server.a ${GE_LIB_PATH})
find_module(runtime libruntime.so ${GE_LIB_PATH})
find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH})
find_module(resource libresource.so ${GE_LIB_PATH})
find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH})
find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${GE_LIB_PATH})
#find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH})
else() else()
message(FATAL_ERROR "Running on a unsupported architecture: ${SYSTEM_TYPE}, build terminated")
endif()
set(GE_LIB_PATH ${GE_LIB_PATH}/${GE_SYS_ARCH})
set(STATIC_ACL_LIB ${GE_LIB_PATH})
find_module(slog libalog.so ${GE_LIB_PATH})
find_module(static_mmpa libmmpa.a ${GE_LIB_PATH})
find_module(msprofiler_ext libmsprofiler.a ${GE_LIB_PATH})
find_module(hccl libhccl.so ${GE_LIB_PATH})
find_module(adump_server libadump_server.a ${GE_LIB_PATH})
find_module(runtime libruntime.so ${GE_LIB_PATH})
find_module(runtime_compile libruntime_compile.so ${GE_LIB_PATH})
find_module(resource libresource.so ${GE_LIB_PATH})
find_module(ascend_hal_stub libascend_hal.so ${GE_LIB_PATH})
find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${GE_LIB_PATH})
#find_module(ascendcl_static libascendcl.a ${GE_LIB_PATH})
elseif(ENABLE_GE_COV OR ENABLE_GE_UT)
add_subdirectory(tests)
else()
find_module(slog libalog.so ${ASCEND_ATC_DIR} ${ASCEND_DRIVER_COMMON_DIR})
find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR} ${ASCEND_RUNTIME_DIR})
if(PLATFORM STREQUAL "train")
find_module(slog libalog.so ${ASCEND_ATC_DIR})
find_module(static_mmpa libmmpa.a ${ASCEND_ATC_DIR})
if(PLATFORM STREQUAL "train")
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
if(PRODUCT STREQUAL "flr3")
message(FATAL_ERROR "This platform is not supported in train mode, build terminated")
endif()
elseif(PLATFORM STREQUAL "inference")
find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR})
find_module(runtime libruntime.so ${ASCEND_ACL_DIR})
find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR})
find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR})
if(PRODUCT STREQUAL "flr3")
elseif(PRODUCT STREQUAL "flr1")
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
elseif(PRODUCT STREQUAL "flr2")
# flr2 ascend_hal_stub limsprof ?
else()
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR})
endif()
elseif(PLATFORM STREQUAL "all")
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR}) find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR}) find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
if(PRODUCT STREQUAL "flr3")
message(FATAL_ERROR "This platform is not supported in train mode, build terminated")
endif()
elseif(PLATFORM STREQUAL "inference")
find_module(adump_server libadump_server.a ${ASCEND_ACL_DIR})
find_module(runtime libruntime.so ${ASCEND_ACL_DIR})
find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR})
find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR})
find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR})
find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR}) find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR})
if(PRODUCT STREQUAL "flr3")
elseif(PRODUCT STREQUAL "flr1")
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR}/driver)
elseif(PRODUCT STREQUAL "flr2")
# flr2 ascend_hal_stub limsprof ?
else() else()
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR})
message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!")
endif() endif()
elseif(PLATFORM STREQUAL "all")
find_module(adump_server libadump_server.a ${ASCEND_RUNTIME_DIR})
find_module(runtime libruntime.so ${ASCEND_RUNTIME_DIR})
find_module(msprofiler_fwk_ext libmsprofiler_fwk.a ${ASCEND_RUNTIME_DIR})
find_module(ascend_hal_stub libascend_hal.so ${ASCEND_DRIVER_DIR})
find_module(runtime_compile libruntime_compile.so ${ASCEND_ATC_DIR})
find_module(msprofiler_ext libmsprofiler.a ${ASCEND_ACL_DIR})
else()
message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!")
endif() endif()
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/parser)
set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..)

add_subdirectory(metadef)
add_subdirectory(parser)
#add_subdirectory(metadef/graph)
#add_subdirectory(metadef/register)
elseif (ENABLE_D OR ENABLE_ACL)
# compiling with MindSpore
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)

# common libraries
find_module(slog libalog.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(static_mmpa libmmpa.a ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})

if (ENABLE_D)
# training
find_module(runtime libruntime.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(register libregister.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
endif ()

set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
add_subdirectory(metadef)
elseif(ENABLE_MS_TESTCASES)
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)

# common libraries
find_module(slog libalog.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(static_mmpa libmmpa.a ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})

set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
add_subdirectory(metadef)
else()
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef)
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/../parser)
set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
endif() endif()


set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/parser)
set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..)

add_subdirectory(metadef)
add_subdirectory(parser)
#add_subdirectory(metadef/graph)
#add_subdirectory(metadef/register)
elseif (ENABLE_D OR ENABLE_ACL)
# compiling with MindSpore
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)

# common libraries
find_module(slog libalog.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(static_mmpa libmmpa.a ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})

if (ENABLE_D)
# training
find_module(runtime libruntime.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(register libregister.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
endif ()

set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
add_subdirectory(metadef)
elseif(ENABLE_MS_TESTCASES)
include(cmake/external_libs/protobuf_static.cmake)
include(cmake/external_libs/protoc.cmake)
include(cmake/external_libs/securec.cmake)
include(cmake/external_libs/json.cmake)
include(cmake/FindModule.cmake)
include(cmake/intf_pub_linux.cmake)

# common libraries
find_module(slog libalog.so ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})
find_module(static_mmpa libmmpa.a ${ASCEND_MS_RUNTIME_PATH} ${ATLAS_MS_RUNTIME_PATH})

set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/metadef)
add_subdirectory(metadef)
else()
set(METADEF_DIR ${CMAKE_CURRENT_LIST_DIR}/../metadef)
set(PARSER_DIR ${CMAKE_CURRENT_LIST_DIR}/../parser)
set(GE_DEPEND_DIR ${CMAKE_CURRENT_LIST_DIR}/..)
endif()
add_subdirectory(ge)


add_subdirectory(ge)
endif ()

+ 31
- 3
build.sh View File

@@ -166,7 +166,7 @@ build_graphengine()
echo "execute command: cmake ${CMAKE_ARGS} .. failed." echo "execute command: cmake ${CMAKE_ARGS} .. failed."
return 1 return 1
fi fi
COMMON_TARGET="ge_local_engine ge_local_opskernel_builder host_cpu_engine host_cpu_opskernel_builder ge_common engine fmk_parser parser_common _caffe_parser fmk_onnx_parser graph register engine_conf.json optimizer_priority.pbtxt "
COMMON_TARGET="ge_local_engine ge_local_opskernel_builder ge_common engine fmk_parser parser_common _caffe_parser fmk_onnx_parser graph register engine_conf.json optimizer_priority.pbtxt "
TARGET=${COMMON_TARGET} TARGET=${COMMON_TARGET}
if [ "x${PLATFORM}" = "xtrain" ] if [ "x${PLATFORM}" = "xtrain" ]
then then
@@ -174,6 +174,9 @@ build_graphengine()
elif [ "x${PLATFORM}" = "xinference" ] elif [ "x${PLATFORM}" = "xinference" ]
then then
TARGET="ge_compiler atc_atc.bin ge_executor_shared ${TARGET}" TARGET="ge_compiler atc_atc.bin ge_executor_shared ${TARGET}"
elif [ "X$ENABLE_GE_ST" = "Xon" ]
then
TARGET="ge_graph_dsl_test graph_engine_test"
elif [ "X$ENABLE_GE_UT" = "Xon" ] elif [ "X$ENABLE_GE_UT" = "Xon" ]
then then
TARGET="ut_libgraph ut_libge_multiparts_utest ut_libge_others_utest ut_libge_kernel_utest ut_libge_distinct_load_utest" TARGET="ut_libgraph ut_libge_multiparts_utest ut_libge_others_utest ut_libge_kernel_utest ut_libge_distinct_load_utest"
@@ -234,6 +237,31 @@ if [[ "X$ENABLE_GE_UT" = "Xon" || "X$ENABLE_GE_COV" = "Xon" ]]; then
genhtml coverage.info genhtml coverage.info
fi fi


if [[ "X$ENABLE_GE_ST" = "Xon" ]]; then
#prepare engine & opskernel so
mkdir -p ${OUTPUT_PATH}/plugin/nnengine
mkdir -p ${OUTPUT_PATH}/plugin/nnengine/ge_config
mkdir -p ${OUTPUT_PATH}/plugin/opskernel
cp ${BUILD_PATH}/tests/framework/libnnengine.so ${OUTPUT_PATH}/plugin/nnengine
cp ${BUILD_PATH}/engine_conf.json ${OUTPUT_PATH}/plugin/nnengine/ge_config
cp ${BUILD_PATH}/tests/framework/libhost_cpu_engine.so ${OUTPUT_PATH}/plugin/opskernel
cp ${BUILD_PATH}/tests/framework/libge_local_engine.so ${OUTPUT_PATH}/plugin/opskernel
cp ${BUILD_PATH}/tests/framework/stub_engine/libfe.so ${OUTPUT_PATH}/plugin/opskernel
#prepare st execution bin
cp ${BUILD_PATH}/tests/st/testcase/graph_engine_test ${OUTPUT_PATH}
cp ${BUILD_PATH}/tests/framework/ge_graph_dsl/tests/ge_graph_dsl_test ${OUTPUT_PATH}
#execute st testcase
RUN_TEST_CASE=${OUTPUT_PATH}/graph_engine_test && ${RUN_TEST_CASE}
RUN_TEST_CASE=${OUTPUT_PATH}/ge_graph_dsl_test && ${RUN_TEST_CASE}
if [[ "$?" -ne 0 ]]; then
echo "!!! ST FAILED, PLEASE CHECK YOUR CHANGES !!!"
echo -e "\033[31m${RUN_TEST_CASE}\033[0m"
exit 1;
fi
# remove plugin
rm -rf ${OUTPUT_PATH}/plugin
fi

# generate output package in tar form, including ut/st libraries/executables # generate output package in tar form, including ut/st libraries/executables
generate_package() generate_package()
{ {
@@ -253,7 +281,7 @@ generate_package()
ACL_LIB=("libge_common.so" "libgraph.so" "libregister.so" "liberror_manager.so" "libge_executor.so") ACL_LIB=("libge_common.so" "libgraph.so" "libregister.so" "liberror_manager.so" "libge_executor.so")
ATC_LIB=("libc_sec.so" "libge_common.so" "libge_compiler.so" "libgraph.so" "libregister.so" "liberror_manager.so") ATC_LIB=("libc_sec.so" "libge_common.so" "libge_compiler.so" "libgraph.so" "libregister.so" "liberror_manager.so")
FWK_LIB=("libge_common.so" "libge_runner.so" "libgraph.so" "libregister.so" "liberror_manager.so") FWK_LIB=("libge_common.so" "libge_runner.so" "libgraph.so" "libregister.so" "liberror_manager.so")
PLUGIN_OPSKERNEL=("libge_local_engine.so" "libge_local_opskernel_builder.so" "libhost_cpu_engine.so" "libhost_cpu_opskernel_builder.so" "optimizer_priority.pbtxt")
PLUGIN_OPSKERNEL=("libge_local_engine.so" "libge_local_opskernel_builder.so" "optimizer_priority.pbtxt")
PARSER_LIB=("lib_caffe_parser.so" "libfmk_onnx_parser.so" "libfmk_parser.so" "libparser_common.so") PARSER_LIB=("lib_caffe_parser.so" "libfmk_onnx_parser.so" "libfmk_parser.so" "libparser_common.so")


rm -rf ${OUTPUT_PATH:?}/${FWK_PATH}/ rm -rf ${OUTPUT_PATH:?}/${FWK_PATH}/
@@ -337,7 +365,7 @@ generate_package()
fi fi
} }


if [[ "X$ENABLE_GE_UT" = "Xoff" && "X$MINDSPORE_MODE" = "Xoff" ]]; then
if [[ "X$ENABLE_GE_UT" = "Xoff" && "X$ENABLE_GE_ST" = "Xoff" && "X$MINDSPORE_MODE" = "Xoff" ]]; then
generate_package generate_package
elif [ "X$MINDSPORE_MODE" = "Xon" ] elif [ "X$MINDSPORE_MODE" = "Xon" ]
then then


+ 1
- 7
ge/CMakeLists.txt View File

@@ -2,7 +2,6 @@ if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES)
add_subdirectory(common) add_subdirectory(common)
add_subdirectory(plugin/engine) add_subdirectory(plugin/engine)
add_subdirectory(ge_local_engine) add_subdirectory(ge_local_engine)
add_subdirectory(host_cpu_engine)
add_subdirectory(executor) add_subdirectory(executor)
add_subdirectory(offline) add_subdirectory(offline)
elseif (ENABLE_D) elseif (ENABLE_D)
@@ -380,6 +379,7 @@ set(TRAIN_SRC_LIST
"single_op/task/tbe_task_builder.cc" "single_op/task/tbe_task_builder.cc"
"single_op/task/aicpu_task_builder.cc" "single_op/task/aicpu_task_builder.cc"
"single_op/task/aicpu_kernel_task_builder.cc" "single_op/task/aicpu_kernel_task_builder.cc"
"single_op/task/rts_kernel_task_builder.cc"
"hybrid/common/tensor_value.cc" "hybrid/common/tensor_value.cc"
"hybrid/common/npu_memory_allocator.cc" "hybrid/common/npu_memory_allocator.cc"
"hybrid/executor/rt_callback_manager.cc" "hybrid/executor/rt_callback_manager.cc"
@@ -408,12 +408,6 @@ set(TRAIN_SRC_LIST
"hybrid/node_executor/compiledsubgraph/known_node_executor.cc" "hybrid/node_executor/compiledsubgraph/known_node_executor.cc"
"hybrid/node_executor/ge_local/ge_local_node_executor.cc" "hybrid/node_executor/ge_local/ge_local_node_executor.cc"
"hybrid/node_executor/host_cpu/host_cpu_node_executor.cc" "hybrid/node_executor/host_cpu/host_cpu_node_executor.cc"
"hybrid/node_executor/host_cpu/kernel_factory.cc"
"hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc"
"hybrid/node_executor/host_cpu/kernel/variable_kernel.cc"
"hybrid/node_executor/host_cpu/kernel/assign_kernel.cc"
"hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc"
"hybrid/node_executor/host_cpu/kernel/data_kernel.cc"
"hybrid/node_executor/controlop/control_op_executor.cc" "hybrid/node_executor/controlop/control_op_executor.cc"
"hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc" "hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc"
"hybrid/node_executor/hccl/hccl_node_executor.cc" "hybrid/node_executor/hccl/hccl_node_executor.cc"


+ 0
- 5
ge/common/auth/file_saver.cc View File

@@ -290,7 +290,6 @@ FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const
copy_header_ret); copy_header_ret);


file_header.length = model.model_len; file_header.length = model.model_len;
file_header.is_encrypt = ModelEncryptType::UNENCRYPTED;


const Status ret = SaveWithFileHeader(file_path, file_header, model.model_data, file_header.length); const Status ret = SaveWithFileHeader(file_path, file_header, model.model_data, file_header.length);
if (ret != SUCCESS) { if (ret != SUCCESS) {
@@ -305,8 +304,6 @@ FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, ModelPartitionTable &model_partition_table,
const std::vector<ModelPartition> &partition_datas) { const std::vector<ModelPartition> &partition_datas) {
file_header.is_encrypt = ModelEncryptType::UNENCRYPTED;

const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_table, partition_datas); const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_table, partition_datas);
GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.", GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.",
file_path.c_str(), file_header.length); file_path.c_str(), file_header.length);
@@ -317,8 +314,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header,
vector<ModelPartitionTable *> &model_partition_tables, vector<ModelPartitionTable *> &model_partition_tables,
const vector<vector<ModelPartition>> &all_partition_datas) { const vector<vector<ModelPartition>> &all_partition_datas) {
file_header.is_encrypt = ModelEncryptType::UNENCRYPTED;

const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_tables, all_partition_datas); const Status ret = SaveWithFileHeader(file_path, file_header, model_partition_tables, all_partition_datas);
GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.", GE_CHK_BOOL_RET_STATUS(ret == SUCCESS, FAILED, "save file failed, file_path:%s, file header len:%u.",
file_path.c_str(), file_header.length); file_path.c_str(), file_header.length);


+ 4
- 5
ge/common/ge/plugin_manager.cc View File

@@ -126,8 +126,8 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
if (handle == nullptr) { if (handle == nullptr) {
const char *error = mmDlerror(); const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = ""); GE_IF_BOOL_EXEC(error == nullptr, error = "");
ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"},
{"mmDlopen", "shared library path is " + FmtToStr(file_path_dlopen) + ". Errormessage" + FmtToStr(error)});
REPORT_INNER_ERROR("E19999", "DLOpen SharedLibraryPath failed, path[%s]. Errormessage[%s]!",
file_path_dlopen.c_str(), error);
GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID, GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID,
"[DLOpen][SharedLibraryPath]Failed, path[%s]. Errormessage[%s]!", "[DLOpen][SharedLibraryPath]Failed, path[%s]. Errormessage[%s]!",
file_path_dlopen.c_str(), error); file_path_dlopen.c_str(), error);
@@ -141,9 +141,8 @@ Status PluginManager::LoadSo(const string &path, const vector<string> &func_chec
if (real_fn == nullptr) { if (real_fn == nullptr) {
const char *error = mmDlerror(); const char *error = mmDlerror();
GE_IF_BOOL_EXEC(error == nullptr, error = ""); GE_IF_BOOL_EXEC(error == nullptr, error = "");
ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"},
{"mmDlsym", FmtToStr(func_name) + " is skipped since function" +
FmtToStr(func_name) + " is not existed!"});
REPORT_INNER_ERROR("E19999", "[Check][So]%s is skipped since function %s is not existed! errmsg:%s",
func_name.c_str(), func_name.c_str(), error);
GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID, GELOGE(ACL_ERROR_GE_PLGMGR_PATH_INVALID,
"[Check][So]%s is skipped since function %s is not existed! errmsg:%s", "[Check][So]%s is skipped since function %s is not existed! errmsg:%s",
func_name.c_str(), func_name.c_str(), error); func_name.c_str(), func_name.c_str(), error);


+ 1
- 2
ge/common/helper/model_cache_helper.cc View File

@@ -1672,10 +1672,9 @@ Status ModelCacheHelper::LoadOmModelFromCache(GeModelPtr &ge_model) const {
} }
GELOGI("load model data from file: %s", om_path.c_str()); GELOGI("load model data from file: %s", om_path.c_str());
Status ret; Status ret;
string key_path;
int32_t priority = 0; int32_t priority = 0;
ModelData model_data; ModelData model_data;
ret = ModelParserBase::LoadFromFile(om_path.c_str(), key_path.c_str(), priority, model_data);
ret = ModelParserBase::LoadFromFile(om_path.c_str(), priority, model_data);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGW("LoadOmModelFromCache: Load model from file failed. ret = %u", ret); GELOGW("LoadOmModelFromCache: Load model from file failed. ret = %u", ret);
return ret; return ret;


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

@@ -39,8 +39,6 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil
const uint8_t *data, size_t size, size_t model_index) { const uint8_t *data, size_t size, size_t model_index) {
if (size < 1 || size > UINT32_MAX) { if (size < 1 || size > UINT32_MAX) {
GELOGE(PARAM_INVALID, "[Add][ModelPartition]Failed, partition size %zu invalid", size); GELOGE(PARAM_INVALID, "[Add][ModelPartition]Failed, partition size %zu invalid", size);
REPORT_INNER_ERROR("E19999", "Add model partition failed, partition size %zu "
"invalid", size);
if (size > UINT32_MAX) { if (size > UINT32_MAX) {
string item = "item"; string item = "item";
if (type == MODEL_DEF) { if (type == MODEL_DEF) {
@@ -57,6 +55,8 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr<OmFileSaveHelper> &om_fil
ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"}, ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"},
{std::to_string(size), item, std::to_string(UINT32_MAX)}); {std::to_string(size), item, std::to_string(UINT32_MAX)});
} }
REPORT_INNER_ERROR("E19999", "Add model partition failed, partition size %zu "
"invalid", size);
return PARAM_INVALID; return PARAM_INVALID;
} }
if (data == nullptr) { if (data == nullptr) {
@@ -469,10 +469,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelHelper::SaveToOmRoo
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status
ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) {
if (output_file.empty()) { if (output_file.empty()) {
GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s",
output_file.c_str());
REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s",
output_file.c_str());
GELOGE(FAILED, "[Save][Model]Received invalid file name prefix, output_file %s", output_file.c_str());
REPORT_INNER_ERROR("E19999", "Save model received invalid file name prefix, output_file %s", output_file.c_str());
return FAILED; return FAILED;
} }
// Get computegraph from graph // Get computegraph from graph
@@ -1015,7 +1013,7 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef
ge::ModelData model; ge::ModelData model;
int32_t priority = 0; int32_t priority = 0;


Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model);
Status ret = ModelParserBase::LoadFromFile(model_file, priority, model);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "[Load][ModelInfo]Failed from file %s, error_code %u", model_file, ret); GELOGE(ret, "[Load][ModelInfo]Failed from file %s, error_code %u", model_file, ret);
REPORT_CALL_ERROR("E19999", "Load model info failed from file %s, error_code %u", REPORT_CALL_ERROR("E19999", "Load model info failed from file %s, error_code %u",
@@ -1035,7 +1033,7 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef
ret = ModelParserBase::ParseModelContent(model, model_data, model_len); ret = ModelParserBase::ParseModelContent(model, model_data, model_len);
if (ret != SUCCESS) { if (ret != SUCCESS) {
ErrorManager::GetInstance().ATCReportErrMessage("E10003", ErrorManager::GetInstance().ATCReportErrMessage("E10003",
{"parameter", "value", "reason"}, {"om", model_file, "invalid om file"});
{"parameter", "value", "reason"}, {"om", model_file, "invalid om file, can't be parsed"});
GELOGE(ACL_ERROR_GE_PARAM_INVALID, GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"[Parse][ModelContent]Failed because of invalid om file %s, please check om param", "[Parse][ModelContent]Failed because of invalid om file %s, please check om param",
model_file); model_file);
@@ -1074,7 +1072,7 @@ Status ModelTool::GetModelInfoFromPbtxt(const char *model_file, ge::proto::Model
ge::ModelData model; ge::ModelData model;
int32_t priority = 0; int32_t priority = 0;


Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model);
Status ret = ModelParserBase::LoadFromFile(model_file, priority, model);
auto free_model_data = [](void **ptr) -> void { auto free_model_data = [](void **ptr) -> void {
if (ptr != nullptr && *ptr != nullptr) { if (ptr != nullptr && *ptr != nullptr) {
delete[] reinterpret_cast<char *>(*ptr); delete[] reinterpret_cast<char *>(*ptr);


+ 4
- 19
ge/common/model_parser/model_parser.cc View File

@@ -27,7 +27,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelParserBase::ModelParserBas
FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelParserBase::~ModelParserBase() {} FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelParserBase::~ModelParserBase() {}


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFromFile(const char *model_path, FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFromFile(const char *model_path,
const char *key, int32_t priority,
int32_t priority,
ge::ModelData &model_data) { ge::ModelData &model_data) {
std::string real_path = RealPath(model_path); std::string real_path = RealPath(model_path);
if (real_path.empty()) { if (real_path.empty()) {
@@ -77,7 +77,6 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::LoadFro
model_data.model_data = data; model_data.model_data = data;
model_data.model_len = len; model_data.model_len = len;
model_data.priority = priority; model_data.priority = priority;
model_data.key = (key == nullptr) ? "" : key;


return SUCCESS; return SUCCESS;
} }
@@ -113,23 +112,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo


// Get data address // Get data address
uint8_t *data = reinterpret_cast<uint8_t *>(model.model_data) + sizeof(ModelFileHeader); uint8_t *data = reinterpret_cast<uint8_t *>(model.model_data) + sizeof(ModelFileHeader);
if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model
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_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;
}
model_data = data;
model_len = file_header->length;
GELOGD("Model_len is %u, model_file_head_len is %zu.", model_len, sizeof(ModelFileHeader));


return res; return res;
} }


+ 1
- 2
ge/common/model_parser/model_parser.h View File

@@ -43,12 +43,11 @@ class ModelParserBase {
* @ingroup hiai * @ingroup hiai
* @brief Parsing a model file * @brief Parsing a model file
* @param [in] model_file model path * @param [in] model_file model path
* @param [in] model_key model secret key
* @param [in] priority modle priority * @param [in] priority modle priority
* @param [out] model_data model data * @param [out] model_data model data
* @return Status result * @return Status result
*/ */
static Status LoadFromFile(const char *model_file, const char *model_key, int32_t priority,
static Status LoadFromFile(const char *model_file, int32_t priority,
ge::ModelData &model_data); ge::ModelData &model_data);


/** /**


+ 2
- 2
ge/common/model_saver.cc View File

@@ -41,12 +41,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi
try { try {
model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore); model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore);
} catch (std::exception &e) { } catch (std::exception &e) {
ErrorManager::GetInstance().ATCReportErrMessage("E19007", {"exception"}, {e.what()});
REPORT_INNER_ERROR("E19999", "Failed to convert JSON to string, reason: %s, savefile:%s.", e.what(), file_path);
GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s, reason %s", GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s, reason %s",
file_path, e.what()); file_path, e.what());
return FAILED; return FAILED;
} catch (...) { } catch (...) {
ErrorManager::GetInstance().ATCReportErrMessage("E19008");
REPORT_INNER_ERROR("E19999", "Failed to convert JSON to string, savefile:%s.", file_path);
GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s", file_path); GELOGE(FAILED, "[Convert][File]Failed to convert JSON to string, file %s", file_path);
return FAILED; return FAILED;
} }


+ 3
- 0
ge/common/profiling/ge_profiling.cc View File

@@ -216,3 +216,6 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le
return ge::SUCCESS; return ge::SUCCESS;
} }


GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream) {
return ge::SUCCESS;
}

+ 17
- 5
ge/common/profiling/profiling_manager.cc View File

@@ -954,8 +954,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMs
static_cast<void *>(&reporter_data), sizeof(ReporterData)); static_cast<void *>(&reporter_data), sizeof(ReporterData));
} }


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetOpInputOutputInfo(
const OpDescPtr &op, TaskDescInfo &task_desc_info) const {
void ProfilingManager::GetOpInputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const {
std::vector<Format> input_format; std::vector<Format> input_format;
std::vector<std::vector<int64_t>> input_shape; std::vector<std::vector<int64_t>> input_shape;
std::vector<DataType> input_data_type; std::vector<DataType> input_data_type;
@@ -968,6 +967,16 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetOpInp
input_shape.emplace_back(input_tensor_desc->GetShape().GetDims()); input_shape.emplace_back(input_tensor_desc->GetShape().GetDims());
input_data_type.emplace_back(input_tensor_desc->GetDataType()); input_data_type.emplace_back(input_tensor_desc->GetDataType());
} }

std::vector<Format> format_default = { FORMAT_NULL };
std::vector<std::vector<int64_t>> shape_default = { {0} };
std::vector<DataType> data_type_default = { DT_UNDEFINED };
task_desc_info.input_format = input_format.empty() ? format_default : input_format;
task_desc_info.input_shape = input_shape.empty() ? shape_default : input_shape;
task_desc_info.input_data_type = input_data_type.empty() ? data_type_default : input_data_type;
}

void ProfilingManager::GetOpOutputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const {
std::vector<Format> output_format; std::vector<Format> output_format;
std::vector<std::vector<int64_t>> output_shape; std::vector<std::vector<int64_t>> output_shape;
std::vector<DataType> output_data_type; std::vector<DataType> output_data_type;
@@ -984,14 +993,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetOpInp
std::vector<Format> format_default = { FORMAT_NULL }; std::vector<Format> format_default = { FORMAT_NULL };
std::vector<std::vector<int64_t>> shape_default = { {0} }; std::vector<std::vector<int64_t>> shape_default = { {0} };
std::vector<DataType> data_type_default = { DT_UNDEFINED }; std::vector<DataType> data_type_default = { DT_UNDEFINED };
task_desc_info.input_format = input_format.empty() ? format_default : input_format;
task_desc_info.input_shape = input_shape.empty() ? shape_default : input_shape;
task_desc_info.input_data_type = input_data_type.empty() ? data_type_default : input_data_type;
task_desc_info.output_format = output_format.empty() ? format_default : output_format; task_desc_info.output_format = output_format.empty() ? format_default : output_format;
task_desc_info.output_shape = output_shape.empty() ? shape_default : output_shape; task_desc_info.output_shape = output_shape.empty() ? shape_default : output_shape;
task_desc_info.output_data_type = output_data_type.empty() ? data_type_default : output_data_type; task_desc_info.output_data_type = output_data_type.empty() ? data_type_default : output_data_type;
} }


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetOpInputOutputInfo(
const OpDescPtr &op, TaskDescInfo &task_desc_info) const {
GetOpInputInfo(op, task_desc_info);
GetOpOutputInfo(op, task_desc_info);
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetFpBpPoint( FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetFpBpPoint(
std::string &fp_point, std::string &bp_point) { std::string &fp_point, std::string &bp_point) {
// Env or options mode, fp_point_/bp_point_ have initiliazed on profiling init // Env or options mode, fp_point_/bp_point_ have initiliazed on profiling init


+ 2
- 0
ge/common/profiling/profiling_manager.h View File

@@ -111,6 +111,8 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager {
uint64_t GetProfilingModule(); uint64_t GetProfilingModule();
void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list); void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector<int32_t> &device_list);
void UpdateSubscribeDeviceModuleMap(std::string prof_type, uint32_t device_id, uint64_t module); void UpdateSubscribeDeviceModuleMap(std::string prof_type, uint32_t device_id, uint64_t module);
void GetOpInputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const;
void GetOpOutputInfo(const OpDescPtr &op, TaskDescInfo &task_desc_info) const;


bool is_load_profiling_; bool is_load_profiling_;
bool is_execute_profiling_; bool is_execute_profiling_;


+ 3
- 0
ge/common/types.cc View File

@@ -92,6 +92,7 @@ REGISTER_OPTYPE_DEFINE(DROPOUTGENMASK, "DropOutGenMask");
REGISTER_OPTYPE_DEFINE(DROPOUTDOMASK, "DropOutDoMask"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASK, "DropOutDoMask");
REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3, "DropOutDoMaskV3"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3, "DropOutDoMaskV3");
REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3D, "DropOutDoMaskV3D"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3D, "DropOutDoMaskV3D");
REGISTER_OPTYPE_DEFINE(SOFTMAXV2WITHDROPOUTDOMASKV3D, "SoftmaxV2WithDropOutDoMaskV3D");
REGISTER_OPTYPE_DEFINE(CONCAT, "Concat"); REGISTER_OPTYPE_DEFINE(CONCAT, "Concat");
REGISTER_OPTYPE_DEFINE(ROIPOOLING, "ROIPooling"); REGISTER_OPTYPE_DEFINE(ROIPOOLING, "ROIPooling");
REGISTER_OPTYPE_DEFINE(PROPOSAL, "Proposal"); REGISTER_OPTYPE_DEFINE(PROPOSAL, "Proposal");
@@ -391,6 +392,8 @@ REGISTER_OPTYPE_DEFINE(HCOMREMOTEREAD, "HcomRemoteRead");
REGISTER_OPTYPE_DEFINE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEREFREAD, "HcomRemoteRefRead");
REGISTER_OPTYPE_DEFINE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEWRITE, "HcomRemoteWrite");
REGISTER_OPTYPE_DEFINE(HCOMREMOTESCATTERWRITE, "HcomRemoteScatterWrite"); REGISTER_OPTYPE_DEFINE(HCOMREMOTESCATTERWRITE, "HcomRemoteScatterWrite");
REGISTER_OPTYPE_DEFINE(HCOMALLTOALLV, "HcomAllToAllV");
REGISTER_OPTYPE_DEFINE(HCOMGATHERALLTOALLV, "HcomGatherAllToAllV");


REGISTER_OPTYPE_DEFINE(VARASSIGN, "VarAssign"); REGISTER_OPTYPE_DEFINE(VARASSIGN, "VarAssign");
REGISTER_OPTYPE_DEFINE(VARISINITIALIZEDOP, "VarIsInitializedOp"); REGISTER_OPTYPE_DEFINE(VARISINITIALIZEDOP, "VarIsInitializedOp");


+ 70
- 51
ge/common/util.cc View File

@@ -70,39 +70,6 @@ static bool ReadProtoFromCodedInputStream(CodedInputStream &coded_stream, Messag
return proto->ParseFromCodedStream(&coded_stream); return proto->ParseFromCodedStream(&coded_stream);
} }


FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromBinaryFile(const char *file, Message *proto) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file == nullptr || proto == nullptr), return false,
"Input parameter file or proto is nullptr!");

std::string real_path = RealPath(file);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(real_path.empty(), return false, "pb file path '%s' not valid", file);

GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetFileLength(real_path) == kFileSizeOutLimitedOrOpenFailed, return false,
"file size not valid.");

std::ifstream fs(real_path, std::ifstream::in | std::ifstream::binary);
if (!fs.is_open()) {
ErrorManager::GetInstance().ATCReportErrMessage("E19001", {"file", "errmsg"}, {file, "ifstream is_open failed"});
GELOGE(ge::FAILED, "[Open][File]Failed, file path %s", file);
return false;
}

google::protobuf::io::IstreamInputStream istream(&fs);
google::protobuf::io::CodedInputStream coded_stream(&istream);

bool ret = ReadProtoFromCodedInputStream(coded_stream, proto);

fs.close();

if (!ret) {
ErrorManager::GetInstance().ATCReportErrMessage("E19005", {"file"}, {file});
GELOGE(ge::FAILED, "[Parse][File]Failed, file %s", file);
return ret;
}

return ret;
}

FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const void *data, int size, Message *proto) { FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromArray(const void *data, int size, Message *proto) {
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((proto == nullptr || data == nullptr || size == 0), return false, GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((proto == nullptr || data == nullptr || size == 0), return false,
"incorrect parameter. proto is nullptr || data is nullptr || size is 0"); "incorrect parameter. proto is nullptr || data is nullptr || size is 0");
@@ -125,13 +92,13 @@ long GetFileLength(const std::string &input_file) {
return kFileSizeOutLimitedOrOpenFailed, "Open file[%s] failed. errmsg:%s", input_file.c_str(), strerror(errno)); return kFileSizeOutLimitedOrOpenFailed, "Open file[%s] failed. errmsg:%s", input_file.c_str(), strerror(errno));


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_length == 0), GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((file_length == 0),
ErrorManager::GetInstance().ATCReportErrMessage("E19015", {"filepath"}, {input_file});
REPORT_INNER_ERROR("E19999", "file:%s size is 0, not valid", input_file.c_str());
return -1, "File[%s] size is 0, not valid.", input_file.c_str()); return -1, "File[%s] size is 0, not valid.", input_file.c_str());


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
file_length > kMaxFileSizeLimit, ErrorManager::GetInstance().ATCReportErrMessage(
"E19016", {"filepath", "filesize", "maxlen"},
{input_file, std::to_string(file_length), std::to_string(kMaxFileSizeLimit)});
file_length > kMaxFileSizeLimit,
REPORT_INNER_ERROR("E19999", "file:%s size:%lld is out of limit: %d.", input_file.c_str(), file_length,
kMaxFileSizeLimit);
return kFileSizeOutLimitedOrOpenFailed, "File[%s] size %lld is out of limit: %d.", input_file.c_str(), file_length, return kFileSizeOutLimitedOrOpenFailed, "File[%s] size %lld is out of limit: %d.", input_file.c_str(), file_length,
kMaxFileSizeLimit); kMaxFileSizeLimit);
return static_cast<long>(file_length); return static_cast<long>(file_length);
@@ -227,7 +194,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::
int32_t ret = mmMkdir(tmp_dir_path, M_IRUSR | M_IWUSR | M_IXUSR); // 700 int32_t ret = mmMkdir(tmp_dir_path, M_IRUSR | M_IWUSR | M_IXUSR); // 700
if (ret != 0) { if (ret != 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path});
REPORT_CALL_ERROR("E19999",
"Can not create directory %s. Make sure the directory exists and writable. errmsg:%s",
directory_path.c_str(), strerror(errno));
GELOGW("Can not create directory %s. Make sure the directory exists and writable. errmsg:%s", GELOGW("Can not create directory %s. Make sure the directory exists and writable. errmsg:%s",
directory_path.c_str(), strerror(errno)); directory_path.c_str(), strerror(errno));
return ret; return ret;
@@ -239,7 +208,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std::
int32_t ret = mmMkdir(const_cast<char *>(directory_path.c_str()), M_IRUSR | M_IWUSR | M_IXUSR); // 700 int32_t ret = mmMkdir(const_cast<char *>(directory_path.c_str()), M_IRUSR | M_IWUSR | M_IXUSR); // 700
if (ret != 0) { if (ret != 0) {
if (errno != EEXIST) { if (errno != EEXIST) {
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {directory_path});
REPORT_CALL_ERROR("E19999",
"Can not create directory %s. Make sure the directory exists and writable. errmsg:%s",
directory_path.c_str(), strerror(errno));
GELOGW("Can not create directory %s. Make sure the directory exists and writable. errmsg:%s", GELOGW("Can not create directory %s. Make sure the directory exists and writable. errmsg:%s",
directory_path.c_str(), strerror(errno)); directory_path.c_str(), strerror(errno));
return ret; return ret;
@@ -279,7 +250,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool ReadProtoFromText(const ch
std::ifstream fs(real_path.c_str(), std::ifstream::in); std::ifstream fs(real_path.c_str(), std::ifstream::in);


if (!fs.is_open()) { if (!fs.is_open()) {
ErrorManager::GetInstance().ATCReportErrMessage("E19017", {"realpth", "protofile"}, {real_path, file});
REPORT_INNER_ERROR("E19999", "open file:%s failed", real_path.c_str());
GELOGE(ge::FAILED, "[Open][ProtoFile]Failed, real path %s, orginal file path %s", GELOGE(ge::FAILED, "[Open][ProtoFile]Failed, real path %s, orginal file path %s",
real_path.c_str(), file); real_path.c_str(), file);
return false; return false;
@@ -374,14 +345,24 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const
// The specified path is empty // The specified path is empty
std::map<std::string, std::string> args_map; std::map<std::string, std::string> args_map;
if (file_path.empty()) { if (file_path.empty()) {
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
} else {
REPORT_INNER_ERROR("E19999", "Param file_path is empty, check invalid");
}
GELOGW("Input parameter %s is empty.", file_path.c_str()); GELOGW("Input parameter %s is empty.", file_path.c_str());
return false; return false;
} }
std::string real_path = RealPath(file_path.c_str()); std::string real_path = RealPath(file_path.c_str());
// Unable to get absolute path (does not exist or does not have permission to access) // Unable to get absolute path (does not exist or does not have permission to access)
if (real_path.empty()) { if (real_path.empty()) {
ErrorManager::GetInstance().ATCReportErrMessage("E19000", {"path", "errmsg"}, {file_path, strerror(errno)});
if (atc_param != "") {
std::string reason = "realpath error, errmsg:" + std::string(strerror(errno));
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s]'s realpath is empty, errmsg[%s]", file_path.c_str(), strerror(errno));
}
GELOGW("Path[%s]'s realpath is empty, errmsg[%s]", file_path.c_str(), strerror(errno)); GELOGW("Path[%s]'s realpath is empty, errmsg[%s]", file_path.c_str(), strerror(errno));
return false; return false;
} }
@@ -397,13 +378,23 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
!ValidateStr(real_path, mode), !ValidateStr(real_path, mode),
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, real_path, kPathValidReason});
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, real_path, kPathValidReason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] has invalid char, %s", file_path.c_str(), kPathValidReason);
}
return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason); return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), real_path.c_str(), kPathValidReason);


// The absolute path points to a file that is not readable // The absolute path points to a file that is not readable
if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) { if (mmAccess2(real_path.c_str(), M_R_OK) != EN_OK) {
ErrorManager::GetInstance().ATCReportErrMessage("E19003", {"file", "errmsg"}, {file_path.c_str(), strerror(errno)});
if (atc_param != "") {
std::string reason = "cat not access, errmsg:" + std::string(strerror(errno));
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] can't acccess, errmsg:%s", file_path.c_str(), strerror(errno));
}
GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno)); GELOGW("Read file[%s] failed, errmsg[%s]", file_path.c_str(), strerror(errno));
return false; return false;
} }
@@ -415,14 +406,27 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
const std::string &atc_param) { const std::string &atc_param) {
// The specified path is empty // The specified path is empty
if (file_path.empty()) { if (file_path.empty()) {
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
} else {
REPORT_INNER_ERROR("E19999", "Param file_path is empty, check invalid");
}
ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param}); ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {atc_param});
GELOGW("Input parameter's value is empty."); GELOGW("Input parameter's value is empty.");
return false; return false;
} }


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH, GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(strlen(file_path.c_str()) >= MMPA_MAX_PATH,
ErrorManager::GetInstance().ATCReportErrMessage(
"E19002", {"filepath", "size"}, {file_path, std::to_string(MMPA_MAX_PATH)});
if (atc_param != "") {
std::string reason = "len is too long, it must be less than " +
std::to_string(MMPA_MAX_PATH);
ErrorManager::GetInstance().ATCReportErrMessage(
"E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] len is too long, it must be less than %d",
file_path.c_str(), MMPA_MAX_PATH);
}
return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(), return "", "Path[%s] len is too long, it must be less than %d", file_path.c_str(),
MMPA_MAX_PATH); MMPA_MAX_PATH);


@@ -437,8 +441,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const


GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(
!ValidateStr(file_path, mode), !ValidateStr(file_path, mode),
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, kPathValidReason});
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, kPathValidReason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] has invalid char, %s", file_path.c_str(), kPathValidReason);
}
return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason); return false, "Invalid value for %s[%s], %s.", atc_param.c_str(), file_path.c_str(), kPathValidReason);


std::string real_path = RealPath(file_path.c_str()); std::string real_path = RealPath(file_path.c_str());
@@ -446,7 +454,13 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
if (!real_path.empty()) { if (!real_path.empty()) {
// File is not readable or writable // File is not readable or writable
if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) { if (mmAccess2(real_path.c_str(), M_W_OK | M_F_OK) != EN_OK) {
ErrorManager::GetInstance().ATCReportErrMessage("E19004", {"file", "errmsg"}, {real_path, strerror(errno)});
if (atc_param != "") {
std::string reason = "cat not access, errmsg:" + std::string(strerror(errno));
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, reason});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] can't acccess, errmsg:%s", file_path.c_str(), strerror(errno));
}
GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno)); GELOGW("Write file[%s] failed, errmsg[%s]", real_path.c_str(), strerror(errno));
return false; return false;
} }
@@ -465,7 +479,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const
std::string prefix_path = std::string(file_path).substr(0, static_cast<size_t>(path_split_pos)); std::string prefix_path = std::string(file_path).substr(0, static_cast<size_t>(path_split_pos));
// Determine whether the specified path is valid by creating the path // Determine whether the specified path is valid by creating the path
if (CreateDirectory(prefix_path) != 0) { if (CreateDirectory(prefix_path) != 0) {
ErrorManager::GetInstance().ATCReportErrMessage("E19006", {"path"}, {file_path});
if (atc_param != "") {
ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"},
{atc_param, file_path, "Can not create directory"});
} else {
REPORT_INNER_ERROR("E19999", "Path[%s] Can not create directory", file_path.c_str());
}
GELOGW("Can not create directory[%s].", file_path.c_str()); GELOGW("Can not create directory[%s].", file_path.c_str());
return false; return false;
} }


+ 12
- 16
ge/engine_manager/dnnengine_manager.cc View File

@@ -31,6 +31,7 @@
#include "graph/utils/graph_utils.h" #include "graph/utils/graph_utils.h"
#include "graph/utils/node_utils.h" #include "graph/utils/node_utils.h"
#include "init/gelib.h" #include "init/gelib.h"
#include "framework/common/types.h"


namespace { namespace {
const char *const kSchedulerUnits = "schedule_units"; const char *const kSchedulerUnits = "schedule_units";
@@ -44,12 +45,20 @@ const char *const kAttch = "attach";
const char *const kVectorCore = "VectorCore"; const char *const kVectorCore = "VectorCore";
const char *const kVectorEngine = "VectorEngine"; const char *const kVectorEngine = "VectorEngine";
const char *const kAIcoreEngine = "AIcoreEngine"; const char *const kAIcoreEngine = "AIcoreEngine";
const char *const kCustomOpFlag = "_custom_op_flag";
const char *const kHostCpuEngineName = "DNN_VM_HOST_CPU"; const char *const kHostCpuEngineName = "DNN_VM_HOST_CPU";
const char *const kHostCpuOpKernelLibName = "DNN_VM_HOST_CPU_OP_STORE"; const char *const kHostCpuOpKernelLibName = "DNN_VM_HOST_CPU_OP_STORE";
} // namespace } // namespace


namespace ge { namespace ge {
namespace {
const std::set<std::string> kNotCpuOp = {DATA, CONSTANT, CONSTANTOP, VARIABLE, NETOUTPUT};

bool ExecOnHostCpu(const OpDescPtr &op_desc) {
bool is_host_cpu_op = (kNotCpuOp.find(op_desc->GetType()) == kNotCpuOp.end());
return ge::GetContext().GetHostExecFlag() && is_host_cpu_op;
}
} // namespace

DNNEngineManager::DNNEngineManager() : init_flag_(false) {} DNNEngineManager::DNNEngineManager() : init_flag_(false) {}
DNNEngineManager::~DNNEngineManager() { DNNEngineManager::~DNNEngineManager() {
engines_attrs_map_.clear(); engines_attrs_map_.clear();
@@ -206,7 +215,7 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) {
GELOGI("DNNEngineManager: Can not get op info by op type %s", op_desc->GetType().c_str()); GELOGI("DNNEngineManager: Can not get op info by op type %s", op_desc->GetType().c_str());
return ""; return "";
} }
GE_IF_BOOL_EXEC(ge::GetContext().GetHostExecFlag(), return GetHostCpuEngineName(op_infos, op_desc));
GE_IF_BOOL_EXEC(ExecOnHostCpu(op_desc), return GetHostCpuEngineName(op_infos, op_desc));
std::string ge_core_type; std::string ge_core_type;
Status ret = ge::GetContext().GetOption(ge::CORE_TYPE, ge_core_type); Status ret = ge::GetContext().GetOption(ge::CORE_TYPE, ge_core_type);
GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGD("get the option CORE_TYPE fail, set it to default value VECTOR_ENGINE")); GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGD("get the option CORE_TYPE fail, set it to default value VECTOR_ENGINE"));
@@ -238,19 +247,6 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) {
return it.engine; return it.engine;
} else { } else {
checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time; checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time;
bool is_custom_op = false;
if ((ge::AttrUtils::GetBool(op_desc, kCustomOpFlag, is_custom_op)) && is_custom_op) {
ErrorManager::GetInstance().ATCReportErrMessage("E13001", {"kernelname", "optype", "opname"},
{kernel_name, op_desc->GetType(), op_desc->GetName()});
GELOGE(FAILED,
"[Check][Param]The custom operator registered by the user does not support "
"the logic function delivered by this network, kernel_name %s, op type %s, "
"op name %s",
kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str());
std::string error_info = "The custom operator registered by the user does not support the logic function"
"delivered by this network";
return "";
}
unsupported_reasons.emplace(kernel_name, unsupported_reason); unsupported_reasons.emplace(kernel_name, unsupported_reason);
GELOGI("DNNEngineManager:Check support failed, kernel_name is %s, op type is %s, op name is %s", GELOGI("DNNEngineManager:Check support failed, kernel_name is %s, op type is %s, op name is %s",
kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str()); kernel_name.c_str(), op_desc->GetType().c_str(), op_desc->GetName().c_str());
@@ -273,7 +269,7 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) {
ErrorManager::GetInstance().ATCReportErrMessage( ErrorManager::GetInstance().ATCReportErrMessage(
"E13002", {"optype", "opskernel", "reason"}, {op_desc->GetType(), it.first, it.second}); "E13002", {"optype", "opskernel", "reason"}, {op_desc->GetType(), it.first, it.second});
GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "[Check][OpSupported]Op type %s of ops kernel %s " GELOGE(GE_GRAPH_ASSIGN_ENGINE_FAILED, "[Check][OpSupported]Op type %s of ops kernel %s "
"is unsupported, reason %s",
"is unsupported, reason : %s",
op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str()); op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str());
} }




+ 1
- 6
ge/executor/CMakeLists.txt View File

@@ -65,6 +65,7 @@ set(SRC_LIST
"../single_op/task/tbe_task_builder.cc" "../single_op/task/tbe_task_builder.cc"
"../single_op/task/aicpu_task_builder.cc" "../single_op/task/aicpu_task_builder.cc"
"../single_op/task/aicpu_kernel_task_builder.cc" "../single_op/task/aicpu_kernel_task_builder.cc"
"../single_op/task/rts_kernel_task_builder.cc"
"../hybrid/common/tensor_value.cc" "../hybrid/common/tensor_value.cc"
"../hybrid/common/npu_memory_allocator.cc" "../hybrid/common/npu_memory_allocator.cc"
"../hybrid/executor/rt_callback_manager.cc" "../hybrid/executor/rt_callback_manager.cc"
@@ -91,12 +92,6 @@ set(SRC_LIST
"../hybrid/node_executor/compiledsubgraph/known_node_executor.cc" "../hybrid/node_executor/compiledsubgraph/known_node_executor.cc"
"../hybrid/node_executor/ge_local/ge_local_node_executor.cc" "../hybrid/node_executor/ge_local/ge_local_node_executor.cc"
"../hybrid/node_executor/host_cpu/host_cpu_node_executor.cc" "../hybrid/node_executor/host_cpu/host_cpu_node_executor.cc"
"../hybrid/node_executor/host_cpu/kernel_factory.cc"
"../hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc"
"../hybrid/node_executor/host_cpu/kernel/variable_kernel.cc"
"../hybrid/node_executor/host_cpu/kernel/assign_kernel.cc"
"../hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc"
"../hybrid/node_executor/host_cpu/kernel/data_kernel.cc"
"../hybrid/node_executor/controlop/control_op_executor.cc" "../hybrid/node_executor/controlop/control_op_executor.cc"
"../hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc" "../hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc"
"../hybrid/node_executor/rts/rts_node_executor.cc" "../hybrid/node_executor/rts/rts_node_executor.cc"


+ 3
- 5
ge/executor/ge_executor.cc View File

@@ -209,7 +209,7 @@ static void InitOpsProtoManager() {
string file_path = RealPath(path.c_str()); string file_path = RealPath(path.c_str());
if (file_path.empty()) { if (file_path.empty()) {
GELOGE(FAILED, "[Check][EnvPath]ASCEND_OPP_PATH path [%s] is invalid.", path.c_str()); GELOGE(FAILED, "[Check][EnvPath]ASCEND_OPP_PATH path [%s] is invalid.", path.c_str());
REPORT_INPUT_ERROR("E68016", {"ASCEND_OPP_PATH", path});
REPORT_INPUT_ERROR("E68016", {"ASCEND_OPP_PATH", path});
return; return;
} }
opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/");
@@ -804,9 +804,8 @@ Status GeExecutor::LoadDataFromFile(const std::string &path, ModelData &model_da
return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
} }
GELOGI("load modelData from file: %s.", path.c_str()); GELOGI("load modelData from file: %s.", path.c_str());
std::string key_path;
int32_t priority = 0; int32_t priority = 0;
Status ret = GraphLoader::LoadDataFromFile(path, key_path, priority, model_data);
Status ret = GraphLoader::LoadDataFromFile(path, priority, model_data);
if (ret != SUCCESS) { if (ret != SUCCESS) {
if (model_data.model_data != nullptr) { if (model_data.model_data != nullptr) {
delete[] static_cast<char *>(model_data.model_data); delete[] static_cast<char *>(model_data.model_data);
@@ -932,8 +931,7 @@ Status GeExecutor::GetMemAndWeightSize(const std::string &path, size_t &mem_size
} }


ModelData model; ModelData model;
std::string key;
Status ret = ge::GraphLoader::LoadDataFromFile(path, key, 0, model);
Status ret = ge::GraphLoader::LoadDataFromFile(path, 0, model);
if ((ret != SUCCESS) || (model.model_data == nullptr)) { if ((ret != SUCCESS) || (model.model_data == nullptr)) {
GELOGE(ret, "Load data from file failed. ret = %d", ret); GELOGE(ret, "Load data from file failed. ret = %d", ret);
return ret; return ret;


+ 4
- 0
ge/ge_local_engine/engine/host_cpu_engine.cc View File

@@ -57,6 +57,7 @@ namespace ge {
namespace { namespace {
const char *kEnvKeyOppPath = "ASCEND_OPP_PATH"; const char *kEnvKeyOppPath = "ASCEND_OPP_PATH";
const char *kHostCpuLibRelativePath = "/op_impl/built-in/host_cpu"; const char *kHostCpuLibRelativePath = "/op_impl/built-in/host_cpu";
const std::string kConstantFoldingName = "libconstant_folding_ops.so";
} }


Status GetDataNumber(const GeTensorDesc &out_desc, uint64_t &data_num) { Status GetDataNumber(const GeTensorDesc &out_desc, uint64_t &data_num) {
@@ -352,6 +353,9 @@ Status HostCpuEngine::LoadLib(const std::string &lib_path) {
} }


GELOGI("Lib: %s has been opened", lib_path.c_str()); GELOGI("Lib: %s has been opened", lib_path.c_str());
if (lib_path.find(kConstantFoldingName) != lib_path.npos) {
constant_folding_handle_ = handle;
}
lib_handles_.emplace_back(handle); lib_handles_.emplace_back(handle);
return SUCCESS; return SUCCESS;
} }


+ 3
- 0
ge/ge_local_engine/engine/host_cpu_engine.h View File

@@ -54,6 +54,8 @@ class GE_FUNC_VISIBILITY HostCpuEngine {


ge::Status Run(NodePtr &node, const vector<ConstGeTensorPtr> &inputs, std::vector<GeTensorPtr> &outputs); ge::Status Run(NodePtr &node, const vector<ConstGeTensorPtr> &inputs, std::vector<GeTensorPtr> &outputs);


void *GetConstantFoldingHandle() const { return constant_folding_handle_; }

private: private:
HostCpuEngine() = default; HostCpuEngine() = default;


@@ -85,6 +87,7 @@ class GE_FUNC_VISIBILITY HostCpuEngine {


std::mutex mu_; std::mutex mu_;
std::vector<void *> lib_handles_; std::vector<void *> lib_handles_;
void *constant_folding_handle_ = nullptr;
bool initialized_ = false; bool initialized_ = false;
}; };
} // namespace ge } // namespace ge


+ 2
- 1
ge/ge_runtime/runtime_model.cc View File

@@ -26,6 +26,7 @@
#include "framework/common/op/op_parser_util.h" #include "framework/common/op/op_parser_util.h"
#include "graph/types.h" #include "graph/types.h"
#include "task/task_factory.h" #include "task/task_factory.h"
#include "ge/common/math/math_util.h"


namespace ge { namespace ge {
namespace model_runner { namespace model_runner {
@@ -501,7 +502,7 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr<DavinciModel> &davinci_model
} }
uint64_t *buff = reinterpret_cast<uint64_t *>(const_cast<char *>(constant->weight_data.data())); uint64_t *buff = reinterpret_cast<uint64_t *>(const_cast<char *>(constant->weight_data.data()));
uint32_t head_len = kOffsetUnit * kStringHeadElems; uint32_t head_len = kOffsetUnit * kStringHeadElems;
if (ge::CheckInt64Uint32MulOverflow(elem_num, head_len) != SUCCESS) {
if (CheckInt64Uint32MulOverflow(elem_num, head_len) != SUCCESS) {
GELOGE(FAILED, "Shape size is invalid"); GELOGE(FAILED, "Shape size is invalid");
return false; return false;
} }


+ 1
- 1
ge/ge_runtime/task/aicpu_task.cc View File

@@ -83,7 +83,7 @@ bool AicpuTask::Distribute() {
return false; return false;
} }


GELOGI("ext info size:", ext_size);
GELOGI("ext info size: %u", ext_size);
aicpu_param_head.extInfoLength = ext_size; aicpu_param_head.extInfoLength = ext_size;
aicpu_param_head.extInfoAddr = reinterpret_cast<uintptr_t>(ext_info_); aicpu_param_head.extInfoAddr = reinterpret_cast<uintptr_t>(ext_info_);
} }


+ 3
- 6
ge/ge_runtime/task/hccl_task.cc View File

@@ -118,7 +118,7 @@ bool HcclTask::SetSecondaryStream() {
Status ret; Status ret;
std::lock_guard<std::mutex> lock(model_stream_mapping_mutex_); std::lock_guard<std::mutex> lock(model_stream_mapping_mutex_);
if (model_stream_mapping_.find(rt_model_handle_) == model_stream_mapping_.end()) { if (model_stream_mapping_.find(rt_model_handle_) == model_stream_mapping_.end()) {
GELOGI("Need to create map for rt_model_handle_:%p with new mainstream %ld.", rt_model_handle_, master_stream_id);
GELOGI("Need to create map for rt_model_handle_:%p with new mainstream %u.", rt_model_handle_, master_stream_id);
ret = CreateStream(hccl_secondary_stream_num, master_stream_id); ret = CreateStream(hccl_secondary_stream_num, master_stream_id);
if (!ret) { if (!ret) {
GELOGE(RT_FAILED, "Create hccl stream failed."); GELOGE(RT_FAILED, "Create hccl stream failed.");
@@ -142,10 +142,7 @@ bool HcclTask::SetSecondaryStream() {
return false; return false;
} }
stream = std::make_shared<HcclTask::StreamGuard>(rt_model_handle_, new_stream); stream = std::make_shared<HcclTask::StreamGuard>(rt_model_handle_, new_stream);
if (stream == nullptr) {
GELOGE(FAILED, "MakeShared failed.");
return false;
}
GE_RT_FALSE_CHECK_NOTNULL(stream);
secondary_stream_vec[index] = stream; secondary_stream_vec[index] = stream;
} }
secondary_stream_list_.push_back(stream); secondary_stream_list_.push_back(stream);
@@ -177,7 +174,7 @@ bool HcclTask::SetSecondaryStream() {
} }
GELOGI("Initialize hccl secondary stream success, hccl_secondary_stream_num =%ld", hccl_secondary_stream_num); GELOGI("Initialize hccl secondary stream success, hccl_secondary_stream_num =%ld", hccl_secondary_stream_num);
} else { } else {
GELOGI("Need to create secondary stream for %s with new mainstream %ld.", task_info_->op_name().c_str(),
GELOGI("Need to create secondary stream for %s with new mainstream %u.", task_info_->op_name().c_str(),
master_stream_id); master_stream_id);
ret = CreateStream(hccl_secondary_stream_num, master_stream_id); ret = CreateStream(hccl_secondary_stream_num, master_stream_id);
if (!ret) { if (!ret) {


+ 42
- 0
ge/ge_runtime/task/label_goto_task.cc View File

@@ -60,6 +60,48 @@ LabelGotoTask::~LabelGotoTask() {


bool LabelGotoTask::Distribute() { bool LabelGotoTask::Distribute() {
GELOGI("LabelGotoTask Distribute start."); GELOGI("LabelGotoTask Distribute start.");
if (!CheckParamValid()) {
return false;
}

const std::vector<void *> label_list = { label_ };
rtError_t rt_ret = rtMalloc(&index_value_, sizeof(uint64_t), RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: %#x", rt_ret);
return false;
}

uint64_t branch_index = 0;
rt_ret = rtMemcpy(index_value_, sizeof(uint64_t), &branch_index, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: %#x", rt_ret);
return false;
}

uint32_t label_info_size = sizeof(rtLabelDevInfo) * label_list.size();
rt_ret = rtMalloc(&label_info_, label_info_size, RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: %#x", rt_ret);
return false;
}

rt_ret = rtLabelListCpy((void**)label_list.data(), label_list.size(), label_info_, label_info_size);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: %#x", rt_ret);
return false;
}

rt_ret = rtLabelSwitchByIndex(index_value_, label_list.size(), label_info_, stream_);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: %#x", rt_ret);
return false;
}

GELOGI("DistributeTask end.");
return true;
}

bool LabelGotoTask::CheckParamValid() {
if (stream_ == nullptr) { if (stream_ == nullptr) {
GELOGE(PARAM_INVALID, "stream is null!"); GELOGE(PARAM_INVALID, "stream is null!");
return false; return false;


+ 28
- 2
ge/ge_runtime/task/label_switch_task.cc View File

@@ -56,8 +56,34 @@ bool LabelSwitchTask::Distribute() {
return false; return false;
} }


void *label_info = label_info_->GetLabelInfo();
rtError_t rt_ret = rtLabelSwitchByIndex(task_info_->cond(), task_info_->label_size(), label_info, stream_);
const std::vector<uint32_t> &label_index_list = task_info_->label_list();
std::vector<void *> label_list(task_info_->label_size(), nullptr);

for (size_t i = 0; i < task_info_->label_size(); ++i) {
uint32_t label_index = label_index_list[i];
if (label_index >= all_label_resource_.size()) {
GELOGE(PARAM_INVALID, "label %zu index is %u, but there are %zu labels in total.", i, label_index,
all_label_resource_.size());
return false;
}
label_list[i] = all_label_resource_[label_index];
GELOGI("Case %zu: label id %zu.", i, (size_t)label_index);
}

uint32_t label_info_size = sizeof(rtLabelDevInfo) * task_info_->label_size();
rtError_t rt_ret = rtMalloc(&label_info_, label_info_size, RT_MEMORY_HBM);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
return false;
}

rt_ret = rtLabelListCpy(label_list.data(), label_list.size(), label_info_, label_info_size);
if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
return false;
}

rt_ret = rtLabelSwitchByIndex(task_info_->cond(), label_list.size(), label_info_, stream_);
if (rt_ret != RT_ERROR_NONE) { if (rt_ret != RT_ERROR_NONE) {
GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret);
return false; return false;


+ 5
- 7
ge/generator/ge_generator.cc View File

@@ -452,7 +452,9 @@ Status GeGenerator::Initialize(const map<string, string> &options, OmgContext &o


Status GeGenerator::Finalize() { Status GeGenerator::Finalize() {
ErrorManager::GetInstance().SetStage(error_message::kFinalize, error_message::kFinalize); ErrorManager::GetInstance().SetStage(error_message::kFinalize, error_message::kFinalize);
GE_CHECK_NOTNULL_EXEC(impl_, return PARAM_INVALID);
if (impl_ == nullptr) {
return SUCCESS;
}
Status ret = impl_->graph_manager_.Finalize(); Status ret = impl_->graph_manager_.Finalize();
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(GE_GENERATOR_GRAPH_MANAGER_FINALIZE_FAILED, "[Call][Finalize] Graph manager finalize failed."); GELOGE(GE_GENERATOR_GRAPH_MANAGER_FINALIZE_FAILED, "[Call][Finalize] Graph manager finalize failed.");
@@ -852,7 +854,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
op_desc->GetName().c_str()); op_desc->GetName().c_str());
return PARAM_INVALID; return PARAM_INVALID;
} }
OmgContext &omg_context = (impl_ == nullptr) ? domi::GetContext() : impl_->omg_context_;
OmgContext &omg_context = impl_->omg_context_;
omg_context.is_dynamic_input = ContainsDynamicInpus(*op_desc); omg_context.is_dynamic_input = ContainsDynamicInpus(*op_desc);


if (op_desc->HasAttr(ATTR_NAME_UNREGST_OPPATH)) { if (op_desc->HasAttr(ATTR_NAME_UNREGST_OPPATH)) {
@@ -867,11 +869,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector<GeTensor> &in
if (!HasShapeRange(inputs) && compile_flag == kFuzzBuildPattern) { if (!HasShapeRange(inputs) && compile_flag == kFuzzBuildPattern) {
fuzz_compile_flag = true; fuzz_compile_flag = true;
} }
if (!AttrUtils::SetBool(op_desc, ATTR_NAME_FUZZ_BUILD, fuzz_compile_flag)) {
REPORT_CALL_ERROR("E19999", "set ATTR_NAME_FUZZ_BUILD failed for %s.", op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][ATTR_NAME_FUZZ_BUILD] Failed to set attr for %s.", op_desc->GetName().c_str());
return FAILED;
}
(void)AttrUtils::SetBool(op_desc, ATTR_NAME_FUZZ_BUILD, fuzz_compile_flag);
impl_->omg_context_.fuzz_compile_flag = fuzz_compile_flag; impl_->omg_context_.fuzz_compile_flag = fuzz_compile_flag;


// 1. Create ComputeGraph. // 1. Create ComputeGraph.


+ 71
- 59
ge/graph/build/memory/graph_mem_assigner.cc View File

@@ -268,12 +268,13 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map<uint64_t, siz
total_mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize(), total_mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize(),
compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); compute_graph_->GetGraphID(), compute_graph_->GetName().c_str());
for (auto iter : mem_type_to_offset) { for (auto iter : mem_type_to_offset) {
ErrorManager::GetInstance().ATCReportErrMessage("E19022", {"memType", "size", "item", "maxsize"},
{std::to_string(iter.first), std::to_string(iter.second), "featuremap",
std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())});
GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu], memtype[%ld]", compute_graph_->GetName().c_str(), GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu], memtype[%ld]", compute_graph_->GetName().c_str(),
iter.second, iter.first); iter.second, iter.first);
} }
REPORT_INPUT_ERROR(
"E19022", std::vector<std::string>({"size", "item", "maxsize"}),
std::vector<std::string>({std::to_string(total_mem_offset), "featuremap",
std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())}));
return ge::FAILED; return ge::FAILED;
} }
return SUCCESS; return SUCCESS;
@@ -543,7 +544,6 @@ Status GraphMemoryAssigner::UpdateRefOpOffsetReverse(const NodePtr &node) {
} }


Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) {
Status ret;
// Stored nodes which need assign continuous input memory in `reverse topo order` // Stored nodes which need assign continuous input memory in `reverse topo order`
std::vector<NodePtr> nodes_stack; std::vector<NodePtr> nodes_stack;
std::map<NodePtr, uint32_t> node_2_continuous_type; std::map<NodePtr, uint32_t> node_2_continuous_type;
@@ -579,11 +579,8 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) {
if (continuous_output) { if (continuous_output) {
GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "output"), GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "output"),
"[Get][MemType]fail for node:%s", node->GetName().c_str()); "[Get][MemType]fail for node:%s", node->GetName().c_str());
ret = AssignContinuousOutputMemory(node, memory_type, continuous_type);
if (ret != ge::SUCCESS) {
GELOGE(ret, "[Assign][Memory:Continuous:Ouput]fail for node:%s", node->GetName().c_str());
return ret;
}
GE_CHK_STATUS_RET(AssignContinuousOutputMemory(node, memory_type, continuous_type),
"[Assign][Memory:Continuous:Output]fail for node:%s", node->GetName().c_str());
} }
} }
// Assign continuous input memory in `reverse topo order` which stored before // Assign continuous input memory in `reverse topo order` which stored before
@@ -612,6 +609,61 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) {
return ge::SUCCESS; return ge::SUCCESS;
} }


Status GraphMemoryAssigner::SetMemOffset(const ge::NodePtr &node, const InDataAnchorPtr &in_data_anchor,
bool reverse_refresh, int64_t &mem_offset, int64_t &continuous_mem_start) {
auto op_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc);
vector<int64_t> output_list_this = op_desc->GetOutputOffset();
if (output_list_this.empty()) {
REPORT_INNER_ERROR("E19999", "No output offset in node :%s, not expected",
node->GetName().c_str());
GELOGE(FAILED, "[Get][OutputOffset] empty is invalid, node:%s", node->GetName().c_str());
return FAILED;
}

auto peer_out_data_anchor = in_data_anchor->GetPeerOutAnchor();
auto peer_op_desc = peer_out_data_anchor->GetOwnerNode()->GetOpDesc();
vector<int64_t> output_list = peer_op_desc->GetOutputOffset();
if (peer_out_data_anchor->GetIdx() >= static_cast<int>(output_list.size())) {
std::string error = "peer node:" + FmtToStr(peer_op_desc->GetName()) +
" anchor_index:" + FmtToStr(peer_out_data_anchor->GetIdx()) +
" is out of range:" + FmtToStr(output_list.size());
GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str());
return FAILED;
}

// when continuous input has been allocated first input is beginning offset
bool is_continuous_input_allocated = false;
(void) ge::AttrUtils::GetBool(op_desc, ATTR_NAME_CONTINUOUS_INPUT_ALLOC, is_continuous_input_allocated);
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());
// 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());
output_list.at(peer_out_data_anchor->GetIdx()) = output_list_this.at(out2ins.begin()->first);
peer_op_desc->SetOutputOffset(output_list);
GELOGI("[Update][Offset]Node %s out %d ref in %d input node %s, use output offset %ld update %ld",
node->GetName().c_str(), out2ins.begin()->first, out2ins.begin()->second,
peer_op_desc->GetName().c_str(), output_list_this.at(out2ins.begin()->first), peer_output_offset);
} else {
GELOGD("Node %s out %d ref in %d input node %s with total ref numbers %zu.", node->GetName().c_str(),
out2ins.begin()->first, out2ins.begin()->second, peer_op_desc->GetName().c_str(), out2ins.size());
}
// first input is beginning offset
mem_offset = output_list.at(peer_out_data_anchor->GetIdx());
continuous_mem_start = output_list.at(peer_out_data_anchor->GetIdx());
} else {
// set offset for input
output_list.at(peer_out_data_anchor->GetIdx()) = mem_offset;
peer_op_desc->SetOutputOffset(output_list);
}

return SUCCESS;
}

Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start,
int64_t &continuous_mem_size, int64_t memory_type, uint32_t continuous_type, bool reverse_refresh) { int64_t &continuous_mem_size, int64_t memory_type, uint32_t continuous_type, bool reverse_refresh) {
GELOGI("[Assign][Memory:Input:Continuous]start for Current node %s", node->GetName().c_str()); GELOGI("[Assign][Memory:Input:Continuous]start for Current node %s", node->GetName().c_str());
@@ -631,13 +683,6 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node,
bool is_continuous_input_allocated = false; bool is_continuous_input_allocated = false;
auto op_desc = node->GetOpDesc(); auto op_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(op_desc);
vector<int64_t> output_list_this = op_desc->GetOutputOffset();
if (output_list_this.empty()) {
REPORT_INNER_ERROR("E19999", "No output offset in node :%s, not expected",
node->GetName().c_str());
GELOGE(FAILED, "[Get][OutputOffset] empty is invalid, node:%s", node->GetName().c_str());
return FAILED;
}
(void) ge::AttrUtils::GetBool(op_desc, ATTR_NAME_CONTINUOUS_INPUT_ALLOC, is_continuous_input_allocated); (void) ge::AttrUtils::GetBool(op_desc, ATTR_NAME_CONTINUOUS_INPUT_ALLOC, is_continuous_input_allocated);
for (auto &in_data_anchor : node->GetAllInDataAnchors()) { for (auto &in_data_anchor : node->GetAllInDataAnchors()) {
GE_IF_BOOL_EXEC(in_data_anchor == nullptr, continue); GE_IF_BOOL_EXEC(in_data_anchor == nullptr, continue);
@@ -669,45 +714,12 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node,
return FAILED; return FAILED;
} }
} }

bool is_nopadding = ((continuous_type & kTypeInputNoPadding) != 0) || lx_fusion;
vector<int64_t> output_list = peer_op_desc->GetOutputOffset();
if (peer_out_data_anchor->GetIdx() >= static_cast<int>(output_list.size())) {
std::string error = "peer node:" + FmtToStr(peer_op_desc->GetName()) +
" anchor_index:" + FmtToStr(peer_out_data_anchor->GetIdx()) +
" is out of range:" + FmtToStr(output_list.size());
GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str());
if (SetMemOffset(node, in_data_anchor, reverse_refresh, mem_offset, continuous_mem_start) != ge::SUCCESS) {
return FAILED; return FAILED;
} }


// when continuous input has been allocated first input is beginning offset
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());
// 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());
output_list.at(peer_out_data_anchor->GetIdx()) = output_list_this.at(out2ins.begin()->first);
peer_op_desc->SetOutputOffset(output_list);
GELOGI("[Update][Offset]Node %s out %d ref in %d input node %s, use output offset %ld update %ld",
node->GetName().c_str(), out2ins.begin()->first, out2ins.begin()->second,
peer_op_desc->GetName().c_str(), output_list_this.at(out2ins.begin()->first), peer_output_offset);
} else {
GELOGD("Node %s out %d ref in %d input node %s with total ref numbers %zu.", node->GetName().c_str(),
out2ins.begin()->first, out2ins.begin()->second, peer_op_desc->GetName().c_str(), out2ins.size());
}
// first input is beginning offset
mem_offset = output_list.at(peer_out_data_anchor->GetIdx());
continuous_mem_start = output_list.at(peer_out_data_anchor->GetIdx());
} else {
// set offset for input
output_list.at(peer_out_data_anchor->GetIdx()) = mem_offset;
peer_op_desc->SetOutputOffset(output_list);
}

int64_t align_size = tensor_desc_size; int64_t align_size = tensor_desc_size;
bool is_nopadding = ((continuous_type & kTypeInputNoPadding) != 0) || lx_fusion;
if (is_nopadding) { if (is_nopadding) {
mem_offset += nopadding_size; mem_offset += nopadding_size;
extra_memory_size += (tensor_desc_size - nopadding_size); extra_memory_size += (tensor_desc_size - nopadding_size);
@@ -719,7 +731,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node,
extra_memory_size = MEM_ALIGN_SIZE; extra_memory_size = MEM_ALIGN_SIZE;
real_size = tensor_desc_size; real_size = tensor_desc_size;
} }
vector<int64_t> output_list = peer_op_desc->GetOutputOffset();
GELOGI("[IMAS]Continuous input : Set %s name[%s] optype[%s] output[%d] offset to [%zu] stream_id[%ld] memtype[%ld] " GELOGI("[IMAS]Continuous input : Set %s name[%s] optype[%s] output[%d] offset to [%zu] stream_id[%ld] memtype[%ld] "
"size[%zu] realsize[%ld] nopadding size[%d]", node->GetOwnerComputeGraph()->GetName().c_str(), "size[%zu] realsize[%ld] nopadding size[%d]", node->GetOwnerComputeGraph()->GetName().c_str(),
peer_op_desc->GetName().c_str(), node->GetType().c_str(), peer_out_data_anchor->GetIdx(), peer_op_desc->GetName().c_str(), node->GetType().c_str(), peer_out_data_anchor->GetIdx(),
@@ -1601,8 +1613,8 @@ ge::Status GraphMemoryAssigner::UpdateRefOpOutputOffset(const NodePtr &node, con
if (has_inner_offset) { if (has_inner_offset) {
(void)ge::AttrUtils::SetInt(opdesc->MutableOutputDesc(out_i), ATTR_NAME_INNER_OFFSET, 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);
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; return ge::SUCCESS;
@@ -1827,17 +1839,17 @@ bool GraphMemoryAssigner::CheckContinuousMemType(vector<int64_t> mem_type_list)
int64_t mem_type_tmp = mem_type_list[0]; int64_t mem_type_tmp = mem_type_list[0];
for (auto mem_type : mem_type_list) { for (auto mem_type : mem_type_list) {
if (mem_type != mem_type_tmp) { if (mem_type != mem_type_tmp) {
std::string error = "The memory is continuous, but the type of the input memory is inconsistent. They are " +
FmtToStr(mem_type_tmp) + " and " + FmtToStr(mem_type);
ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error});
REPORT_INNER_ERROR(
"E19999",
"The memory is continuous, but the type of the input memory is inconsistent. They are %s and %s",
FmtToStr(mem_type_tmp).c_str(), FmtToStr(mem_type).c_str());
GELOGW("The memory is continuous, but the type of the input memory is inconsistent. They are [%ld] and [%ld].", GELOGW("The memory is continuous, but the type of the input memory is inconsistent. They are [%ld] and [%ld].",
mem_type_tmp, mem_type); mem_type_tmp, mem_type);
return false; return false;
} }
} }
if (memory_offset_.find(mem_type_tmp) == memory_offset_.end()) { if (memory_offset_.find(mem_type_tmp) == memory_offset_.end()) {
std::string error = "Memory offset map does not have memory type" + FmtToStr(mem_type_tmp);
ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {error});
REPORT_INNER_ERROR("E19999", "Memory offset map does not have memory type %s", FmtToStr(mem_type_tmp).c_str());
GELOGW("Memory offset map does not have memory type[%ld].", mem_type_tmp); GELOGW("Memory offset map does not have memory type[%ld].", mem_type_tmp);
return false; return false;
} }


+ 3
- 0
ge/graph/build/memory/graph_mem_assigner.h View File

@@ -146,6 +146,9 @@ class GraphMemoryAssigner {
ge::Status FilterAtomicNodesForMemoryAssign(map<string, map<NodePtr, vector<NodePtr>>> &normal_atomic_nodes_map, ge::Status FilterAtomicNodesForMemoryAssign(map<string, map<NodePtr, vector<NodePtr>>> &normal_atomic_nodes_map,
map<string, vector<NodePtr>> &connecting_output_atomic_nodes); map<string, vector<NodePtr>> &connecting_output_atomic_nodes);


Status SetMemOffset(const ge::NodePtr &node, const InDataAnchorPtr &in_data_anchor, bool reverse_refresh,
int64_t &mem_offset, int64_t &continuous_mem_start);

ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start, ge::Status AssignContinuousInputMemory(const ge::NodePtr &node, int64_t &continuous_mem_start,
int64_t &continuous_mem_size, int64_t memory_type, uint32_t continuous_type, int64_t &continuous_mem_size, int64_t memory_type, uint32_t continuous_type,
bool reverse_refresh = false); bool reverse_refresh = false);


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

@@ -1212,7 +1212,8 @@ Status StreamAllocator::SetActiveStreamsForLoop() {
for (const auto &node : whole_graph_->GetNodes(whole_graph_->GetGraphUnknownFlag())) { for (const auto &node : whole_graph_->GetNodes(whole_graph_->GetGraphUnknownFlag())) {
GE_CHECK_NOTNULL(node->GetOpDesc()); GE_CHECK_NOTNULL(node->GetOpDesc());
bool is_loop_active = false; bool is_loop_active = false;
if (AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, is_loop_active) && is_loop_active) {
(void)AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, is_loop_active);
if (is_loop_active) {
vector<string> activated_label_list; vector<string> activated_label_list;


NodePtr pre_switch_node = FindSwitchNodeBeforeLoopActiveNode(node); NodePtr pre_switch_node = FindSwitchNodeBeforeLoopActiveNode(node);


+ 7
- 1
ge/graph/build/task_generator.cc View File

@@ -771,6 +771,7 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
GELOGI("Start AutoFindBpOpIndex"); GELOGI("Start AutoFindBpOpIndex");
NodePtr bp_node = nullptr; NodePtr bp_node = nullptr;
uint32_t current_idx = 0; uint32_t current_idx = 0;
uint32_t netoutput_idx = 0;
for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) { for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) {
OpDescPtr op_desc = node->GetOpDesc(); OpDescPtr op_desc = node->GetOpDesc();
GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(op_desc);
@@ -788,6 +789,7 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) { if (op_desc->GetName() == NODE_NAME_NET_OUTPUT) {
if (bp_node == nullptr) { if (bp_node == nullptr) {
bp_node = node; bp_node = node;
netoutput_idx = current_idx - 1;
} }
} }
if (graph->GetNeedIteration()) { if (graph->GetNeedIteration()) {
@@ -812,9 +814,13 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP
if (bp_node == nullptr) { if (bp_node == nullptr) {
GELOGW("not find bp_node."); GELOGW("not find bp_node.");
return SUCCESS; return SUCCESS;
} else if (bp_node->GetName() == NODE_NAME_NET_OUTPUT) {
profiling_point.bp_index = netoutput_idx;
GELOGI("First bp name %s, idx %u", bp_node->GetName().c_str(), netoutput_idx);
} else {
profiling_point.bp_index = FindLastBpFromBpNode(graph, bp_node);
} }


profiling_point.bp_index = FindLastBpFromBpNode(graph, bp_node);
return SUCCESS; return SUCCESS;
} }




+ 12
- 2
ge/graph/common/omg_util.cc View File

@@ -286,13 +286,23 @@ void MarkForceUnknownShape(const NodePtr &node, bool force_unknown, int64_t grou
return; return;
} }


SetControlFlowGroup(node, group_index);
}

///
/// @brief Set Op _control_flow_group flag
/// @param [in] node
/// @param [in] group, condition group index of node.
/// @return
///
void SetControlFlowGroup(const NodePtr &node, int64_t group) {
GE_RT_VOID_CHECK_NOTNULL(node); GE_RT_VOID_CHECK_NOTNULL(node);
const auto &op_desc = node->GetOpDesc(); const auto &op_desc = node->GetOpDesc();
GE_RT_VOID_CHECK_NOTNULL(op_desc); GE_RT_VOID_CHECK_NOTNULL(op_desc);


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


+ 8
- 0
ge/graph/common/omg_util.h View File

@@ -133,6 +133,14 @@ bool IsUnknownShapeTensor(const GeTensorDesc &tensor_desc);
/// @return /// @return
/// ///
void MarkForceUnknownShape(const NodePtr &node, bool force_unknown, int64_t group_index); void MarkForceUnknownShape(const NodePtr &node, bool force_unknown, int64_t group_index);

///
/// @brief Set Op _control_flow_group flag
/// @param [in] node
/// @param [in] group, condition group index of node.
/// @return
///
void SetControlFlowGroup(const NodePtr &node, int64_t group);
} // namespace ge } // namespace ge


#endif // GE_GRAPH_COMMON_OMG_UTIL_H_ #endif // GE_GRAPH_COMMON_OMG_UTIL_H_

+ 4
- 10
ge/graph/load/graph_loader.cc View File

@@ -123,23 +123,17 @@ Status GraphLoader::GetMaxUsedMemory(uint32_t model_id, uint64_t &max_size) {
return SUCCESS; return SUCCESS;
} }


Status GraphLoader::LoadDataFromFile(const std::string &path, const std::string &key_path, int32_t priority,
ModelData &model_data) {
if (!CheckInputPathValid(path)) {
Status GraphLoader::LoadDataFromFile(const std::string &path, int32_t priority, ModelData &model_data) {
if (!CheckInputPathValid(path, "model_file")) {
GELOGE(ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID, "[Check][Param] 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; return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID;
} }


GELOGI("Load model begin, model path is: %s", path.c_str()); 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, "[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);
Status ret = ModelParserBase::LoadFromFile(path.c_str(), priority, model_data);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "[Call][LoadFromFile] failed. ret = %u, path:%s, key path:%s", ret, path.c_str(), key_path.c_str());
GELOGE(ret, "[Call][LoadFromFile] failed. ret = %u, path:%s", ret, path.c_str());
if (model_data.model_data != nullptr) { if (model_data.model_data != nullptr) {
delete[] static_cast<char *>(model_data.model_data); delete[] static_cast<char *>(model_data.model_data);
model_data.model_data = nullptr; model_data.model_data = nullptr;


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

@@ -48,8 +48,7 @@ class GraphLoader {


static Status GetMemoryInfo(int64_t &free); static Status GetMemoryInfo(int64_t &free);


static Status LoadDataFromFile(const std::string &path, const std::string &key_path, int32_t priority,
ModelData &model_data);
static Status LoadDataFromFile(const std::string &path, int32_t priority, ModelData &model_data);


static Status LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, size_t mem_size, static Status LoadModelFromData(uint32_t &model_id, const ModelData &model_data, void *dev_ptr, size_t mem_size,
void *weight_ptr, size_t weight_size); void *weight_ptr, size_t weight_size);


+ 29
- 26
ge/graph/load/model_manager/davinci_model.cc View File

@@ -984,11 +984,12 @@ Status DavinciModel::InitDataOp(const ComputeGraphPtr &graph, const NodePtr &nod
return SUCCESS; return SUCCESS;
} }


GELOGI("Init data node: %s.", op_desc->GetName().c_str());
auto data_index = data_op_index++; auto data_index = data_op_index++;
if (AttrUtils::GetInt(op_desc, ATTR_NAME_INDEX, data_index)) {
const auto &index_attr = GraphUtils::FindRootGraph(graph) == graph ? ATTR_NAME_INDEX : ATTR_NAME_PARENT_NODE_INDEX;
if (AttrUtils::GetInt(op_desc, index_attr, data_index)) {
GELOGD("Get new index %u, old %u", data_index, data_op_index - 1); GELOGD("Get new index %u, old %u", data_index, data_op_index - 1);
} }
GELOGI("Init data node: %s, index: %u.", op_desc->GetName().c_str(), data_index);


data_by_index[data_index] = op_desc; data_by_index[data_index] = op_desc;
if (known_node_) { if (known_node_) {
@@ -3435,37 +3436,39 @@ void DavinciModel::SetZeroCopyAddr(const OpDescPtr &op_desc, const std::vector<v
/// @param [in] is_dynamic: dynamic batch input flag. /// @param [in] is_dynamic: dynamic batch input flag.
/// @return true if success /// @return true if success
/// ///
bool DavinciModel::CheckInputAndModelSize(const int64_t &input_size, const int64_t &op_size, bool is_dynamic) {
bool DavinciModel::CheckUserAndModelSize(const int64_t &size, const int64_t &op_size,
bool is_input, bool is_dynamic) {
const std::string input_or_output = is_input ? "input" : "output";
if (is_dynamic) { // dynamic is max size. if (is_dynamic) { // dynamic is max size.
GELOGI("No need to check input and model size.");
GELOGI("No need to check user %s and model size.", input_or_output.c_str());
return true; return true;
} }


if (input_size > op_size) {
if (size > op_size) {
GELOGW( GELOGW(
"Input size [%ld] is bigger than om size need [%ld], "
"User %s size [%ld] is bigger than om size need [%ld], "
"MAY cause inference result ERROR, please check model input", "MAY cause inference result ERROR, please check model input",
input_size, op_size);
input_or_output.c_str(), size, op_size);
} }


if (is_dynamic_aipp_) { if (is_dynamic_aipp_) {
GELOGI("This is dynamic aipp model, no need to judge smaller input size");
GELOGI("This is dynamic aipp model, no need to judge smaller user size");
return true; return true;
} }
// Judge overflow first // Judge overflow first
if (input_size > (INT64_MAX - kDataMemAlignSizeCompare)) {
GELOGI("The Input size [%ld] is smaller than model size [%ld] and is in the range of 64 bytes", input_size,
op_size);
if (size > (INT64_MAX - kDataMemAlignSizeCompare)) {
GELOGI("The user %s size [%ld] is smaller than model size [%ld] and is in the range of 64 bytes",
input_or_output.c_str(), size, op_size);
return true; return true;
} }
// The input and model input size can not be exactly equal because user input is not definite. // The input and model input size can not be exactly equal because user input is not definite.
if ((input_size + kDataMemAlignSizeCompare) < op_size) {
REPORT_INNER_ERROR("E19999", "input size:%ld from user add align:%u > input_op_size:%ld in model, model_id:%u, "
if ((size + kDataMemAlignSizeCompare) < op_size) {
REPORT_INNER_ERROR("E19999", "%s size:%ld from user add align:%u < input_op_size:%ld in model, model_id:%u, "
"check invalid", "check invalid",
input_size, kDataMemAlignSizeCompare, op_size, model_id_);
input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_);
GELOGE(ACL_ERROR_GE_PARAM_INVALID, GELOGE(ACL_ERROR_GE_PARAM_INVALID,
"[Check][Param] input size:%ld from user add align:%u > input_op_size:%ld in model, model_id:%u",
input_size, kDataMemAlignSizeCompare, op_size, model_id_);
"[Check][Param] %s size:%ld from user add align:%u < input_op_size:%ld in model, model_id:%u",
input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_);
return false; return false;
} }
return true; return true;
@@ -3543,7 +3546,7 @@ Status DavinciModel::UpdateIoTaskArgs(const std::map<uint32_t, ZeroCopyOffset> &
return ACL_ERROR_GE_PARAM_INVALID; return ACL_ERROR_GE_PARAM_INVALID;
} }


if (!CheckInputAndModelSize(buffer.length, data.second.GetDataSize(), is_dynamic)) {
if (!CheckUserAndModelSize(buffer.length, data.second.GetDataSize(), is_input, is_dynamic)) {
GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Call][CheckInputAndModelSize] failed, op[%s]", GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[Call][CheckInputAndModelSize] failed, op[%s]",
data.second.GetOpName().c_str()); data.second.GetOpName().c_str());
return ACL_ERROR_GE_PARAM_INVALID; return ACL_ERROR_GE_PARAM_INVALID;
@@ -3727,6 +3730,8 @@ Status DavinciModel::InitTbeHandle(const OpDescPtr &op_desc) {
binary.magic = RT_DEV_BINARY_MAGIC_ELF; binary.magic = RT_DEV_BINARY_MAGIC_ELF;
} else if (json_string == "RT_DEV_BINARY_MAGIC_ELF_AIVEC") { } else if (json_string == "RT_DEV_BINARY_MAGIC_ELF_AIVEC") {
binary.magic = RT_DEV_BINARY_MAGIC_ELF_AIVEC; binary.magic = RT_DEV_BINARY_MAGIC_ELF_AIVEC;
} else if (json_string == "RT_DEV_BINARY_MAGIC_ELF_AICUBE") {
binary.magic = RT_DEV_BINARY_MAGIC_ELF_AICUBE;
} else { } else {
REPORT_INNER_ERROR("E19999", "Attr:%s value:%s in op:%s(%s), model_id:%u, check invalid", REPORT_INNER_ERROR("E19999", "Attr:%s value:%s in op:%s(%s), model_id:%u, check invalid",
TVM_ATTR_NAME_MAGIC.c_str(), json_string.c_str(), TVM_ATTR_NAME_MAGIC.c_str(), json_string.c_str(),
@@ -4007,13 +4012,11 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa
iterator_count_++; iterator_count_++;
} }


if (!is_async_mode_) {
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_AFTER_PROC_START));
ret = CopyOutputData(input_data.index, output_data, RT_MEMCPY_DEVICE_TO_DEVICE);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return ACL_ERROR_GE_INTERNAL_ERROR,
"[Copy][OutputData] to user failed, ret:%d, model_id:%u.", ret, model_id_);
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_AFTER_PROC_END));
}
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_AFTER_PROC_START));
ret = CopyOutputData(input_data.index, output_data, RT_MEMCPY_DEVICE_TO_DEVICE);
GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(ret != SUCCESS, return ACL_ERROR_GE_INTERNAL_ERROR,
"[Copy][OutputData] to user failed, ret:%d, model_id:%u.", ret, model_id_);
GE_IF_BOOL_EXEC(profiling_model_execute_on, SetProfileTime(MODEL_AFTER_PROC_END));


// report model time data // report model time data
GE_IF_BOOL_EXEC(profiling_model_execute_on, (void)SinkTimeProfile(input_data)); GE_IF_BOOL_EXEC(profiling_model_execute_on, (void)SinkTimeProfile(input_data));
@@ -4095,7 +4098,7 @@ uint8_t *DavinciModel::MallocFeatureMapMem(size_t data_size) {
Status DavinciModel::MallocExMem() { Status DavinciModel::MallocExMem() {
char ge_static_mem_env[MMPA_MAX_PATH] = {0x00}; char ge_static_mem_env[MMPA_MAX_PATH] = {0x00};
INT32 res_static_memory = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH); INT32 res_static_memory = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH);
for (auto it : runtime_param_.memory_infos) {
for (auto &it : runtime_param_.memory_infos) {
auto mem_size = it.second.memory_size; auto mem_size = it.second.memory_size;
if (mem_size == 0) { if (mem_size == 0) {
continue; continue;
@@ -4166,7 +4169,7 @@ void DavinciModel::FreeFeatureMapMem() {
void DavinciModel::FreeExMem() { void DavinciModel::FreeExMem() {
char ge_static_mem_env[MMPA_MAX_PATH] = {0x00}; char ge_static_mem_env[MMPA_MAX_PATH] = {0x00};
INT32 res_static_memory = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH); INT32 res_static_memory = mmGetEnv(kEnvGeuseStaticMemory, ge_static_mem_env, MMPA_MAX_PATH);
for (auto it : runtime_param_.memory_infos) {
for (auto &it : runtime_param_.memory_infos) {
// free when session destory // free when session destory
if ((kSessionScopeMemory & it.first) == kSessionScopeMemory) { if ((kSessionScopeMemory & it.first) == kSessionScopeMemory) {
continue; continue;


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

@@ -611,7 +611,7 @@ class DavinciModel {
/// @param [in] is_dynamic: dynamic batch input flag. /// @param [in] is_dynamic: dynamic batch input flag.
/// @return true if success /// @return true if success
/// ///
bool CheckInputAndModelSize(const int64_t &input_size, const int64_t &op_size, bool is_dynamic);
bool CheckUserAndModelSize(const int64_t &size, const int64_t &op_size, bool is_input, bool is_dynamic);


/// ///
/// @ingroup ge /// @ingroup ge


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

@@ -1668,42 +1668,23 @@ Status ModelManager::LaunchKernelCheckAicpuOp(std::vector<std::string> &aicpu_op
}; };
GE_MAKE_GUARD(release, callback); GE_MAKE_GUARD(release, callback);
// malloc sysOpInfoList in SysOpCheckInfo // malloc sysOpInfoList in SysOpCheckInfo
status = rtMalloc(&d_req_op_list, op_nums * sizeof(SysOpInfo), RT_MEMORY_HBM);
if (status != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, size:%zu, ret = 0x%X", op_nums * sizeof(SysOpInfo), status);
GELOGE(RT_FAILED, "[Call][RtMalloc] fail, size:%zu, ret = 0x%X", op_nums * sizeof(SysOpInfo), status);
return RT_ERROR_TO_GE_STATUS(status);
}
GE_CHK_RT_RET(rtMalloc(&d_req_op_list, op_nums * sizeof(SysOpInfo), RT_MEMORY_HBM));
allocated_mem.push_back(d_req_op_list); allocated_mem.push_back(d_req_op_list);


// malloc sysOpInfoList in SysOpCheckResp // malloc sysOpInfoList in SysOpCheckResp
status = rtMalloc(&d_res_op_list, op_nums * sizeof(SysOpInfo), RT_MEMORY_HBM);
if (status != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, size:%zu, ret = 0x%X", op_nums * sizeof(SysOpInfo), status);
GELOGE(RT_FAILED, "[Call][RtMalloc] fail, size:%zu, ret = 0x%X", op_nums * sizeof(SysOpInfo), status);
return RT_ERROR_TO_GE_STATUS(status);
}
GE_CHK_RT_RET(rtMalloc(&d_res_op_list, op_nums * sizeof(SysOpInfo), RT_MEMORY_HBM));
allocated_mem.push_back(d_res_op_list); allocated_mem.push_back(d_res_op_list);


// malloc returnCodeList in SysOpCheckResp // malloc returnCodeList in SysOpCheckResp
status = rtMalloc(&d_ret_code_list, op_nums * sizeof(ReturnCode), RT_MEMORY_HBM);
if (status != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, size:%zu, ret = 0x%X", op_nums * sizeof(ReturnCode), status);
GELOGE(RT_FAILED, "[Call][RtMalloc] fail, size:%zu, ret = 0x%X", op_nums * sizeof(ReturnCode), status);
return RT_ERROR_TO_GE_STATUS(status);
}
GE_CHK_RT_RET(rtMalloc(&d_ret_code_list, op_nums * sizeof(ReturnCode), RT_MEMORY_HBM));
allocated_mem.push_back(d_ret_code_list); allocated_mem.push_back(d_ret_code_list);


for (const auto &op_type : aicpu_optype_list) { for (const auto &op_type : aicpu_optype_list) {
SysOpInfo op_info; SysOpInfo op_info;
// malloc op_type name in SysOpInfo // malloc op_type name in SysOpInfo
void *d_op_type_name = nullptr; void *d_op_type_name = nullptr;
status = rtMalloc(&d_op_type_name, op_type.length(), RT_MEMORY_HBM);
if (status != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, size:%lu, ret = 0x%X", op_type.length(), status);
GELOGE(RT_FAILED, "[Call][RtMalloc] fail, size:%lu, ret = 0x%X", op_type.length(), status);
return RT_ERROR_TO_GE_STATUS(status);
}
GE_CHK_RT_RET(rtMalloc(&d_op_type_name, op_type.length(), RT_MEMORY_HBM));

allocated_mem.push_back(d_op_type_name); allocated_mem.push_back(d_op_type_name);
GE_CHK_RT(rtMemcpy(d_op_type_name, op_type.length(), op_type.c_str(), op_type.length(), RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT(rtMemcpy(d_op_type_name, op_type.length(), op_type.c_str(), op_type.length(), RT_MEMCPY_HOST_TO_DEVICE));
op_info.opType = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(d_op_type_name)); op_info.opType = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(d_op_type_name));
@@ -1716,12 +1697,8 @@ Status ModelManager::LaunchKernelCheckAicpuOp(std::vector<std::string> &aicpu_op
SysOpInfo op_info; SysOpInfo op_info;
// malloc op_type name in SysOpInfo // malloc op_type name in SysOpInfo
void *d_op_type_name = nullptr; void *d_op_type_name = nullptr;
status = rtMalloc(&d_op_type_name, op_type.size(), RT_MEMORY_HBM);
if (status != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, size:%lu, ret = 0x%X", op_type.length(), status);
GELOGE(RT_FAILED, "[Call][RtMalloc] fail, size:%lu, ret = 0x%X", op_type.size(), status);
return RT_ERROR_TO_GE_STATUS(status);
}
GE_CHK_RT_RET(rtMalloc(&d_op_type_name, op_type.length(), RT_MEMORY_HBM));

allocated_mem.push_back(d_op_type_name); allocated_mem.push_back(d_op_type_name);
GE_CHK_RT(rtMemcpy(d_op_type_name, op_type.size(), op_type.c_str(), op_type.size(), RT_MEMCPY_HOST_TO_DEVICE)); GE_CHK_RT(rtMemcpy(d_op_type_name, op_type.size(), op_type.c_str(), op_type.size(), RT_MEMCPY_HOST_TO_DEVICE));
op_info.opType = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(d_op_type_name)); op_info.opType = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(d_op_type_name));
@@ -1745,12 +1722,8 @@ Status ModelManager::LaunchKernelCheckAicpuOp(std::vector<std::string> &aicpu_op
op_check_info_res.sysOpInfoList = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(d_res_op_list)); op_check_info_res.sysOpInfoList = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(d_res_op_list));


uint32_t args_size = sizeof(SysOpCheckInfo) + sizeof(SysOpCheckResp); uint32_t args_size = sizeof(SysOpCheckInfo) + sizeof(SysOpCheckResp);
status = rtMalloc(&args, args_size, RT_MEMORY_HBM);
if (status != RT_ERROR_NONE) {
REPORT_CALL_ERROR("E19999", "Call rtMalloc fail, size:%u, ret = 0x%X", args_size, status);
GELOGE(RT_FAILED, "[Call][RtMalloc] fail, size:%u, ret = 0x%X", args_size, status);
return RT_ERROR_TO_GE_STATUS(status);
}
GE_CHK_RT_RET(rtMalloc(&args, args_size, RT_MEMORY_HBM));

allocated_mem.push_back(args); allocated_mem.push_back(args);
GE_CHK_RT(rtMemcpy(args, sizeof(SysOpCheckInfo), reinterpret_cast<void *>(&op_check_info_req), sizeof(SysOpCheckInfo), GE_CHK_RT(rtMemcpy(args, sizeof(SysOpCheckInfo), reinterpret_cast<void *>(&op_check_info_req), sizeof(SysOpCheckInfo),
RT_MEMCPY_HOST_TO_DEVICE)); RT_MEMCPY_HOST_TO_DEVICE));


+ 4
- 2
ge/graph/load/model_manager/model_utils.cc View File

@@ -355,7 +355,8 @@ vector<void *> ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co
non_const_index++; non_const_index++;
int64_t inner_offset = 0; int64_t inner_offset = 0;
(void)ge::AttrUtils::GetInt(op_desc->MutableInputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset); (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),
GE_IF_BOOL_EXEC(model_param.var_size != 0
&& ge::VarManager::Instance(session_id)->IsVarAddr(input_offset - inner_offset),
uint8_t *variable_addr = nullptr; uint8_t *variable_addr = nullptr;
GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, input_offset - inner_offset, GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, input_offset - inner_offset,
tensor_size + inner_offset, variable_addr), return {}); tensor_size + inner_offset, variable_addr), return {});
@@ -470,7 +471,8 @@ vector<void *> ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C
(void)ge::AttrUtils::GetInt(op_desc->MutableOutputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset); (void)ge::AttrUtils::GetInt(op_desc->MutableOutputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset);
int64_t tensor_size = 0; int64_t tensor_size = 0;
GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {}); 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),
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; uint8_t *variable_addr = nullptr;
GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, v_output_offset[i] - inner_offset, GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, v_output_offset[i] - inner_offset,
tensor_size + inner_offset, variable_addr), return {}); tensor_size + inner_offset, variable_addr), return {});


+ 8
- 8
ge/graph/manager/graph_manager.cc View File

@@ -490,9 +490,10 @@ Status GraphManager::ModifyDataIndex(const Graph &graph, const std::map<std::str
auto iter = graph_option.find(OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE); auto iter = graph_option.find(OPTION_EXEC_DATA_INPUTS_SHAPE_RANGE);
if (iter != graph_option.end() && !iter->second.empty()) { if (iter != graph_option.end() && !iter->second.empty()) {
// If data inputs shape range is set, user must set valid data index. // If data inputs shape range is set, user must set valid data index.
std::string failed_reason = "Data index must be set continuous from 0 when data shape range enabled!";
REPORT_INPUT_ERROR("E10003", std::vector<std::string>({"parameter", "value", "reason"}),
std::vector<std::string>({"--data_index", "-", failed_reason}));
std::string situation = "Data op index";
std::string reason = "Data index must be set continuous from 0 when data shape range enabled!";
REPORT_INPUT_ERROR("E19025", std::vector<std::string>({"situation", "reason"}),
std::vector<std::string>({situation, reason}));
GELOGE(GRAPH_PARAM_INVALID, "[COMP][AddGraph]Input data index is invalid when data shape range enabled."); GELOGE(GRAPH_PARAM_INVALID, "[COMP][AddGraph]Input data index is invalid when data shape range enabled.");
return GRAPH_PARAM_INVALID; return GRAPH_PARAM_INVALID;
} }
@@ -1787,8 +1788,7 @@ Status GraphManager::ParseOptions(const std::map<std::string, std::string> &opti
return GE_GRAPH_OPTIONS_INVALID); return GE_GRAPH_OPTIONS_INVALID);


// ge.graphType // ge.graphType
ret =
ParseTrainGraphFlag(options_.run_graph_flag, options_.train_graph_flag);
ret = ParseTrainGraphFlag(options_.run_graph_flag, options_.train_graph_flag);
GE_IF_BOOL_EXEC(ret != SUCCESS, GE_IF_BOOL_EXEC(ret != SUCCESS,
GELOGE(GE_GRAPH_OPTIONS_INVALID, "[Parse][TrainGraphFlag] Key:ge.runFlag value is invalid"); GELOGE(GE_GRAPH_OPTIONS_INVALID, "[Parse][TrainGraphFlag] Key:ge.runFlag value is invalid");
return GE_GRAPH_OPTIONS_INVALID); return GE_GRAPH_OPTIONS_INVALID);
@@ -2767,6 +2767,7 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) {
GELOGI("End optimize after merge sub graph."); GELOGI("End optimize after merge sub graph.");
return SUCCESS; return SUCCESS;
} }

void GraphManager::ChangeConstTypeWhenTraining(const ComputeGraphPtr &compute_graph) { void GraphManager::ChangeConstTypeWhenTraining(const ComputeGraphPtr &compute_graph) {
// The constant for train is CONSTANTOP, and is CONSTANT for inference. They will be unified in future. // The constant for train is CONSTANTOP, and is CONSTANT for inference. They will be unified in future.
if (options_.train_graph_flag) { if (options_.train_graph_flag) {
@@ -3519,9 +3520,8 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra
return ret; return ret;
} }
GE_TIMESTAMP_EVENT_END(SetSubgraph, "OptimizeSubgraph::SetSubGraph"); GE_TIMESTAMP_EVENT_END(SetSubgraph, "OptimizeSubgraph::SetSubGraph");
if ((options_.build_mode == BUILD_MODE_TUNING) &&
(options_.build_step == BUILD_STEP_BEFORE_UB_MATCH || options_.build_step == BUILD_STEP_AFTER_BUILDER ||
options_.build_step == BUILD_STEP_AFTER_BUILDER_SUB)) {
std::set<string> build_steps = {BUILD_STEP_BEFORE_UB_MATCH, BUILD_STEP_AFTER_BUILDER, BUILD_STEP_AFTER_BUILDER_SUB};
if ((options_.build_mode == BUILD_MODE_TUNING) && (build_steps.count(options_.build_step) > 0)) {
GE_TIMESTAMP_START(ConvertGraphToFile); GE_TIMESTAMP_START(ConvertGraphToFile);
std::string tuning_path; std::string tuning_path;
(void) GetContext().GetOption(TUNING_PATH, tuning_path); (void) GetContext().GetOption(TUNING_PATH, tuning_path);


+ 7
- 8
ge/graph/manager/host_mem_manager.cc View File

@@ -107,16 +107,15 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) {
return SUCCESS; return SUCCESS;
} }


Status HostMemManager::QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size) {
bool HostMemManager::QueryVarMemInfo(const string &op_name, SharedMemInfo &mem_info) {
std::lock_guard<std::recursive_mutex> lock(mutex_); 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, "[Check][Param] Find host base base_addr failed, node name:%s!", op_name.c_str());
return INTERNAL_ERROR;
auto it = var_memory_base_map_.find(op_name);
if (it == var_memory_base_map_.end()) {
GELOGW("Host memory for node [%s] not found.", op_name.c_str());
return false;
} }
base_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(var_memory_base_map_[op_name].device_address));
data_size = var_memory_base_map_[op_name].mem_size;
return SUCCESS;
mem_info = it->second;
return true;
} }


string HostMemManager::OpNameToShmName(const string &op_name) { string HostMemManager::OpNameToShmName(const string &op_name) {


+ 1
- 1
ge/graph/manager/host_mem_manager.h View File

@@ -66,7 +66,7 @@ class HostMemManager {
Status Initialize(); Status Initialize();
void Finalize() noexcept; void Finalize() noexcept;
Status MallocSharedMemory(SharedMemInfo &mem_nfo); Status MallocSharedMemory(SharedMemInfo &mem_nfo);
Status QueryVarMemInfo(const string &op_name, uint64_t &base_addr, uint64_t &data_size);
bool QueryVarMemInfo(const string &op_name, SharedMemInfo &mem_info);


private: private:
static string OpNameToShmName(const string &op_name); static string OpNameToShmName(const string &op_name);


+ 9
- 2
ge/graph/manager/memory_api.cc View File

@@ -110,7 +110,14 @@ Status MallocSharedMemory(const TensorInfo &tensor_info, uint64_t &dev_addr, uin
} }


Status GetVarBaseAddrAndSize(const string &var_name, uint64_t &base_addr, uint64_t &var_size) { Status GetVarBaseAddrAndSize(const string &var_name, uint64_t &base_addr, uint64_t &var_size) {
GELOGD("GetVarBaseAddrAndSize in");
return HostMemManager::Instance().QueryVarMemInfo(var_name, base_addr, var_size);
GELOGD("GetVarBaseAddrAndSize in, var name:[%s]", var_name.c_str());
SharedMemInfo mem_info;
if (!HostMemManager::Instance().QueryVarMemInfo(var_name, mem_info)) {
GELOGE(FAILED, "Get addr and size failed, name:[%s]", var_name.c_str());
return FAILED;
}
base_addr = static_cast<uint64_t>(reinterpret_cast<uintptr_t>(mem_info.host_aligned_ptr->Get()));
var_size = mem_info.mem_size;
return SUCCESS;
} }
} // namespace ge } // namespace ge

+ 9
- 8
ge/graph/optimize/graph_optimize.cc View File

@@ -26,6 +26,7 @@ namespace {
const char *const kVectorCore = "VectorCore"; const char *const kVectorCore = "VectorCore";
const char *const kVectorEngine = "VectorEngine"; const char *const kVectorEngine = "VectorEngine";
const char *const kAicoreEngine = "AIcoreEngine"; const char *const kAicoreEngine = "AIcoreEngine";
const char *const kHostCpuEngine = "DNN_VM_HOST_CPU";
} // namespace } // namespace


namespace ge { namespace ge {
@@ -140,10 +141,6 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std
} }


Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) { Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) {
if (GetContext().GetHostExecFlag()) {
// graph exec on host, no need OptimizeOriginalGraph
return SUCCESS;
}
if (compute_graph == nullptr) { if (compute_graph == nullptr) {
REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid");
GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr."); GELOGE(GE_GRAPH_OPTIMIZE_COMPUTE_GRAPH_NULL, "[Check][Param] compute_graph is nullptr.");
@@ -170,6 +167,10 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) {
if (iter->first == exclude_core_Type) { if (iter->first == exclude_core_Type) {
continue; continue;
} }
if (GetContext().GetHostExecFlag() && iter->first != kHostCpuEngine) {
// graph exec on host, no need OptimizeOriginalGraph for other engine.
continue;
}
ret = (iter->second)->OptimizeOriginalGraph(*compute_graph); ret = (iter->second)->OptimizeOriginalGraph(*compute_graph);
if (ret != SUCCESS) { if (ret != SUCCESS) {
REPORT_INNER_ERROR("E19999", "Call OptimizeOriginalGraph failed, ret:%d, engine_name:%s, " REPORT_INNER_ERROR("E19999", "Call OptimizeOriginalGraph failed, ret:%d, engine_name:%s, "
@@ -186,10 +187,6 @@ Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) {


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


GE_CHECK_NOTNULL(compute_graph); GE_CHECK_NOTNULL(compute_graph);
Status ret = SUCCESS; Status ret = SUCCESS;
@@ -212,6 +209,10 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_
GELOGI("[OptimizeOriginalGraphJudgeInsert]: engine type will exclude: %s", exclude_core_Type.c_str()); GELOGI("[OptimizeOriginalGraphJudgeInsert]: engine type will exclude: %s", exclude_core_Type.c_str());
continue; continue;
} }
if (GetContext().GetHostExecFlag() && iter->first != kHostCpuEngine) {
// graph exec on host, no need OptimizeOriginalGraphJudgeInsert for other engine.
continue;
}
GELOGI("Begin to refine running format by engine %s", iter->first.c_str()); GELOGI("Begin to refine running format by engine %s", iter->first.c_str());
ret = (iter->second)->OptimizeOriginalGraphJudgeInsert(*compute_graph); ret = (iter->second)->OptimizeOriginalGraphJudgeInsert(*compute_graph);
if (ret != SUCCESS) { if (ret != SUCCESS) {


+ 2
- 4
ge/graph/optimize/mem_rw_conflict_optimize.cc View File

@@ -743,12 +743,10 @@ Status GraphOptimize::HandleMemoryRWConflict(ComputeGraphPtr &compute_graph) {
continue; continue;
} }
// ignore data / netoutput of subgraph // ignore data / netoutput of subgraph
if (node->GetType() == DATA && AttrUtils::HasAttr(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX)) {
continue;
}
if (node->GetType() == NETOUTPUT && AttrUtils::HasAttr(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX)) {
if (IsSubgraphInputNode(node) || IsSubgraphOutputNode(node)) {
continue; continue;
} }

bool identity_reserved = false; bool identity_reserved = false;
AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CANNOT_BE_DELETED, identity_reserved); AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CANNOT_BE_DELETED, identity_reserved);
if (identity_reserved) { if (identity_reserved) {


+ 4
- 10
ge/graph/partition/graph_partition.cc View File

@@ -366,11 +366,8 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
// link input -> end // link input -> end
string end_name = kEndType + std::to_string(graph_info_.num_of_pld_end_); 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); auto end_op_desc = MakeShared<OpDesc>(end_graph->GetName() + "_" + end_name, END);
if (end_op_desc == 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_CHECK_NOTNULL(end_op_desc);

GE_IF_BOOL_EXEC(!AttrUtils::SetInt(end_op_desc, "peerIndex", graph_info_.num_of_pld_end_), GE_IF_BOOL_EXEC(!AttrUtils::SetInt(end_op_desc, "peerIndex", graph_info_.num_of_pld_end_),
GELOGW("SetInt peerIndex failed");) GELOGW("SetInt peerIndex failed");)
GE_IF_BOOL_EXEC(!AttrUtils::SetStr(end_op_desc, "parentOpType", dst_node->GetType()), GE_IF_BOOL_EXEC(!AttrUtils::SetStr(end_op_desc, "parentOpType", dst_node->GetType()),
@@ -429,11 +426,8 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr
int64_t node_id = src_node_opdesc->GetId(); int64_t node_id = src_node_opdesc->GetId();
const string pld_name = kPlaceHolderType + std::to_string(graph_info_.num_of_pld_end_); 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); auto pld_op_desc = MakeShared<OpDesc>(pld_graph->GetName() + "_" + pld_name, PLACEHOLDER);
if (pld_op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New Memory for OpDesc failed.");
GELOGE(GRAPH_PARAM_INVALID, "[New][Memory] for OpDesc failed.");
return FAILED;
}
GE_CHECK_NOTNULL(pld_op_desc);

GE_IF_BOOL_EXEC(!AttrUtils::SetInt(pld_op_desc, "peerIndex", graph_info_.num_of_pld_end_), GE_IF_BOOL_EXEC(!AttrUtils::SetInt(pld_op_desc, "peerIndex", graph_info_.num_of_pld_end_),
GELOGW("SetInt peerIndex failed");) GELOGW("SetInt peerIndex failed");)
GE_IF_BOOL_EXEC(!AttrUtils::SetStr(pld_op_desc, "_peerNodeName", new_end_node->GetName()), GE_IF_BOOL_EXEC(!AttrUtils::SetStr(pld_op_desc, "_peerNodeName", new_end_node->GetName()),


+ 19
- 9
ge/graph/passes/base_pass.cc View File

@@ -199,6 +199,24 @@ void ClearOption(NamesToPass names_to_pass) {
name_to_pass.second->ClearOptions(); name_to_pass.second->ClearOptions();
} }
} }

bool CheckNode(const NodePtr &node, const DuringPassNodeSets &during_pass_node_set) {
if (node == nullptr) {
GELOGW("node is null");
return false;
}
if (during_pass_node_set.nodes_deleted.count(node) > 0) {
GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str());
return false;
}
if (during_pass_node_set.nodes_suspend.count(node) > 0) {
GELOGD("The node %s has been added to suspend-iteration nodes list, the iteration of it will be suspend.",
node->GetName().c_str());
return false;
}

return true;
}
} // namespace } // namespace


Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map) { Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector<int> &io_map) {
@@ -277,17 +295,9 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) {
nodes.pop_front(); nodes.pop_front();


(void)during_pass_node_set.nodes_re_pass.erase(node); (void)during_pass_node_set.nodes_re_pass.erase(node);
GE_IF_BOOL_EXEC(node == nullptr, GELOGW("node is null"); continue);
if (during_pass_node_set.nodes_deleted.count(node) > 0) {
GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str());
if (!CheckNode(node, during_pass_node_set)) {
continue; continue;
} }
if (during_pass_node_set.nodes_suspend.count(node) > 0) {
GELOGD("The node %s has been added to suspend-iteration nodes list, the iteration of it will be suspend.",
node->GetName().c_str());
continue;
}

AddNextIterNodes(node->GetOutNodes(), nodes, during_pass_node_set); AddNextIterNodes(node->GetOutNodes(), nodes, during_pass_node_set);


auto ret = RunPasses(node, names_to_passes, during_pass_node_set); auto ret = RunPasses(node, names_to_passes, during_pass_node_set);


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

@@ -70,9 +70,9 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) {
} }
GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, continue); GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, continue);
bool need_cycle_flag = false; bool need_cycle_flag = false;
bool is_found = AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_STREAM_CYCLE_EVENT_FLAG, need_cycle_flag);
(void)AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_STREAM_CYCLE_EVENT_FLAG, need_cycle_flag);
// small cycle flag is need_stream_cycle_event == true // small cycle flag is need_stream_cycle_event == true
if (is_found && need_cycle_flag) {
if (need_cycle_flag) {
Status ret = AddSpecialNodeIteratorCtrl(compute_graph, node); Status ret = AddSpecialNodeIteratorCtrl(compute_graph, node);
if (ret != SUCCESS) { if (ret != SUCCESS) {
GELOGE(ret, "[Add][SpecialNodeIteratorCtrl] failed, node:%s, graph:%s.", GELOGE(ret, "[Add][SpecialNodeIteratorCtrl] failed, node:%s, graph:%s.",


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

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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




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

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


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


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


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


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


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


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


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


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


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


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


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


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


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




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

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


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




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

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


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


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

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


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


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


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


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

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


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

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


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


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


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


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


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


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


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

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


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


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


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


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


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


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


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


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


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


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


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


return op_desc; return op_desc;


+ 7
- 3
ge/graph/passes/link_gen_mask_nodes_pass.cc View File

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


@@ -73,7 +73,9 @@ Status LinkGenMaskNodesPass::Run(ComputeGraphPtr graph) {
REPORT_CALL_ERROR("E19999", "Op:%s(%s) link control to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Op:%s(%s) link control to op:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(), src_node->GetName().c_str(), src_node->GetType().c_str(),
dest_node->GetName().c_str(), dest_node->GetType().c_str()); dest_node->GetName().c_str(), dest_node->GetType().c_str());
GELOGE(FAILED, "Link from %s to %s failed.", src_node->GetName().c_str(), dest_node->GetName().c_str());
GELOGE(FAILED, "[Add][Edge] Op:%s(%s) link control to op:%s(%s) failed",
src_node->GetName().c_str(), src_node->GetType().c_str(),
dest_node->GetName().c_str(), dest_node->GetType().c_str());
return FAILED; return FAILED;
} }
GELOGD("Link from %s to %s.", src_node->GetName().c_str(), dest_node->GetName().c_str()); GELOGD("Link from %s to %s.", src_node->GetName().c_str(), dest_node->GetName().c_str());
@@ -96,7 +98,9 @@ bool LinkGenMaskNodesPass::AreAllInputsConst(const NodePtr &node) const {
void LinkGenMaskNodesPass::GetAllGenMaskNodes(ComputeGraphPtr graph, vector<NodePtr> &gen_mask_nodes) const { void LinkGenMaskNodesPass::GetAllGenMaskNodes(ComputeGraphPtr graph, vector<NodePtr> &gen_mask_nodes) const {
set<NodePtr> nodes_set; set<NodePtr> nodes_set;
for (const NodePtr &node : graph->GetDirectNode()) { for (const NodePtr &node : graph->GetDirectNode()) {
if (node->GetType() != DROPOUTDOMASK && node->GetType() != DROPOUTDOMASKV3 && node->GetType() != DROPOUTDOMASKV3D) {
bool not_domask = node->GetType() != DROPOUTDOMASK && node->GetType() != DROPOUTDOMASKV3 &&
node->GetType() != DROPOUTDOMASKV3D && node->GetType() != SOFTMAXV2WITHDROPOUTDOMASKV3D;
if (not_domask) {
continue; continue;
} }




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

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


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


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

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


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

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


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

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


if (value == RT_CAPABILITY_NOT_SUPPORT) {
GELOGW("Not support zero copy, skip it.");
return SUCCESS;
}

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


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


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


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


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


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


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


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


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


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

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


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


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


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


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


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


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


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


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

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


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


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


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


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


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


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




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

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


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


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


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


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


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


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


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


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


return SUCCESS; return SUCCESS;


+ 224
- 134
ge/graph/passes/multi_batch_clone_pass.cc View File

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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

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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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

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


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


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


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


+ 54
- 49
ge/graph/passes/next_iteration_pass.cc View File

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


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


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


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


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


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


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


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


@@ -179,16 +182,10 @@ bool NextIterationPass::VerifyWhileGroup() {
if ((pair_iter.first == nullptr) || (pair_iter.second == nullptr)) { if ((pair_iter.first == nullptr) || (pair_iter.second == nullptr)) {
REPORT_INNER_ERROR("E19999", "Verify while group failed, merge_node/next_node is null, frame_name:%s.", REPORT_INNER_ERROR("E19999", "Verify while group failed, merge_node/next_node is null, frame_name:%s.",
frame_name.c_str()); frame_name.c_str());
GELOGE(INTERNAL_ERROR, "Verify while group failed, merge_node/next_node is null, frame_name: %s.",
GELOGE(INTERNAL_ERROR, "[Check][Param] Verify while group failed, merge_node/next_node is null, frame_name:%s.",
frame_name.c_str()); frame_name.c_str());
return false; return false;
} }

// Mark loop as unknown shape If any merge has unknown shape output.
const auto &op_desc = pair_iter.first->GetOpDesc();
if (IsUnknownShapeTensor(op_desc->GetOutputDesc(0))) {
loop_group_iter.second->is_unknown_shape = true; // under check loop, cannot break.
}
} }
} }


@@ -211,7 +208,7 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
NodePtr enter_active = CreateActiveNode(graph, cond_name + "_Enter_" + STREAMACTIVE); NodePtr enter_active = CreateActiveNode(graph, cond_name + "_Enter_" + STREAMACTIVE);
NodePtr next_active = CreateActiveNode(graph, cond_name + "_Next_" + STREAMACTIVE); NodePtr next_active = CreateActiveNode(graph, cond_name + "_Next_" + STREAMACTIVE);
if ((enter_active == nullptr) || (next_active == nullptr)) { if ((enter_active == nullptr) || (next_active == nullptr)) {
GELOGE(INTERNAL_ERROR, "Create active node failed, cond_name: %s.", cond_name.c_str());
GELOGE(INTERNAL_ERROR, "[Create][ActiveNode] failed, cond_name:%s.", cond_name.c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


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


for (const auto &pair : loop_cond_iter.second->merge_next_pairs) { for (const auto &pair : loop_cond_iter.second->merge_next_pairs) {
@@ -236,7 +234,9 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed",
enter_active->GetName().c_str(), enter_active->GetType().c_str(), enter_active->GetName().c_str(), enter_active->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str()); merge_node->GetName().c_str(), merge_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Add control edge failed.");
GELOGE(INTERNAL_ERROR, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
enter_active->GetName().c_str(), enter_active->GetType().c_str(),
merge_node->GetName().c_str(), merge_node->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


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


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


MarkForceUnknownShape(next_node, loop_group.is_unknown_shape, group_index);
MarkForceUnknownShape(merge_node, loop_group.is_unknown_shape, group_index);
SetControlFlowGroup(next_node, group_index);
SetControlFlowGroup(merge_node, group_index);
} }


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


MarkForceUnknownShape(loop_group.loop_cond, loop_group.is_unknown_shape, group_index);
MarkForceUnknownShape(enter_active, loop_group.is_unknown_shape, group_index);
MarkForceUnknownShape(next_active, loop_group.is_unknown_shape, group_index);
SetControlFlowGroup(loop_group.loop_cond, group_index);
SetControlFlowGroup(enter_active, group_index);
SetControlFlowGroup(next_active, group_index);
HandleSwitchExitNodes(loop_group, group_index); HandleSwitchExitNodes(loop_group, group_index);
} }


@@ -281,17 +284,13 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) {
/// @return void /// @return void
/// ///
void NextIterationPass::HandleSwitchExitNodes(const LoopCondGroup &loop_group, int64_t group_index) { void NextIterationPass::HandleSwitchExitNodes(const LoopCondGroup &loop_group, int64_t group_index) {
if (!loop_group.is_unknown_shape) {
return;
}

for (const auto &switch_node : loop_group.switch_nodes) { for (const auto &switch_node : loop_group.switch_nodes) {
MarkForceUnknownShape(switch_node, loop_group.is_unknown_shape, group_index);
SetControlFlowGroup(switch_node, group_index);
for (const auto &node : switch_node->GetOutDataNodes()) { for (const auto &node : switch_node->GetOutDataNodes()) {
std::string node_type; std::string node_type;
(void)GetOriginalType(node, node_type); (void)GetOriginalType(node, node_type);
if (kExitOpTypes.count(node_type) > 0) { if (kExitOpTypes.count(node_type) > 0) {
MarkForceUnknownShape(node, loop_group.is_unknown_shape, group_index);
SetControlFlowGroup(node, group_index);
} }
} }
} }
@@ -307,6 +306,7 @@ NodePtr NextIterationPass::CreateActiveNode(ComputeGraphPtr &graph, const std::s
OpDescPtr op_desc = MakeShared<OpDesc>(name, STREAMACTIVE); OpDescPtr op_desc = MakeShared<OpDesc>(name, STREAMACTIVE);
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "[New][OpDesc] failed");
return nullptr; return nullptr;
} }


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


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


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


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


+ 0
- 1
ge/graph/passes/next_iteration_pass.h View File

@@ -24,7 +24,6 @@ struct LoopCondGroup {
std::vector<ge::NodePtr> enter_nodes; // Enter nodes std::vector<ge::NodePtr> enter_nodes; // Enter nodes
std::vector<std::pair<ge::NodePtr, ge::NodePtr>> merge_next_pairs; // <Merge, NextIteration> std::vector<std::pair<ge::NodePtr, ge::NodePtr>> merge_next_pairs; // <Merge, NextIteration>
std::vector<ge::NodePtr> switch_nodes; // Switch nodes std::vector<ge::NodePtr> switch_nodes; // Switch nodes
bool is_unknown_shape{false};
}; };
using LoopCondGroupPtr = std::shared_ptr<LoopCondGroup>; using LoopCondGroupPtr = std::shared_ptr<LoopCondGroup>;




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

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


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


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

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


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


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

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


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

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


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


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


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


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


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


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


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


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


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


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




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

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


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


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


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

@@ -26,7 +26,7 @@ Status PlaceholderWithDefaultPass::Run(NodePtr &node) {
string type; string type;
Status status_ret = GetOriginalType(node, type); Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) { if (status_ret != SUCCESS) {
GELOGE(status_ret, "Placeholder with default pass get original type fail.");
GELOGE(status_ret, "[Get][OriginalType] of node:%s failed.", node->GetName().c_str());
return status_ret; return status_ret;
} }
if (type == PLACEHOLDERWITHDEFAULT) { if (type == PLACEHOLDERWITHDEFAULT) {


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

@@ -27,7 +27,7 @@ Status PreventGradientPass::Run(NodePtr &node) {
string type; string type;
Status status_ret = GetOriginalType(node, type); Status status_ret = GetOriginalType(node, type);
if (status_ret != SUCCESS) { if (status_ret != SUCCESS) {
GELOGE(status_ret, "PreventGradientPass get original type fail.");
GELOGE(status_ret, "[Get][OriginalType] of node:%s failed.", node->GetName().c_str());
return status_ret; return status_ret;
} }
if (type == PREVENTGRADIENT) { if (type == PREVENTGRADIENT) {


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

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


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

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


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

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


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

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


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




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

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


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


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


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


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


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




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

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


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

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


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


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

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


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

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


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

@@ -72,7 +72,7 @@ OpDescPtr SameTransdataBreadthFusionPass::GetCastOp(const GeTensorDesc &in_desc,
node_op.BreakConnect(); node_op.BreakConnect();
if (cast_op == nullptr) { if (cast_op == nullptr) {
REPORT_INNER_ERROR("E19999", "Create Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST); REPORT_INNER_ERROR("E19999", "Create Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST);
GELOGE(INTERNAL_ERROR, "new fusion cast op failed!");
GELOGE(INTERNAL_ERROR, "[Get][OpDesc] From Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST);
return nullptr; return nullptr;
} }
const int default_output_index = 0; const int default_output_index = 0;
@@ -99,7 +99,8 @@ OpDescPtr SameTransdataBreadthFusionPass::GetCastOp(const GeTensorDesc &in_desc,
if (!AttrUtils::SetInt(cast_op, CAST_ATTR_DST_TYPE, static_cast<int64_t>(out_desc.GetDataType()))) { if (!AttrUtils::SetInt(cast_op, CAST_ATTR_DST_TYPE, static_cast<int64_t>(out_desc.GetDataType()))) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str()); cast_op->GetName().c_str(), cast_op->GetType().c_str());
GELOGE(INTERNAL_ERROR, "set dst_type attr failed");
GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(),
cast_op->GetName().c_str(), cast_op->GetType().c_str());
return nullptr; return nullptr;
} }
return cast_op; return cast_op;
@@ -213,8 +214,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_anchor->GetIdx()); transdata_peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Remove][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
out_anchor->GetIdx(), transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetIdx());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
GELOGI("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(), GELOGI("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(),
@@ -226,9 +229,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_anchor->GetIdx()); transdata_peer_in_anchor->GetIdx());
GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetType().c_str(),
pre_out_anchor->GetIdx(), transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetIdx());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -251,8 +255,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN
out_anchor->GetOwnerNode()->GetType().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str());
GELOGE(GRAPH_FAILED, "Remove control edge between op:%s(%s) and op:%s(%s) failed",
out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(),
transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }


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


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


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


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


@@ -729,7 +776,9 @@ graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata(
REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed",
transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(), transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(),
graph->GetName().c_str()); graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "remove node %s failed!", transdata_node_remove->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Remove][Node] %s(%s) from graph:%s failed",
transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(),
graph->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -751,8 +800,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkInControlEdge(const NodePtr &n
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_src->GetName().c_str(), node_src->GetType().c_str()); node_src->GetName().c_str(), node_src->GetType().c_str());
GELOGE(GRAPH_FAILED, "remove edge faliled!src:%s, dst:%s",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), node_src->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Remove][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_src->GetName().c_str(), node_src->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
GELOGD("add edge.src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), GELOGD("add edge.src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
@@ -762,8 +813,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkInControlEdge(const NodePtr &n
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(), peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_dst->GetName().c_str(), node_dst->GetType().c_str()); node_dst->GetName().c_str(), node_dst->GetType().c_str());
GELOGE(GRAPH_FAILED, "add edge failed!src:%s, dst:%s", peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
node_dst->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed",
peer_out_control_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_control_anchor->GetOwnerNode()->GetType().c_str(),
node_dst->GetName().c_str(), node_dst->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
} }
@@ -810,6 +863,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
if (cast_node == nullptr) { if (cast_node == nullptr) {
REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed",
cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str(), graph->GetName().c_str()); cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str(), graph->GetName().c_str());
GELOGE(GRAPH_FAILED, "[Add][Node] %s(%s) to graph:%s failed",
cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str(), graph->GetName().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(), cast_node->GetName().c_str()); GELOGD("add edge.src:%s, dst:%s", pre_out_anchor->GetOwnerNode()->GetName().c_str(), cast_node->GetName().c_str());
@@ -818,6 +873,10 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
pre_out_anchor->GetOwnerNode()->GetName().c_str(), pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(), pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(),
cast_node->GetName().c_str(), cast_node->GetType().c_str()); cast_node->GetName().c_str(), cast_node->GetType().c_str());
GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed",
pre_out_anchor->GetOwnerNode()->GetName().c_str(),
pre_out_anchor->GetOwnerNode()->GetType().c_str(), pre_out_anchor->GetIdx(),
cast_node->GetName().c_str(), cast_node->GetType().c_str());
return GRAPH_FAILED; return GRAPH_FAILED;
} }
if (i == 0) { if (i == 0) {
@@ -827,7 +886,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g
if (!AttrUtils::SetBool(cast_op_desc, ATTR_NEED_COMPILE, true)) { if (!AttrUtils::SetBool(cast_op_desc, ATTR_NEED_COMPILE, true)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str()); cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str());
GELOGE(FAILED, "SetExtAttr fail.");
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(),
cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str());
return FAILED; return FAILED;
} }
pre_out_anchor = cast_node->GetOutDataAnchor(0); pre_out_anchor = cast_node->GetOutDataAnchor(0);
@@ -842,7 +902,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat
graphStatus ret = GRAPH_SUCCESS; graphStatus ret = GRAPH_SUCCESS;
if (out_anchor == nullptr) { if (out_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid");
GELOGE(GRAPH_FAILED, "out data anchor is null!This should not happen!");
GELOGE(GRAPH_FAILED, "[Check][Param] out data anchor is null! This should not happen!");
return GRAPH_FAILED; return GRAPH_FAILED;
} }


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


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

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




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

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


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

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


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

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


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

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




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

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


@@ -160,7 +161,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap
if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str()); data->GetName().c_str(), data->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
data->GetName().c_str(), data->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -234,7 +236,7 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
auto data_it = data_nodes.find(node_idx); auto data_it = data_nodes.find(node_idx);
if (data_it == data_nodes.end()) { if (data_it == data_nodes.end()) {
REPORT_INNER_ERROR("E19999", "Find node in data_nodes by index:%u failed", node_idx); REPORT_INNER_ERROR("E19999", "Find node in data_nodes by index:%u failed", node_idx);
GELOGE(FAILED, "Data: %s not fount, index: %u", base_node->GetName().c_str(), node_idx);
GELOGE(FAILED, "[Check][Param] Find node in data_nodes by index:%u failed", node_idx);
return false; return false;
} }


@@ -245,14 +247,15 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const map<ComputeGraphPtr, m
if (in_anchor == nullptr) { if (in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)", REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)",
node_idx, kDataOutIndex, work_data->GetName().c_str(), work_data->GetType().c_str()); node_idx, kDataOutIndex, work_data->GetName().c_str(), work_data->GetType().c_str());
GELOGE(FAILED, "Data anchor size: %u, anchor size: %zu", anchor_idx, in_anchors.size());
GELOGE(FAILED, "[Check][Param] Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)",
node_idx, kDataOutIndex, work_data->GetName().c_str(), work_data->GetType().c_str());
return false; return false;
} }


const auto &work_node = in_anchor->GetOwnerNode(); const auto &work_node = in_anchor->GetOwnerNode();
if (work_node == nullptr) { if (work_node == nullptr) {
REPORT_INNER_ERROR("E19999", "Owner node of anchor is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "Owner node of anchor is nullptr, check invalid");
GELOGE(FAILED, "Data: %s not found, index: %u", base_node->GetName().c_str(), node_idx);
GELOGE(FAILED, "[Check][Param] Owner node of anchor is nullptr");
return false; return false;
} }


@@ -347,7 +350,7 @@ Status SubexpressionMigrationPass::AppendParallelNode(map<ComputeGraphPtr, map<u
const OpDescPtr op_desc = op_builder.AddInput("x").AddOutput("y").Build(); const OpDescPtr op_desc = op_builder.AddInput("x").AddOutput("y").Build();
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA); REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA);
GELOGE(OUT_OF_MEMORY, "Create multi-batch case desc failed");
GELOGE(OUT_OF_MEMORY, "[Build][Op] %s(%s) failed", data_name.c_str(), DATA);
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -355,14 +358,16 @@ Status SubexpressionMigrationPass::AppendParallelNode(map<ComputeGraphPtr, map<u
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) { if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }


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


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


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


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


const auto &owner_node = out_anchor->GetOwnerNode(); const auto &owner_node = out_anchor->GetOwnerNode();
GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str()); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str());
@@ -405,15 +413,15 @@ Status SubexpressionMigrationPass::DetachParallelNode(const map<uint32_t, NodePt
for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) { for (uint32_t i = 0; i < detach->GetAllOutDataAnchorsSize(); ++i) {
auto it_idx = outputs.find(i); auto it_idx = outputs.find(i);
if (it_idx == outputs.end()) { if (it_idx == outputs.end()) {
REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i);
REPORT_INNER_ERROR("E19999", "Node:%s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "[Check][Param] Node:%s parent index %u not found", detach->GetName().c_str(), i);
return FAILED; return FAILED;
} }


auto it_data = graph_datas.find(it_idx->second); auto it_data = graph_datas.find(it_idx->second);
if (it_data == graph_datas.end()) { if (it_data == graph_datas.end()) {
REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i);
REPORT_INNER_ERROR("E19999", "Node:%s parent index %u not found, check invalid", detach->GetName().c_str(), i);
GELOGE(FAILED, "[Check][Param] Node:%s parent index %u not found", detach->GetName().c_str(), i);
return FAILED; return FAILED;
} }


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


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


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


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


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


@@ -546,23 +565,26 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
if (in_anchor == nullptr) { if (in_anchor == nullptr) {
REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)", REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)",
anchor_idx, kDataOutIndex, base_data->GetName().c_str(), base_data->GetType().c_str()); anchor_idx, kDataOutIndex, base_data->GetName().c_str(), base_data->GetType().c_str());
GELOGE(FAILED, "Data anchor index: %u, anchor size: %zu", anchor_idx, in_anchors.size());
GELOGE(FAILED, "[Check][Param] Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)",
anchor_idx, kDataOutIndex, base_data->GetName().c_str(), base_data->GetType().c_str());
return FAILED; return FAILED;
} }


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


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


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




+ 67
- 41
ge/graph/passes/subgraph_const_migration_pass.cc View File

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


@@ -156,6 +157,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str()); node->GetName().c_str(), node->GetType().c_str());
GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(),
node->GetName().c_str(), node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -163,26 +166,7 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra
GELOGD("%s, index: %u, Data: %s", subgraph->GetName().c_str(), parent_index, node->GetName().c_str()); GELOGD("%s, index: %u, Data: %s", subgraph->GetName().c_str(), parent_index, node->GetName().c_str());
} else if ((node->GetType() == CONSTANT) && (node->GetOutDataAnchor(kZeroIndex) != nullptr)) { } else if ((node->GetType() == CONSTANT) && (node->GetOutDataAnchor(kZeroIndex) != nullptr)) {
set<string> peer_name_list; set<string> peer_name_list;
const auto &out_anchor = node->GetOutDataAnchor(kZeroIndex);
for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
const auto &peer_node = in_anchor->GetOwnerNode();
// Trim subgraph node name prefix.
string node_full_name = peer_node->GetName();
size_t pos = node_full_name.find(kMbatchNodeNameMark);
if (pos == string::npos) {
GELOGI("Can not find: %s of multi-batch in node: %s", kMbatchNodeNameMark.c_str(), node_full_name.c_str());
continue;
}

string fixed_name = node_full_name.substr(0, pos);
pos = node_full_name.find("_", pos + kMbatchNodeNameMark.length());
if (pos != string::npos) {
fixed_name += node_full_name.substr(pos);
}

peer_name_list.insert(fixed_name + ":" + std::to_string(in_anchor->GetIdx()));
}

GetPeerNameList(node, peer_name_list);
if (peer_name_list.empty()) { if (peer_name_list.empty()) {
GELOGI("%s, Const: %s, no data output", subgraph->GetName().c_str(), node->GetName().c_str()); GELOGI("%s, Const: %s, no data output", subgraph->GetName().c_str(), node->GetName().c_str());
const auto in_all_nodes = node->GetInAllNodes(); const auto in_all_nodes = node->GetInAllNodes();
@@ -205,13 +189,36 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra


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


return SUCCESS; return SUCCESS;
} }


void SubgraphConstMigrationPass::GetPeerNameList(const NodePtr &node, set<string> &peer_name_list) {
const auto &out_anchor = node->GetOutDataAnchor(kZeroIndex);
for (const auto &in_anchor : out_anchor->GetPeerInDataAnchors()) {
const auto &peer_node = in_anchor->GetOwnerNode();
// Trim subgraph node name prefix.
string node_full_name = peer_node->GetName();
size_t pos = node_full_name.find(kMbatchNodeNameMark);
if (pos == string::npos) {
GELOGI("Can not find: %s of multi-batch in node: %s", kMbatchNodeNameMark.c_str(), node_full_name.c_str());
continue;
}

string fixed_name = node_full_name.substr(0, pos);
pos = node_full_name.find("_", pos + kMbatchNodeNameMark.length());
if (pos != string::npos) {
fixed_name += node_full_name.substr(pos);
}

peer_name_list.insert(fixed_name + ":" + std::to_string(in_anchor->GetIdx()));
}
}

/// ///
/// @ingroup ge /// @ingroup ge
/// @brief Get parent_index for Const node migration. /// @brief Get parent_index for Const node migration.
@@ -331,7 +338,7 @@ Status SubgraphConstMigrationPass::AppendParallelNode(const NodePtr &func_node,
const auto op_desc = op_builder.AddInput("x").AddOutput("y").Build(); const auto op_desc = op_builder.AddInput("x").AddOutput("y").Build();
if (op_desc == nullptr) { if (op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA); REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA);
GELOGE(OUT_OF_MEMORY, "Create multi-batch subgraph data desc failed");
GELOGE(OUT_OF_MEMORY, "[Build][OpDesc] %s(%s) failed", data_name.c_str(), DATA);
return OUT_OF_MEMORY; return OUT_OF_MEMORY;
} }


@@ -339,14 +346,16 @@ Status SubgraphConstMigrationPass::AppendParallelNode(const NodePtr &func_node,
if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) { if (!AttrUtils::SetInt(op_desc, ATTR_NAME_INDEX, data_index)) {
REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str());
GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED; return FAILED;
} }


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


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


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


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


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


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


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


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


@@ -483,7 +505,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
if (it_const == item.second.end()) { if (it_const == item.second.end()) {
REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str()); node_key.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
GELOGE(FAILED, "[Check][Param] Const node name:%s not found in graph:%s",
node_key.c_str(), subgraph->GetName().c_str());
return FAILED; return FAILED;
} }
move_node = it_const->second; move_node = it_const->second;
@@ -492,24 +515,27 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph
if (it_nodes == all_data_nodes.end()) { if (it_nodes == all_data_nodes.end()) {
REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str()); node_key.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
GELOGE(FAILED, "[Check][Param] Const node name:%s not found in graph:%s",
node_key.c_str(), subgraph->GetName().c_str());
return FAILED; return FAILED;
} }
const auto it_data = it_nodes->second.find(parent_index); const auto it_data = it_nodes->second.find(parent_index);
if (it_data == it_nodes->second.end()) { if (it_data == it_nodes->second.end()) {
REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid", REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid",
node_key.c_str(), subgraph->GetName().c_str()); node_key.c_str(), subgraph->GetName().c_str());
GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str());
GELOGE(FAILED, "[Check][Param] Const node name:%s not found in graph:%s",
node_key.c_str(), subgraph->GetName().c_str());
return FAILED; return FAILED;
} }


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


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




+ 2
- 0
ge/graph/passes/subgraph_const_migration_pass.h View File

@@ -133,6 +133,8 @@ class SubgraphConstMigrationPass : public GraphPass {
/// ///
Status AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node, Status AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node,
const NodePtr &const_node, uint32_t parent_index); const NodePtr &const_node, uint32_t parent_index);

void GetPeerNameList(const NodePtr &node, set<string> &peer_name_list);
}; };
} // namespace ge } // namespace ge
#endif // GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ #endif // GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_

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

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


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


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


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


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


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


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

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


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


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


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


return SUCCESS; return SUCCESS;
} }


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

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


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


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


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


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




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

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




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

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


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


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


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


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


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


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


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


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


@@ -218,7 +234,7 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph,
if (SetOriginalNodeName(stream_switch, switch_node->GetName()) != SUCCESS) { if (SetOriginalNodeName(stream_switch, switch_node->GetName()) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set original node name:%s to node:%s(%s) failed", switch_node->GetName().c_str(), REPORT_CALL_ERROR("E19999", "Set original node name:%s to node:%s(%s) failed", switch_node->GetName().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str()); stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
GELOGE(FAILED, "SetOriginalNodeName for node %s failed.", stream_switch->GetName().c_str());
GELOGE(FAILED, "[Set][OriginalNodeName] for node %s failed.", stream_switch->GetName().c_str());
return FAILED; return FAILED;
} }
}); });
@@ -248,8 +264,10 @@ Status SwitchToStreamSwitchPass::BypassSwitchNode(const NodePtr &switch_node, Ou
peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx(), peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx(),
switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx); switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx);
GELOGE(FAILED, "Remove data edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(),
switch_node->GetName().c_str());
GELOGE(FAILED, "[Remove][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%u) failed",
peer_out_anchor->GetOwnerNode()->GetName().c_str(),
peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx(),
switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx);
return FAILED; return FAILED;
} }


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


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


@@ -304,13 +322,13 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr &
OpDescPtr switch_op_desc = switch_node->GetOpDesc(); OpDescPtr switch_op_desc = switch_node->GetOpDesc();
GE_CHK_BOOL_EXEC(switch_op_desc != nullptr, GE_CHK_BOOL_EXEC(switch_op_desc != nullptr,
REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid");
return nullptr, "OpDesc of Switch node is invalid.");
return nullptr, "[Get][OpDesc] failed, OpDesc of Switch node is invalid.");
GE_IF_BOOL_EXEC(switch_op_desc->GetInputsSize() != SWITCH_INPUT_NUM, { GE_IF_BOOL_EXEC(switch_op_desc->GetInputsSize() != SWITCH_INPUT_NUM, {
REPORT_INNER_ERROR("E19999", "Input desc size:%zu of node:%s(%s) not equal to %u, check invalid", REPORT_INNER_ERROR("E19999", "Input desc size:%zu of node:%s(%s) not equal to %u, check invalid",
switch_op_desc->GetInputsSize(), switch_op_desc->GetInputsSize(),
switch_op_desc->GetName().c_str(), switch_op_desc->GetType().c_str(), SWITCH_INPUT_NUM); switch_op_desc->GetName().c_str(), switch_op_desc->GetType().c_str(), SWITCH_INPUT_NUM);
GELOGE(FAILED, "Switch input param invalid, input_size=%lu, should be %u.", switch_op_desc->GetInputsSize(),
SWITCH_INPUT_NUM);
GELOGE(FAILED, "[Check][Param] Switch input param invalid, input_size=%lu, should be %u.",
switch_op_desc->GetInputsSize(), SWITCH_INPUT_NUM);
return nullptr; return nullptr;
}); });


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


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


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


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


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


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


NodePtr active_node = CreateActiveNode(graph, cond_node); NodePtr active_node = CreateActiveNode(graph, cond_node);
GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED, "Create StreamActive node failed.");
GE_CHK_BOOL_EXEC(active_node != nullptr, return FAILED,
"[Create][StreamActiveNode] for cond node:%s failed.", cond_node->GetName().c_str());
GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()), GE_CHK_STATUS(GraphUtils::AddEdge(cast_node->GetOutControlAnchor(), active_node->GetInControlAnchor()),
"StreamActive add ctl edge failed.");
"[Add][ControlEdge] between %s and %s failed.",
cond_node->GetName().c_str(), active_node->GetName().c_str());
if (SetActiveLabelList(active_node, { cast_node->GetName() }) != SUCCESS) { if (SetActiveLabelList(active_node, { cast_node->GetName() }) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed",
cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str()); cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
GELOGE(FAILED, "Set active_label_list attr for node %s failed.", active_node->GetName().c_str());
GELOGE(FAILED, "[Set][ActiveLabelList] %s to op:%s(%s) failed.",
cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str());
return FAILED; return FAILED;
} }


@@ -505,38 +535,48 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph)


// select first stream_switch // select first stream_switch
NodePtr stream_switch = switch_list.front(); NodePtr stream_switch = switch_list.front();
OpDescPtr switch_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc);
// set stream_label // set stream_label
if (SetStreamLabel(stream_switch, cast_node->GetName()) != SUCCESS) { if (SetStreamLabel(stream_switch, cast_node->GetName()) != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed",
cast_node->GetName().c_str(), stream_switch->GetName().c_str(), cast_node->GetName().c_str(), stream_switch->GetName().c_str(),
stream_switch->GetType().c_str()); stream_switch->GetType().c_str());
GELOGE(FAILED, "Set stream label failed.");
GELOGE(FAILED, "[Set][StreamLabel] %s to op:%s(%s) failed", cast_node->GetName().c_str(),
stream_switch->GetName().c_str(), stream_switch->GetType().c_str());
return FAILED; return FAILED;
} }
OpDescPtr switch_desc = stream_switch->GetOpDesc();
GE_CHECK_NOTNULL(switch_desc);
switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f"))); switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f")));
stream_switch_nodes_.emplace_back(stream_switch); stream_switch_nodes_.emplace_back(stream_switch);


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


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


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


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


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


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


const std::string &cast_name = CheckDuplicateName(cond_desc->GetName() + "_" + CAST); const std::string &cast_name = CheckDuplicateName(cond_desc->GetName() + "_" + CAST);
GELOGI("Create cast_node: %s, input datatype:DT_BOOL, out datatype:DT_INT32", cast_name.c_str()); GELOGI("Create cast_node: %s, input datatype:DT_BOOL, out datatype:DT_INT32", cast_name.c_str());
OpDescPtr cast_desc = MakeShared<OpDesc>(cast_name, CAST); OpDescPtr cast_desc = MakeShared<OpDesc>(cast_name, CAST);
if (cast_desc == nullptr) { if (cast_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Cast:%s.", cast_name.c_str());
GELOGE(FAILED, "[New][OpDesc] failed.");
return nullptr; return nullptr;
} }
if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, (int64_t)DT_BOOL) && if (!(AttrUtils::SetInt(cast_desc, CAST_ATTR_SRCT, (int64_t)DT_BOOL) &&
@@ -600,8 +644,10 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(), CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(),
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(), CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(),
cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
GELOGE(FAILED, "Set CAST_ATTR_SRCT or CAST_ATTR_DSTT or CAST_ATTR_DST_TYPE or CAST_ATTR_TRUNCATE failed, node: %s.",
cast_name.c_str());
GELOGE(FAILED, "[Set][Attr] %s or %s or %s or %s to op:%s(%s) failed",
CAST_ATTR_SRCT.c_str(), CAST_ATTR_DSTT.c_str(),
CAST_ATTR_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(),
cast_desc->GetName().c_str(), cast_desc->GetType().c_str());
return nullptr; return nullptr;
} }


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


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


return cast_node; return cast_node;
} }
@@ -646,14 +699,15 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons
ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str()); op_desc->GetName().c_str(), op_desc->GetType().c_str());
return FAILED, return FAILED,
"StreamSwitch get attr TRUE_BRANCH_STREAM failed.");
"[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(),
op_desc->GetName().c_str(), op_desc->GetType().c_str());


const std::string &const_node_name = op_desc->GetName() + "_Constant_" + (value ? "t" : "f"); const std::string &const_node_name = op_desc->GetName() + "_Constant_" + (value ? "t" : "f");
GELOGI("Create const op: %s", const_node_name.c_str()); GELOGI("Create const op: %s", const_node_name.c_str());
OpDescPtr const_op_desc = MakeShared<OpDesc>(const_node_name, CONSTANT); OpDescPtr const_op_desc = MakeShared<OpDesc>(const_node_name, CONSTANT);
if (const_op_desc == nullptr) { if (const_op_desc == nullptr) {
REPORT_CALL_ERROR("E19999", "New OpDesc failed"); REPORT_CALL_ERROR("E19999", "New OpDesc failed");
GELOGE(FAILED, "Create op_desc failed, Constant:%s.", const_node_name.c_str());
GELOGE(FAILED, "New OpDesc failed.");
return FAILED; return FAILED;
} }


@@ -663,27 +717,34 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons
MakeShared<GeTensor>(data_desc, reinterpret_cast<uint8_t *>(&resize_value), sizeof(int32_t)); MakeShared<GeTensor>(data_desc, reinterpret_cast<uint8_t *>(&resize_value), sizeof(int32_t));
if (const_value == nullptr) { if (const_value == nullptr) {
REPORT_CALL_ERROR("E19999", "New GeTensor failed"); REPORT_CALL_ERROR("E19999", "New GeTensor failed");
GELOGE(FAILED, "Create tensor failed.");
GELOGE(FAILED, "[New][GeTensor] failed.");
return FAILED; return FAILED;
} }
GE_CHK_BOOL_EXEC(AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value), GE_CHK_BOOL_EXEC(AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value),
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str()); const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return FAILED);
return FAILED,
"[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(),
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
GE_CHK_BOOL_EXEC(const_op_desc->AddOutputDesc(data_desc) == GRAPH_SUCCESS, GE_CHK_BOOL_EXEC(const_op_desc->AddOutputDesc(data_desc) == GRAPH_SUCCESS,
REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str()); const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());
return FAILED, return FAILED,
"Create Const op: add output desc failed.");
"[Add][OutputDesc] to op:%s(%s) failed",
const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str());


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


return SUCCESS; return SUCCESS;
} }
@@ -705,22 +766,26 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no
if (!AttrUtils::GetStr(switch_desc, ATTR_NAME_ORIG_NODE_NAME, orig_switch_name) || orig_switch_name.empty()) { if (!AttrUtils::GetStr(switch_desc, ATTR_NAME_ORIG_NODE_NAME, orig_switch_name) || orig_switch_name.empty()) {
REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(),
switch_desc->GetName().c_str(), switch_desc->GetType().c_str()); switch_desc->GetName().c_str(), switch_desc->GetType().c_str());
GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ORIG_NODE_NAME failed, node: %s", switch_desc->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(),
switch_desc->GetName().c_str(), switch_desc->GetType().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
} }


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


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


@@ -728,7 +793,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no
GE_IF_BOOL_EXEC(find_res1 == switch_node_map_.end(), { GE_IF_BOOL_EXEC(find_res1 == switch_node_map_.end(), {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid",
in_ctrl_node->GetName().c_str(), in_ctrl_node->GetType().c_str()); in_ctrl_node->GetName().c_str(), in_ctrl_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", in_ctrl_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] StreamSwitch node %s not found in switch_node_map_.",
in_ctrl_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });
auto find_res2 = find_res1->second.find(orig_switch_name); auto find_res2 = find_res1->second.find(orig_switch_name);
@@ -758,27 +824,31 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n
GE_IF_BOOL_EXEC(find_res == switch_node_map_.end(), { GE_IF_BOOL_EXEC(find_res == switch_node_map_.end(), {
REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid", REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str()); switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", switch_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] StreamSwitch node %s not found in switch_node_map_.",
switch_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });
GE_IF_BOOL_EXEC(find_res->second.empty(), { GE_IF_BOOL_EXEC(find_res->second.empty(), {
REPORT_INNER_ERROR("E19999", "True_nodes of StreamSwitch node:%s(%s) is empty, check invalid", REPORT_INNER_ERROR("E19999", "True_nodes of StreamSwitch node:%s(%s) is empty, check invalid",
switch_node->GetName().c_str(), switch_node->GetType().c_str()); switch_node->GetName().c_str(), switch_node->GetType().c_str());
GELOGE(INTERNAL_ERROR, "true_nodes of StreamSwitch node %s is empty.", switch_node->GetName().c_str());
GELOGE(INTERNAL_ERROR, "[Check][Param] true_nodes of StreamSwitch node %s is empty.",
switch_node->GetName().c_str());
return INTERNAL_ERROR; return INTERNAL_ERROR;
}); });


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


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

+ 7
- 4
ge/graph/passes/transop_breadth_fusion_pass.cc View File

@@ -32,7 +32,7 @@ Status TransOpBreadthFusionPass::Run(ge::ComputeGraphPtr graph) {
Status ret_topo = graph->TopologicalSorting(); Status ret_topo = graph->TopologicalSorting();
if (ret_topo != SUCCESS) { if (ret_topo != SUCCESS) {
REPORT_CALL_ERROR("E19999", "Topological sorting for graph:%s failed", graph->GetName().c_str()); REPORT_CALL_ERROR("E19999", "Topological sorting for graph:%s failed", graph->GetName().c_str());
GELOGE(ret_topo, "TopologicalSorting the merged graph failed.");
GELOGE(ret_topo, "[Call][TopologicalSorting] for graph:%s failed.", graph->GetName().c_str());
return ret_topo; return ret_topo;
} }


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


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

std::set<std::string> trans_shapes = { RESHAPE, EXPANDDIMS, SQUEEZE };
std::set<std::string> trans_shape_and_format = { TRANSPOSE, TRANSPOSED, EXPANDDIMS };
if (node->GetType() == CAST) { if (node->GetType() == CAST) {
trans_data_type = true; trans_data_type = true;
} else if (node->GetType() == TRANSPOSE || node->GetType() == TRANSPOSED || node->GetType() == EXPANDDIMS) {
} else if (trans_shape_and_format.count(node->GetType()) > 0) {
trans_format = true; trans_format = true;
trans_shape = true; trans_shape = true;
} else if (node->GetType() == TRANSDATA) { } else if (node->GetType() == TRANSDATA) {
trans_data_type = true; trans_data_type = true;
trans_format = true; trans_format = true;
trans_shape = true; trans_shape = true;
} else if (node->GetType() == RESHAPE || node->GetType() == EXPANDDIMS || node->GetType() == SQUEEZE) {
} else if (trans_shapes.count(node->GetType()) > 0) {
trans_shape = true; trans_shape = true;
} else if (node->GetType() == REFORMAT) { } else if (node->GetType() == REFORMAT) {
trans_format = true; trans_format = true;


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

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


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


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


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


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

Loading…
Cancel
Save