diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f97d245..34ef19ac 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) -if (ENABLE_OPEN_SRC) +if (ENABLE_GE_COV OR ENABLE_GE_UT OR ENABLE_GE_ST) set(HI_PYTHON python3) include(cmake/external_libs/protobuf_shared.cmake) @@ -51,119 +51,131 @@ if (ENABLE_OPEN_SRC) 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") + 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() - 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(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}) - 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}) + message(STATUS "PLATFORM param is invalid, should be train or inference, you choose nothing!") 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() + 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() - 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 () \ No newline at end of file diff --git a/build.sh b/build.sh index 5931bbaa..96c46e1a 100755 --- a/build.sh +++ b/build.sh @@ -166,7 +166,7 @@ build_graphengine() echo "execute command: cmake ${CMAKE_ARGS} .. failed." return 1 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} if [ "x${PLATFORM}" = "xtrain" ] then @@ -174,6 +174,9 @@ build_graphengine() elif [ "x${PLATFORM}" = "xinference" ] then 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" ] then 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 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_package() { @@ -253,7 +281,7 @@ generate_package() 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") 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") rm -rf ${OUTPUT_PATH:?}/${FWK_PATH}/ @@ -337,7 +365,7 @@ generate_package() 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 elif [ "X$MINDSPORE_MODE" = "Xon" ] then diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 6f54cf7b..215d2832 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -2,7 +2,6 @@ if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) add_subdirectory(common) add_subdirectory(plugin/engine) add_subdirectory(ge_local_engine) - add_subdirectory(host_cpu_engine) add_subdirectory(executor) add_subdirectory(offline) elseif (ENABLE_D) @@ -380,6 +379,7 @@ set(TRAIN_SRC_LIST "single_op/task/tbe_task_builder.cc" "single_op/task/aicpu_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/npu_memory_allocator.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/ge_local/ge_local_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/partitioned_call/partitioned_call_node_executor.cc" "hybrid/node_executor/hccl/hccl_node_executor.cc" diff --git a/ge/common/auth/file_saver.cc b/ge/common/auth/file_saver.cc index b1e94c59..57ab901b 100755 --- a/ge/common/auth/file_saver.cc +++ b/ge/common/auth/file_saver.cc @@ -290,7 +290,6 @@ FileSaver::SaveToFile(const string &file_path, const ge::ModelData &model, const copy_header_ret); 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); 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 FileSaver::SaveToFile(const string &file_path, ModelFileHeader &file_header, ModelPartitionTable &model_partition_table, const std::vector &partition_datas) { - file_header.is_encrypt = ModelEncryptType::UNENCRYPTED; - 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.", 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, vector &model_partition_tables, const vector> &all_partition_datas) { - file_header.is_encrypt = ModelEncryptType::UNENCRYPTED; - 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.", file_path.c_str(), file_header.length); diff --git a/ge/common/ge/plugin_manager.cc b/ge/common/ge/plugin_manager.cc index 09a9b870..5e8b3d2b 100644 --- a/ge/common/ge/plugin_manager.cc +++ b/ge/common/ge/plugin_manager.cc @@ -126,8 +126,8 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec if (handle == nullptr) { const char *error = mmDlerror(); 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, "[DLOpen][SharedLibraryPath]Failed, path[%s]. Errormessage[%s]!", file_path_dlopen.c_str(), error); @@ -141,9 +141,8 @@ Status PluginManager::LoadSo(const string &path, const vector &func_chec if (real_fn == nullptr) { const char *error = mmDlerror(); 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, "[Check][So]%s is skipped since function %s is not existed! errmsg:%s", func_name.c_str(), func_name.c_str(), error); diff --git a/ge/common/helper/model_cache_helper.cc b/ge/common/helper/model_cache_helper.cc index 78ca697f..9cd88ef1 100755 --- a/ge/common/helper/model_cache_helper.cc +++ b/ge/common/helper/model_cache_helper.cc @@ -1672,10 +1672,9 @@ Status ModelCacheHelper::LoadOmModelFromCache(GeModelPtr &ge_model) const { } GELOGI("load model data from file: %s", om_path.c_str()); Status ret; - string key_path; int32_t priority = 0; 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) { GELOGW("LoadOmModelFromCache: Load model from file failed. ret = %u", ret); return ret; diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index 45443c17..4e760a4a 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -39,8 +39,6 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil const uint8_t *data, size_t size, size_t model_index) { if (size < 1 || size > UINT32_MAX) { 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) { string item = "item"; if (type == MODEL_DEF) { @@ -57,6 +55,8 @@ Status ModelHelper::SaveModelPartition(std::shared_ptr &om_fil ErrorManager::GetInstance().ATCReportErrMessage("E19023", {"size", "item", "maxsize"}, {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; } 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 ModelHelper::SaveOriginalGraphToOmModel(const ge::Graph &graph, const std::string &output_file) { 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; } // Get computegraph from graph @@ -1015,7 +1013,7 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef ge::ModelData model; int32_t priority = 0; - Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model); + Status ret = ModelParserBase::LoadFromFile(model_file, priority, model); if (ret != SUCCESS) { 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", @@ -1035,7 +1033,7 @@ Status ModelTool::GetModelInfoFromOm(const char *model_file, ge::proto::ModelDef ret = ModelParserBase::ParseModelContent(model, model_data, model_len); if (ret != SUCCESS) { 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, "[Parse][ModelContent]Failed because of invalid om file %s, please check om param", model_file); @@ -1074,7 +1072,7 @@ Status ModelTool::GetModelInfoFromPbtxt(const char *model_file, ge::proto::Model ge::ModelData model; 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 { if (ptr != nullptr && *ptr != nullptr) { delete[] reinterpret_cast(*ptr); diff --git a/ge/common/model_parser/model_parser.cc b/ge/common/model_parser/model_parser.cc index 5c68eea8..ef9ab9e6 100644 --- a/ge/common/model_parser/model_parser.cc +++ b/ge/common/model_parser/model_parser.cc @@ -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 Status ModelParserBase::LoadFromFile(const char *model_path, - const char *key, int32_t priority, + int32_t priority, ge::ModelData &model_data) { std::string real_path = RealPath(model_path); 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_len = len; model_data.priority = priority; - model_data.key = (key == nullptr) ? "" : key; return SUCCESS; } @@ -113,23 +112,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelParserBase::ParseMo // Get data address uint8_t *data = reinterpret_cast(model.model_data) + sizeof(ModelFileHeader); - if (file_header->is_encrypt == ModelEncryptType::UNENCRYPTED) { // Unencrypted model - if (!model.key.empty()) { - REPORT_INPUT_ERROR("E10003", std::vector({"parameter", "value", "reason"}), - std::vector({"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({"parameter", "value", "reason"}), - std::vector({"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; } diff --git a/ge/common/model_parser/model_parser.h b/ge/common/model_parser/model_parser.h index 75db8b11..cef0f13b 100755 --- a/ge/common/model_parser/model_parser.h +++ b/ge/common/model_parser/model_parser.h @@ -43,12 +43,11 @@ class ModelParserBase { * @ingroup hiai * @brief Parsing a model file * @param [in] model_file model path - * @param [in] model_key model secret key * @param [in] priority modle priority * @param [out] model_data model data * @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); /** diff --git a/ge/common/model_saver.cc b/ge/common/model_saver.cc index 42cdf26e..24e837f7 100755 --- a/ge/common/model_saver.cc +++ b/ge/common/model_saver.cc @@ -41,12 +41,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ModelSaver::SaveJsonToFi try { model_str = model.dump(kInteval, ' ', false, Json::error_handler_t::ignore); } 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", file_path, e.what()); return FAILED; } 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); return FAILED; } diff --git a/ge/common/profiling/ge_profiling.cc b/ge/common/profiling/ge_profiling.cc index 5e892ff8..d0343326 100644 --- a/ge/common/profiling/ge_profiling.cc +++ b/ge/common/profiling/ge_profiling.cc @@ -216,3 +216,6 @@ ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t le return ge::SUCCESS; } +GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream) { + return ge::SUCCESS; +} diff --git a/ge/common/profiling/profiling_manager.cc b/ge/common/profiling/profiling_manager.cc index d615187f..61210de6 100644 --- a/ge/common/profiling/profiling_manager.cc +++ b/ge/common/profiling/profiling_manager.cc @@ -954,8 +954,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status ProfilingManager::CallMs static_cast(&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 input_format; std::vector> input_shape; std::vector 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_data_type.emplace_back(input_tensor_desc->GetDataType()); } + + std::vector format_default = { FORMAT_NULL }; + std::vector> shape_default = { {0} }; + std::vector 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 output_format; std::vector> output_shape; std::vector output_data_type; @@ -984,14 +993,17 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void ProfilingManager::GetOpInp std::vector format_default = { FORMAT_NULL }; std::vector> shape_default = { {0} }; std::vector 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_shape = output_shape.empty() ? shape_default : output_shape; 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( std::string &fp_point, std::string &bp_point) { // Env or options mode, fp_point_/bp_point_ have initiliazed on profiling init diff --git a/ge/common/profiling/profiling_manager.h b/ge/common/profiling/profiling_manager.h index 12293fc5..049a4df4 100755 --- a/ge/common/profiling/profiling_manager.h +++ b/ge/common/profiling/profiling_manager.h @@ -111,6 +111,8 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ProfilingManager { uint64_t GetProfilingModule(); void UpdateDeviceIdModuleMap(string prof_type, uint64_t module, const vector &device_list); 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_execute_profiling_; diff --git a/ge/common/types.cc b/ge/common/types.cc index 33b7f437..98ae7737 100644 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -92,6 +92,7 @@ REGISTER_OPTYPE_DEFINE(DROPOUTGENMASK, "DropOutGenMask"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASK, "DropOutDoMask"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3, "DropOutDoMaskV3"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3D, "DropOutDoMaskV3D"); +REGISTER_OPTYPE_DEFINE(SOFTMAXV2WITHDROPOUTDOMASKV3D, "SoftmaxV2WithDropOutDoMaskV3D"); REGISTER_OPTYPE_DEFINE(CONCAT, "Concat"); REGISTER_OPTYPE_DEFINE(ROIPOOLING, "ROIPooling"); REGISTER_OPTYPE_DEFINE(PROPOSAL, "Proposal"); @@ -391,6 +392,8 @@ REGISTER_OPTYPE_DEFINE(HCOMREMOTEREAD, "HcomRemoteRead"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DEFINE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DEFINE(HCOMREMOTESCATTERWRITE, "HcomRemoteScatterWrite"); +REGISTER_OPTYPE_DEFINE(HCOMALLTOALLV, "HcomAllToAllV"); +REGISTER_OPTYPE_DEFINE(HCOMGATHERALLTOALLV, "HcomGatherAllToAllV"); REGISTER_OPTYPE_DEFINE(VARASSIGN, "VarAssign"); REGISTER_OPTYPE_DEFINE(VARISINITIALIZEDOP, "VarIsInitializedOp"); diff --git a/ge/common/util.cc b/ge/common/util.cc index 6887b096..448efc0f 100644 --- a/ge/common/util.cc +++ b/ge/common/util.cc @@ -70,39 +70,6 @@ static bool ReadProtoFromCodedInputStream(CodedInputStream &coded_stream, Messag 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) { 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"); @@ -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)); 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()); 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, kMaxFileSizeLimit); return static_cast(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 if (ret != 0) { 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", directory_path.c_str(), strerror(errno)); return ret; @@ -239,7 +208,9 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY int CreateDirectory(const std:: int32_t ret = mmMkdir(const_cast(directory_path.c_str()), M_IRUSR | M_IWUSR | M_IXUSR); // 700 if (ret != 0) { 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", directory_path.c_str(), strerror(errno)); 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); 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", real_path.c_str(), file); return false; @@ -374,14 +345,24 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const // The specified path is empty std::map args_map; 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()); return false; } std::string real_path = RealPath(file_path.c_str()); // Unable to get absolute path (does not exist or does not have permission to access) 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)); return false; } @@ -397,13 +378,23 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckInputPathValid(const GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( !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); // The absolute path points to a file that is not readable 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)); return false; } @@ -415,14 +406,27 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY bool CheckOutputPathValid(const const std::string &atc_param) { // The specified path is 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}); GELOGW("Input parameter's value is empty."); return false; } 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(), 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( !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); 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()) { // File is not readable or writable 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)); 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(path_split_pos)); // Determine whether the specified path is valid by creating the path 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()); return false; } diff --git a/ge/engine_manager/dnnengine_manager.cc b/ge/engine_manager/dnnengine_manager.cc index a2e39146..e89fc847 100644 --- a/ge/engine_manager/dnnengine_manager.cc +++ b/ge/engine_manager/dnnengine_manager.cc @@ -31,6 +31,7 @@ #include "graph/utils/graph_utils.h" #include "graph/utils/node_utils.h" #include "init/gelib.h" +#include "framework/common/types.h" namespace { const char *const kSchedulerUnits = "schedule_units"; @@ -44,12 +45,20 @@ const char *const kAttch = "attach"; const char *const kVectorCore = "VectorCore"; const char *const kVectorEngine = "VectorEngine"; const char *const kAIcoreEngine = "AIcoreEngine"; -const char *const kCustomOpFlag = "_custom_op_flag"; const char *const kHostCpuEngineName = "DNN_VM_HOST_CPU"; const char *const kHostCpuOpKernelLibName = "DNN_VM_HOST_CPU_OP_STORE"; } // namespace namespace ge { +namespace { +const std::set 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() { 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()); 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; 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")); @@ -238,19 +247,6 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { return it.engine; } else { 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); 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()); @@ -273,7 +269,7 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { ErrorManager::GetInstance().ATCReportErrMessage( "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 " - "is unsupported, reason %s", + "is unsupported, reason : %s", op_desc->GetType().c_str(), it.first.c_str(), it.second.c_str()); } diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index d7da8916..f1267c1e 100644 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -65,6 +65,7 @@ set(SRC_LIST "../single_op/task/tbe_task_builder.cc" "../single_op/task/aicpu_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/npu_memory_allocator.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/ge_local/ge_local_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/partitioned_call/partitioned_call_node_executor.cc" "../hybrid/node_executor/rts/rts_node_executor.cc" diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index e66dcb58..049d012f 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -209,7 +209,7 @@ static void InitOpsProtoManager() { string file_path = RealPath(path.c_str()); if (file_path.empty()) { 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; } 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; } GELOGI("load modelData from file: %s.", path.c_str()); - std::string key_path; 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 (model_data.model_data != nullptr) { delete[] static_cast(model_data.model_data); @@ -932,8 +931,7 @@ Status GeExecutor::GetMemAndWeightSize(const std::string &path, size_t &mem_size } 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)) { GELOGE(ret, "Load data from file failed. ret = %d", ret); return ret; diff --git a/ge/ge_local_engine/engine/host_cpu_engine.cc b/ge/ge_local_engine/engine/host_cpu_engine.cc index f3a14317..cd68ae15 100755 --- a/ge/ge_local_engine/engine/host_cpu_engine.cc +++ b/ge/ge_local_engine/engine/host_cpu_engine.cc @@ -57,6 +57,7 @@ namespace ge { namespace { const char *kEnvKeyOppPath = "ASCEND_OPP_PATH"; 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) { @@ -352,6 +353,9 @@ Status HostCpuEngine::LoadLib(const std::string &lib_path) { } 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); return SUCCESS; } diff --git a/ge/ge_local_engine/engine/host_cpu_engine.h b/ge/ge_local_engine/engine/host_cpu_engine.h index fdec212e..d13fcae1 100644 --- a/ge/ge_local_engine/engine/host_cpu_engine.h +++ b/ge/ge_local_engine/engine/host_cpu_engine.h @@ -54,6 +54,8 @@ class GE_FUNC_VISIBILITY HostCpuEngine { ge::Status Run(NodePtr &node, const vector &inputs, std::vector &outputs); + void *GetConstantFoldingHandle() const { return constant_folding_handle_; } + private: HostCpuEngine() = default; @@ -85,6 +87,7 @@ class GE_FUNC_VISIBILITY HostCpuEngine { std::mutex mu_; std::vector lib_handles_; + void *constant_folding_handle_ = nullptr; bool initialized_ = false; }; } // namespace ge diff --git a/ge/ge_runtime/runtime_model.cc b/ge/ge_runtime/runtime_model.cc index 2c1f2d3b..a19fbcaf 100644 --- a/ge/ge_runtime/runtime_model.cc +++ b/ge/ge_runtime/runtime_model.cc @@ -26,6 +26,7 @@ #include "framework/common/op/op_parser_util.h" #include "graph/types.h" #include "task/task_factory.h" +#include "ge/common/math/math_util.h" namespace ge { namespace model_runner { @@ -501,7 +502,7 @@ bool RuntimeModel::InitConstantInfo(std::shared_ptr &davinci_model } uint64_t *buff = reinterpret_cast(const_cast(constant->weight_data.data())); 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"); return false; } diff --git a/ge/ge_runtime/task/aicpu_task.cc b/ge/ge_runtime/task/aicpu_task.cc index cc07365d..ddd6557b 100644 --- a/ge/ge_runtime/task/aicpu_task.cc +++ b/ge/ge_runtime/task/aicpu_task.cc @@ -83,7 +83,7 @@ bool AicpuTask::Distribute() { return false; } - GELOGI("ext info size:", ext_size); + GELOGI("ext info size: %u", ext_size); aicpu_param_head.extInfoLength = ext_size; aicpu_param_head.extInfoAddr = reinterpret_cast(ext_info_); } diff --git a/ge/ge_runtime/task/hccl_task.cc b/ge/ge_runtime/task/hccl_task.cc index c3040697..df4bf4c8 100644 --- a/ge/ge_runtime/task/hccl_task.cc +++ b/ge/ge_runtime/task/hccl_task.cc @@ -118,7 +118,7 @@ bool HcclTask::SetSecondaryStream() { Status ret; std::lock_guard lock(model_stream_mapping_mutex_); 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); if (!ret) { GELOGE(RT_FAILED, "Create hccl stream failed."); @@ -142,10 +142,7 @@ bool HcclTask::SetSecondaryStream() { return false; } stream = std::make_shared(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_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); } 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); ret = CreateStream(hccl_secondary_stream_num, master_stream_id); if (!ret) { diff --git a/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc index c04bd5cf..e9046026 100644 --- a/ge/ge_runtime/task/label_goto_task.cc +++ b/ge/ge_runtime/task/label_goto_task.cc @@ -60,6 +60,48 @@ LabelGotoTask::~LabelGotoTask() { bool LabelGotoTask::Distribute() { GELOGI("LabelGotoTask Distribute start."); + if (!CheckParamValid()) { + return false; + } + + const std::vector 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) { GELOGE(PARAM_INVALID, "stream is null!"); return false; diff --git a/ge/ge_runtime/task/label_switch_task.cc b/ge/ge_runtime/task/label_switch_task.cc index 1f913d74..cde278d9 100644 --- a/ge/ge_runtime/task/label_switch_task.cc +++ b/ge/ge_runtime/task/label_switch_task.cc @@ -56,8 +56,34 @@ bool LabelSwitchTask::Distribute() { 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 &label_index_list = task_info_->label_list(); + std::vector 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) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return false; diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 8a94aa9b..575afb35 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -452,7 +452,9 @@ Status GeGenerator::Initialize(const map &options, OmgContext &o Status GeGenerator::Finalize() { 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(); if (ret != SUCCESS) { 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 &in op_desc->GetName().c_str()); 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); if (op_desc->HasAttr(ATTR_NAME_UNREGST_OPPATH)) { @@ -867,11 +869,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in if (!HasShapeRange(inputs) && compile_flag == kFuzzBuildPattern) { 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; // 1. Create ComputeGraph. diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index 12790ec5..e086940a 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -268,12 +268,13 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, mapGetGraphMemoryMaxSize(), compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); 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(), iter.second, iter.first); } + REPORT_INPUT_ERROR( + "E19022", std::vector({"size", "item", "maxsize"}), + std::vector({std::to_string(total_mem_offset), "featuremap", + std::to_string(VarManager::Instance(session_id)->GetGraphMemoryMaxSize())})); return ge::FAILED; } return SUCCESS; @@ -543,7 +544,6 @@ Status GraphMemoryAssigner::UpdateRefOpOffsetReverse(const NodePtr &node) { } Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { - Status ret; // Stored nodes which need assign continuous input memory in `reverse topo order` std::vector nodes_stack; std::map node_2_continuous_type; @@ -579,11 +579,8 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { if (continuous_output) { GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "output"), "[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 @@ -612,6 +609,61 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { 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 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 output_list = peer_op_desc->GetOutputOffset(); + if (peer_out_data_anchor->GetIdx() >= static_cast(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 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, 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()); @@ -631,13 +683,6 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, bool is_continuous_input_allocated = false; auto op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); - vector 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); for (auto &in_data_anchor : node->GetAllInDataAnchors()) { GE_IF_BOOL_EXEC(in_data_anchor == nullptr, continue); @@ -669,45 +714,12 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, return FAILED; } } - - bool is_nopadding = ((continuous_type & kTypeInputNoPadding) != 0) || lx_fusion; - vector output_list = peer_op_desc->GetOutputOffset(); - if (peer_out_data_anchor->GetIdx() >= static_cast(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; } - // 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 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; + bool is_nopadding = ((continuous_type & kTypeInputNoPadding) != 0) || lx_fusion; if (is_nopadding) { mem_offset += 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; real_size = tensor_desc_size; } - + vector 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] " "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(), @@ -1601,8 +1613,8 @@ ge::Status GraphMemoryAssigner::UpdateRefOpOutputOffset(const NodePtr &node, con if (has_inner_offset) { (void)ge::AttrUtils::SetInt(opdesc->MutableOutputDesc(out_i), ATTR_NAME_INNER_OFFSET, inner_offset); } - GELOGI("Node[%s] output[%d] is updated from reuse input index[%d] to offset[%ld], inner_offset[%ld]", opdesc->GetName().c_str(), - out_i, ref_in, input_offset, inner_offset); + 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; @@ -1827,17 +1839,17 @@ bool GraphMemoryAssigner::CheckContinuousMemType(vector mem_type_list) int64_t mem_type_tmp = mem_type_list[0]; for (auto mem_type : mem_type_list) { 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].", mem_type_tmp, mem_type); return false; } } 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); return false; } diff --git a/ge/graph/build/memory/graph_mem_assigner.h b/ge/graph/build/memory/graph_mem_assigner.h index a6a2a686..46e27b32 100755 --- a/ge/graph/build/memory/graph_mem_assigner.h +++ b/ge/graph/build/memory/graph_mem_assigner.h @@ -146,6 +146,9 @@ class GraphMemoryAssigner { ge::Status FilterAtomicNodesForMemoryAssign(map>> &normal_atomic_nodes_map, map> &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, int64_t &continuous_mem_size, int64_t memory_type, uint32_t continuous_type, bool reverse_refresh = false); diff --git a/ge/graph/build/stream_allocator.cc b/ge/graph/build/stream_allocator.cc index a5a1112e..dae36b83 100644 --- a/ge/graph/build/stream_allocator.cc +++ b/ge/graph/build/stream_allocator.cc @@ -1212,7 +1212,8 @@ Status StreamAllocator::SetActiveStreamsForLoop() { for (const auto &node : whole_graph_->GetNodes(whole_graph_->GetGraphUnknownFlag())) { GE_CHECK_NOTNULL(node->GetOpDesc()); 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 activated_label_list; NodePtr pre_switch_node = FindSwitchNodeBeforeLoopActiveNode(node); diff --git a/ge/graph/build/task_generator.cc b/ge/graph/build/task_generator.cc index 2db0b6b7..12da803d 100755 --- a/ge/graph/build/task_generator.cc +++ b/ge/graph/build/task_generator.cc @@ -771,6 +771,7 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP GELOGI("Start AutoFindBpOpIndex"); NodePtr bp_node = nullptr; uint32_t current_idx = 0; + uint32_t netoutput_idx = 0; for (auto &node : graph->GetNodes(graph->GetGraphUnknownFlag())) { OpDescPtr op_desc = node->GetOpDesc(); 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 (bp_node == nullptr) { bp_node = node; + netoutput_idx = current_idx - 1; } } if (graph->GetNeedIteration()) { @@ -812,9 +814,13 @@ Status TaskGenerator::AutoFindBpOpIndex(const ComputeGraphPtr &graph, ProfilingP if (bp_node == nullptr) { GELOGW("not find bp_node."); 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; } diff --git a/ge/graph/common/omg_util.cc b/ge/graph/common/omg_util.cc index 598677bd..52e6cb9c 100644 --- a/ge/graph/common/omg_util.cc +++ b/ge/graph/common/omg_util.cc @@ -286,13 +286,23 @@ void MarkForceUnknownShape(const NodePtr &node, bool force_unknown, int64_t grou 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); const auto &op_desc = node->GetOpDesc(); GE_RT_VOID_CHECK_NOTNULL(op_desc); // op_desc as AttrHolderAdapter valid, Set attribute always success, just log for check. - GELOGD("[%s] Set control flow group index: %ld", node->GetName().c_str(), group_index); - if (!AttrUtils::SetInt(op_desc, ATTR_NAME_CONTROL_FLOW_GROUP, group_index)) { + 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(), 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(), diff --git a/ge/graph/common/omg_util.h b/ge/graph/common/omg_util.h index 91fcd29e..148e4102 100644 --- a/ge/graph/common/omg_util.h +++ b/ge/graph/common/omg_util.h @@ -133,6 +133,14 @@ bool IsUnknownShapeTensor(const GeTensorDesc &tensor_desc); /// @return /// 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 #endif // GE_GRAPH_COMMON_OMG_UTIL_H_ diff --git a/ge/graph/load/graph_loader.cc b/ge/graph/load/graph_loader.cc index 7ee74d1d..94b90d69 100755 --- a/ge/graph/load/graph_loader.cc +++ b/ge/graph/load/graph_loader.cc @@ -123,23 +123,17 @@ Status GraphLoader::GetMaxUsedMemory(uint32_t model_id, uint64_t &max_size) { 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()); return ACL_ERROR_GE_EXEC_MODEL_PATH_INVALID; } GELOGI("Load model begin, model path is: %s", path.c_str()); - if (!key_path.empty() && !CheckInputPathValid(key_path)) { - REPORT_INNER_ERROR("E19999", "Param key_path:%s empty or invalid", key_path.c_str()); - GELOGE(ACL_ERROR_GE_PARAM_INVALID, "[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) { - 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) { delete[] static_cast(model_data.model_data); model_data.model_data = nullptr; diff --git a/ge/graph/load/graph_loader.h b/ge/graph/load/graph_loader.h index 4704e4e2..e11af749 100755 --- a/ge/graph/load/graph_loader.h +++ b/ge/graph/load/graph_loader.h @@ -48,8 +48,7 @@ class GraphLoader { 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, void *weight_ptr, size_t weight_size); diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index f8b61216..5b67c205 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -984,11 +984,12 @@ Status DavinciModel::InitDataOp(const ComputeGraphPtr &graph, const NodePtr &nod return SUCCESS; } - GELOGI("Init data node: %s.", op_desc->GetName().c_str()); 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); } + GELOGI("Init data node: %s, index: %u.", op_desc->GetName().c_str(), data_index); data_by_index[data_index] = op_desc; if (known_node_) { @@ -3435,37 +3436,39 @@ void DavinciModel::SetZeroCopyAddr(const OpDescPtr &op_desc, const std::vector op_size) { + if (size > op_size) { 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", - input_size, op_size); + input_or_output.c_str(), size, op_size); } 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; } // 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; } // 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", - input_size, kDataMemAlignSizeCompare, op_size, model_id_); + input_or_output.c_str(), size, kDataMemAlignSizeCompare, op_size, model_id_); 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 true; @@ -3543,7 +3546,7 @@ Status DavinciModel::UpdateIoTaskArgs(const std::map & 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]", data.second.GetOpName().c_str()); return ACL_ERROR_GE_PARAM_INVALID; @@ -3727,6 +3730,8 @@ Status DavinciModel::InitTbeHandle(const OpDescPtr &op_desc) { binary.magic = RT_DEV_BINARY_MAGIC_ELF; } else if (json_string == "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 { 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(), @@ -4007,13 +4012,11 @@ Status DavinciModel::NnExecute(rtStream_t stream, bool async_mode, const InputDa 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 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() { char ge_static_mem_env[MMPA_MAX_PATH] = {0x00}; 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; if (mem_size == 0) { continue; @@ -4166,7 +4169,7 @@ void DavinciModel::FreeFeatureMapMem() { void DavinciModel::FreeExMem() { char ge_static_mem_env[MMPA_MAX_PATH] = {0x00}; 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 if ((kSessionScopeMemory & it.first) == kSessionScopeMemory) { continue; diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index 8a8fb35e..819a2ea2 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -611,7 +611,7 @@ class DavinciModel { /// @param [in] is_dynamic: dynamic batch input flag. /// @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 diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index d7a6ca25..6a563d2f 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -1668,42 +1668,23 @@ Status ModelManager::LaunchKernelCheckAicpuOp(std::vector &aicpu_op }; GE_MAKE_GUARD(release, callback); // 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); // 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); // 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); for (const auto &op_type : aicpu_optype_list) { SysOpInfo op_info; // malloc op_type name in SysOpInfo 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); 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(reinterpret_cast(d_op_type_name)); @@ -1716,12 +1697,8 @@ Status ModelManager::LaunchKernelCheckAicpuOp(std::vector &aicpu_op SysOpInfo op_info; // malloc op_type name in SysOpInfo 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); 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(reinterpret_cast(d_op_type_name)); @@ -1745,12 +1722,8 @@ Status ModelManager::LaunchKernelCheckAicpuOp(std::vector &aicpu_op op_check_info_res.sysOpInfoList = static_cast(reinterpret_cast(d_res_op_list)); 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); GE_CHK_RT(rtMemcpy(args, sizeof(SysOpCheckInfo), reinterpret_cast(&op_check_info_req), sizeof(SysOpCheckInfo), RT_MEMCPY_HOST_TO_DEVICE)); diff --git a/ge/graph/load/model_manager/model_utils.cc b/ge/graph/load/model_manager/model_utils.cc index c15c6872..224a3331 100755 --- a/ge/graph/load/model_manager/model_utils.cc +++ b/ge/graph/load/model_manager/model_utils.cc @@ -355,7 +355,8 @@ vector ModelUtils::GetInputDataAddrs(const RuntimeParam &model_param, Co non_const_index++; int64_t inner_offset = 0; (void)ge::AttrUtils::GetInt(op_desc->MutableInputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset); - GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset - inner_offset), + GE_IF_BOOL_EXEC(model_param.var_size != 0 + && ge::VarManager::Instance(session_id)->IsVarAddr(input_offset - inner_offset), uint8_t *variable_addr = nullptr; GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, input_offset - inner_offset, tensor_size + inner_offset, variable_addr), return {}); @@ -470,7 +471,8 @@ vector ModelUtils::GetOutputDataAddrs(const RuntimeParam &model_param, C (void)ge::AttrUtils::GetInt(op_desc->MutableOutputDesc(i), ATTR_NAME_INNER_OFFSET, inner_offset); int64_t tensor_size = 0; GE_CHK_STATUS_EXEC(TensorUtils::GetSize(*tensor_desc, tensor_size), return {}); - GE_IF_BOOL_EXEC(model_param.var_size != 0 && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i] - inner_offset), + GE_IF_BOOL_EXEC(model_param.var_size != 0 + && ge::VarManager::Instance(session_id)->IsVarAddr(v_output_offset[i] - inner_offset), uint8_t *variable_addr = nullptr; GE_CHK_STATUS_EXEC(GetVarAddr(model_param, op_desc, v_output_offset[i] - inner_offset, tensor_size + inner_offset, variable_addr), return {}); diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 273d2195..bf04ed58 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -490,9 +490,10 @@ Status GraphManager::ModifyDataIndex(const Graph &graph, const std::mapsecond.empty()) { // 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({"parameter", "value", "reason"}), - std::vector({"--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({"situation", "reason"}), + std::vector({situation, reason})); GELOGE(GRAPH_PARAM_INVALID, "[COMP][AddGraph]Input data index is invalid when data shape range enabled."); return GRAPH_PARAM_INVALID; } @@ -1787,8 +1788,7 @@ Status GraphManager::ParseOptions(const std::map &opti return GE_GRAPH_OPTIONS_INVALID); // 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, GELOGE(GE_GRAPH_OPTIONS_INVALID, "[Parse][TrainGraphFlag] Key:ge.runFlag value is invalid"); return GE_GRAPH_OPTIONS_INVALID); @@ -2767,6 +2767,7 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { GELOGI("End optimize after merge sub graph."); return SUCCESS; } + void GraphManager::ChangeConstTypeWhenTraining(const ComputeGraphPtr &compute_graph) { // The constant for train is CONSTANTOP, and is CONSTANT for inference. They will be unified in future. if (options_.train_graph_flag) { @@ -3519,9 +3520,8 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra return ret; } 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 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); std::string tuning_path; (void) GetContext().GetOption(TUNING_PATH, tuning_path); diff --git a/ge/graph/manager/host_mem_manager.cc b/ge/graph/manager/host_mem_manager.cc index 63265bf4..5e65bac0 100644 --- a/ge/graph/manager/host_mem_manager.cc +++ b/ge/graph/manager/host_mem_manager.cc @@ -107,16 +107,15 @@ Status HostMemManager::MallocSharedMemory(SharedMemInfo &mem_info) { 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 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(reinterpret_cast(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) { diff --git a/ge/graph/manager/host_mem_manager.h b/ge/graph/manager/host_mem_manager.h index be3237c3..84d5aebe 100644 --- a/ge/graph/manager/host_mem_manager.h +++ b/ge/graph/manager/host_mem_manager.h @@ -66,7 +66,7 @@ class HostMemManager { Status Initialize(); void Finalize() noexcept; 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: static string OpNameToShmName(const string &op_name); diff --git a/ge/graph/manager/memory_api.cc b/ge/graph/manager/memory_api.cc index 8ea0594b..777e2d59 100644 --- a/ge/graph/manager/memory_api.cc +++ b/ge/graph/manager/memory_api.cc @@ -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) { - 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(reinterpret_cast(mem_info.host_aligned_ptr->Get())); + var_size = mem_info.mem_size; + return SUCCESS; } } // namespace ge diff --git a/ge/graph/optimize/graph_optimize.cc b/ge/graph/optimize/graph_optimize.cc index 3f1a64cc..835e257b 100644 --- a/ge/graph/optimize/graph_optimize.cc +++ b/ge/graph/optimize/graph_optimize.cc @@ -26,6 +26,7 @@ namespace { const char *const kVectorCore = "VectorCore"; const char *const kVectorEngine = "VectorEngine"; const char *const kAicoreEngine = "AIcoreEngine"; +const char *const kHostCpuEngine = "DNN_VM_HOST_CPU"; } // namespace namespace ge { @@ -140,10 +141,6 @@ Status GraphOptimize::OptimizeSubGraph(ComputeGraphPtr &compute_graph, const std } Status GraphOptimize::OptimizeOriginalGraph(ComputeGraphPtr &compute_graph) { - if (GetContext().GetHostExecFlag()) { - // graph exec on host, no need OptimizeOriginalGraph - return SUCCESS; - } if (compute_graph == nullptr) { REPORT_INNER_ERROR("E19999", "Param compute_graph is nullptr, check invalid"); 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) { continue; } + if (GetContext().GetHostExecFlag() && iter->first != kHostCpuEngine) { + // graph exec on host, no need OptimizeOriginalGraph for other engine. + continue; + } ret = (iter->second)->OptimizeOriginalGraph(*compute_graph); if (ret != SUCCESS) { 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) { GELOGD("OptimizeOriginalGraphJudgeInsert in"); - if (GetContext().GetHostExecFlag()) { - // graph exec on host, no need OptimizeOriginalGraphJudgeInsert - return SUCCESS; - } GE_CHECK_NOTNULL(compute_graph); Status ret = SUCCESS; @@ -212,6 +209,10 @@ Status GraphOptimize::OptimizeOriginalGraphJudgeInsert(ComputeGraphPtr &compute_ GELOGI("[OptimizeOriginalGraphJudgeInsert]: engine type will exclude: %s", exclude_core_Type.c_str()); 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()); ret = (iter->second)->OptimizeOriginalGraphJudgeInsert(*compute_graph); if (ret != SUCCESS) { diff --git a/ge/graph/optimize/mem_rw_conflict_optimize.cc b/ge/graph/optimize/mem_rw_conflict_optimize.cc index 6ffd099d..7e7ab908 100644 --- a/ge/graph/optimize/mem_rw_conflict_optimize.cc +++ b/ge/graph/optimize/mem_rw_conflict_optimize.cc @@ -743,12 +743,10 @@ Status GraphOptimize::HandleMemoryRWConflict(ComputeGraphPtr &compute_graph) { continue; } // 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; } + bool identity_reserved = false; AttrUtils::GetBool(node->GetOpDesc(), ATTR_NAME_CANNOT_BE_DELETED, identity_reserved); if (identity_reserved) { diff --git a/ge/graph/partition/graph_partition.cc b/ge/graph/partition/graph_partition.cc index 503979cb..c3f9480d 100755 --- a/ge/graph/partition/graph_partition.cc +++ b/ge/graph/partition/graph_partition.cc @@ -366,11 +366,8 @@ graphStatus ge::GraphPartitioner::AddPlaceHolderEndInSrcDstGraph(const AnchorPtr // link input -> end string end_name = kEndType + std::to_string(graph_info_.num_of_pld_end_); auto end_op_desc = MakeShared(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_), GELOGW("SetInt peerIndex failed");) 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(); const string pld_name = kPlaceHolderType + std::to_string(graph_info_.num_of_pld_end_); auto pld_op_desc = MakeShared(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_), GELOGW("SetInt peerIndex failed");) GE_IF_BOOL_EXEC(!AttrUtils::SetStr(pld_op_desc, "_peerNodeName", new_end_node->GetName()), diff --git a/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc index 6d933295..165e7e81 100755 --- a/ge/graph/passes/base_pass.cc +++ b/ge/graph/passes/base_pass.cc @@ -199,6 +199,24 @@ void ClearOption(NamesToPass names_to_pass) { 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 Status BaseNodePass::IsolateAndDeleteNode(NodePtr &node, const std::vector &io_map) { @@ -277,17 +295,9 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { nodes.pop_front(); (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; } - 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); auto ret = RunPasses(node, names_to_passes, during_pass_node_set); diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index fe0cb9ea..87896dc3 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -70,9 +70,9 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) { } GE_IF_BOOL_EXEC(node->GetOpDesc() == nullptr, continue); 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 - if (is_found && need_cycle_flag) { + if (need_cycle_flag) { Status ret = AddSpecialNodeIteratorCtrl(compute_graph, node); if (ret != SUCCESS) { GELOGE(ret, "[Add][SpecialNodeIteratorCtrl] failed, node:%s, graph:%s.", diff --git a/ge/graph/passes/hccl_continuous_memcpy_pass.cc b/ge/graph/passes/hccl_continuous_memcpy_pass.cc index 61066d63..56cbb005 100644 --- a/ge/graph/passes/hccl_continuous_memcpy_pass.cc +++ b/ge/graph/passes/hccl_continuous_memcpy_pass.cc @@ -39,19 +39,20 @@ Status HcclContinuousMemcpyPass::Run(ge::ComputeGraphPtr graph) { if (op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "Node with nullptr op_desc exist in Param graph:%s, check invalid", 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; } Status ret = ContinuousInputProcess(graph, node); 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; } ret = P2pmemInputProcess(graph, node); 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; } @@ -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", node->GetName().c_str(), node->GetType().c_str(), 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; } if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) { Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); 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; } } @@ -122,16 +125,17 @@ Status HcclContinuousMemcpyPass::P2pmemInputProcess(const ComputeGraphPtr &graph auto src_out_anchor = hccl_in_anchor->GetPeerOutAnchor(); if (src_out_anchor == nullptr) { 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; } if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) { Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); 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; } } @@ -156,7 +160,7 @@ NodePtr HcclContinuousMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &grap OpDescPtr pre_op_desc = pre_node->GetOpDesc(); if (pre_op_desc == nullptr) { 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; } @@ -175,7 +179,8 @@ NodePtr HcclContinuousMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &grap if (identity_node == nullptr) { 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()); - 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 identity_node; @@ -213,7 +218,7 @@ Status HcclContinuousMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &gra Status ret = InsertIdentityBeforeHccl(graph, src_out_anchor, hccl_in_anchor); 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(), hccl_in_anchor->GetOwnerNode()->GetName().c_str()); return ret; @@ -221,7 +226,7 @@ Status HcclContinuousMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &gra ret = InsertAssignAfterBroadcastIfNeed(graph, src_out_anchor, hccl_in_anchor); 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(), hccl_in_anchor->GetOwnerNode()->GetName().c_str()); return ret; @@ -246,16 +251,14 @@ Status HcclContinuousMemcpyPass::InsertIdentityBeforeHccl(const ComputeGraphPtr auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex); 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(), hccl_in_anchor->GetOwnerNode()->GetName().c_str(), hccl_in_anchor->GetOwnerNode()->GetType().c_str(), 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(), - 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()); return FAILED; } @@ -300,27 +303,29 @@ Status HcclContinuousMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeG Status ret = hccl_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignValueIndex)); 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()->GetType().c_str(), hccl_out_anchor->GetIdx(), assign_node->GetName().c_str(), assign_node->GetType().c_str(), 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; } ret = var_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignRefIndex)); 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()->GetType().c_str(), var_out_anchor->GetIdx(), assign_node->GetName().c_str(), assign_node->GetType().c_str(), 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; } @@ -339,9 +344,10 @@ Status HcclContinuousMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeG assign_out_control_anchor->GetOwnerNode()->GetType().c_str(), in_data_anchor->GetOwnerNode()->GetName().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(), - 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; } } @@ -357,9 +363,11 @@ Status HcclContinuousMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeG assign_out_control_anchor->GetOwnerNode()->GetType().c_str(), in_control_anchor->GetOwnerNode()->GetName().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(), - 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; } } @@ -379,7 +387,7 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, OpDescPtr pre_op_desc = pre_node->GetOpDesc(); if (pre_op_desc == nullptr) { 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; } @@ -388,16 +396,16 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, OpDescPtr op_desc = MakeShared(node_name.c_str(), ASSIGN); if (op_desc == nullptr) { 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; } GELOGI("Create Assign op:%s.", op_desc->GetName().c_str()); 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()); - 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; } @@ -405,7 +413,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:ref", 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; } @@ -413,7 +422,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:value", 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; } @@ -421,7 +431,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:ref", 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; } @@ -429,7 +440,8 @@ NodePtr HcclContinuousMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, if (assign_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - GELOGE(INTERNAL_ERROR, "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; } diff --git a/ge/graph/passes/hccl_memcpy_pass.cc b/ge/graph/passes/hccl_memcpy_pass.cc index 125780fa..d56ee342 100755 --- a/ge/graph/passes/hccl_memcpy_pass.cc +++ b/ge/graph/passes/hccl_memcpy_pass.cc @@ -42,13 +42,14 @@ Status HcclMemcpyPass::Run(ge::ComputeGraphPtr graph) { if (op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "Node with nullptr op_desc exist in Param graph:%s, check invalid", 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; } Status ret = MutableInputProcess(graph, node); 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; } } @@ -80,7 +81,8 @@ Status HcclMemcpyPass::MutableInputProcess(const ComputeGraphPtr &graph, const N if (IsDataNode(src_out_anchor->GetOwnerNode()->GetType())) { Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); 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; } } @@ -89,7 +91,8 @@ Status HcclMemcpyPass::MutableInputProcess(const ComputeGraphPtr &graph, const N Status ret = ModifyEdgeConnection(graph, src_out_anchor, hccl_in_anchor); 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; } } @@ -112,7 +115,7 @@ NodePtr HcclMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &graph, const O OpDescPtr pre_op_desc = pre_node->GetOpDesc(); if (pre_op_desc == nullptr) { 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; } @@ -131,7 +134,8 @@ NodePtr HcclMemcpyPass::CreateIdentityNode(const ComputeGraphPtr &graph, const O if (identity_node == nullptr) { 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()); - 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 identity_node; @@ -168,7 +172,7 @@ Status HcclMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &graph, const Status ret = InsertIdentityBeforeHccl(graph, src_out_anchor, hccl_in_anchor); 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(), hccl_in_anchor->GetOwnerNode()->GetName().c_str()); return ret; @@ -176,7 +180,7 @@ Status HcclMemcpyPass::ModifyEdgeConnection(const ComputeGraphPtr &graph, const ret = InsertAssignAfterBroadcastIfNeed(graph, src_out_anchor, hccl_in_anchor); 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(), hccl_in_anchor->GetOwnerNode()->GetName().c_str()); return ret; @@ -200,13 +204,12 @@ Status HcclMemcpyPass::InsertIdentityBeforeHccl(const ComputeGraphPtr &graph, co auto ret = GraphUtils::InsertNodeBefore(hccl_in_anchor, identity_node, kAnchorIdentityIndex, kAnchorIdentityIndex); 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(), hccl_in_anchor->GetOwnerNode()->GetName().c_str(), hccl_in_anchor->GetOwnerNode()->GetType().c_str(), 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(), hccl_in_anchor->GetOwnerNode()->GetName().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)); 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()->GetType().c_str(), hccl_out_anchor->GetIdx(), assign_node->GetName().c_str(), assign_node->GetType().c_str(), 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; } ret = var_out_anchor->LinkTo(assign_node->GetInDataAnchor(kAnchorAssignRefIndex)); 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()->GetType().c_str(), var_out_anchor->GetIdx(), assign_node->GetName().c_str(), assign_node->GetType().c_str(), 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; } @@ -295,9 +302,13 @@ Status HcclMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeGraphPtr &g in_data_anchor->GetOwnerNode()->GetName().c_str(), in_data_anchor->GetOwnerNode()->GetType().c_str(), 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(), - 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; } } @@ -313,9 +324,11 @@ Status HcclMemcpyPass::InsertAssignAfterBroadcastIfNeed(const ComputeGraphPtr &g assign_out_control_anchor->GetOwnerNode()->GetType().c_str(), in_control_anchor->GetOwnerNode()->GetName().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(), - 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; } } @@ -334,7 +347,7 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out OpDescPtr pre_op_desc = pre_node->GetOpDesc(); if (pre_op_desc == nullptr) { 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; } @@ -343,7 +356,7 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out OpDescPtr op_desc = MakeShared(node_name.c_str(), ASSIGN); if (op_desc == nullptr) { 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; } 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) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:ref", 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; } @@ -360,7 +374,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:value", 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; } @@ -368,7 +383,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed, name:ref", 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; } @@ -376,7 +392,8 @@ NodePtr HcclMemcpyPass::CreateAssignNode(const ComputeGraphPtr &graph, const Out if (assign_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - GELOGE(INTERNAL_ERROR, "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; } diff --git a/ge/graph/passes/hccl_tailing_optimization_pass.cc b/ge/graph/passes/hccl_tailing_optimization_pass.cc index a1bdb2d1..e1e2f276 100644 --- a/ge/graph/passes/hccl_tailing_optimization_pass.cc +++ b/ge/graph/passes/hccl_tailing_optimization_pass.cc @@ -61,9 +61,10 @@ Status HcclTailingOptimizationPass::CopyControlEdgesForTransOp(NodePtr &first_tr for (auto &src_out_ctrl_anchor : src_out_ctrl_anchors) { 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()); } } diff --git a/ge/graph/passes/identity_pass.cc b/ge/graph/passes/identity_pass.cc index 461b126a..f0653983 100755 --- a/ge/graph/passes/identity_pass.cc +++ b/ge/graph/passes/identity_pass.cc @@ -54,7 +54,7 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { } 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); if (need_skip) { GELOGD("skip identity %s connected to switch", node->GetName().c_str()); @@ -76,7 +76,7 @@ Status CheckIdentityUsable(const NodePtr &node, bool &usable) { return SUCCESS; } 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)) { GELOGD("skip identity %s connected to merge", node->GetName().c_str()); break; @@ -99,9 +99,8 @@ Status IdentityPass::Run(NodePtr &node) { string type; Status status_ret = GetOriginalType(node, type); if (status_ret != SUCCESS) { - REPORT_CALL_ERROR("E19999", "Get original type for node:%s failed", - node->GetName().c_str()); - GELOGE(status_ret, "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; } 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, " "check invalid", node->GetOpDesc()->GetInputsSize(), 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; } std::vector io_map; diff --git a/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc index cb649240..b74d1c97 100755 --- a/ge/graph/passes/infershape_pass.cc +++ b/ge/graph/passes/infershape_pass.cc @@ -86,14 +86,15 @@ Status InferShapePass::Run(NodePtr &node) { auto root_graph = ge::GraphUtils::FindRootGraph(graph); GE_CHECK_NOTNULL(root_graph); 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()->SaveAnalyzerDataToFile(root_graph->GetSessionID(), root_graph->GetGraphID()); 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()); - 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; } @@ -120,7 +121,7 @@ Status InferShapePass::RePassLoopNode(const NodePtr &node) { for (auto &n : node->GetOutDataNodes()) { GE_CHECK_NOTNULL(n); 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) { AddImmediateRePassNode(n); (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()) { GE_CHECK_NOTNULL(n); 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) { proc_func(this, n); 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; - 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) { return RePassNode(kMergeOpTypes); // Re-Pass Merge } diff --git a/ge/graph/passes/inplace_support_check_pass.cc b/ge/graph/passes/inplace_support_check_pass.cc index abdb4001..4d11f9b0 100644 --- a/ge/graph/passes/inplace_support_check_pass.cc +++ b/ge/graph/passes/inplace_support_check_pass.cc @@ -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", INPLACE_SUPPORT_INPUT_INDEX.c_str(), kInplaceSupportOutputIndex, 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; } AddRePassNode(node); diff --git a/ge/graph/passes/input_output_connection_identify_pass.cc b/ge/graph/passes/input_output_connection_identify_pass.cc index e27c2e1f..5779fb41 100644 --- a/ge/graph/passes/input_output_connection_identify_pass.cc +++ b/ge/graph/passes/input_output_connection_identify_pass.cc @@ -43,7 +43,8 @@ inline bool IsDataOp(const std::string &node_type) { Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) { if (graph == nullptr) { 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; } @@ -55,16 +56,14 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) { GELOGD("Start to identify nodes that connect to input and output."); 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; } 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; } @@ -77,7 +76,7 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) { 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); 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; } } @@ -86,7 +85,7 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) { 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); 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; } } @@ -94,7 +93,7 @@ Status InputOutputConnectionIdentifyPass::Run(ComputeGraphPtr graph) { status = SetNodeAttrOfConnectingInputOutput(connect_input_node_idx_map, connect_output_node_idx_map); 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; } @@ -118,7 +117,7 @@ Status InputOutputConnectionIdentifyPass::ProcessInputNode(const NodePtr &node, const string &symbol = anchor_iter->second; auto status = UpdateNodeIdxMap(symbol, connect_input_node_idx, connect_output_node_idx); 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; } } @@ -132,7 +131,7 @@ Status InputOutputConnectionIdentifyPass::UpdateNodeIdxMap(const string &symbol_ if (symbol_iter == symbol_to_anchors_.end()) { REPORT_CALL_ERROR("E19999", "Can't find symbol:%s in symbol_to_anchors map, check invalid", 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; } 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; auto status = UpdateNodeIdxMap(symbol, connect_input_node_idx, connect_output_node_idx); 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; } } @@ -178,11 +177,10 @@ Status InputOutputConnectionIdentifyPass::SetNodeAttrOfConnectingInputOutput( GE_CHECK_NOTNULL(iter.first); if (iter.first->GetOpDesc() != nullptr) { 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()); - 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; } } @@ -192,11 +190,10 @@ Status InputOutputConnectionIdentifyPass::SetNodeAttrOfConnectingInputOutput( GE_CHECK_NOTNULL(iter.first); if (iter.first->GetOpDesc() != nullptr) { 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()); - 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; } } diff --git a/ge/graph/passes/iterator_op_pass.cc b/ge/graph/passes/iterator_op_pass.cc index d0cb434b..3e85887b 100644 --- a/ge/graph/passes/iterator_op_pass.cc +++ b/ge/graph/passes/iterator_op_pass.cc @@ -59,7 +59,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { if (status != ge::SUCCESS) { REPORT_CALL_ERROR("E19999", "Set cycle event to op:%s(%s) failed", 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; } @@ -68,7 +69,9 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { 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->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; } @@ -76,7 +79,8 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { if (status != ge::SUCCESS) { 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()); - 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; } @@ -99,7 +103,10 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { ret = SetRtContext(graph->GetSessionID(), graph->GetGraphID(), rtContext_t(), RT_CTX_GEN_MODE); // 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."); continue); @@ -113,7 +120,9 @@ Status IteratorOpPass::Run(ge::ComputeGraphPtr graph) { 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->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; } GELOGI("Insert EndOfSequence node success."); @@ -134,9 +143,8 @@ Status IteratorOpPass::GetVariableValue(uint64_t session_id, const ge::GeTensorD uint8_t *dev_ptr = nullptr; auto status = VarManager::Instance(session_id)->GetVarAddr(var_name, tensor_desc, &dev_ptr); 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; } int64_t offset = static_cast(reinterpret_cast(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_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_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 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(), end_of_seq_node->GetName().c_str(), end_of_seq_node->GetType().c_str()); 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 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); @@ -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(), out_node->GetName().c_str(), out_node->GetType().c_str()); 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.", out_node->GetName().c_str()); } @@ -212,26 +224,26 @@ ge::OpDescPtr IteratorOpPass::CreateEndOfSequenceOp(const ge::NodePtr &pre_node) GELOGI("Start to create endOfSequence op."); GE_CHK_BOOL_EXEC(pre_node != nullptr, 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"; ge::OpDescPtr op_desc = MakeShared(node_name, ENDOFSEQUENCE); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "MakeShared fail."); + GELOGE(FAILED, "[New][OpDesc] failed."); return op_desc; } ge::OpDescPtr pre_node_op_desc = pre_node->GetOpDesc(); GE_CHK_BOOL_EXEC(pre_node_op_desc != nullptr, 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()); 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", op_desc->GetName().c_str(), op_desc->GetType().c_str()); 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; } @@ -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", memcpy_async_op_desc->GetName().c_str(), memcpy_async_op_desc->GetType().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 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); status = GraphUtils::RemoveEdge(out_anchor, peer_in_anchor); 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); 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, - "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(), peer_in_anchor->GetIdx(), peer_in_anchor->GetOwnerNode()->GetName().c_str()); } status = GraphUtils::AddEdge(out_anchor, memcpy_async_node->GetInDataAnchor(out_anchor->GetIdx())); 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()); } // 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()) { ge::graphStatus status = GraphUtils::RemoveEdge(out_ctrl_anchor, peer_in_ctrl_anchor); 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); 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, - "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.", 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(node_name.c_str(), MEMCPYASYNC); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "MakeShared fail."); + GELOGE(FAILED, "[New][OpDesc] failed"); return op_desc; } 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_CHK_BOOL_EXEC(pre_node_op_desc != nullptr, 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(); 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", pre_node_op_desc->GetName().c_str(), pre_node_op_desc->GetType().c_str()); 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, 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()); 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; diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc index e00ede45..522c20ad 100755 --- a/ge/graph/passes/link_gen_mask_nodes_pass.cc +++ b/ge/graph/passes/link_gen_mask_nodes_pass.cc @@ -46,7 +46,7 @@ Status LinkGenMaskNodesPass::Run(ComputeGraphPtr graph) { size_t gen_mask_group_size = gen_mask_nodes.size(); Status status = GetGenMaskGroupSize(gen_mask_nodes, gen_mask_group_size); if (status != SUCCESS) { - GELOGE(FAILED, "Get GenMask group size failed."); + GELOGE(FAILED, "[Get][GenMaskGroupSize] 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", src_node->GetName().c_str(), src_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; } 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 &gen_mask_nodes) const { set nodes_set; 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; } diff --git a/ge/graph/passes/mark_agnostic_pass.cc b/ge/graph/passes/mark_agnostic_pass.cc index 4c489bbe..7798be5b 100644 --- a/ge/graph/passes/mark_agnostic_pass.cc +++ b/ge/graph/passes/mark_agnostic_pass.cc @@ -68,7 +68,7 @@ Status MarkAgnosticPass::Run(ComputeGraphPtr graph) { // Set attr for enter and nextiteration 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; } continue; diff --git a/ge/graph/passes/mark_force_unknown_for_cond_pass.cc b/ge/graph/passes/mark_force_unknown_for_cond_pass.cc index f6c87d58..08b358ee 100644 --- a/ge/graph/passes/mark_force_unknown_for_cond_pass.cc +++ b/ge/graph/passes/mark_force_unknown_for_cond_pass.cc @@ -45,7 +45,8 @@ Status MarkForceUnknownForCondPass::Run(ComputeGraphPtr graph) { std::map> switch_groups; for (const auto &node : graph->GetDirectNode()) { 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) { continue; } diff --git a/ge/graph/passes/mark_graph_unknown_status_pass.cc b/ge/graph/passes/mark_graph_unknown_status_pass.cc index 6aab5478..2d7b179b 100644 --- a/ge/graph/passes/mark_graph_unknown_status_pass.cc +++ b/ge/graph/passes/mark_graph_unknown_status_pass.cc @@ -29,7 +29,7 @@ Status MarkGraphUnknownStatusPass::Run(ComputeGraphPtr graph) { bool forced_unknown = false; for (const auto &node : graph->GetDirectNode()) { 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) { break; } diff --git a/ge/graph/passes/memcpy_addr_async_pass.cc b/ge/graph/passes/memcpy_addr_async_pass.cc index e8e4ebd8..d6962ad8 100755 --- a/ge/graph/passes/memcpy_addr_async_pass.cc +++ b/ge/graph/passes/memcpy_addr_async_pass.cc @@ -30,7 +30,9 @@ Status MemcpyAddrAsyncPass::Run(ComputeGraphPtr graph) { if (node->GetType() == STREAMSWITCH) { auto sub_graph = node->GetOwnerComputeGraph(); 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; rtError_t rt_ret = rtGetRtCapability(FEATURE_TYPE_MEMCPY, MEMCPY_INFO_SUPPORT_ZEROCOPY, &value); 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; } + if (value == RT_CAPABILITY_NOT_SUPPORT) { + GELOGW("Not support zero copy, skip it."); + return SUCCESS; + } + for (auto &node : graph->GetAllNodes()) { auto op_desc = node->GetOpDesc(); 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) { Status ret = AddMemcpyAddrAsyncNode(graph, node); 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; } } @@ -64,7 +71,8 @@ Status MemcpyAddrAsyncPass::Run(ComputeGraphPtr graph) { if (node->GetOwnerComputeGraph()->GetParentNode() == nullptr) { Status ret = InsertMemAddrAsyncNodeBeforeNetoutput(node->GetOwnerComputeGraph(), node); 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; } } @@ -83,12 +91,13 @@ Status MemcpyAddrAsyncPass::AddMemcpyAsyncNode(const NodePtr &node) { GE_IF_BOOL_EXEC(peer_out_anchor == nullptr, continue); auto memcpy_async_node = CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor, node); 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; } Status ret = InsertMemcpyAddrAsyncNode(peer_out_anchor, in_data_anchor, memcpy_async_node); 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; } } @@ -109,18 +118,23 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph, if (owner_graph->GetParentGraph() == nullptr) { GELOGI("Need to insert MemcpyAddrAsync directly when data in parent graph."); 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); 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 { uint32_t parent_index = 0; 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()); - 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; } // Data is in sub_graph @@ -136,11 +150,15 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph, GE_CHECK_NOTNULL(peer_out_anchor_); NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(graph, peer_out_anchor_, out_of_user_data_); 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); 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_) { GELOGI("Insert memcpy_addr_async for known graph."); @@ -148,12 +166,17 @@ Status MemcpyAddrAsyncPass::AddMemcpyAddrAsyncNode(const ComputeGraphPtr &graph, NodePtr memcpy_addr_async_node = CreateMemcpyAddrAsyncNode(sub_graph, peer_out_anchor_for_known_, out_of_user_data_for_known_); 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); Status ret = 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(); GE_IF_BOOL_EXEC(out_anchor == nullptr, 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); NodePtr in_node = out_anchor->GetOwnerNode(); 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; NodePtr pre_in_node = in_node->GetOwnerComputeGraph()->GetParentNode(); 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()); - 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; } 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) { 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()); - 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; } FindUserData(in_node, parent_index); @@ -253,7 +276,7 @@ NodePtr MemcpyAddrAsyncPass::CreateMemcpyAddrAsyncNode(const ComputeGraphPtr &gr OpDescPtr pre_op_desc = out_data_anchor->GetOwnerNode()->GetOpDesc(); GE_CHK_BOOL_EXEC(pre_op_desc != nullptr, 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; 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++); op_desc = MakeShared(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) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", 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; } 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", 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; } @@ -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); if (labeled_input) { 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()); - 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; } 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()); - 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; } } @@ -330,29 +351,30 @@ Status MemcpyAddrAsyncPass::InsertMemcpyAddrAsyncNode(const OutDataAnchorPtr &ou 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", 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; } 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->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; } 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 SUCCESS; @@ -376,11 +398,16 @@ Status MemcpyAddrAsyncPass::InsertMemAddrAsyncNodeBeforeNetoutput(const ComputeG } GELOGI("Need to insert MemcpyAddrAsync before netoutput on parent graph."); 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); 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(), 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. diff --git a/ge/graph/passes/merge_input_memcpy_pass.cc b/ge/graph/passes/merge_input_memcpy_pass.cc index c4273584..00c04131 100644 --- a/ge/graph/passes/merge_input_memcpy_pass.cc +++ b/ge/graph/passes/merge_input_memcpy_pass.cc @@ -26,14 +26,16 @@ Status MergeInputMemcpyPass::Run(ComputeGraphPtr graph) { std::unordered_map> switch_groups; for (const auto &node : graph->GetDirectNode()) { 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)) { continue; } GE_CHECK_NOTNULL(node->GetOpDesc()); 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"); @@ -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()); 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), - "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)), - "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), - "MemcpyAsync node add edge failed."); + "[Add][Edge] between %s and %s failed.", memcpy_node->GetName().c_str(), + node->GetName().c_str()); } return SUCCESS; @@ -83,25 +89,30 @@ Status MergeInputMemcpyPass::AddMemcpyAsyncNodes(const ComputeGraphPtr &graph, c NodePtr MergeInputMemcpyPass::CreateMemcpyAsyncNode(const ComputeGraphPtr &graph, const std::string &name, const OutDataAnchorPtr &out_data_anchor, bool multi_batch_flag) { 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 &node_name = name + "_" + memcpy_type; GELOGI("Create MemcpyAsync op:%s.", node_name.c_str()); OpDescPtr op_desc = MakeShared(node_name, memcpy_type); 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; } 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", 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, REPORT_CALL_ERROR("E19999", "Add output to op:%s(%s) failed", 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); } diff --git a/ge/graph/passes/merge_pass.cc b/ge/graph/passes/merge_pass.cc index 3206efa9..fec9c6d0 100644 --- a/ge/graph/passes/merge_pass.cc +++ b/ge/graph/passes/merge_pass.cc @@ -36,12 +36,12 @@ Status MergePass::Run(NodePtr &node) { GELOGD("MergePass running"); if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "param [node] must not be null."); + GELOGE(PARAM_INVALID, "[Check][Param] param [node] must not be null."); return PARAM_INVALID; } 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) { return SUCCESS; } @@ -49,7 +49,8 @@ Status MergePass::Run(NodePtr &node) { if (node->GetAllOutDataAnchors().empty()) { REPORT_INNER_ERROR("E19999", "Param node:%s(%s) all data anchor size is 0, check invalid", 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; } @@ -75,7 +76,7 @@ Status MergePass::Run(NodePtr &node) { if (merge_io_map[0] != -1 && IsNeedChangeIndexToConstant(node)) { int index = merge_io_map[0]; 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; } } @@ -84,7 +85,7 @@ Status MergePass::Run(NodePtr &node) { if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", in_node->GetName().c_str(), in_node->GetType().c_str()); - GELOGE(FAILED, "Isolate and delete node %s failed.", in_node->GetName().c_str()); + GELOGE(FAILED, "[Remove][Node] %s failed.", in_node->GetName().c_str()); return FAILED; } } @@ -122,7 +123,8 @@ Status MergePass::ChangeIndexToConstant(NodePtr &node, int &value_index) { if (graph == nullptr) { REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid", node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str()); + GELOGE(FAILED, "[Get][ComputeGraph] failed, Owner graph of node:%s(%s) is nullptr.", + node->GetName().c_str(), node->GetType().c_str()); 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", node->GetName().c_str(), 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; } auto out_control_anchor = node->GetOutControlAnchor(); @@ -165,7 +169,7 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr & op_desc = MakeShared(constant_name, CONSTANT); if (op_desc == nullptr) { 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; } @@ -173,7 +177,7 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr & OpDescPtr original_op_desc = node->GetOpDesc(); if (original_op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); - GELOGE(FAILED, "[%s] Op desc must not be null.", constant_name.c_str()); + GELOGE(FAILED, "[Get][OpDesc] failed, Op desc must not be null."); return FAILED; } GeTensorDesc original_out_tensor_desc = original_op_desc->GetOutputDesc(1); @@ -184,18 +188,21 @@ Status MergePass::CreateConstByValue(NodePtr &node, int value_index, OpDescPtr & MakeShared(original_out_tensor_desc, reinterpret_cast(&value_index), sizeof(int)); if (const_tensor_ptr == nullptr) { 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; } 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()); - 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 - 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; } diff --git a/ge/graph/passes/merge_to_stream_merge_pass.cc b/ge/graph/passes/merge_to_stream_merge_pass.cc index 4c1ad1ae..0b383911 100644 --- a/ge/graph/passes/merge_to_stream_merge_pass.cc +++ b/ge/graph/passes/merge_to_stream_merge_pass.cc @@ -26,7 +26,8 @@ Status MergeToStreamMergePass::Run(ComputeGraphPtr graph) { bypass_nodes_.clear(); for (const auto &node : graph->GetDirectNode()) { 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)) { continue; } @@ -39,21 +40,24 @@ Status MergeToStreamMergePass::Run(ComputeGraphPtr graph) { if (status != ge::SUCCESS) { 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()); - 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; } } 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_) { GE_CHK_BOOL_EXEC(GraphUtils::RemoveNodeWithoutRelink(graph, node) == GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", - node->GetName().c_str(), - node->GetType().c_str(), graph->GetName().c_str()); + node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); 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"); @@ -83,7 +87,7 @@ Status MergeToStreamMergePass::ReplaceMergeNode(const ComputeGraphPtr &graph, co Status MergeToStreamMergePass::AddActiveNodes(const ComputeGraphPtr &graph, const NodePtr &node) { GE_CHK_BOOL_EXEC(node != nullptr, 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; bool force_unknown = AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_CONTROL_FLOW_GROUP, 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), continue); 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()), - "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) { - 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; } 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()); OpDescPtr op_desc = MakeShared(node_name, STREAMACTIVE); 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; } @@ -129,15 +135,20 @@ NodePtr MergeToStreamMergePass::CreateActiveNode(const ComputeGraphPtr &graph, c GE_CHK_BOOL_EXEC(active_node != nullptr, REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - return nullptr, "Create StreamActive node failed."); + 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, REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "add edge failed"); + GELOGE(INTERNAL_ERROR, "[Add][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); 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 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_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())), - "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 InDataAnchorPtr &peer_in_anchor : out_data_anchor->GetPeerInDataAnchors()) { 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), - "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()) { 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()), - "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()) { 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()), - "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; diff --git a/ge/graph/passes/multi_batch_clone_pass.cc b/ge/graph/passes/multi_batch_clone_pass.cc index 8fc25f9d..d36b4186 100755 --- a/ge/graph/passes/multi_batch_clone_pass.cc +++ b/ge/graph/passes/multi_batch_clone_pass.cc @@ -55,7 +55,7 @@ inline bool IsGetNextType(const NodePtr &node) { Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { GE_IF_BOOL_EXEC(graph == nullptr, 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) { GELOGD("Subgraph %s skip the MultiBatchClonePass", graph->GetName().c_str()); return SUCCESS; @@ -68,15 +68,16 @@ Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { std::vector getnext_nosink_nodes; std::vector getnext_sink_nodes; 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; } 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; } 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; } if (!multibatch::InitDynamicParams(batch_shapes_)) { @@ -84,37 +85,38 @@ Status MultiBatchClonePass::Run(ComputeGraphPtr graph) { return 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; } 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) { - GELOGE(INTERNAL_ERROR, "Collect input output nodes failed"); + GELOGE(INTERNAL_ERROR, "[Collect][IoNodes] failed, graph:%s", graph->GetName().c_str()); return INTERNAL_ERROR; } // parser data dynamic info from atc parameter --input_shape if (CheckAndParseDynamicData() != SUCCESS) { - GELOGE(PARAM_INVALID, "Parse each data's own dynamic info failed"); + GELOGE(PARAM_INVALID, "[CheckAndParse][DynamicData] failed"); return PARAM_INVALID; } (void)AttrUtils::GetStr(graph, ATTR_NAME_SESSION_GRAPH_ID, session_graph_id_); ComputeGraphPtr branch = MakeShared(graph->GetName()); 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_); graph->InValid(); // Will modify, need topological again. 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"); return SUCCESS; } @@ -129,7 +131,7 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) { for (const auto &node : graph->GetDirectNode()) { if (!GetLocalOmgContext().dynamic_node_type.empty() && IsGetNextType(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) { 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) { REPORT_INNER_ERROR("E19999", "Data node num is 0 or output node num != 1, graph:%s, check invalid", 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; } @@ -172,9 +174,10 @@ Status MultiBatchClonePass::CollectIoNodes(const ComputeGraphPtr &graph) { const auto data_node = out_anchor->GetOwnerNode(); if (data_node->GetType() == DATA) { 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.", @@ -208,16 +211,18 @@ Status MultiBatchClonePass::CheckAndParseDynamicData() { if (iter == data_name_order.end()) { if (!GetLocalOmgContext().dynamic_batch_size.empty()) { 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()) { 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()) { - 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()); return INTERNAL_ERROR; } @@ -226,11 +231,11 @@ Status MultiBatchClonePass::CheckAndParseDynamicData() { } } 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) { 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 SUCCESS; @@ -288,7 +293,7 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { const OpDescPtr op_desc = op_builder.Build(); if (op_desc == nullptr) { 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; } @@ -297,7 +302,8 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { if (case_node_ == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - GELOGE(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; } @@ -305,7 +311,8 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { 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(), 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; } @@ -314,7 +321,8 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { 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(), 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; } } @@ -326,22 +334,25 @@ Status MultiBatchClonePass::CreateRootGraph(const ComputeGraphPtr &graph) { 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(), 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; } 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(), 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; } - 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; } @@ -357,7 +368,7 @@ Status MultiBatchClonePass::CreateIndexDataNode(const ComputeGraphPtr &graph, No const OpDescPtr data_desc = MakeShared(kMultiBatchDataNode, DATA); if (data_desc == nullptr) { 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; } @@ -365,13 +376,15 @@ Status MultiBatchClonePass::CreateIndexDataNode(const ComputeGraphPtr &graph, No if (data_desc->AddInputDesc(data_tensor) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", 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; } if (data_desc->AddOutputDesc(data_tensor) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed", 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; } @@ -384,7 +397,8 @@ Status MultiBatchClonePass::CreateIndexDataNode(const ComputeGraphPtr &graph, No if (shape_node == nullptr) { 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()); - 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; } @@ -402,7 +416,7 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N const OpDescPtr const_desc = MakeShared(kMultiBatchConstNode, CONSTANT); if (const_desc == nullptr) { 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; } @@ -423,14 +437,16 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N 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(), 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; } if (const_desc->AddOutputDesc(const_tensor) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed", 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; } @@ -438,7 +454,8 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N if (node == nullptr) { 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()); - 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; } @@ -454,13 +471,16 @@ Status MultiBatchClonePass::CreateIndexConstNode(const ComputeGraphPtr &graph, N Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) { // Data/GetDynamicDims --> MapIndex --> Case 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 { - 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; - 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(), shape_node_->GetType().c_str(), const_node->GetName().c_str()); OpDescBuilder op_builder(kMultiBatchMapIndexNode, "MapIndex"); @@ -471,32 +491,34 @@ Status MultiBatchClonePass::CreateIndexNode(const ComputeGraphPtr &graph) { const OpDescPtr op_desc = op_builder.Build(); if (op_desc == nullptr) { 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; } NodePtr index_node = graph->AddNode(op_desc); if (index_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - GELOGE(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; } - 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()); 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", shape_node_->GetName().c_str(), shape_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; } 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", const_node->GetName().c_str(), const_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()); 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", index_node->GetName().c_str(), index_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; } @@ -516,7 +539,7 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap const OpDescPtr data_desc = MakeShared(kMultiBatchGetDynamicDimsNode, GETDYNAMICDIMS); if (data_desc == nullptr) { 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; } @@ -532,7 +555,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", 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); continue; } @@ -541,7 +565,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap GE_IF_BOOL_EXEC(ret != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", 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); } GeTensorDesc tensor_desc(GeShape({static_cast(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, REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", 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); (void)AttrUtils::SetBool(data_desc, ATTR_INSERT_BY_MBATCH, true); @@ -558,7 +584,8 @@ Status MultiBatchClonePass::CreateGetDynamicDimsNode(const ComputeGraphPtr &grap if (shape_node == nullptr) { 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()); - 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 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_)) { 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()); - 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; } vector 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)) { 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()); - 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 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", getnext_node->GetName().c_str(), getnext_node->GetType().c_str(), out_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 SUCCESS; @@ -623,7 +653,8 @@ Status MultiBatchClonePass::LinkGetDynamicDimsToNetOutput(const NodePtr &output_ 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(), 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; } } @@ -633,7 +664,8 @@ Status MultiBatchClonePass::LinkGetDynamicDimsToNetOutput(const NodePtr &output_ if (NodeUtils::AppendInputAnchor(output_node, input_index + 1) != GRAPH_SUCCESS) { 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); - 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; } 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", shape_node_->GetName().c_str(), shape_node_->GetType().c_str(), kDataOutIndex, 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); 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(), 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; } } @@ -674,13 +707,16 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) { if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed", 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; } if (GraphUtils::CopyTensorAttrs(op_desc, node) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed", 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; } @@ -690,7 +726,9 @@ Status MultiBatchClonePass::CreateInputNode(const ComputeGraphPtr &graph) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - return 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)) { getnext_node = data; 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", data->GetName().c_str(), data->GetType().c_str(), 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; } } 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; } all_data_nodes.emplace_back(data); } if (getnext_node != nullptr) { 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; } 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; } 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", 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); - 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; } } 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()); } return SUCCESS; @@ -771,7 +811,7 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed", 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; } @@ -779,6 +819,8 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { if (GraphUtils::CopyTensorAttrs(op_desc, node) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed", 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; } @@ -787,13 +829,16 @@ Status MultiBatchClonePass::CreateConstNode(const ComputeGraphPtr &graph) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - return 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) { 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(), 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; } all_const_nodes.emplace_back(data); @@ -842,13 +887,16 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "Copy op_desc from op:%s(%s) failed", 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; } if (GraphUtils::CopyTensorAttrs(op_desc, output) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Copy tensor attr from op:%s(%s) failed", 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; } @@ -858,7 +906,9 @@ Status MultiBatchClonePass::CreateOutputNode(const ComputeGraphPtr &graph) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - return 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) { 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", case_node_->GetName().c_str(), case_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; } } else { const auto data_node = graph->FindNode(it->second); if (data_node == nullptr) { 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; } 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", data_node->GetName().c_str(), data_node->GetType().c_str(), kDataOutIndex, 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; } } } - 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()); all_output_nodes_.clear(); 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()); if (!IsGetNextType(data)) { 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; } } else { for (size_t out_anchor_index = 0; out_anchor_index < data_count_from_getnext_; ++out_anchor_index) { 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; } } @@ -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 (getnext_sink_dynamic_dims_) { // 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; } @@ -947,7 +1002,8 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an if (!AttrUtils::SetStr(node->GetOpDesc(), kMbatchCaseName, case_node_->GetName())) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to node:%s(%s) failed", 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; } @@ -957,7 +1013,7 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an auto shape = data_shape; auto ret = multibatch::CalcShape(data_to_dynamic_info_.at(data_name).at(i), shape); 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; } tensor.SetShape(shape); @@ -979,7 +1035,7 @@ Status MultiBatchClonePass::SetMaxShapeToData(const NodePtr &node, size_t out_an if (INT64_MAX / dim < size) { 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()); - 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()); return PARAM_INVALID; } @@ -1006,7 +1062,7 @@ Status MultiBatchClonePass::SetShapeToData(const std::vector &shapes, c size_t out_anchor_index) { GELOGD("Start set shape to %zu out of %s.", out_anchor_index, data->GetName().c_str()); 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()); return INTERNAL_ERROR; } @@ -1014,20 +1070,24 @@ Status MultiBatchClonePass::SetShapeToData(const std::vector &shapes, c 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", 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; } if (!IsGetNextType(data)) { if (NodeUtils::UpdateInputShape(*data, kDataInIndex, data_shape) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Update input desc shape to op:%s(%s) failed, index:%u", 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; } } else { if (getnext_sink_dynamic_dims_) { // 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) { REPORT_CALL_ERROR("E19999", "Update ouput desc to op:%s(%s) failed, index:%zu", 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 SUCCESS; @@ -1066,7 +1127,8 @@ Status MultiBatchClonePass::UpdateSubgraphData(const NodePtr &data, size_t batch 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(), 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; } @@ -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)) { 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()); - 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; } @@ -1092,8 +1155,8 @@ Status MultiBatchClonePass::UpdateSubgraphData(const NodePtr &data, size_t batch if (pos == string::npos) { 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()); - 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; } @@ -1116,7 +1179,7 @@ Status MultiBatchClonePass::CreateOriGraph(const ComputeGraphPtr &graph) { NodePtr data_node = CreateDataNode(graph, out_data_anchor, data_index); GE_IF_BOOL_EXEC(data_node == nullptr, 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); for (auto &in_anchor : out_data_anchor->GetPeerInDataAnchors()) { 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", node->GetName().c_str(), node->GetType().c_str(), out_index, 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; } 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", data_node->GetName().c_str(), data_node->GetType().c_str(), 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; } } @@ -1143,7 +1208,8 @@ Status MultiBatchClonePass::CreateOriGraph(const ComputeGraphPtr &graph) { if (graph->RemoveNode(node) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", 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; } break; @@ -1159,7 +1225,7 @@ NodePtr MultiBatchClonePass::CreateDataNode(const ComputeGraphPtr &graph, const OpDescPtr op_desc = MakeShared(node_name, DATA); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(OUT_OF_MEMORY, "Create data node failed."); + GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed."); return nullptr; } (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(); if (getnext_op_desc == nullptr) { 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; } 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", 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; } 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", 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; } 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); GE_IF_BOOL_EXEC(subgraph == nullptr, 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->SetParentNode(case_node_); 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()); 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(); op_desc->SetName(n->GetName() + kMultiBatchNodePostfix + "0"); 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", ATTR_NAME_PARENT_NODE_INDEX.c_str(), index, 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; } } @@ -1286,16 +1360,20 @@ Status MultiBatchClonePass::PruneDirectOutput(const ComputeGraphPtr &graph) { 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) { 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_) { - 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; @@ -1325,11 +1403,17 @@ Status MultiBatchClonePass::UpdateOutputTensor(uint32_t parent_index, uint32_t u const auto &op_desc = node->GetOpDesc(); (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", 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()); } @@ -1337,10 +1421,16 @@ Status MultiBatchClonePass::UpdateOutputTensor(uint32_t parent_index, uint32_t u const auto &old_anchor = case_node_->GetOutDataAnchor(parent_index); for (const auto in_anchor : old_anchor->GetPeerInDataAnchors()) { 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()); - 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", case_node_->GetName().c_str(), in_node->GetName().c_str(), parent_index, update_index); } diff --git a/ge/graph/passes/multi_batch_pass.cc b/ge/graph/passes/multi_batch_pass.cc index 2c654801..25d629fa 100644 --- a/ge/graph/passes/multi_batch_pass.cc +++ b/ge/graph/passes/multi_batch_pass.cc @@ -38,22 +38,22 @@ Status MultiBatchPass::Run(ComputeGraphPtr graph) { return SUCCESS; } if (ret != SUCCESS) { - GELOGE(FAILED, "FindPredValue failed."); + GELOGE(FAILED, "[Find][PredValue] in graph:%s failed.", graph->GetName().c_str()); return FAILED; } if (GetDynamicType() != SUCCESS) { - GELOGE(FAILED, "Get dynamic type failed."); + GELOGE(FAILED, "[Get][DynamicType] in graph:%s failed.", graph->GetName().c_str()); return FAILED; } if (GetUserDesignateShape() != SUCCESS) { - GELOGE(FAILED, "Get user designate shape failed."); + GELOGE(FAILED, "[Get][UserDesignateShape] in graph:%s failed.", graph->GetName().c_str()); return FAILED; } std::vector> batch_shape; std::vector> 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; } @@ -62,12 +62,13 @@ Status MultiBatchPass::Run(ComputeGraphPtr graph) { } 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; } 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; } @@ -75,7 +76,8 @@ Status MultiBatchPass::Run(ComputeGraphPtr graph) { if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); - GELOGE(FAILED, "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; } } @@ -133,7 +135,9 @@ Status MultiBatchPass::SetCaseLabel(const ComputeGraphPtr &graph, const NodePtr Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchorPtr &pred_value) { for (const NodePtr &node : graph->GetDirectNode()) { 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; } if (node->GetType() != SWITCHN) { @@ -144,14 +148,16 @@ Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchor if (in_data_anchor == nullptr) { 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()); - 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; } const auto &pred_input = in_data_anchor->GetPeerOutAnchor(); if (pred_input == nullptr) { 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()); - 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; } @@ -160,7 +166,7 @@ Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchor } else if (pred_value != pred_input) { REPORT_INNER_ERROR("E19999", "Multi pred_value of case node exist in graph:%s, check invalid", 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; } switch_n_nodes_.emplace_back(node); @@ -173,7 +179,7 @@ Status MultiBatchPass::FindPredValue(const ComputeGraphPtr &graph, OutDataAnchor if (pred_value == nullptr) { 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; } @@ -191,13 +197,15 @@ Status MultiBatchPass::GetDynamicType() { 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(), 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; } if (dynamic_type == static_cast(FIXED)) { 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); - 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; } if (dynamic_type_ != static_cast(FIXED) && dynamic_type_ != dynamic_type) { @@ -205,7 +213,8 @@ Status MultiBatchPass::GetDynamicType() { "check invalid", ATTR_DYNAMIC_TYPE.c_str(), switch_n->GetName().c_str(), switch_n->GetType().c_str(), 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_); return FAILED; } @@ -213,7 +222,7 @@ Status MultiBatchPass::GetDynamicType() { } if (dynamic_type_ == static_cast(FIXED)) { 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; } @@ -232,7 +241,8 @@ Status MultiBatchPass::GetUserDesignateShape() { 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(), 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; } if (first_check) { @@ -245,15 +255,16 @@ Status MultiBatchPass::GetUserDesignateShape() { 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()); - 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; } } } if (data_name_order_.empty()) { 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; } @@ -277,24 +288,25 @@ bool MultiBatchPass::CheckSwitchN(std::vector> &batch_shape } 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, " "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; } } 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; } if (batch_shape.empty()) { 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; } if (combined_batch.empty()) { 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; } size_t dim_num = batch_shape[0].size(); @@ -304,14 +316,15 @@ bool MultiBatchPass::CheckSwitchN(std::vector> &batch_shape 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", 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; } size_t tmp_combined_dim_num = combined_batch[i].size(); 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", 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); return false; } @@ -339,7 +352,7 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vectorGetOpDesc(); if (op_desc == nullptr) { 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; } std::vector output_dims; @@ -347,7 +360,8 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vectorGetName().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; } idx_batch_shape.emplace_back(output_dims); @@ -356,7 +370,8 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vectorGetName().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; } idx_combined_batch.emplace_back(output_dims); @@ -364,7 +379,8 @@ bool MultiBatchPass::GetBatchInfo(uint32_t batch_num, std::vectorGetName().c_str(), node->GetType().c_str(), i, 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; } 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", out_node->GetName().c_str(), 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; } } @@ -438,29 +456,31 @@ Status MultiBatchPass::ReplaceSwitchN(const ComputeGraphPtr &graph, const OutDat 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); 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; } for (const NodePtr &switch_n_node : switch_n_nodes_) { 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; } } // Add switchCase input edge 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(), 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; } 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; } @@ -474,7 +494,7 @@ Status MultiBatchPass::ReplaceSwitchN(const ComputeGraphPtr &graph, const OutDat /// bool MultiBatchPass::CheckDims(const std::vector> &output_shape) const { if (output_shape.empty()) { - GELOGE(FAILED, "CheckDims failed: output_shape is empty."); + GELOGE(FAILED, "[Check][Param] output_shape is empty."); return false; } @@ -502,7 +522,7 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const OpDescPtr op_desc = MakeShared(name, STREAMSWITCHN); if (op_desc == nullptr) { 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; } @@ -510,13 +530,14 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const OpDescPtr pred_desc = pred_value->GetOwnerNode()->GetOpDesc(); if (pred_desc == nullptr) { 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; } if (op_desc->AddInputDesc(pred_desc->GetOutputDesc(pred_value->GetIdx())) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(FAILED, "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; } @@ -524,7 +545,8 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const if (switch_case_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - GELOGE(FAILED, "Create 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; } @@ -532,19 +554,22 @@ NodePtr MultiBatchPass::CreateSwitchCaseNode(const ComputeGraphPtr &graph, const 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(), 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; } 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(), 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; } 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(), 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; } 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])) { 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()); - 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; } 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])) { 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()); - 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; } } @@ -578,14 +605,16 @@ Status MultiBatchPass::BypassSwitchN(const NodePtr &switch_n_node, const NodePtr if (in_data_anchor == nullptr) { 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()); - 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; } OutDataAnchorPtr peer_data_anchor = in_data_anchor->GetPeerOutAnchor(); 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", 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; } 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", 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); - 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; } 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", data_input->GetName().c_str(), data_input->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; } @@ -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_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()); - 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; } 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", switch_case->GetName().c_str(), switch_case->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; } } } - 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); 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 stream_label_list; for (uint32_t i = 0; i < static_cast(batch_head_nodes_.size()); i++) { if (AttachBatchLabel(i) != SUCCESS) { - GELOGE(FAILED, "AttachBatchLabel failed, batch_idx=%u", i); + GELOGE(FAILED, "[Attach][BatchLabel] failed, batch_idx=%u", i); return FAILED; } const std::string &stream_label = "stream_label_batch_" + std::to_string(i); 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; } 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)) { 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()); - 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; } if (tmp_label != batch_label) { 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(), 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()); return FAILED; } @@ -708,7 +748,8 @@ Status MultiBatchPass::AttachBatchLabel(uint32_t batch_idx) { 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(), 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; } @@ -722,7 +763,7 @@ Status MultiBatchPass::AttachBatchLabel(uint32_t batch_idx) { if (type == NETOUTPUT) { 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()); - 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; } 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) { 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()); - 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; } @@ -786,16 +828,20 @@ Status MultiBatchPass::MoveCtrlEdges(const NodePtr &old_node, const NodePtr &new } for (const NodePtr &in_ctrl_node : old_node->GetInControlNodes()) { 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()), - "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()) { 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()), - "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; } diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index 2b27e003..30455fa0 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -50,13 +50,15 @@ Status NetOutputPass::GetRetvalOutputInfo(const ge::NodePtr &node, 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(), 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; } 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", 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; } 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); } if (ret != SUCCESS) { - GELOGE(ret, "GetRetvalOutputInfo failed"); + GELOGE(ret, "[Get][RetvalOutputInfo] for node:%s failed", node->GetName().c_str()); return ret; } } @@ -143,13 +145,14 @@ Status NetOutputPass::CheckOutputNodeInfo(const ComputeGraphPtr &graph, const st NodePtr node = item.output_node; if (node == nullptr) { 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; } else { if (graph->FindNode(node->GetName()) == nullptr) { REPORT_INNER_ERROR("E19999", "Find node:%s from graph:%s failed", 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; } GE_CHECK_NOTNULL(node->GetOpDesc()); @@ -158,10 +161,8 @@ Status NetOutputPass::CheckOutputNodeInfo(const ComputeGraphPtr &graph, const st 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)", 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; } } @@ -189,7 +190,8 @@ Status NetOutputPass::RemoveUnusedNode(const ge::ComputeGraphPtr &graph) { if (graph->RemoveNode(node) != GRAPH_SUCCESS) { REPORT_INNER_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", 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; } } @@ -200,13 +202,14 @@ Status NetOutputPass::UpdateNetOutputDesc(const ge::NodePtr &net_output) { OpDescPtr net_output_desc = net_output->GetOpDesc(); if (net_output_desc == nullptr) { 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; } if (net_output_desc->GetInputsSize() == 0) { 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()); - 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; } @@ -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", net_output_desc->GetName().c_str(), net_output_desc->GetType().c_str(), index, 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()); 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) { 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); - 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; } 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) { if (net_out_node == nullptr) { 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; } // 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", node->GetName().c_str(), 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; } 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", 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); - 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; } 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) { 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); - 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; } 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", ATTR_NAME_PARENT_NODE_INDEX.c_str(), net_input_index, 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; } } net_input_index++; } 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; } 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; } // Add true stream, netoutput is 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(), 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 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) { if (net_out_node == nullptr) { 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; } 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", 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()); - 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; } } else { @@ -387,14 +400,16 @@ Status NetOutputPass::UnLinkControlAnchorOfNetoutput(const ge::ComputeGraphPtr & const ge::NodePtr &net_out_node) { if (net_out_node == nullptr) { 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; } Status ret = SUCCESS; auto in_control_anchor = net_out_node->GetInControlAnchor(); 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; } // 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", net_out_node->GetName().c_str(), net_out_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; } } 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) { 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; } 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; } 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 SUCCESS; @@ -484,7 +502,8 @@ Status NetOutputPass::AddCtrlEdgesBetweenLeafAndNetOutput(const ge::ComputeGraph graph_has_only_one_node_except_netoutput) && node->GetOutDataNodesSize() == 0 && node->GetOutControlNodes().size() == 0) { 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(), net_out_node->GetName().c_str()); } @@ -499,7 +518,7 @@ Status NetOutputPass::CreateNetOutputNode(OpDescPtr &net_output_desc, const ge:: net_output_desc = MakeShared(node_name, NETOUTPUT); if (net_output_desc == nullptr) { 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; } (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) { if (graph == nullptr) { REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid"); - GELOGE(GE_GRAPH_PARAM_NULLPTR, "Compute graph is null."); + GELOGE(GE_GRAPH_PARAM_NULLPTR, "[Check][Param] Compute graph is nullptr."); return GE_GRAPH_PARAM_NULLPTR; } GELOGI("[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, std::move(std::vector())); 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; } } else { 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; } } @@ -538,12 +558,12 @@ Status NetOutputPass::Run(ge::ComputeGraphPtr graph) { Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph, NodePtr &output_node) { OpDescPtr net_output_desc = nullptr; 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; } std::vector output_nodes_info; 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; } 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"); output_node = graph->AddNode(net_output_desc); 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)) { 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()); - 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; } 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", net_output_desc->GetName().c_str(), net_output_desc->GetType().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; } - 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 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(), 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 SUCCESS; } @@ -591,15 +615,16 @@ Status NetOutputPass::AddNetOutputNodeToGraph(const ge::ComputeGraphPtr &graph, REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", net_output_desc->GetName().c_str(), net_output_desc->GetType().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; } 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; } 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; } 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) { 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"); - 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; } 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)) { 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()); - 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; } 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", 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 SUCCESS; diff --git a/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc index 71b9e621..67735b8b 100644 --- a/ge/graph/passes/next_iteration_pass.cc +++ b/ge/graph/passes/next_iteration_pass.cc @@ -38,23 +38,23 @@ Status NextIterationPass::Run(ComputeGraphPtr graph) { continue; } 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; } } 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; } 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; } if (HandleWhileGroup(graph) != SUCCESS) { - GELOGE(FAILED, "Handle while groups failed."); + GELOGE(FAILED, "[Handle][WhileGroup] in graph:%s failed.", graph->GetName().c_str()); 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()) { 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()); - 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; } @@ -88,7 +89,7 @@ Status NextIterationPass::GroupEnterNode(const NodePtr &enter_node) { LoopCondGroupPtr loop_group = MakeShared(); if (loop_group == nullptr) { REPORT_CALL_ERROR("E19999", "New LoopCondGroup failed"); - GELOGE(FAILED, "MakeShared for LoopCondGroup failed."); + GELOGE(FAILED, "[New][LoopCondGroup] failed."); return FAILED; } 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 &out_node : enter_node->GetOutAllNodes()) { 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)) { continue; } NodePtr next_node = nullptr; 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; } loop_group_iter.second->merge_next_pairs.emplace_back(std::make_pair(out_node, next_node)); NodePtr switch_node = nullptr; 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; } if (switch_node == nullptr) { @@ -133,12 +134,13 @@ Status NextIterationPass::FindWhileGroups() { 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(), 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; } NodePtr loop_cond = nullptr; 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; } 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; } 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()); - 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; } } @@ -166,12 +168,13 @@ bool NextIterationPass::VerifyWhileGroup() { const std::string &frame_name = loop_group_iter.first; if (frame_name.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; } 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()); - 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; } @@ -179,16 +182,10 @@ bool NextIterationPass::VerifyWhileGroup() { 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.", 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()); 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 next_active = CreateActiveNode(graph, cond_name + "_Next_" + STREAMACTIVE); 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; } @@ -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", enter_node->GetName().c_str(), enter_node->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; } - 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) { @@ -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", enter_active->GetName().c_str(), enter_active->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; } @@ -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", next_node->GetName().c_str(), next_node->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; } // break link between NextIteration and Merge 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; } - 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) || (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; } - 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); } @@ -281,17 +284,13 @@ Status NextIterationPass::HandleWhileGroup(ComputeGraphPtr &graph) { /// @return void /// 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) { - MarkForceUnknownShape(switch_node, loop_group.is_unknown_shape, group_index); + SetControlFlowGroup(switch_node, group_index); for (const auto &node : switch_node->GetOutDataNodes()) { std::string node_type; (void)GetOriginalType(node, node_type); 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(name, STREAMACTIVE); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); + GELOGE(FAILED, "[New][OpDesc] failed"); return nullptr; } @@ -315,14 +315,16 @@ NodePtr NextIterationPass::CreateActiveNode(ComputeGraphPtr &graph, const std::s if (active_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - 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; } if (SetSwitchBranchNodeLabel(active_node, name) != SUCCESS) { 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()); - 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; } @@ -337,7 +339,7 @@ NodePtr NextIterationPass::CreateActiveNode(ComputeGraphPtr &graph, const std::s /// Status NextIterationPass::BreakNextIteration(const NodePtr &next_node, NodePtr &merge_node) { 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; } 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->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; } if (SetNextIteration(merge_node, next_node) != SUCCESS) { 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()); - 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; } } @@ -376,7 +380,7 @@ Status NextIterationPass::FindTargetNode(const NodePtr &node, const std::string NodePtr &target_node) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "node is null."); + GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr."); return PARAM_INVALID; } std::vector nodes; @@ -392,7 +396,7 @@ Status NextIterationPass::FindTargetNode(const NodePtr &node, const std::string for (const auto &tmp_node : nodes) { 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)) { target_node = tmp_node; break; @@ -405,7 +409,8 @@ Status NextIterationPass::FindTargetNode(const NodePtr &node, const std::string if ((target_type != SWITCH) && (target_node == nullptr)) { 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()); - 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 SUCCESS; diff --git a/ge/graph/passes/next_iteration_pass.h b/ge/graph/passes/next_iteration_pass.h index b6a0846d..2143719c 100755 --- a/ge/graph/passes/next_iteration_pass.h +++ b/ge/graph/passes/next_iteration_pass.h @@ -24,7 +24,6 @@ struct LoopCondGroup { std::vector enter_nodes; // Enter nodes std::vector> merge_next_pairs; // std::vector switch_nodes; // Switch nodes - bool is_unknown_shape{false}; }; using LoopCondGroupPtr = std::shared_ptr; diff --git a/ge/graph/passes/no_use_reshape_remove_pass.cc b/ge/graph/passes/no_use_reshape_remove_pass.cc index ca71378e..b3074565 100644 --- a/ge/graph/passes/no_use_reshape_remove_pass.cc +++ b/ge/graph/passes/no_use_reshape_remove_pass.cc @@ -38,7 +38,7 @@ Status NoUseReshapeRemovePass::Run(ge::NodePtr &node) { OpDescPtr op_desc_ptr = node->GetOpDesc(); if (op_desc_ptr == nullptr) { 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; } 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()) { 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()); - 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->GetAllOutputsDesc().size()); return INTERNAL_ERROR; @@ -112,14 +112,15 @@ Status NoUseReshapeRemovePass::TryRemoveConstShapeInput(ge::NodePtr &reshape_nod if (ret != SUCCESS) { 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); - 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; } // remove const without any data_output if (shape_input->GetOutDataNodesSize() == 0) { 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()); } return SUCCESS; diff --git a/ge/graph/passes/parallel_concat_start_op_pass.cc b/ge/graph/passes/parallel_concat_start_op_pass.cc index f64fa2f3..7509bc54 100755 --- a/ge/graph/passes/parallel_concat_start_op_pass.cc +++ b/ge/graph/passes/parallel_concat_start_op_pass.cc @@ -46,15 +46,15 @@ Status ParallelConcatStartOpPass::Run(NodePtr &node) { 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->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; } auto output_tensor_desc = node_op_desc->GetOutputDesc(kParallelConcatStartOutputDataIndex); GeTensorPtr output_ptr = MakeShared(output_tensor_desc); if (output_ptr == nullptr) { 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; } @@ -62,7 +62,8 @@ Status ParallelConcatStartOpPass::Run(NodePtr &node) { if (!ge::AttrUtils::GetDataType(node_op_desc, kAttrDtype, attr_dtype)) { 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()); - 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; } 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)) { 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()); - 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; } output_ptr->MutableTensorDesc().SetShape(GeShape(attr_shape_list)); diff --git a/ge/graph/passes/pass_manager.cc b/ge/graph/passes/pass_manager.cc index 59ede66b..fa2f1e17 100644 --- a/ge/graph/passes/pass_manager.cc +++ b/ge/graph/passes/pass_manager.cc @@ -50,12 +50,12 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vectorGetName().c_str()); + GELOGE(status, "[Pass][Run] failed on graph %s", graph->GetName().c_str()); return status; } for (const auto &subgraph :graph->GetAllSubgraphs()) { 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(); GE_TIMESTAMP_START(PassRunSubgraph); status = pass->Run(subgraph); @@ -63,7 +63,7 @@ Status PassManager::Run(const ComputeGraphPtr &graph, vectorGetName().c_str()); + GELOGE(status, "[Pass][Run] failed on subgraph %s", subgraph->GetName().c_str()); return status; } } diff --git a/ge/graph/passes/pass_utils.cc b/ge/graph/passes/pass_utils.cc index 1fc675b1..c0ef7685 100644 --- a/ge/graph/passes/pass_utils.cc +++ b/ge/graph/passes/pass_utils.cc @@ -48,13 +48,13 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, std: unique_ptr buf(new (std::nothrow) int32_t[dim_size]()); if (buf == nullptr) { 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; } for (uint32_t i = 0; i < dim_size; i++) { if (data[i] >= INT_MAX) { 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; } buf[i] = static_cast(data[i]); @@ -64,7 +64,7 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, std: unique_ptr buf(new (std::nothrow) int64_t[dim_size]()); if (buf == nullptr) { 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; } for (uint32_t i = 0; i < dim_size; i++) { @@ -74,13 +74,13 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, std: } else { REPORT_CALL_ERROR("E19999", "Only support DT_INT32 and DT_INT64. Input data_type:%s not support", 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()); return PARAM_INVALID; } if (ret != SUCCESS) { - GELOGE(ret, "GetShapeTensor failed."); + GELOGE(ret, "[Get][ShapeTensor] failed, ret:%u.", ret); return ret; } @@ -99,7 +99,7 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, T *b output_tensor_desc, reinterpret_cast(buf), sizeof(T) * len); if (output_tensor_ptr == nullptr) { REPORT_CALL_ERROR("E19999", "New GeTensor failed"); - GELOGE(MEMALLOC_FAILED, "Make shared failed"); + GELOGE(MEMALLOC_FAILED, "[New][GeTensor] failed"); return MEMALLOC_FAILED; } @@ -110,7 +110,7 @@ Status PassUtils::ConstructTensorDescWithData(const GeTensorDesc &out_desc, T *b bool PassUtils::IsConstant(const ConstNodePtr &node) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "node is null"); + GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr"); return false; } @@ -122,7 +122,7 @@ bool PassUtils::IsConstant(const ConstNodePtr &node) { Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, const NodePtr &src_node) { GE_IF_BOOL_EXEC(src_node == nullptr, 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)) { return SUCCESS; } @@ -131,6 +131,8 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons if (weights.empty()) { REPORT_INNER_ERROR("E19999", "Weight of node:%s(%s) is empty, check invalid", 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; } @@ -139,7 +141,8 @@ Status PassUtils::SetOutNodeWeight(const OutDataAnchorPtr &out_data_anchor, cons 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, " "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; } 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); } - 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); if (ret != SUCCESS) { 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 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()), - "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 for (const auto &dst_in_ctrl : out_data_anchor->GetPeerInControlAnchors()) { 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 &delete std::vector &end_nodes) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); return FAILED; } GELOGI("Remove branch starting from node %s", node->GetName().c_str()); @@ -213,25 +224,30 @@ Status PassUtils::RemoveBranch(const NodePtr &node, std::vector &delete } auto dst_node = dst_in_anchor->GetOwnerNode(); 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 (dst_in_anchor->IsTypeOf()) { 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()); - 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()); return INTERNAL_ERROR; } else { // 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); } } else if (node_type == MERGE) { /// Unlink connection between the inactive branch and Merge/NetOutput. /// 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); GELOGD("Reach the end merge node %s, the branch removing stop", dst_node->GetName().c_str()); } else { @@ -291,7 +307,7 @@ int PassUtils::GetUniqueInDataAnchorIndex(const NodePtr &node_ptr) { const int invalid_index = -1; if (node_ptr == nullptr) { 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; } 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", 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; } Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "node is null."); + GELOGE(PARAM_INVALID, "[Check][Param] node is nullptr."); return PARAM_INVALID; } auto in_data_anchor = node->GetInDataAnchor(index); @@ -325,7 +339,8 @@ Status PassUtils::UnlinkNodeWithControlCopy(NodePtr &node, int index) { 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", 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; } // 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", father_node->GetName().c_str(), father_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 SUCCESS; @@ -346,7 +364,7 @@ Status PassUtils::RemoveInactiveBranchToMerge(const OutDataAnchorPtr &inactive_o std::vector &delete_nodes, std::vector &end_nodes) { if (inactive_output_anchor == nullptr) { 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; } 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(); if (dst_node != nullptr) { 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) { 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; } diff --git a/ge/graph/passes/permute_pass.cc b/ge/graph/passes/permute_pass.cc index 8ac3aedf..8254db72 100644 --- a/ge/graph/passes/permute_pass.cc +++ b/ge/graph/passes/permute_pass.cc @@ -68,8 +68,10 @@ Status PermutePass::Run(ComputeGraphPtr graph) { int64_t permute_src_format = 0; GE_IF_BOOL_EXEC(!AttrUtils::GetInt(op_desc_ptr, "permute_src_format", permute_src_format), continue); // Get dim_index_ - std::vector 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 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); @@ -110,12 +112,13 @@ Status PermutePass::Run(ComputeGraphPtr graph) { 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(), 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; } } - 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; } diff --git a/ge/graph/passes/placeholder_with_default_pass.cc b/ge/graph/passes/placeholder_with_default_pass.cc index 4c902322..893ee798 100644 --- a/ge/graph/passes/placeholder_with_default_pass.cc +++ b/ge/graph/passes/placeholder_with_default_pass.cc @@ -26,7 +26,7 @@ Status PlaceholderWithDefaultPass::Run(NodePtr &node) { string type; Status status_ret = GetOriginalType(node, type); 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; } if (type == PLACEHOLDERWITHDEFAULT) { diff --git a/ge/graph/passes/prevent_gradient_pass.cc b/ge/graph/passes/prevent_gradient_pass.cc index 402529c3..c531fd2f 100644 --- a/ge/graph/passes/prevent_gradient_pass.cc +++ b/ge/graph/passes/prevent_gradient_pass.cc @@ -27,7 +27,7 @@ Status PreventGradientPass::Run(NodePtr &node) { string type; Status status_ret = GetOriginalType(node, type); 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; } if (type == PREVENTGRADIENT) { diff --git a/ge/graph/passes/print_op_pass.cc b/ge/graph/passes/print_op_pass.cc index 0b20da84..07ff7ee4 100755 --- a/ge/graph/passes/print_op_pass.cc +++ b/ge/graph/passes/print_op_pass.cc @@ -22,13 +22,13 @@ Status PrintOpPass::Run(ge::NodePtr &node) { GELOGD("PrintOpPass running"); if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "param [node] must not be null."); + GELOGE(PARAM_INVALID, "[Check][Param] param [node] must not be null."); return PARAM_INVALID; } string type; Status ret = GetOriginalType(node, type); if (ret != SUCCESS) { - GELOGE(ret, "PrintOpPass: Get node type fail"); + GELOGE(ret, "[Get][OriginalType] of node:%s failed", node->GetName().c_str()); return ret; } if (type == "Print") { diff --git a/ge/graph/passes/prune_pass.cc b/ge/graph/passes/prune_pass.cc index 49daa037..1e2ec4ab 100644 --- a/ge/graph/passes/prune_pass.cc +++ b/ge/graph/passes/prune_pass.cc @@ -30,7 +30,7 @@ Status PrunePass::Run(ge::ComputeGraphPtr graph) { GELOGD("PrunePass Start, graph is [%s]", graph->GetName().c_str()); if (graph == nullptr) { 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; } std::vector 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", node_ptr->GetName().c_str(), node_ptr->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()); return INTERNAL_ERROR; } diff --git a/ge/graph/passes/ref_identity_delete_op_pass.cc b/ge/graph/passes/ref_identity_delete_op_pass.cc index b729b443..39794cff 100644 --- a/ge/graph/passes/ref_identity_delete_op_pass.cc +++ b/ge/graph/passes/ref_identity_delete_op_pass.cc @@ -31,10 +31,12 @@ Status RefIdentityDeleteOpPass::Run(ComputeGraphPtr graph) { CHECK_FALSE_EXEC(GetRefNode(node, input_index) != nullptr, REPORT_CALL_ERROR("E19999", "Get Ref node of node:%s(%s) failed", 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); 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 SUCCESS; @@ -65,8 +67,7 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP if (variable_ref == nullptr) { REPORT_CALL_ERROR("E19999", "Get variable ref of node:%s(%s) failed", 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; } 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", node->GetName().c_str(), 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; } 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", node->GetName().c_str(), 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; } } else { @@ -117,7 +122,9 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP // +--------+ +--------+ auto ret = RemoveUselessControlEdge(node, variable_ref); 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; } } @@ -125,15 +132,15 @@ Status RefIdentityDeleteOpPass::DealNoOutputRef(const NodePtr &node, const NodeP if (GraphUtils::IsolateNode(ref_identity, {0}) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate op:%s(%s) failed", 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()); return FAILED; } if (GraphUtils::RemoveNodeWithoutRelink(graph, ref_identity) != GRAPH_SUCCESS) { 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()); - 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 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", variable_ref->GetName().c_str(), variable_ref->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()); return FAILED; } diff --git a/ge/graph/passes/remove_same_const_pass.cc b/ge/graph/passes/remove_same_const_pass.cc index ec38a0af..a06eea43 100644 --- a/ge/graph/passes/remove_same_const_pass.cc +++ b/ge/graph/passes/remove_same_const_pass.cc @@ -88,8 +88,9 @@ Status RemoveSameConstPass::Run(ComputeGraphPtr graph) { REPORT_CALL_ERROR("E19999", "Replace node:%s(%s)'s anchor by node:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str(), iter->second->GetName().c_str(), iter->second->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "Failed to replace node %s by node %s, 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; } @@ -99,7 +100,8 @@ Status RemoveSameConstPass::Run(ComputeGraphPtr graph) { if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); - GELOGE(INTERNAL_ERROR, "Failed to remove node %s from graph", node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Remove][Node] %s(%s) without relink in graph:%s failed", + node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); return INTERNAL_ERROR; } diff --git a/ge/graph/passes/replace_transshape_pass.cc b/ge/graph/passes/replace_transshape_pass.cc index ac654083..28957a61 100644 --- a/ge/graph/passes/replace_transshape_pass.cc +++ b/ge/graph/passes/replace_transshape_pass.cc @@ -45,7 +45,8 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed", 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; } auto src_op_desc = trans_shape_node->GetOpDesc(); @@ -55,7 +56,7 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node auto dst_op_desc = MakeShared(node_name, MEMCPYASYNC); if (dst_op_desc == nullptr) { 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; } GELOGI("Create memcpy Op, name=%s.", node_name.c_str()); @@ -64,7 +65,8 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", 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; } } @@ -73,7 +75,8 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", 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; } } @@ -84,16 +87,22 @@ Status ReplaceTransShapePass::ReplaceTransShapeNode(ComputeGraphPtr &graph, Node OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); 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())), - "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 (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), - "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); @@ -107,14 +116,17 @@ void ReplaceTransShapePass::CopyControlEdges(NodePtr &old_node, NodePtr &new_nod for (NodePtr &node : old_node->GetInControlNodes()) { auto out_control_anchor = node->GetOutControlAnchor(); 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()) { GE_IF_BOOL_EXEC(!new_node->GetOutControlAnchor()->IsLinkedWith(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); for (NodePtr &in_node : node->GetInControlNodes()) { 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 &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(); GE_CHECK_NOTNULL_JUST_RETURN(out_control_anchor); 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()); } } diff --git a/ge/graph/passes/replace_with_empty_const_pass.cc b/ge/graph/passes/replace_with_empty_const_pass.cc index bfa6ff95..9459c852 100644 --- a/ge/graph/passes/replace_with_empty_const_pass.cc +++ b/ge/graph/passes/replace_with_empty_const_pass.cc @@ -27,12 +27,12 @@ Status ReplaceWithEmptyConstPass::Run(NodePtr &node) { GELOGD("ReplaceWithEmptyConstPass in."); if (node == nullptr) { 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; } if (node->GetOpDesc() == nullptr) { REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "Param [opDesc] must not be null."); + GELOGE(PARAM_INVALID, "[Get][OpDesc] failed, Param [opDesc] must not be null."); return PARAM_INVALID; } if (node->GetType() == CONSTANT || node->GetType() == CONSTANTOP || node->GetType() == DATA) { diff --git a/ge/graph/passes/reshape_recovery_pass.cc b/ge/graph/passes/reshape_recovery_pass.cc index ba12ba15..9df6ec7b 100644 --- a/ge/graph/passes/reshape_recovery_pass.cc +++ b/ge/graph/passes/reshape_recovery_pass.cc @@ -24,24 +24,31 @@ NodePtr CreateReshape(const ConstGeTensorDescPtr &src, const ConstGeTensorDescPt auto reshape = MakeShared("Reshape_ReshapeRecoveryPass_" + std::to_string(next_num), RESHAPE); if (reshape == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); + GELOGE(FAILED, "[New][OpDesc] failed"); return nullptr; } auto ret = reshape->AddInputDesc("x", *src); if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:x", 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; } ret = reshape->AddInputDesc("shape", GeTensorDesc(GeShape(), Format(), DT_INT32)); if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed, name:shape", 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; } ret = reshape->AddOutputDesc("y", *dst); 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()); + GELOGE(FAILED, "[Add][OutputDesc] to op:%s(%s) failed, name:y", + reshape->GetName().c_str(), reshape->GetType().c_str()); return nullptr; } @@ -89,8 +96,11 @@ Status InsertReshapeIfNeed(const NodePtr &node) { 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()); - 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; } GELOGI("Insert reshape between %s and %s to keep the shape continues", diff --git a/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc index cd93725d..a104a95e 100755 --- a/ge/graph/passes/resource_pair_add_control_pass.cc +++ b/ge/graph/passes/resource_pair_add_control_pass.cc @@ -86,9 +86,9 @@ Status ResourcePairAddControlPass::Run(ComputeGraphPtr graph) { 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(), 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; } GELOGD("link success, from_node:%s, to_node:%s, from_type:%s, to_type:%s", from_node->GetName().c_str(), diff --git a/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc index 64b04a13..73b96008 100755 --- a/ge/graph/passes/resource_pair_remove_control_pass.cc +++ b/ge/graph/passes/resource_pair_remove_control_pass.cc @@ -85,9 +85,9 @@ Status ResourcePairRemoveControlPass::Run(ComputeGraphPtr graph) { 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(), 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; } GELOGD("unlink success, from_node:%s, to_node:%s, from_type:%s, to_type:%s", from_node->GetName().c_str(), diff --git a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc index c0a3328e..60f5c7c9 100644 --- a/ge/graph/passes/same_transdata_breadth_fusion_pass.cc +++ b/ge/graph/passes/same_transdata_breadth_fusion_pass.cc @@ -72,7 +72,7 @@ OpDescPtr SameTransdataBreadthFusionPass::GetCastOp(const GeTensorDesc &in_desc, node_op.BreakConnect(); if (cast_op == nullptr) { REPORT_INNER_ERROR("E19999", "Create Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST); - GELOGE(INTERNAL_ERROR, "new fusion cast op failed!"); + GELOGE(INTERNAL_ERROR, "[Get][OpDesc] From Operator:%s(%s) failed", cast_op_name.str().c_str(), CAST); return nullptr; } 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(out_desc.GetDataType()))) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(), cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set dst_type attr failed"); + GELOGE(INTERNAL_ERROR, "[Set][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 cast_op; @@ -213,8 +214,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkDataOutput2PreNode(const NodeP transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_anchor->GetIdx()); - GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(), - transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str()); + 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; } 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()->GetType().c_str(), transdata_peer_in_anchor->GetIdx()); - GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s", - pre_out_anchor->GetOwnerNode()->GetName().c_str(), - transdata_peer_in_anchor->GetOwnerNode()->GetName().c_str()); + 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; } } @@ -251,8 +255,10 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN out_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "remove edge failed!src node:%s, dst node:%s", transdata_node->GetName().c_str(), - transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str()); + 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; } @@ -265,9 +271,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN pre_out_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s", + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", 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; } } else { @@ -279,9 +287,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutDataPeerInControlNodes2PreN transdata_peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "add edge failed!src node:%s, dst node:%s", - pre_out_anchor->GetOwnerNode()->GetName().c_str(), - transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str()); + 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; } } @@ -325,7 +335,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors out_control_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "remove transdata control edge failed!"); + GELOGE(GRAPH_FAILED, "[Remove][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; } @@ -338,7 +352,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors pre_out_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "add control edge failed!"); + GELOGE(GRAPH_FAILED, "[Add][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; } } else { @@ -350,7 +368,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInControlAnchors transdata_peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_control_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "add control edge failed!"); + GELOGE(GRAPH_FAILED, "[Add][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; } } @@ -379,7 +401,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( out_control_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "remove transdata control edge failed!"); + GELOGE(GRAPH_FAILED, "[Remove][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; } @@ -393,7 +419,12 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_data_anchor->GetIdx()); - GELOGE(GRAPH_FAILED, "add control edge failed!"); + GELOGE(GRAPH_FAILED, "[Add][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; } } else { @@ -405,7 +436,11 @@ graphStatus SameTransdataBreadthFusionPass::ReLinkOutControlPeerInDataAnchors( transdata_peer_out_control_anchor->GetOwnerNode()->GetType().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetName().c_str(), transdata_peer_in_data_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(GRAPH_FAILED, "add control edge failed!"); + GELOGE(GRAPH_FAILED, "[Add][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; } } @@ -527,8 +562,10 @@ graphStatus SameTransdataBreadthFusionPass::RelinkRemainTransdata(const ComputeG transdata_in_anchor->GetOwnerNode()->GetName().c_str(), transdata_in_anchor->GetOwnerNode()->GetType().c_str(), transdata_in_anchor->GetIdx()); - GELOGE(GRAPH_FAILED, "add edge failed!out node %s, in node %s", head_node->GetName().c_str(), - transdata_node_keep->GetName().c_str()); + 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; } @@ -618,8 +655,11 @@ graphStatus SameTransdataBreadthFusionPass::ReuseNodesBeforeTransdata(int anchor head_node_peer_anchor->GetOwnerNode()->GetName().c_str(), head_node_peer_anchor->GetOwnerNode()->GetType().c_str(), head_node_peer_anchor->GetIdx()); - GELOGE(GRAPH_FAILED, "add edge.src:%s, dst:%s", transdata_node_keep->GetName().c_str(), - head_node_peer_anchor->GetOwnerNode()->GetName().c_str()); + 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; } 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) { REPORT_CALL_ERROR("E19999", "Update input:%d desc in op:%s(%s) failed", in_data_anchor->GetIdx(), in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str()); - GELOGE(FAILED, "UpdateInputDesc fail."); + GELOGE(FAILED, "[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; } 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, REPORT_CALL_ERROR("E19999", "Update output:%d desc in op:%s(%s) failed", output_idx, in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str()); - GELOGE(GRAPH_FAILED, "update input desc failed"); + GELOGE(GRAPH_FAILED, "[Update][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); // relink control edge 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()->GetType().c_str(), 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; } @@ -729,7 +776,9 @@ graphStatus SameTransdataBreadthFusionPass::LinkNewCastNode2RemainTransdata( REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(), graph->GetName().c_str()); - GELOGE(GRAPH_FAILED, "remove node %s failed!", transdata_node_remove->GetName().c_str()); + GELOGE(GRAPH_FAILED, "[Remove][Node] %s(%s) from graph:%s failed", + transdata_node_remove->GetName().c_str(), transdata_node_remove->GetType().c_str(), + graph->GetName().c_str()); 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()->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; } 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()->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; } } @@ -810,6 +863,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g if (cast_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str(), graph->GetName().c_str()); + 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; } 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()->GetType().c_str(), pre_out_anchor->GetIdx(), 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; } if (i == 0) { @@ -827,7 +886,8 @@ graphStatus SameTransdataBreadthFusionPass::AddCastNode(const ComputeGraphPtr &g if (!AttrUtils::SetBool(cast_op_desc, ATTR_NEED_COMPILE, true)) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(), cast_op_desc->GetName().c_str(), cast_op_desc->GetType().c_str()); - GELOGE(FAILED, "SetExtAttr fail."); + 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; } pre_out_anchor = cast_node->GetOutDataAnchor(0); @@ -842,7 +902,7 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat graphStatus ret = GRAPH_SUCCESS; if (out_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid"); - GELOGE(GRAPH_FAILED, "out data anchor is null!This should not happen!"); + GELOGE(GRAPH_FAILED, "[Check][Param] out data anchor is null! This should not happen!"); return GRAPH_FAILED; } @@ -868,7 +928,8 @@ graphStatus SameTransdataBreadthFusionPass::GetSubGraphsBetweenNormalAndTransdat for (auto &peer_out_anchor : peer_in_node->GetAllOutDataAnchors()) { ret = GetSubGraphsBetweenNormalAndTransdataNode(peer_out_anchor, sub_graphs_out, nodes_list); 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; } } diff --git a/ge/graph/passes/save_pass.cc b/ge/graph/passes/save_pass.cc index b82a6420..1181461b 100755 --- a/ge/graph/passes/save_pass.cc +++ b/ge/graph/passes/save_pass.cc @@ -49,7 +49,9 @@ Status SavePass::Run(ge::ComputeGraphPtr graph) { GE_IF_BOOL_EXEC(!ge::AttrUtils::SetStr(op_desc, kVarAttrVarIsSave, kVarIsSave), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kVarAttrVarIsSave, op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "get kVarAttrVarIsSave failed"); return INTERNAL_ERROR); + 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) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) from graph:%s failed", node_ptr->GetName().c_str(), node_ptr->GetType().c_str(), graph->GetName().c_str()); - GELOGE(ret, "GraphUtils::RemoveNodeWithoutRelink failed."); + GELOGE(ret, "[Remove][Node] %s(%s) from graph:%s failed", + node_ptr->GetName().c_str(), node_ptr->GetType().c_str(), graph->GetName().c_str()); return ret; } diff --git a/ge/graph/passes/set_input_output_offset_pass.cc b/ge/graph/passes/set_input_output_offset_pass.cc index d3c1e07d..55d037e2 100644 --- a/ge/graph/passes/set_input_output_offset_pass.cc +++ b/ge/graph/passes/set_input_output_offset_pass.cc @@ -28,7 +28,7 @@ Status SetInputOutputOffsetPass::Run(ComputeGraphPtr graph) { if (!connect_input.empty()) { Status ret = SetInputOffset(node, connect_input); if (ret != SUCCESS) { - GELOGE(ret, "SetInputOffset failed."); + GELOGE(ret, "[Set][InputOffset] for node:%s failed.", node->GetName().c_str()); return ret; } } @@ -37,7 +37,7 @@ Status SetInputOutputOffsetPass::Run(ComputeGraphPtr graph) { if (!connect_output.empty()) { Status ret = SetOutputOffset(node, connect_output); if (ret != SUCCESS) { - GELOGE(ret, "SetOutputOffset failed."); + GELOGE(ret, "[Set][OutputOffset] for node:%s failed.", node->GetName().c_str()); return ret; } } @@ -56,7 +56,8 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vectorGetName().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; } int64_t input_offset = input_offset_of_node.at(i); @@ -82,14 +83,17 @@ Status SetInputOutputOffsetPass::SetInputOffsetForFusion(const std::vectorGetName().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); - 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; @@ -125,14 +129,17 @@ Status SetInputOutputOffsetPass::SetInputOffsetForHcom(const ge::NodePtr &node, REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_BASIC_OFFSET.c_str(), in_op_desc->GetName().c_str(), in_op_desc->GetType().c_str()); - GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed."); + GELOGE(FAILED, "[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); - 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()) { Status ret = SetInputOffsetForFusion(memory_type, node); if (ret != SUCCESS) { - GELOGE(ret, "SetInputOffsetForFusion failed."); + GELOGE(ret, "[Set][InputOffset] For Fusion failed, node:%s.", node->GetName().c_str()); return ret; } } @@ -157,7 +164,7 @@ Status SetInputOutputOffsetPass::SetInputOffset(const NodePtr &node, const vecto if (is_input_continuous) { Status ret = SetInputOffsetForHcom(node, connect_input); if (ret != SUCCESS) { - GELOGE(ret, "SetInputOffsetForHcom failed."); + GELOGE(ret, "[Set][InputOffset] For Hcom failed, node:%s.", node->GetName().c_str()); 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", output_offset_of_concat.size(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(PARAM_INVALID, "%s should has one output.", node->GetName().c_str()); + GELOGE(PARAM_INVALID, "[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); NodePtr net_output = node->GetOutDataNodes().at(0); 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), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_BASIC_OFFSET.c_str(), out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str()); - GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed."); + GELOGE(FAILED, "[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); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(), out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str()); - GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed."); + GELOGE(FAILED, "[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 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), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_BASIC_OFFSET.c_str(), out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str()); - GELOGE(FAILED, "SetListInt of zero_copy_basic_offset failed."); + GELOGE(FAILED, "[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); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(out_op_desc, ATTR_ZERO_COPY_RELATIVE_OFFSET, zero_copy_relative_offset), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_ZERO_COPY_RELATIVE_OFFSET.c_str(), out_op_desc->GetName().c_str(), out_op_desc->GetType().c_str()); - GELOGE(FAILED, "SetListInt of zero_copy_relative_offset failed."); + GELOGE(FAILED, "[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 SUCCESS; } @@ -277,7 +289,7 @@ Status SetInputOutputOffsetPass::SetOutputOffset(const NodePtr &node, const vect if (is_input_continuous || buffer_fusion) { Status ret = SetOutputOffsetForConcat(node); if (ret != SUCCESS) { - GELOGE(ret, "SetOutputOffsetForConcat failed."); + GELOGE(ret, "[Set][OutputOffset] For Concat failed, node:%s.", node->GetName().c_str()); return ret; } } @@ -288,7 +300,7 @@ Status SetInputOutputOffsetPass::SetOutputOffset(const NodePtr &node, const vect if (is_output_continuous) { Status ret = SetOutputOffsetForHcom(node, connect_output); if (ret != SUCCESS) { - GELOGE(ret, "SetOutputOffsetForHcom failed."); + GELOGE(ret, "[Set][OutputOffset] For Hcom failed, node:%s.", node->GetName().c_str()); return ret; } } diff --git a/ge/graph/passes/shape_operate_op_remove_pass.cc b/ge/graph/passes/shape_operate_op_remove_pass.cc index 9d6d7c40..a703f1c9 100755 --- a/ge/graph/passes/shape_operate_op_remove_pass.cc +++ b/ge/graph/passes/shape_operate_op_remove_pass.cc @@ -30,7 +30,10 @@ Status ShapeOperateOpRemovePass::Run(ComputeGraphPtr graph) { GE_IF_BOOL_EXEC(op_desc == nullptr, continue); 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(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; } diff --git a/ge/graph/passes/snapshot_pass.cc b/ge/graph/passes/snapshot_pass.cc index 469a70af..95733e67 100644 --- a/ge/graph/passes/snapshot_pass.cc +++ b/ge/graph/passes/snapshot_pass.cc @@ -23,7 +23,8 @@ namespace ge { Status SnapshotPass::Run(NodePtr &node) { 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; } string type; @@ -31,7 +32,8 @@ Status SnapshotPass::Run(NodePtr &node) { if (status_ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str()); - GELOGE(status_ret, "SnapshotPass get original type failed."); + GELOGE(status_ret, "[Get][OriginalType] of op:%s(%s) failed", + node->GetName().c_str(), node->GetType().c_str()); return status_ret; } if (type == SNAPSHOT) { diff --git a/ge/graph/passes/stop_gradient_pass.cc b/ge/graph/passes/stop_gradient_pass.cc index 33d07803..8acc7e3a 100644 --- a/ge/graph/passes/stop_gradient_pass.cc +++ b/ge/graph/passes/stop_gradient_pass.cc @@ -21,7 +21,7 @@ namespace ge { Status StopGradientPass::Run(NodePtr &node) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); return FAILED; } string type; @@ -29,7 +29,8 @@ Status StopGradientPass::Run(NodePtr &node) { if (status_ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Get OriginalType of op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str()); - GELOGE(status_ret, "StopGradientPass get original type failed."); + GELOGE(status_ret, "[Get][OriginalType] of op:%s(%s) failed", + node->GetName().c_str(), node->GetType().c_str()); return status_ret; } diff --git a/ge/graph/passes/subexpression_migration_pass.cc b/ge/graph/passes/subexpression_migration_pass.cc index d70ed05d..6265851a 100755 --- a/ge/graph/passes/subexpression_migration_pass.cc +++ b/ge/graph/passes/subexpression_migration_pass.cc @@ -146,7 +146,8 @@ Status SubexpressionMigrationPass::ClassifyDataNodes(const ComputeGraphPtr &grap if (subgraph == nullptr) { REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed", graph->GetName().c_str(), name.c_str()); - GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str()); + GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "[Get][SubGraph] from graph:%s by name:%s failed", + graph->GetName().c_str(), name.c_str()); 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)) { REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), data->GetName().c_str(), data->GetType().c_str()); - GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str()); + GELOGE(FAILED, "[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; } @@ -234,7 +236,7 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const mapGetName().c_str(), node_idx); + GELOGE(FAILED, "[Check][Param] Find node in data_nodes by index:%u failed", node_idx); return false; } @@ -245,14 +247,15 @@ bool SubexpressionMigrationPass::IsParallelNodeSame(const mapGetName().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; } const auto &work_node = in_anchor->GetOwnerNode(); if (work_node == nullptr) { REPORT_INNER_ERROR("E19999", "Owner node of anchor is nullptr, check invalid"); - GELOGE(FAILED, "Data: %s not found, index: %u", base_node->GetName().c_str(), node_idx); + GELOGE(FAILED, "[Check][Param] Owner node of anchor is nullptr"); return false; } @@ -347,7 +350,7 @@ Status SubexpressionMigrationPass::AppendParallelNode(mapGetName().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; } if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, item.second)) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); + GELOGE(FAILED, "[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; } @@ -372,7 +377,8 @@ Status SubexpressionMigrationPass::AppendParallelNode(mapGetName().c_str()); migration_append_ = true; } @@ -395,7 +401,9 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetOwnerNode()->GetName().c_str(), detach->GetName().c_str()); const auto &owner_node = out_anchor->GetOwnerNode(); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), detach->GetName().c_str()); @@ -405,15 +413,15 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetAllOutDataAnchorsSize(); ++i) { auto it_idx = outputs.find(i); if (it_idx == outputs.end()) { - REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", detach->GetName().c_str(), i); - GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i); + 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; } auto it_data = graph_datas.find(it_idx->second); if (it_data == graph_datas.end()) { - REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", detach->GetName().c_str(), i); - GELOGE(FAILED, "Node: %s parent index %u not found", detach->GetName().c_str(), i); + 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; } @@ -429,12 +437,16 @@ Status SubexpressionMigrationPass::DetachParallelNode(const mapGetName().c_str(), in_anchor->GetOwnerNode()->GetName().c_str()); const auto &owner_node = in_anchor->GetOwnerNode(); GELOGI("Remove Edge: %s %s", detach->GetName().c_str(), owner_node->GetName().c_str()); 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()); } } @@ -459,8 +471,8 @@ Status SubexpressionMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra for (uint32_t i = 0; i < attach->GetAllInDataAnchorsSize(); ++i) { auto it_idx = inputs.find(i); if (it_idx == inputs.end()) { - REPORT_INNER_ERROR("E19999", "Node: %s parent index %u not found, check invalid", attach->GetName().c_str(), i); - GELOGE(FAILED, "Node: %s parent index %u not found", attach->GetName().c_str(), i); + 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; } 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 &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(); 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 &out_anchor = in_anchor->GetPeerOutAnchor(); 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(); 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()); } @@ -522,7 +540,7 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph const map &outputs) { if (inputs.empty()) { REPORT_INNER_ERROR("E19999", "Param inputs is empty, check invalid"); - GELOGE(FAILED, "Graph: %s, inputs is empty", graph->GetName().c_str()); + GELOGE(FAILED, "[Check][Param] Param inputs is empty"); return FAILED; } @@ -535,7 +553,8 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph if (it == subnodes.end()) { REPORT_INNER_ERROR("E19999", "Index:%u data node not found in graph:%s, check invalid", base_index, subgraph->GetName().c_str()); - GELOGE(FAILED, "Graph: %s, Data: %u node not found", subgraph->GetName().c_str(), base_index); + GELOGE(FAILED, "[Check][Param] Index:%u data node not found in graph:%s", + base_index, subgraph->GetName().c_str()); return FAILED; } @@ -546,23 +565,26 @@ Status SubexpressionMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph if (in_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Index:%u anchor not exist in out:%u data anchor's peer of node:%s(%s)", anchor_idx, kDataOutIndex, base_data->GetName().c_str(), base_data->GetType().c_str()); - GELOGE(FAILED, "Data anchor index: %u, anchor size: %zu", anchor_idx, in_anchors.size()); + GELOGE(FAILED, "[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; } move_node = in_anchor->GetOwnerNode(); if (move_node == nullptr) { REPORT_INNER_ERROR("E19999", "Owner node of anchor is nullptr, check invalid"); - GELOGE(FAILED, "Data: %s not found, index: %u", base_data->GetName().c_str(), base_index); + GELOGE(FAILED, "[Check][Param] Owner node of anchor is nullptr"); return FAILED; } 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; } - 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()); } diff --git a/ge/graph/passes/subgraph_const_migration_pass.cc b/ge/graph/passes/subgraph_const_migration_pass.cc index 3b3b7e0b..d15e60cf 100644 --- a/ge/graph/passes/subgraph_const_migration_pass.cc +++ b/ge/graph/passes/subgraph_const_migration_pass.cc @@ -143,7 +143,8 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra if (subgraph == nullptr) { REPORT_INNER_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed", graph->GetName().c_str(), name.c_str()); - GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str()); + GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "[Get][SubGraph] from graph:%s by name:%s failed", + graph->GetName().c_str(), name.c_str()); 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)) { REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), node->GetName().c_str(), node->GetType().c_str()); + GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), + node->GetName().c_str(), node->GetType().c_str()); 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()); } else if ((node->GetType() == CONSTANT) && (node->GetOutDataAnchor(kZeroIndex) != nullptr)) { set 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()) { GELOGI("%s, Const: %s, no data output", subgraph->GetName().c_str(), node->GetName().c_str()); const auto in_all_nodes = node->GetInAllNodes(); @@ -205,13 +189,36 @@ Status SubgraphConstMigrationPass::ClassifyGraphNodes(const ComputeGraphPtr &gra for (auto &node : ctrl_only_const_nodes) { 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; } +void SubgraphConstMigrationPass::GetPeerNameList(const NodePtr &node, set &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 /// @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(); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "Build op:%s(%s) failed", data_name.c_str(), DATA); - GELOGE(OUT_OF_MEMORY, "Create multi-batch subgraph data desc failed"); + GELOGE(OUT_OF_MEMORY, "[Build][OpDesc] %s(%s) failed", data_name.c_str(), DATA); 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)) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INDEX.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); + GELOGE(FAILED, "[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; } if (!AttrUtils::SetInt(op_desc, ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(FAILED, "Parent index not found, name: %s", op_desc->GetName().c_str()); + GELOGE(FAILED, "[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; } @@ -373,22 +382,28 @@ Status SubgraphConstMigrationPass::DetachParallelNode(const ComputeGraphPtr &gra const auto &in_anchor = const_node->GetInControlAnchor(); const auto out_anchors = in_anchor->GetPeerOutControlAnchors(); 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(); 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) { 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_anchors = ctrl_anchor->GetPeerInControlAnchors(); 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()); - 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()); } @@ -396,10 +411,14 @@ Status SubgraphConstMigrationPass::DetachParallelNode(const ComputeGraphPtr &gra const auto &out_anchor = const_node->GetOutDataAnchor(kZeroIndex); const auto in_anchors = out_anchor->GetPeerInDataAnchors(); 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()); - 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()); } @@ -436,15 +455,19 @@ Status SubgraphConstMigrationPass::AttachParallelNode(const ComputeGraphPtr &gra const auto &in_anchor = func_node->GetInDataAnchor(parent_index); const auto &out_anchor = in_anchor->GetPeerOutAnchor(); 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(); GELOGI("Remove Edge: %s %s", owner_node->GetName().c_str(), func_node->GetName().c_str()); if (owner_node->GetInAllNodes().empty() && owner_node->GetOutAllNodes().empty()) { 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); (void)graph->AddNode(const_node); @@ -471,8 +494,7 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph if (node_key.empty() || parent_index == kInvalidParent) { REPORT_INNER_ERROR("E19999", "Param node_key is empty or param parent_index is 0x%X, check invalid", kInvalidParent); - GELOGE(FAILED, "Graph: %s, node key: %s, parent index: %u invalid", - graph->GetName().c_str(), node_key.c_str(), parent_index); + GELOGE(FAILED, "[Check][Param] Param node_key is empty or param parent_index is 0x%X", kInvalidParent); return FAILED; } @@ -483,7 +505,8 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph if (it_const == item.second.end()) { REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid", node_key.c_str(), subgraph->GetName().c_str()); - GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str()); + GELOGE(FAILED, "[Check][Param] Const node name:%s not found in graph:%s", + node_key.c_str(), subgraph->GetName().c_str()); return FAILED; } move_node = it_const->second; @@ -492,24 +515,27 @@ Status SubgraphConstMigrationPass::MoveNodeToParent(const ComputeGraphPtr &graph if (it_nodes == all_data_nodes.end()) { REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid", node_key.c_str(), subgraph->GetName().c_str()); - GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str()); + GELOGE(FAILED, "[Check][Param] Const node name:%s not found in graph:%s", + node_key.c_str(), subgraph->GetName().c_str()); return FAILED; } const auto it_data = it_nodes->second.find(parent_index); if (it_data == it_nodes->second.end()) { REPORT_INNER_ERROR("E19999", "Const node name:%s not found in graph:%s, check invalid", node_key.c_str(), subgraph->GetName().c_str()); - GELOGE(FAILED, "Graph: %s, Const: %s node not found", subgraph->GetName().c_str(), node_key.c_str()); + GELOGE(FAILED, "[Check][Param] Const node name:%s not found in graph:%s", + node_key.c_str(), subgraph->GetName().c_str()); return FAILED; } 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; } 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()); } diff --git a/ge/graph/passes/subgraph_const_migration_pass.h b/ge/graph/passes/subgraph_const_migration_pass.h index d93da839..2834fd66 100755 --- a/ge/graph/passes/subgraph_const_migration_pass.h +++ b/ge/graph/passes/subgraph_const_migration_pass.h @@ -133,6 +133,8 @@ class SubgraphConstMigrationPass : public GraphPass { /// Status AttachParallelNode(const ComputeGraphPtr &graph, const NodePtr &func_node, const NodePtr &const_node, uint32_t parent_index); + + void GetPeerNameList(const NodePtr &node, set &peer_name_list); }; } // namespace ge #endif // GE_COMMON_SUBGRAPH_CONST_MIGRATION_H_ \ No newline at end of file diff --git a/ge/graph/passes/subgraph_pass.cc b/ge/graph/passes/subgraph_pass.cc index 401dee54..2fd32d6a 100755 --- a/ge/graph/passes/subgraph_pass.cc +++ b/ge/graph/passes/subgraph_pass.cc @@ -31,7 +31,8 @@ Status SubgraphPass::Run(ComputeGraphPtr graph) { for (const NodePtr &node : graph->GetDirectNode()) { if (is_sub_graph && (node->GetType() == DATA)) { 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; } continue; @@ -40,7 +41,8 @@ Status SubgraphPass::Run(ComputeGraphPtr graph) { // NetOutput in subgraph if (is_sub_graph && (node->GetType() == NETOUTPUT)) { 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; } continue; @@ -49,12 +51,14 @@ Status SubgraphPass::Run(ComputeGraphPtr graph) { if (kWhileOpTypes.count(node->GetType()) > 0) { // Input->While and Input link to other nodes 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; } // body subgraph of While op 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; } 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()); std::string name = node->GetName() + "_output_0_Memcpy"; 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; } } @@ -96,7 +100,8 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP if (!AttrUtils::GetInt(node->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "Get attr PARENT_NODE_INDEX failed, node:%s.", node->GetName().c_str()); + GELOGE(FAILED, "[Get][Attr] %s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), + node->GetName().c_str(), node->GetType().c_str()); return FAILED; } @@ -119,7 +124,7 @@ Status SubgraphPass::SubgraphInputNode(const ComputeGraphPtr &graph, const NodeP parent_node->GetName().c_str()); 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) { - 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()); 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()); 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) { - 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; } } @@ -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()); 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) { - 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; } } @@ -212,7 +219,7 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP if (while_body == nullptr) { REPORT_INNER_ERROR("E19999", "While_body of node:%s(%s) is nullptr, check invalid", node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "while_body of %s is NULL.", node->GetName().c_str()); + GELOGE(FAILED, "[Get][Subgraph] failed, while_body of %s is nullptr.", node->GetName().c_str()); return FAILED; } if (GraphUtils::IsUnknownShapeGraph(while_body)) { @@ -230,7 +237,8 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP 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 data_nodes; @@ -248,7 +256,7 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP } else { REPORT_INNER_ERROR("E19999", "While_body graph:%s exists multi NetOutput nodes, check invalid", while_body->GetName().c_str()); - GELOGE(FAILED, "while_body %s exists multi NetOutput nodes.", while_body->GetName().c_str()); + GELOGE(FAILED, "[Check][Param] while_body %s exists multi NetOutput nodes.", while_body->GetName().c_str()); return FAILED; } } @@ -256,13 +264,13 @@ Status SubgraphPass::WhileBodySubgraph(const ComputeGraphPtr &graph, const NodeP if (output_node == nullptr) { REPORT_INNER_ERROR("E19999", "While_body graph:%s has no output, check invalid", while_body->GetName().c_str()); - GELOGE(FAILED, "while_body %s has no output.", while_body->GetName().c_str()); + GELOGE(FAILED, "[Check][Param] while_body %s has no output.", while_body->GetName().c_str()); return FAILED; } if ((InsertInputMemcpy(while_body, data_nodes) != 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; } @@ -300,7 +308,7 @@ Status SubgraphPass::InsertInputMemcpy(const ComputeGraphPtr &graph, const std:: in_anchors.emplace_back(peer_in_anchor); } 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; } } @@ -341,7 +349,7 @@ Status SubgraphPass::InsertOutputMemcpy(const ComputeGraphPtr &graph, const Node InDataAnchorPtr in_data_anchor = output_node->GetInDataAnchor(i); OutDataAnchorPtr peer_out_anchor = in_data_anchor->GetPeerOutAnchor(); 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; } cnt++; @@ -474,7 +482,9 @@ Status SubgraphPass::InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDat op_desc->GetName().c_str(), op_desc->GetType().c_str(), out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str()); - GELOGE(FAILED, "Insert IDENTITY node %s after %s failed.", name.c_str(), in_node->GetName().c_str()); + GELOGE(FAILED, "[Insert][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; } @@ -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", src->GetOwnerNode()->GetName().c_str(), src->GetOwnerNode()->GetType().c_str(), src->GetIdx(), insert_node->GetName().c_str(), insert_node->GetType().c_str(), input_index); - GELOGE(FAILED, "Add data_edge %s:%d->%s:%u failed.", - src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), insert_node->GetName().c_str(), input_index); + 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; } 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(), insert_node->GetName().c_str(), insert_node->GetType().c_str(), output_index, dst->GetOwnerNode()->GetName().c_str(), dst->GetOwnerNode()->GetType().c_str(), dst->GetIdx()); - GELOGE(FAILED, "Replace data_edge %s:%d->%s:%d by %s:%u->%s:%d failed.", + GELOGE(FAILED, "[Replace][DataEdge] %s:%d->%s:%d by %s:%u->%s:%d failed.", src->GetOwnerNode()->GetName().c_str(), src->GetIdx(), dst->GetOwnerNode()->GetName().c_str(), dst->GetIdx(), insert_node->GetName().c_str(), output_index, diff --git a/ge/graph/passes/switch_data_edges_bypass.cc b/ge/graph/passes/switch_data_edges_bypass.cc index 5c324238..5f66a0ca 100644 --- a/ge/graph/passes/switch_data_edges_bypass.cc +++ b/ge/graph/passes/switch_data_edges_bypass.cc @@ -52,8 +52,8 @@ std::vector> GetOutDataNodesByIndex(const No if (out_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d out data anchor, check invalid", node->GetName().c_str(), node->GetType().c_str(), index); - GELOGE(PARAM_INVALID, "Failed to get out data nodes of index %d from node %s, the anchor does not exists", index, - node->GetName().c_str()); + GELOGE(PARAM_INVALID, "[Get][OutDataNodes] of index %d from node %s failed, the anchor does not exists", + index, node->GetName().c_str()); return {}; } std::vector> nodes_and_anchors; @@ -87,24 +87,23 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) { auto node_desc = node->GetOpDesc(); if (node_desc == nullptr) { REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "Failed to add identity after node %s index %d, the op desc is null", - node->GetName().c_str(), index); + GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, the op desc is nullptr"); return nullptr; } auto tensor = node_desc->GetOutputDescPtr(index); if (tensor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d output tensor, check invalid", node_desc->GetName().c_str(), node_desc->GetType().c_str(), index); - GELOGE(INTERNAL_ERROR, "Failed to find the tensor by index %d from node %s, can not add the identity node", index, - node->GetName().c_str()); + 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; } auto anchor = node->GetOutDataAnchor(index); if (anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d out data anchor, check invalid", node->GetName().c_str(), node->GetType().c_str(), index); - GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d, the out anchor does not exists", - node->GetName().c_str(), index); + 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; } @@ -112,7 +111,7 @@ NodePtr AddIdentityAfterNode(const NodePtr &node, int index) { MakeShared("SwitchDataEdgesByPass_Identity_" + std::to_string(identity_counter), IDENTITY); if (identity_opdesc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index); + GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed"); return nullptr; } 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", identity_opdesc->GetName().c_str(), identity_opdesc->GetType().c_str(), node->GetOwnerComputeGraph()->GetName().c_str()); - GELOGE(OUT_OF_MEMORY, "Failed to add identity after node %s index %d", node->GetName().c_str(), index); + GELOGE(OUT_OF_MEMORY, "[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; } (void)anchor->LinkTo(identity->GetInDataAnchor(0)); @@ -136,31 +137,30 @@ NodePtr AddMemcpyBeforeNode(const NodePtr &node, int index) { auto node_desc = node->GetOpDesc(); if (node_desc == nullptr) { REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, null op desc", node->GetName().c_str(), - index); + GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, OpDesc in node is nullptr"); return nullptr; } auto tensor = node_desc->GetInputDescPtr(index); if (tensor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d input tensor, check invalid", node_desc->GetName().c_str(), node_desc->GetType().c_str(), index); - GELOGE(INTERNAL_ERROR, "Failed to find the tensor by index %d from node %s, can not add the memcpy node", index, - node->GetName().c_str()); + 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; } auto anchor = node->GetInDataAnchor(index); if (anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d in data anchor, check invalid", node->GetName().c_str(), node->GetType().c_str(), index); - GELOGE(INTERNAL_ERROR, "Failed to add memcpy before node %s index %d, the in anchor does not exists", - node->GetName().c_str(), index); + 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; } auto memcpy_opdesc = MakeShared("SwitchDataEdgesByPass_Memcpy_" + std::to_string(counter), MEMCPYASYNC); if (memcpy_opdesc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(OUT_OF_MEMORY, "Failed to add memcpy before node %s index %d", node->GetName().c_str(), index); + GELOGE(OUT_OF_MEMORY, "[New][OpDesc] failed"); return nullptr; } 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", memcpy_opdesc->GetName().c_str(), memcpy_opdesc->GetType().c_str(), node->GetOwnerComputeGraph()->GetName().c_str()); - GELOGE(OUT_OF_MEMORY, "Failed to add memcpy before node %s index %d", node->GetName().c_str(), index); + GELOGE(OUT_OF_MEMORY, "[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; } (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) { for (const auto &node : graph->GetDirectNode()) { 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; } @@ -235,9 +237,9 @@ Status SwitchDataEdgesBypass::BypassSwitch(const NodePtr &node) { } 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); - 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; } diff --git a/ge/graph/passes/switch_dead_branch_elimination.cc b/ge/graph/passes/switch_dead_branch_elimination.cc index b840bfc7..3c6c57d0 100644 --- a/ge/graph/passes/switch_dead_branch_elimination.cc +++ b/ge/graph/passes/switch_dead_branch_elimination.cc @@ -32,7 +32,7 @@ const int kDefaultInputIndex = -1; bool ParsePred(const ConstGeTensorPtr &tensor) { if (tensor == nullptr) { REPORT_INNER_ERROR("E19999", "Param tensor is nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] parameter tensor is nullptr."); return false; } 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()) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no weight, check invalid", 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; } @@ -76,7 +78,7 @@ bool ParseOutDataAnchors(const NodePtr &node, const NodePtr &pred_node, OutDataA if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); return false; } 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) { if (node == nullptr || active_out_data_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Param node or active_out_data_anchor is nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] parameter node or active_out_data_anchor is nullptr."); 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", pred_node->GetName().c_str(), pred_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; } // Remove link between pred and switch @@ -124,7 +129,8 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre if (out_index >= switch_io_map.size()) { REPORT_INNER_ERROR("E19999", "Out index:%zu of node:%s(%s) >= %zu, check invalid", out_index, node->GetName().c_str(), node->GetType().c_str(), switch_io_map.size()); - GELOGE(FAILED, "[%s] out index check failed, out_index:%zu.", node->GetName().c_str(), out_index); + GELOGE(FAILED, "[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; } switch_io_map[out_index] = kDataInputIndex; @@ -134,12 +140,13 @@ Status SwitchDeadBranchElimination::DeleteSwitchNode(NodePtr &node, NodePtr &pre Status SwitchDeadBranchElimination::Run(NodePtr &node) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "Param [node] must not be null."); + GELOGE(PARAM_INVALID, "[Check][Param] Param [node] must not be null."); return PARAM_INVALID; } 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)) { return SUCCESS; } @@ -181,6 +188,8 @@ Status SwitchDeadBranchElimination::Run(NodePtr &node) { if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove inactive branch from node:%s(%s) to merge failed", node->GetName().c_str(), node->GetType().c_str()); + GELOGE(FAILED, "[Remove][InactiveBranch] from node:%s(%s) to merge failed", + node->GetName().c_str(), node->GetType().c_str()); return ret; } diff --git a/ge/graph/passes/switch_logic_remove_pass.cc b/ge/graph/passes/switch_logic_remove_pass.cc index bce714ad..13b409c5 100644 --- a/ge/graph/passes/switch_logic_remove_pass.cc +++ b/ge/graph/passes/switch_logic_remove_pass.cc @@ -47,7 +47,8 @@ Status GetPredNode(const NodePtr &switch_node, PredNodeAndOut &pred_node_index) if (pred_in_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no index:%d in data anchor, check invalid", switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex); - GELOGE(INTERNAL_ERROR, "Failed to get pred node for switch %s, no pred anchor", switch_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[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; } 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", switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex); GELOGE(INTERNAL_ERROR, - "Failed to get pred node for switch %s, node peer out anchor", - switch_node->GetName().c_str()); + "[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; } 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", switch_node->GetName().c_str(), switch_node->GetType().c_str(), kSwitchPredIndex); GELOGE(INTERNAL_ERROR, - "Failed to get pred node for switch %s, null node", - switch_node->GetName().c_str()); + "[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; } pred_node_index.first = pred_node; @@ -82,7 +83,7 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) { PredNodeAndOut pred_node_and_out; auto ret = GetPredNode(node, pred_node_and_out); 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()); return INTERNAL_ERROR; } @@ -97,14 +98,16 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) { if (in_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d out data anchor, its peer anchors has nullptr, " "check invalid", node->GetName().c_str(), node->GetType().c_str(), i); - GELOGE(INTERNAL_ERROR, "The in-anchor from out anchor %d node %s is null", i, node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[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; } auto dst_node = in_anchor->GetOwnerNode(); if (dst_node == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s)'s index:%d out data anchor, its peer nodes has nullptr, " "check invalid", node->GetName().c_str(), node->GetType().c_str(), i); - GELOGE(INTERNAL_ERROR, "The peer node from out anchor %d node %s is null", i, node->GetName().c_str()); + 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; } if (!IsSwitch(dst_node->GetType())) { @@ -113,7 +116,8 @@ Status SwitchLogicRemovePass::Run(NodePtr &node) { PredNodeAndOut pred_node_next_switch; ret = GetPredNode(dst_node, pred_node_next_switch); 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()); return INTERNAL_ERROR; } @@ -153,8 +157,10 @@ Status SwitchLogicRemovePass::RemoveSwitchNodeLogically(int parent_index, NodePt std::vector end_nodes; auto ret = PassUtils::RemoveInactiveBranchToMerge(out_anchor, deleted_nodes, end_nodes); if (ret != SUCCESS) { - REPORT_CALL_ERROR("E19999", "Remove inactive branch from node:%s(%s) to merge failed", + REPORT_CALL_ERROR("E19999", "Remove inactivate branch from node:%s(%s) to merge failed", 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; } diff --git a/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc index af87dafa..e7743130 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.cc +++ b/ge/graph/passes/switch_to_stream_switch_pass.cc @@ -26,22 +26,28 @@ namespace ge { Status SwitchToStreamSwitchPass::Run(ComputeGraphPtr graph) { 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_) { - 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_) { GE_CHK_BOOL_EXEC(graph->IsolateNode(node) == GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); - return FAILED, "Isolate node failed."); + 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, REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); return FAILED, - "Remove switch node failed."); + "[Remove][Node] %s(%s) without relink in graph:%s failed", + node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); } GELOGD("SwitchToStreamSwitchPass Leave"); @@ -72,7 +78,8 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra std::string type; std::unordered_map> cond_switch_map; 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)) { continue; } @@ -81,7 +88,7 @@ Status SwitchToStreamSwitchPass::CheckCycleDependence(const ComputeGraphPtr &gra OutDataAnchorPtr peer_out_anchor = in_cond_anchor->GetPeerOutAnchor(); GE_CHECK_NOTNULL(peer_out_anchor); 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; } @@ -159,7 +166,7 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph, OutDataAnchorPtr peer_data_anchor = nullptr; OutDataAnchorPtr peer_cond_anchor = nullptr; 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_cond_anchor); 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(), TypeUtils::DataTypeToSerialString(cond_data_type).c_str()); 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()); 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()) { GE_IF_BOOL_EXEC(stream_switch == nullptr, { 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) { REPORT_CALL_ERROR("E19999", "Set switch true branch flag from node:%s(%s) failed", stream_switch->GetName().c_str(), stream_switch->GetType().c_str()); - GELOGE(FAILED, "SetSwitchTrueBranchFlag for node %s failed.", stream_switch->GetName().c_str()); + GELOGE(FAILED, "[Set][SwitchTrueBranchFlag] for node %s failed.", stream_switch->GetName().c_str()); return FAILED; } 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; } if (!cyclic_flag) { GE_CHK_STATUS(GraphUtils::AddEdge(peer_data_anchor->GetOwnerNode()->GetOutControlAnchor(), 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(); - 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()), - "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()); } @@ -218,7 +234,7 @@ Status SwitchToStreamSwitchPass::ReplaceSwitchNode(const ComputeGraphPtr &graph, if (SetOriginalNodeName(stream_switch, switch_node->GetName()) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Set original node name:%s to node:%s(%s) failed", switch_node->GetName().c_str(), stream_switch->GetName().c_str(), stream_switch->GetType().c_str()); - GELOGE(FAILED, "SetOriginalNodeName for node %s failed.", stream_switch->GetName().c_str()); + GELOGE(FAILED, "[Set][OriginalNodeName] for node %s failed.", stream_switch->GetName().c_str()); 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()->GetType().c_str(), peer_out_anchor->GetIdx(), switch_node->GetName().c_str(), switch_node->GetType().c_str(), idx); - GELOGE(FAILED, "Remove data edge %s->%s failed.", peer_out_anchor->GetOwnerNode()->GetName().c_str(), - switch_node->GetName().c_str()); + 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; } @@ -283,7 +301,7 @@ Status SwitchToStreamSwitchPass::FindSwitchCondInput(OutDataAnchorPtr &peer_cond 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)); } @@ -304,13 +322,13 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr & OpDescPtr switch_op_desc = switch_node->GetOpDesc(); GE_CHK_BOOL_EXEC(switch_op_desc != nullptr, REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); - return nullptr, "OpDesc of Switch node is invalid."); + return nullptr, "[Get][OpDesc] failed, OpDesc of Switch node is invalid."); GE_IF_BOOL_EXEC(switch_op_desc->GetInputsSize() != SWITCH_INPUT_NUM, { REPORT_INNER_ERROR("E19999", "Input desc size:%zu of node:%s(%s) not equal to %u, check invalid", switch_op_desc->GetInputsSize(), switch_op_desc->GetName().c_str(), switch_op_desc->GetType().c_str(), SWITCH_INPUT_NUM); - GELOGE(FAILED, "Switch input param invalid, input_size=%lu, should be %u.", switch_op_desc->GetInputsSize(), - SWITCH_INPUT_NUM); + GELOGE(FAILED, "[Check][Param] Switch input param invalid, input_size=%lu, should be %u.", + switch_op_desc->GetInputsSize(), SWITCH_INPUT_NUM); return nullptr; }); @@ -319,7 +337,7 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr & OpDescPtr op_desc = MakeShared(node_name, STREAMSWITCH); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "Create op_desc failed, StreamSwitch:%s.", node_name.c_str()); + GELOGE(FAILED, "[New][OpDesc] failed."); 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", ATTR_NAME_SWITCH_DATA_TYPE.c_str(), ATTR_NAME_STREAM_SWITCH_COND.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set int failed"); + GELOGE(INTERNAL_ERROR, "[Set][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; } @@ -354,20 +374,25 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr & REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", op_desc->GetName().c_str(), op_desc->GetType().c_str()); return nullptr, - "Create StreamSwitch node: add input desc failed."); + "[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, - 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()); 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); GE_CHK_BOOL_EXEC(stream_switch != nullptr, REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - return nullptr, "Insert StreamSwitch node failed."); + 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)), - "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; 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, { REPORT_INNER_ERROR("E19999", "switch group size:%zu not equal to %u, group_id:%ld, check invalid", switch_group_it->second.size(), SWITCH_OUTPUT_NUM, switch_group_id); - GELOGE(INTERNAL_ERROR, "Check size failed, node: %s", stream_switch->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][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; }); 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()); 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); - 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()), - "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) { REPORT_CALL_ERROR("E19999", "Set active label list:%s to op:%s(%s) failed", cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str()); - GELOGE(FAILED, "Set active_label_list attr for node %s failed.", active_node->GetName().c_str()); + GELOGE(FAILED, "[Set][ActiveLabelList] %s to op:%s(%s) failed.", + cast_node->GetName().c_str(), active_node->GetName().c_str(), active_node->GetType().c_str()); return FAILED; } @@ -505,38 +535,48 @@ Status SwitchToStreamSwitchPass::CombineSwitchNode(const ComputeGraphPtr &graph) // select first stream_switch NodePtr stream_switch = switch_list.front(); + OpDescPtr switch_desc = stream_switch->GetOpDesc(); + GE_CHECK_NOTNULL(switch_desc); // set stream_label if (SetStreamLabel(stream_switch, cast_node->GetName()) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Set stream_label:%s to op:%s(%s) failed", cast_node->GetName().c_str(), stream_switch->GetName().c_str(), stream_switch->GetType().c_str()); - GELOGE(FAILED, "Set stream label failed."); + 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; } - OpDescPtr switch_desc = stream_switch->GetOpDesc(); - GE_CHECK_NOTNULL(switch_desc); switch_desc->SetName(CheckDuplicateName(cond_group + "/" + STREAMSWITCH + (true_branch_flag ? "_t" : "_f"))); stream_switch_nodes_.emplace_back(stream_switch); // 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)), - "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)), - "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); for (const NodePtr &node : switch_list) { GE_IF_BOOL_EXEC(node != stream_switch, { 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()), - "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(node_name, STREAMACTIVE); if (op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "Create op_desc failed, StreamActive:%s.", node_name.c_str()); + GELOGE(FAILED, "[New][OpDesc] failed."); return nullptr; } @@ -563,12 +603,15 @@ NodePtr SwitchToStreamSwitchPass::CreateActiveNode(const ComputeGraphPtr &graph, GE_CHK_BOOL_EXEC(active_node != nullptr, REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", op_desc->GetName().c_str(), op_desc->GetType().c_str(), graph->GetName().c_str()); - return nullptr, "Create StreamActive node failed."); + 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, REPORT_CALL_ERROR("E19999", "Set switch branch node label:%s to node:%s(%s) failed", node_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set switch branch node label failed"); + GELOGE(INTERNAL_ERROR, "[Set][SwitchBranchNodeLabel] %s to node:%s(%s) failed", + node_name.c_str(), active_node->GetName().c_str(), active_node->GetType().c_str()); return nullptr); return active_node; @@ -582,14 +625,15 @@ NodePtr SwitchToStreamSwitchPass::CreateActiveNode(const ComputeGraphPtr &graph, /// NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, const OutDataAnchorPtr &peer_cond_anchor) { 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); GELOGI("Create cast_node: %s, input datatype:DT_BOOL, out datatype:DT_INT32", cast_name.c_str()); OpDescPtr cast_desc = MakeShared(cast_name, CAST); if (cast_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "Create op_desc failed, Cast:%s.", cast_name.c_str()); + GELOGE(FAILED, "[New][OpDesc] failed."); return nullptr; } 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_DST_TYPE.c_str(), CAST_ATTR_TRUNCATE.c_str(), cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); - GELOGE(FAILED, "Set CAST_ATTR_SRCT or CAST_ATTR_DSTT or CAST_ATTR_DST_TYPE or CAST_ATTR_TRUNCATE failed, node: %s.", - cast_name.c_str()); + 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; } @@ -611,22 +657,29 @@ NodePtr SwitchToStreamSwitchPass::CreateCastOp(const ComputeGraphPtr &graph, con REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); return nullptr, - "Cast_node add input desc failed."); + "[Add][InputDesc] to op:%s(%s) failed", + cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); tensor_desc.SetDataType(DT_INT32); GE_CHK_BOOL_EXEC(cast_desc->AddOutputDesc(tensor_desc) == SUCCESS, REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); return nullptr, - "Cast_node add output desc failed."); + "[Add][OutputDesc] to op:%s(%s) failed", + cast_desc->GetName().c_str(), cast_desc->GetType().c_str()); NodePtr cast_node = graph->AddNode(cast_desc); GE_CHK_BOOL_EXEC(cast_node != nullptr, REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", cast_desc->GetName().c_str(), cast_desc->GetType().c_str(), graph->GetName().c_str()); - return nullptr, "Create cast_node failed."); + 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 - 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; } @@ -646,14 +699,15 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); return FAILED, - "StreamSwitch get attr TRUE_BRANCH_STREAM failed."); + "[Get][Attr] %s 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"); GELOGI("Create const op: %s", const_node_name.c_str()); OpDescPtr const_op_desc = MakeShared(const_node_name, CONSTANT); if (const_op_desc == nullptr) { REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "Create op_desc failed, Constant:%s.", const_node_name.c_str()); + GELOGE(FAILED, "New OpDesc failed."); return FAILED; } @@ -663,27 +717,34 @@ Status SwitchToStreamSwitchPass::AddConstNode(const ComputeGraphPtr &graph, cons MakeShared(data_desc, reinterpret_cast(&resize_value), sizeof(int32_t)); if (const_value == nullptr) { REPORT_CALL_ERROR("E19999", "New GeTensor failed"); - GELOGE(FAILED, "Create tensor failed."); + GELOGE(FAILED, "[New][GeTensor] failed."); return FAILED; } GE_CHK_BOOL_EXEC(AttrUtils::SetTensor(const_op_desc, ATTR_NAME_WEIGHTS, const_value), REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(), const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str()); - return FAILED); + 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, REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str()); return FAILED, - "Create Const op: add output desc failed."); + "[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); GE_CHK_BOOL_EXEC(const_node != nullptr, REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", const_op_desc->GetName().c_str(), const_op_desc->GetType().c_str(), graph->GetName().c_str()); - return FAILED, "Insert Const node failed."); + 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)), - "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; } @@ -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()) { REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(), switch_desc->GetName().c_str(), switch_desc->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ORIG_NODE_NAME failed, node: %s", switch_desc->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Get][Attr] %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; } for (const NodePtr &in_ctrl_node : switch_node->GetInControlNodes()) { 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_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); if (same_cond_switch.count(in_ctrl_node) > 0) { 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; } @@ -728,7 +793,8 @@ Status SwitchToStreamSwitchPass::ModifySwitchInCtlEdges(const NodePtr &switch_no GE_IF_BOOL_EXEC(find_res1 == switch_node_map_.end(), { REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid", in_ctrl_node->GetName().c_str(), in_ctrl_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", in_ctrl_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][Param] StreamSwitch node %s not found in switch_node_map_.", + in_ctrl_node->GetName().c_str()); return INTERNAL_ERROR; }); 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(), { REPORT_INNER_ERROR("E19999", "Node:%s(%s) can't find in switch_node_map_, check invalid", switch_node->GetName().c_str(), switch_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "StreamSwitch node %s not found in switch_node_map_.", switch_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][Param] StreamSwitch node %s not found in switch_node_map_.", + switch_node->GetName().c_str()); return INTERNAL_ERROR; }); GE_IF_BOOL_EXEC(find_res->second.empty(), { REPORT_INNER_ERROR("E19999", "True_nodes of StreamSwitch node:%s(%s) is empty, check invalid", switch_node->GetName().c_str(), switch_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "true_nodes of StreamSwitch node %s is empty.", switch_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][Param] true_nodes of StreamSwitch node %s is empty.", + switch_node->GetName().c_str()); return INTERNAL_ERROR; }); 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(); 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(); GE_IF_BOOL_EXEC(op_desc->HasAttr(ATTR_NAME_ORIG_NODE_NAME), { if (!AttrUtils::GetStr(op_desc, ATTR_NAME_ORIG_NODE_NAME, orig_name) || orig_name.empty()) { REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_ORIG_NODE_NAME.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "Get attr ATTR_NAME_ORIG_NODE_NAME failed, node: %s.", op_desc->GetName().c_str()); + 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; } }); @@ -786,13 +856,17 @@ Status SwitchToStreamSwitchPass::ModifySwitchOutCtlEdges(const NodePtr &switch_n auto active_out_ctrl_anchor = active_node->GetOutControlAnchor(); GE_CHECK_NOTNULL(active_out_ctrl_anchor); 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 { auto switch_out_ctrl_anchor = stream_switch->GetOutControlAnchor(); GE_CHECK_NOTNULL(switch_out_ctrl_anchor); 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()) { GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(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 { GE_IF_BOOL_EXEC(!out_ctrl_anchor->IsLinkedWith(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()), - "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()) { GE_IF_BOOL_EXEC(!new_node->GetOutControlAnchor()->IsLinkedWith(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()), - "Remove out ctrl edge failed."); + "[Remove][ControlEdge] between %s and %s failed.", + old_node->GetName().c_str(), out_node->GetName().c_str()); } } } // namespace ge diff --git a/ge/graph/passes/transop_breadth_fusion_pass.cc b/ge/graph/passes/transop_breadth_fusion_pass.cc index a52f4389..58b40a5f 100644 --- a/ge/graph/passes/transop_breadth_fusion_pass.cc +++ b/ge/graph/passes/transop_breadth_fusion_pass.cc @@ -32,7 +32,7 @@ Status TransOpBreadthFusionPass::Run(ge::ComputeGraphPtr graph) { Status ret_topo = graph->TopologicalSorting(); if (ret_topo != SUCCESS) { REPORT_CALL_ERROR("E19999", "Topological sorting for graph:%s failed", graph->GetName().c_str()); - GELOGE(ret_topo, "TopologicalSorting the merged graph failed."); + GELOGE(ret_topo, "[Call][TopologicalSorting] for graph:%s failed.", graph->GetName().c_str()); 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, 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 trans_shapes = { RESHAPE, EXPANDDIMS, SQUEEZE }; + std::set trans_shape_and_format = { TRANSPOSE, TRANSPOSED, EXPANDDIMS }; if (node->GetType() == CAST) { 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_shape = true; } else if (node->GetType() == TRANSDATA) { trans_data_type = true; trans_format = 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; } else if (node->GetType() == REFORMAT) { trans_format = true; diff --git a/ge/graph/passes/transop_depth_fusion_pass.cc b/ge/graph/passes/transop_depth_fusion_pass.cc index 05b55307..ea4add35 100755 --- a/ge/graph/passes/transop_depth_fusion_pass.cc +++ b/ge/graph/passes/transop_depth_fusion_pass.cc @@ -44,7 +44,7 @@ graphStatus TransOpDepthFusionPass::Run(ComputeGraphPtr graph) { GE_CHECK_NOTNULL(out_anchor); for (const auto &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { 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()); } } @@ -83,7 +83,7 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_ if (dst_in_anchor == nullptr || dst_in_anchor->GetOwnerNode() == nullptr || dst_in_anchor->GetOwnerNode()->GetOpDesc() == nullptr) { REPORT_INNER_ERROR("E19999", "Param dst_in_anchor related node info has nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] Param dst_in_anchor related node info has nullptr."); return GRAPH_FAILED; } auto node = dst_in_anchor->GetOwnerNode(); @@ -98,12 +98,15 @@ graphStatus TransOpDepthFusionPass::RecursiveInDepth(const InDataAnchorPtr &dst_ auto out_anchor = node->GetOutDataAnchor(0); GE_CHECK_NOTNULL(out_anchor); 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()); for (auto &in_anchor : in_anchors) { 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)) { 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); GE_CHECK_NOTNULL(out_anchor); 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) { - 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()); } 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(); GE_CHECK_NOTNULL(new_out_anchor); 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) auto out_anchor = node->GetOutDataAnchor(0); 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(), trans_op_.top()->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(); for (const auto &in_anchor : in_anchors) { 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(), @@ -259,17 +267,23 @@ graphStatus TransOpDepthFusionPass::RelinkEdges(const OutDataAnchorPtr &new_out_ const InDataAnchorPtr &in_data_anchor) { if (new_out_anchor == nullptr || old_out_anchor == nullptr || in_data_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Param anchor info has nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "new_out_anchor or old_out_anchor or in_data_anchor is nullptr"); + GELOGE(INTERNAL_ERROR, "[Check][Param] new_out_anchor or old_out_anchor or in_data_anchor is nullptr"); return GRAPH_FAILED; } if (new_out_anchor->GetOwnerNode() == nullptr || old_out_anchor->GetOwnerNode() == nullptr || in_data_anchor->GetOwnerNode() == nullptr) { REPORT_INNER_ERROR("E19999", "Param anchor info owner node has nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "anchor's owner node is nullptr"); + GELOGE(INTERNAL_ERROR, "[Check][Param] anchor's owner node has nullptr"); 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( "relink edges before remove node, remove data edge between node: %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) { auto out_ctrl_anchor = src_node->GetOutControlAnchor(); 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( "relink edges before remove node, add control edge between node: %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) { 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; } if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); - GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", node->GetName().c_str(), - 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_SUCCESS; diff --git a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc index 78c60eda..76233f53 100644 --- a/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc +++ b/ge/graph/passes/transop_nearby_allreduce_fusion_pass.cc @@ -32,7 +32,7 @@ Status TransOpNearbyAllreduceFusionPass::Run(NodePtr &node) { GELOGI("found allreduce op %s", node->GetName().c_str()); Status ret = RemoveNearbyPairedTransOps(node); if (ret != SUCCESS) { - GELOGE(FAILED, "failed to remove paired transop for allreduce op %s", node->GetName().c_str()); + GELOGE(FAILED, "[Remove][PairedTransOp] for allreduce op:%s", node->GetName().c_str()); return FAILED; } GELOGI("successfully remove paired transop for allreduce op (%s)", node->GetName().c_str()); @@ -102,7 +102,7 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt REPORT_INNER_ERROR("E19999", "In data anchors size:%zu not equal to out data anchors size:%zu in node:%s(%s), " "check invalid", in_data_anchors.size(), out_data_anchors.size(), node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "in and out data anchor size are not equal, node=%s, in_size=%zu, out_size=%zu", + GELOGE(FAILED, "[Check][Param] in and out data anchor size are not equal, node=%s, in_size=%zu, out_size=%zu", node->GetName().c_str(), in_data_anchors.size(), out_data_anchors.size()); return FAILED; } @@ -148,7 +148,7 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt if (IsolateAndDeleteNode(in_node, {0}) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", in_node->GetName().c_str(), in_node->GetType().c_str()); - GELOGE(FAILED, "remove node %s failed", in_node->GetName().c_str()); + GELOGE(FAILED, "[Remove][Node] %s failed", in_node->GetName().c_str()); return FAILED; } removed_node_count++; @@ -157,7 +157,7 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt if (IsolateAndDeleteNode(out_node, {0}) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", out_node->GetName().c_str(), out_node->GetType().c_str()); - GELOGE(FAILED, "remove node %s failed", out_node->GetName().c_str()); + GELOGE(FAILED, "[Remove][Node] %s failed", out_node->GetName().c_str()); return FAILED; } removed_node_count++; @@ -171,12 +171,14 @@ Status TransOpNearbyAllreduceFusionPass::RemoveNearbyPairedTransOps(const NodePt if (node->GetOpDesc()->UpdateInputDesc(static_cast(i), input_desc) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Update input:%zu desc in op:%s(%s) failed", i, node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "UpdateInputDesc fail."); + GELOGE(FAILED, "[Update][InputDesc] in op:%s(%s) failed, input index:%zu", + node->GetName().c_str(), node->GetType().c_str(), i); } if (node->GetOpDesc()->UpdateOutputDesc(static_cast(i), output_desc) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Update output:%zu desc in op:%s(%s) failed", i, node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "UpdateOutputDesc"); + GELOGE(FAILED, "[Update][OutputDesc] in op:%s(%s) failed, input index:%zu", + node->GetName().c_str(), node->GetType().c_str(), i); } GELOGI("successfully remove paired transop (%s and %s) for node %s", in_node->GetName().c_str(), out_node->GetName().c_str(), node->GetName().c_str()); diff --git a/ge/graph/passes/transop_symmetry_elimination_pass.cc b/ge/graph/passes/transop_symmetry_elimination_pass.cc index 2ea7fac1..665f4bd8 100644 --- a/ge/graph/passes/transop_symmetry_elimination_pass.cc +++ b/ge/graph/passes/transop_symmetry_elimination_pass.cc @@ -178,7 +178,11 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(), dst_in_anchor->GetOwnerNode()->GetName().c_str(), dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx()); - GELOGE(FAILED, "Unlink data anchor from %s to %s.", src_node->GetName().c_str(), dst_node->GetName().c_str()); + GELOGE(FAILED, "[Unlink][DataAnchor] from %s(%s)(index:%d) to %s(%s)(index:%d) failed.", + src_out_anchor->GetOwnerNode()->GetName().c_str(), + src_out_anchor->GetOwnerNode()->GetType().c_str(), src_out_anchor->GetIdx(), + dst_in_anchor->GetOwnerNode()->GetName().c_str(), + dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx()); return ret; } // 2.Link A->T2 @@ -194,8 +198,11 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const in_anchor->GetPeerOutAnchor()->GetIdx(), dst_in_anchor->GetOwnerNode()->GetName().c_str(), dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx()); - GELOGE(FAILED, "Add data edge from %s to %s failed.", pre_normal_node->GetName().c_str(), - dst_node->GetName().c_str()); + GELOGE(FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", + pre_normal_node->GetName().c_str(), pre_normal_node->GetType().c_str(), + in_anchor->GetPeerOutAnchor()->GetIdx(), + dst_in_anchor->GetOwnerNode()->GetName().c_str(), + dst_in_anchor->GetOwnerNode()->GetType().c_str(), dst_in_anchor->GetIdx()); return ret; } // 3.Copy in-control/data-in-control from T1->T2 @@ -204,7 +211,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed", src_node->GetName().c_str(), src_node->GetType().c_str(), dst_node->GetName().c_str(), dst_node->GetType().c_str()); - GELOGE(FAILED, "Copy control edge from %s to %s failed.", src_node->GetName().c_str(), dst_node->GetName().c_str()); + GELOGE(FAILED, "[Copy][InCtrlEdges] from node:%s(%s) to node:%s(%s) failed", + src_node->GetName().c_str(), src_node->GetType().c_str(), + dst_node->GetName().c_str(), dst_node->GetType().c_str()); return ret; } // 4.Add control edge from T1 other input to T2, like reshape second input @@ -215,7 +224,9 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", in_node->GetName().c_str(), in_node->GetType().c_str(), dst_node->GetName().c_str(), dst_node->GetType().c_str()); - GELOGE(FAILED, "Add control edge from %s to %s failed.", in_node->GetName().c_str(), dst_node->GetName().c_str()); + GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + in_node->GetName().c_str(), in_node->GetType().c_str(), + dst_node->GetName().c_str(), dst_node->GetType().c_str()); return ret; } } @@ -224,15 +235,16 @@ Status TransOpSymmetryEliminationPass::EliminateTransOp(NodePtr &src_node, const if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", dst_node->GetName().c_str(), dst_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", dst_node->GetName().c_str(), - dst_node->GetType().c_str()); + GELOGE(INTERNAL_ERROR, "[IsolateAndDelete][Node] failed, node name:%s, node type:%s ", + dst_node->GetName().c_str(), dst_node->GetType().c_str()); return ret; } GELOGI("Trans op symmetry eliminate successfully. Node %s has been removed.", dst_node->GetName().c_str()); // 6.If T1 has no data out, isolate and deleted it. ret = RemoveTransOpWithoutOutput(pre_normal_node, src_node); if (ret != GRAPH_SUCCESS) { - GELOGE(ret, "Isolate removed node: %s, type: %s failed", src_node->GetName().c_str(), src_node->GetType().c_str()); + GELOGE(ret, "[Call][RemoveTransOpWithoutOutput] for node:%s(%s) failed", + src_node->GetName().c_str(), src_node->GetType().c_str()); return ret; } return SUCCESS; @@ -245,7 +257,7 @@ Status TransOpSymmetryEliminationPass::RemoveTransOpWithoutOutput(NodePtr &pre_n REPORT_CALL_ERROR("E19999", "Copy out control edge from node:%s(%s) to node:%s(%s) failed", trans_node->GetName().c_str(), trans_node->GetType().c_str(), pre_node->GetName().c_str(), pre_node->GetType().c_str()); - GELOGE(FAILED, "Copy control edge from %s to %s failed.", trans_node->GetName().c_str(), + GELOGE(FAILED, "[Copy][OutCtrlEdges] from %s to %s failed.", trans_node->GetName().c_str(), pre_node->GetName().c_str()); return ret; } @@ -254,7 +266,7 @@ Status TransOpSymmetryEliminationPass::RemoveTransOpWithoutOutput(NodePtr &pre_n if (ret != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate and delete node:%s(%s) failed", trans_node->GetName().c_str(), trans_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", trans_node->GetName().c_str(), + GELOGE(INTERNAL_ERROR, "[IsolateAndDelete][Node] %s(%s) failed", trans_node->GetName().c_str(), trans_node->GetType().c_str()); return ret; } diff --git a/ge/graph/passes/transop_without_reshape_fusion_pass.cc b/ge/graph/passes/transop_without_reshape_fusion_pass.cc index cd16258a..7e80299b 100644 --- a/ge/graph/passes/transop_without_reshape_fusion_pass.cc +++ b/ge/graph/passes/transop_without_reshape_fusion_pass.cc @@ -66,7 +66,9 @@ void TransOpWithoutReshapeFusionPass::SetRemainNode( GE_IF_BOOL_EXEC(!op_desc->SetExtAttr(kRemainNode, true), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kRemainNode, op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set ext attr failed"); return); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", kRemainNode, + op_desc->GetName().c_str(), op_desc->GetType().c_str()); + return); } } @@ -79,27 +81,33 @@ bool TransOpWithoutReshapeFusionPass::FormatContinuousCheck(const OutDataAnchorP auto in_node = in_anchor->GetOwnerNode(); GE_IF_BOOL_EXEC(in_node == nullptr, REPORT_INNER_ERROR("E19999", "Param in_anchor's owner node is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "in_node is null"); return false); + GELOGE(INTERNAL_ERROR, "[Check][Param]Param in_anchor's owner node is nullptr"); + return false); auto in_op = in_node->GetOpDesc(); auto out_owner_node = out_anchor->GetOwnerNode(); GE_IF_BOOL_EXEC(out_owner_node == nullptr, REPORT_INNER_ERROR("E19999", "Param out_anchor's owner node is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "out_owner_node is null"); return false); + GELOGE(INTERNAL_ERROR, "[Check][Param] Param out_anchor's owner node is nullptr"); + return false); auto out_op = out_owner_node->GetOpDesc(); GE_IF_BOOL_EXEC(in_op == nullptr, REPORT_INNER_ERROR("E19999", "Param in_anchor's owner op_desc is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "in_op is null"); return false); + GELOGE(INTERNAL_ERROR, "[Check][Param] Param in_anchor's owner op_desc is nullptr"); + return false); GE_IF_BOOL_EXEC(out_op == nullptr, REPORT_INNER_ERROR("E19999", "Param out_anchor's owner op_desc is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "out_op is null"); return false); + GELOGE(INTERNAL_ERROR, "[Check][Param] Param out_anchor's owner op_desc is nullptr"); + return false); auto in_op_desc = in_op->GetInputDescPtr(in_anchor->GetIdx()); auto out_op_desc = out_op->GetOutputDescPtr(out_anchor->GetIdx()); GE_IF_BOOL_EXEC(in_op_desc == nullptr, REPORT_INNER_ERROR("E19999", "Param in_anchor corresponding tensor is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "in_op_desc is null"); return false); + GELOGE(INTERNAL_ERROR, "[Check][Param] Param in_anchor corresponding tensor is nullptr"); + return false); GE_IF_BOOL_EXEC(out_op_desc == nullptr, REPORT_INNER_ERROR("E19999", "Param out_anchor corresponding tensor is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "out_op_desc is null"); return false); + GELOGE(INTERNAL_ERROR, "[Check][Param] Param out_anchor corresponding tensor is nullptr"); + return false); if (!ShapeEqualCheck(in_op_desc->GetShape(), out_op_desc->GetShape())) { return false; } @@ -375,6 +383,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkSubGraphControlEdges( REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), + in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); return GRAPH_FAILED; } } @@ -386,6 +397,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkSubGraphControlEdges( REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), + in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); return GRAPH_FAILED; } } @@ -417,6 +431,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add]ControlEdge] between op:%s(%s) and op:%s(%s) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), + peer_in_anchor->GetOwnerNode()->GetType().c_str()); return GRAPH_FAILED; } } @@ -430,6 +448,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(), in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add]ControlEdge] between op:%s(%s) and op:%s(%s) failed", + peer_out_anchor->GetOwnerNode()->GetName().c_str(), + peer_out_anchor->GetOwnerNode()->GetType().c_str(), + in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str()); return GRAPH_FAILED; } } @@ -443,6 +465,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add]ControlEdge] between op:%s(%s) and op:%s(%s) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), + peer_in_anchor->GetOwnerNode()->GetType().c_str()); return GRAPH_FAILED; } } @@ -456,6 +482,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdgesWhenDescNotChange out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add]ControlEdge] between op:%s(%s) and op:%s(%s) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), + peer_in_anchor->GetOwnerNode()->GetType().c_str()); return GRAPH_FAILED; } } @@ -476,15 +506,19 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkNodesWhenDescNotChanged( GELOGI("remove edge.src %s, src idx:%d, dst:%s, dst idx:%d", end_anchors_pair.first->GetOwnerNode()->GetName().c_str(), end_anchors_pair.first->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_anchors_pair.first, in_anchor), "remove edge failed"); + GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_anchors_pair.first, in_anchor), + "[Remove][Edge] between %s(%s)(index:%d) and %s(%s)(index:%d) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(), + in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx()); GELOGI("relink node.src node:%s, src idx:%d, dst node:%s, dst idx:%d", out_owner_node->GetName().c_str(), out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx()); if (GraphUtils::AddEdge(out_anchor, in_anchor) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx()); - GELOGE(GRAPH_FAILED, "add edge failed!src:%s, src idx:%d, dst:%s, dst idx:%d", out_owner_node->GetName().c_str(), - out_anchor->GetIdx(), in_owner_node->GetName().c_str(), in_anchor->GetIdx()); + GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(), + in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx()); return GRAPH_FAILED; } else { auto old_peer_in_anchor = begin_anchors_pair.second; @@ -506,8 +540,8 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes format_transfer_op_name << "fusion_format_transfer_" << fusion_format_transfer_op_count; OpDescPtr format_transfer_op = MakeShared(format_transfer_op_name.str().c_str(), TRANSDATA); if (format_transfer_op == nullptr) { - REPORT_CALL_ERROR("E19999", "New GeTensor failed"); - GELOGE(INTERNAL_ERROR, "new format transfer op failed!"); + REPORT_CALL_ERROR("E19999", "New OpDesc failed"); + GELOGE(INTERNAL_ERROR, "[New][OpDesc] failed"); return nullptr; } @@ -515,13 +549,15 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes static_cast(format_trans_input_desc.GetFormat())), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(), format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set ATTR_NAME_INPUT_FORMAT failed"); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_INPUT_FORMAT.c_str(), + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); GE_IF_BOOL_EXEC(!AttrUtils::SetInt(format_transfer_op, ATTR_NAME_OUTPUT_FORMAT, static_cast(format_trans_output_desc.GetFormat())), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(), format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set ATTR_NAME_OUTPUT_FORMAT failed"); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_OUTPUT_FORMAT.c_str(), + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); string src_format = TypeUtils::FormatToSerialString(format_trans_input_desc.GetFormat()); @@ -530,31 +566,36 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetFormatTransferOp(const GeTensorDes GE_IF_BOOL_EXEC(!AttrUtils::SetStr(format_transfer_op, kAttrNameSrcFormat, src_format), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kAttrNameSrcFormat, format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set kAttrNameSrcFormat failed"); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", kAttrNameSrcFormat, + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); GE_IF_BOOL_EXEC(!AttrUtils::SetStr(format_transfer_op, kAttrNameDstFormat, dst_format), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", kAttrNameDstFormat, format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set kAttrNameDstFormat failed"); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", kAttrNameDstFormat, + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); GE_IF_BOOL_EXEC(format_transfer_op->AddInputDesc(format_trans_input_desc) != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "add input desc failed"); + GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed", + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); GE_IF_BOOL_EXEC(format_transfer_op->AddOutputDesc(format_trans_output_desc) != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Add ouput desc to op:%s(%s) failed", format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "add output desc failed"); + GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed", + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); GE_IF_BOOL_EXEC(!ge::AttrUtils::SetBool(format_transfer_op, ATTR_NEED_COMPILE, true), REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(), format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set ext attr failed"); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(), + format_transfer_op->GetName().c_str(), format_transfer_op->GetType().c_str()); return nullptr); return format_transfer_op; } @@ -571,7 +612,7 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in node_op.BreakConnect(); if (cast_op == nullptr) { REPORT_CALL_ERROR("E19999", "Create operator:%s(%s) failed", cast_op_name.str().c_str(), CAST); - GELOGE(INTERNAL_ERROR, "new cast op failed!"); + GELOGE(INTERNAL_ERROR, "[Create][Operator] %s(%s) failed", cast_op_name.str().c_str(), CAST); return nullptr; } const int default_input_index = 0; @@ -580,13 +621,15 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in GE_IF_BOOL_EXEC(cast_op->AddInputDesc(cast_input_desc) != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Add input desc to op:%s(%s) failed", cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "add input desc failed"); + GELOGE(INTERNAL_ERROR, "[Add][InputDesc] to op:%s(%s) failed", + cast_op->GetName().c_str(), cast_op->GetType().c_str()); return nullptr); } else { GE_IF_BOOL_EXEC(cast_op->UpdateInputDesc(default_input_index, cast_input_desc) != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Update input:%d desc of op:%s(%s) failed", default_input_index, cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "update input desc failed"); + GELOGE(INTERNAL_ERROR, "[Update][InputDesc] of op:%s(%s) failed, input index:%d", + cast_op->GetName().c_str(), cast_op->GetType().c_str(), default_input_index); return nullptr); } @@ -594,26 +637,30 @@ OpDescPtr TransOpWithoutReshapeFusionPass::GetCastOp(const GeTensorDesc &cast_in GE_IF_BOOL_EXEC(cast_op->AddOutputDesc(cast_output_desc) != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Add output desc to op:%s(%s) failed", cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "add output desc failed"); + GELOGE(INTERNAL_ERROR, "[Add][OutputDesc] to op:%s(%s) failed", + cast_op->GetName().c_str(), cast_op->GetType().c_str()); return nullptr); } else { GE_IF_BOOL_EXEC(cast_op->UpdateOutputDesc(default_output_index, cast_output_desc) != GRAPH_SUCCESS, REPORT_CALL_ERROR("E19999", "Update output:%d desc of op:%s(%s) failed", default_output_index, cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "update output desc failed"); + GELOGE(INTERNAL_ERROR, "[Update][OutputDesc] of op:%s(%s) failed, output index:%d", + cast_op->GetName().c_str(), cast_op->GetType().c_str(), default_output_index); return nullptr); } if (!AttrUtils::SetInt(cast_op, CAST_ATTR_DST_TYPE, static_cast(cast_output_desc.GetDataType()))) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", CAST_ATTR_DST_TYPE.c_str(), cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set dst_type attr failed"); + GELOGE(INTERNAL_ERROR, "[Set][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; } if (!AttrUtils::SetBool(cast_op, ATTR_NEED_COMPILE, true)) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(), cast_op->GetName().c_str(), cast_op->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "set need_compile attr failed"); + GELOGE(INTERNAL_ERROR, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NEED_COMPILE.c_str(), + cast_op->GetName().c_str(), cast_op->GetType().c_str()); return nullptr; } return cast_op; @@ -662,7 +709,8 @@ void TransOpWithoutReshapeFusionPass::GetBeginOutDescAndEndInDesc(const int inde auto out_owner_node = out_peer_anchor->GetOwnerNode(); GE_CHECK_NOTNULL_JUST_RETURN(out_owner_node); auto out_peer_op_desc = out_owner_node->GetOpDesc(); - GE_IF_BOOL_EXEC(out_peer_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "out_peer_op_desc is nullptr"); return); + GE_IF_BOOL_EXEC(out_peer_op_desc == nullptr, + GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, out_peer_op_desc is nullptr"); return); out_desc = out_peer_op_desc->GetInputDesc(out_peer_anchor->GetIdx()); auto in_peer_anchor = nodes_anchor.back().first; @@ -670,7 +718,8 @@ void TransOpWithoutReshapeFusionPass::GetBeginOutDescAndEndInDesc(const int inde auto in_owner_node = in_peer_anchor->GetOwnerNode(); GE_CHECK_NOTNULL_JUST_RETURN(in_owner_node); auto in_peer_op_desc = in_owner_node->GetOpDesc(); - GE_IF_BOOL_EXEC(in_peer_op_desc == nullptr, GELOGE(INTERNAL_ERROR, "in_peer_op_desc is nullptr"); return); + GE_IF_BOOL_EXEC(in_peer_op_desc == nullptr, + GELOGE(INTERNAL_ERROR, "[Get][OpDesc] failed, in_peer_op_desc is nullptr"); return); in_desc = in_peer_op_desc->GetOutputDesc(in_peer_anchor->GetIdx()); } @@ -802,7 +851,8 @@ void TransOpWithoutReshapeFusionPass::RemoveNousedNodes(const ComputeGraphPtr &g continue; } - GE_IF_BOOL_EXEC(!op_desc->SetExtAttr(kRemainNode, true), GELOGE(INTERNAL_ERROR, "set ext attr failed"); return); + GE_IF_BOOL_EXEC(!op_desc->SetExtAttr(kRemainNode, true), + GELOGE(INTERNAL_ERROR, "[Set][ExtAttr] for op:%s failed", op_desc->GetName().c_str()); return); GELOGI("remove node:%s", node->GetName().c_str()); if (GraphUtils::IsolateNode(node, {0}) != GRAPH_SUCCESS) { GELOGW("Isolate node: %s failed.", node->GetName().c_str()); @@ -949,7 +999,8 @@ graphStatus TransOpWithoutReshapeFusionPass::AddTransNode(const ComputeGraphPtr if (trans_node == nullptr) { REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s failed", transop->GetName().c_str(), transop->GetType().c_str(), graph->GetName().c_str()); - GELOGE(GRAPH_FAILED, "add node failed!"); + GELOGE(GRAPH_FAILED, "[Add][Node] %s(%s) to graph:%s failed", + transop->GetName().c_str(), transop->GetType().c_str(), graph->GetName().c_str()); return GRAPH_FAILED; } return GRAPH_SUCCESS; @@ -1011,13 +1062,18 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph GE_CHECK_NOTNULL(in_owner_node); GELOGI("remove edge.src:%s, src idx:%d, dst:%s, dst idx:%d", end_in.first->GetOwnerNode()->GetName().c_str(), end_in.first->GetIdx(), in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetIdx()); - GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_in.first, in_anchor), "remove edge failed"); + GE_CHK_STATUS_RET(GraphUtils::RemoveEdge(end_in.first, in_anchor), + "[Remove][Edge] between %s and %s failed", + out_owner_node->GetName().c_str(), in_owner_node->GetName().c_str()); GELOGI("add edge.src:%s, src idx:%d, dst:%s", out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetIdx(), new_trans_nodes.front()->GetName().c_str()); if (GraphUtils::AddEdge(out_anchor, new_trans_nodes.front()->GetInAnchor(0)) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed", out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(), new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed", + out_owner_node->GetName().c_str(), out_owner_node->GetType().c_str(), out_anchor->GetIdx(), + new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); return GRAPH_FAILED; } else { auto old_peer_in_anchor = begin_out.second; @@ -1033,6 +1089,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed", new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str(), new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:0) failed", + new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str(), + new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str()); return GRAPH_FAILED; } else { auto old_peer_out_anchor = end_in.first; @@ -1046,6 +1105,9 @@ graphStatus TransOpWithoutReshapeFusionPass::InsertNewTransOp(const ComputeGraph REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed", new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str(), in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx()); + GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed", + new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str(), + in_owner_node->GetName().c_str(), in_owner_node->GetType().c_str(), in_anchor->GetIdx()); return GRAPH_FAILED; } @@ -1057,6 +1119,7 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, GE_CHECK_NOTNULL(out_anchor); if (new_trans_nodes.front() == nullptr || new_trans_nodes.back() == nullptr) { REPORT_INNER_ERROR("E19999", "Param new_trans_nodes front or back is nullptr, check invalid"); + GELOGE(GRAPH_FAILED, "[Check][Param] Param new_trans_nodes front or back is nullptr"); return GRAPH_FAILED; } if (sub_graph_has_control_edge_[index]) { @@ -1067,6 +1130,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(), new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + out_anchor->GetOwnerNode()->GetName().c_str(), out_anchor->GetOwnerNode()->GetType().c_str(), + new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); return GRAPH_FAILED; } } @@ -1080,6 +1146,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); return GRAPH_FAILED; } } @@ -1093,6 +1162,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(), new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(), + new_trans_nodes.front()->GetName().c_str(), new_trans_nodes.front()->GetType().c_str()); return GRAPH_FAILED; } } @@ -1106,6 +1178,9 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str()); return GRAPH_FAILED; } } @@ -1119,6 +1194,10 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), peer_in_anchor->GetOwnerNode()->GetName().c_str(), peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx()); + GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s)(index:0) and op:%s(%s)(index:%d) failed", + new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), + peer_in_anchor->GetOwnerNode()->GetName().c_str(), + peer_in_anchor->GetOwnerNode()->GetType().c_str(), peer_in_anchor->GetIdx()); return GRAPH_FAILED; } } @@ -1129,6 +1208,12 @@ graphStatus TransOpWithoutReshapeFusionPass::RelinkControlEdge(const int index, in_anchor->GetOwnerNode()->GetName().c_str()); if (GraphUtils::AddEdge(new_trans_nodes.back()->GetOutDataAnchor(0), in_anchor->GetOwnerNode()->GetInControlAnchor()) != GRAPH_SUCCESS) { + REPORT_CALL_ERROR("E19999", "Add edge between op:%s(%s) and op:%s(%s) failed", + new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), + in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str()); + GELOGE(GRAPH_FAILED, "[Add][Edge] between op:%s(%s) and op:%s(%s) failed", + new_trans_nodes.back()->GetName().c_str(), new_trans_nodes.back()->GetType().c_str(), + in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str()); return GRAPH_FAILED; } } @@ -1181,6 +1266,7 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphsBetweenNormalNode( graphStatus ret = GRAPH_SUCCESS; if (out_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Param out_anchor is nullptr, check invalid"); + GELOGE(GRAPH_FAILED, "[Check][Param] param out_anchor is nullptr"); return GRAPH_FAILED; } @@ -1200,7 +1286,8 @@ graphStatus TransOpWithoutReshapeFusionPass::GetSubGraphsBetweenNormalNode( for (const auto &peer_out_anchor : peer_in_node->GetAllOutDataAnchors()) { ret = GetSubGraphsBetweenNormalNode(peer_out_anchor, sub_graphs_out, nodes_list); if (ret != GRAPH_SUCCESS) { - GELOGE(GRAPH_FAILED, "get all transops between normal node failed!node:%s", peer_in_node->GetName().c_str()); + GELOGE(GRAPH_FAILED, "[Get][SubGraphs] Between Normal Node failed! node:%s", + peer_in_node->GetName().c_str()); return GRAPH_FAILED; } } diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index 674804bd..27797245 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -35,13 +35,13 @@ namespace ge { Status TransposeTransDataPass::Run(NodePtr &node) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "param [node] must not be null."); + GELOGE(PARAM_INVALID, "[Check][Param] param [node] must not be null."); return PARAM_INVALID; } auto op_desc = node->GetOpDesc(); if (op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "OpDesc of param [node] must not be null."); + GELOGE(PARAM_INVALID, "[Get][OpDesc] failed, OpDesc of param [node] must not be null."); return PARAM_INVALID; } @@ -80,7 +80,7 @@ Status TransposeTransDataPass::Run(NodePtr &node) { OpDescPtr out_op_desc = out_node->GetOpDesc(); if (out_op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); - GELOGE(FAILED, "OpDesc of out data node of [%s] must not be null.", node->GetName().c_str()); + GELOGE(FAILED, "[Get][OpDesc] failed, OpDesc of out data node must not be null."); return FAILED; } if (out_op_desc->GetType() != TRANSDATA) { @@ -115,11 +115,11 @@ Status TransposeTransDataPass::CheckOneInAndOneOutDataAnchor(NodePtr &node) cons uint32_t in_data_node_nums = node->GetInDataNodes().size(); if (in_data_anchor_nums != 1 || out_data_anchor_nums != 1 || in_data_node_nums != 1) { REPORT_INNER_ERROR("E19999", "In data anchor num:%u, out data anchor num:%u, in data node num:%u of node:%s(%s) " - "must be all equal to 1, check invalid", - in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums, - node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "[%s] %s has %u in %u out data anchor, has %u in data node.", node->GetType().c_str(), - node->GetName().c_str(), in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums); + "must be all equal to 1, check invalid", in_data_anchor_nums, + out_data_anchor_nums, in_data_node_nums, node->GetName().c_str(), node->GetType().c_str()); + GELOGE(FAILED, "[Check][Param] In data anchor num:%u, out data anchor num:%u, in data node num:%u of node:%s(%s) " + "must be all equal to 1.", in_data_anchor_nums, out_data_anchor_nums, in_data_node_nums, + node->GetName().c_str(), node->GetType().c_str()); return FAILED; } return SUCCESS; @@ -131,7 +131,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) { if (graph == nullptr) { REPORT_INNER_ERROR("E19999", "Owner graph of node:%s(%s) is nullptr, check invalid", node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "[%s] The owner graph must not be null.", node->GetName().c_str()); + GELOGE(FAILED, "[Get][OwnerComputeGraph] failed, The owner graph of node:%s(%s) must not be null.", + node->GetName().c_str(), node->GetType().c_str()); return FAILED; } @@ -142,7 +143,9 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) { for (auto &peer_anchor : node->GetOutControlAnchor()->GetPeerInControlAnchors()) { GE_CHECK_NOTNULL(origin_node_in); GE_CHECK_NOTNULL(origin_node_in->GetOutControlAnchor()); - GE_CHK_STATUS_RET(origin_node_in->GetOutControlAnchor()->LinkTo(peer_anchor), "link failed"); + GE_CHK_STATUS_RET(origin_node_in->GetOutControlAnchor()->LinkTo(peer_anchor), + "[Link][Anchor] between %s and %s failed", + origin_node_in->GetName().c_str(), peer_anchor->GetOwnerNode()->GetName().c_str()); } for (const auto &anchor : node->GetAllInAnchors()) { @@ -157,7 +160,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) { if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); - GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str()); + GELOGE(FAILED, "[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 SUCCESS; diff --git a/ge/graph/passes/unused_args_clean_pass.cc b/ge/graph/passes/unused_args_clean_pass.cc index df70e99b..33250311 100755 --- a/ge/graph/passes/unused_args_clean_pass.cc +++ b/ge/graph/passes/unused_args_clean_pass.cc @@ -103,7 +103,8 @@ Status UnusedArgsCleanPass::ClassifyDataNodes(const ComputeGraphPtr &graph, cons if (subgraph == nullptr) { REPORT_CALL_ERROR("E19999", "Get subgraph from graph:%s by name:%s failed", graph->GetName().c_str(), name.c_str()); - GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "Subgraph not found, name: %s", name.c_str()); + GELOGE(GE_GRAPH_EMPTY_SUBGRAPH, "[Get][SubGraph] from graph:%s by name:%s failed", + graph->GetName().c_str(), name.c_str()); return GE_GRAPH_EMPTY_SUBGRAPH; } @@ -117,7 +118,8 @@ Status UnusedArgsCleanPass::ClassifyDataNodes(const ComputeGraphPtr &graph, cons if (!AttrUtils::GetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, parent_index)) { REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), data->GetName().c_str(), data->GetType().c_str()); - GELOGE(FAILED, "Parent index not found, name: %s", data->GetName().c_str()); + GELOGE(FAILED, "[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; } @@ -154,9 +156,10 @@ Status UnusedArgsCleanPass::UpdateInputTensor(const mapsecond; if (!AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, update_index)) { - REPORT_CALL_ERROR("E19999", "Get Attr:%s from op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), + REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), data->GetName().c_str(), data->GetType().c_str()); - GELOGE(FAILED, "Set parent index failed, name: %s", data->GetName().c_str()); + GELOGE(FAILED, "[Set][Attr] %s to op:%s(%s) failed", ATTR_NAME_PARENT_NODE_INDEX.c_str(), + data->GetName().c_str(), data->GetType().c_str()); return FAILED; } } @@ -170,11 +173,17 @@ Status UnusedArgsCleanPass::UpdateInputTensor(const mapGetInputDesc(parent_index); (void)func_desc->UpdateInputDesc(update_index, old_desc); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor), "Add edge failed"); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::AddEdge(out_anchor, new_anchor), + "[Add][Edge] between %s(index:%d) and %s(index:%d) failed", + out_node->GetName().c_str(), out_anchor->GetIdx(), + func_node->GetName().c_str(), update_index); GELOGI("Add edge success, func node: %s, node: %s, parent index: %u, update index: %u", func_node->GetName().c_str(), out_node->GetName().c_str(), parent_index, update_index); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed"); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), + "[Remove][Edge] between %s(index:%d) and %s(index:%d) failed", + out_node->GetName().c_str(), out_anchor->GetIdx(), + func_node->GetName().c_str(), parent_index); GELOGI("Remove edge success, func node: %s, node: %s", func_node->GetName().c_str(), out_node->GetName().c_str()); return SUCCESS; @@ -199,7 +208,9 @@ Status UnusedArgsCleanPass::RemoveInputTensor(const mapsecond; - GE_CHK_GRAPH_STATUS_RET(graph->RemoveNode(data), "Remove node failed: %s", data->GetName().c_str()); + GE_CHK_GRAPH_STATUS_RET(graph->RemoveNode(data), + "[Remove][Node] %s from graph:%s failed", + data->GetName().c_str(), graph->GetName().c_str()); GELOGI("Remove Node: %s %s", graph->GetName().c_str(), data->GetName().c_str()); } @@ -207,12 +218,16 @@ Status UnusedArgsCleanPass::RemoveInputTensor(const mapGetPeerOutAnchor(); const auto &out_node = out_anchor->GetOwnerNode(); - GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), "Remove edge failed"); + GE_CHK_GRAPH_STATUS_RET(GraphUtils::RemoveEdge(out_anchor, old_anchor), + "[Remove][Edge] between %s(index:%d) and %s(index:%d) failed", + out_node->GetName().c_str(), out_anchor->GetIdx(), + func_node->GetName().c_str(), parent_index); GELOGI("Remove edge: %s %s", out_node->GetName().c_str(), func_node->GetName().c_str()); if (out_node->GetInDataNodes().size() == 0 && out_node->GetOutAllNodes().size() == 0) { - GE_CHK_GRAPH_STATUS_RET(out_node->GetOwnerComputeGraph()->RemoveNode(out_node), "Remove node failed: %s", - out_node->GetName().c_str()); + GE_CHK_GRAPH_STATUS_RET(out_node->GetOwnerComputeGraph()->RemoveNode(out_node), + "[Remove][Node] %s from graph:%s failed", + out_node->GetName().c_str(), out_node->GetOwnerComputeGraph()->GetName().c_str()); } return SUCCESS; } diff --git a/ge/graph/passes/unused_const_pass.cc b/ge/graph/passes/unused_const_pass.cc index 80e43d08..46aaae5c 100644 --- a/ge/graph/passes/unused_const_pass.cc +++ b/ge/graph/passes/unused_const_pass.cc @@ -28,12 +28,12 @@ namespace ge { Status UnusedConstPass::Run(NodePtr &node) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); - GELOGE(FAILED, "parameter is null."); + GELOGE(FAILED, "[Check][Param] parameter node is nullptr."); return FAILED; } if (node->GetOpDesc() == nullptr) { REPORT_INNER_ERROR("E19999", "Param node's op_desc is nullptr, check invalid"); - GELOGE(PARAM_INVALID, "param [opDesc] must not be null."); + GELOGE(PARAM_INVALID, "[Get][OpDesc] failed, param [opDesc] must not be null."); return PARAM_INVALID; } diff --git a/ge/graph/passes/var_is_initialized_op_pass.cc b/ge/graph/passes/var_is_initialized_op_pass.cc index e1f982d6..e387eea4 100644 --- a/ge/graph/passes/var_is_initialized_op_pass.cc +++ b/ge/graph/passes/var_is_initialized_op_pass.cc @@ -36,7 +36,7 @@ Status VarIsInitializedOpPass::Run(NodePtr &node) { GE_CHECK_NOTNULL(node); auto ret = UpdateInitedVars(node); if (ret != SUCCESS) { - GELOGE(ret, "Failed to run var is init pass on node %s", node->GetName().c_str()); + GELOGE(ret, "[Call][UpdateInitedVars] for node:%s failed", node->GetName().c_str()); return ret; } @@ -46,6 +46,7 @@ Status VarIsInitializedOpPass::Run(NodePtr &node) { bool inited = false; if (CheckSrcNode(node, inited) != SUCCESS) { + GELOGE(ret, "[Call][CheckSrcNode] for node:%s failed", node->GetName().c_str()); return FAILED; } GELOGI("The variable inited status %s on node %s", @@ -63,10 +64,8 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c if (input_nodes.size() != kVarIsInitializedIOCnt) { REPORT_INNER_ERROR("E19999", "In data node num:%zu of node:%s(%s) not equal to %d, check invalid", input_nodes.size(), node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt); - GELOGE(FAILED, - "[%s] Node input data nodes size [%zu] is not equal 1.", - node->GetName().c_str(), - input_nodes.size()); + GELOGE(FAILED, "[Check][Param] In data node num:%zu of node:%s(%s) not equal to %d.", + input_nodes.size(), node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt); return FAILED; } @@ -78,8 +77,9 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c REPORT_INNER_ERROR("E19999", "Index:%d In data node of node:%s(%s), type:%s not %s, check invalid", kVarIsInitVarInputIndex, node->GetName().c_str(), node->GetType().c_str(), input_node_type.c_str(), VARIABLE); - GELOGE(FAILED, "[%s] Src node %s is not Variable, is %s.", node->GetName().c_str(), input_node_name.c_str(), - input_node_type.c_str()); + GELOGE(FAILED, "[Check][Param] Index:%d In data node of node:%s(%s), type:%s not equal to %s.", + kVarIsInitVarInputIndex, node->GetName().c_str(), node->GetType().c_str(), + input_node_type.c_str(), VARIABLE); return FAILED; } @@ -97,40 +97,43 @@ Status VarIsInitializedOpPass::CheckSrcNode(const NodePtr &node, bool &inited) c Status VarIsInitializedOpPass::CreateConstant(NodePtr &node, OpDescPtr &op_desc, bool inited) { GE_CHECK_NOTNULL(node); - // 1. create Constant OpDesc - op_desc = MakeShared(node->GetName().c_str(), CONSTANT); - if (op_desc == nullptr) { - REPORT_CALL_ERROR("E19999", "New OpDesc failed"); - GELOGE(FAILED, "[%s] Make shared of Constant op desc failed.", node->GetName().c_str()); - return FAILED; - } - - // 2. get OpDesc of VarIsInitializedOp + // 1. get OpDesc of VarIsInitializedOp OpDescPtr original_op_desc = node->GetOpDesc(); if (original_op_desc == nullptr) { REPORT_INNER_ERROR("E19999", "OpDesc in node is nullptr, check invalid"); - GELOGE(FAILED, "[%s] Op desc must not be null.", node->GetName().c_str()); + GELOGE(FAILED, "[Get][OpDesc] failed, Op desc of node must not be null."); return FAILED; } GeTensorDesc original_desc = original_op_desc->GetOutputDesc(0); + // 2. create Constant OpDesc + op_desc = MakeShared(node->GetName().c_str(), CONSTANT); + if (op_desc == nullptr) { + REPORT_CALL_ERROR("E19999", "New OpDesc failed"); + GELOGE(FAILED, "[New][OpDesc] failed."); + return FAILED; + } + // 3. create attr value of Constant, is a tensor bool val = inited; GeTensorPtr const_tensor_ptr = MakeShared(original_desc, reinterpret_cast(&val), sizeof(bool)); if (const_tensor_ptr == nullptr) { REPORT_CALL_ERROR("E19999", "New GeTensor failed"); - GELOGE(FAILED, "[%s] Make shared of Constant tensor failed.", node->GetName().c_str()); + GELOGE(FAILED, "[New][GeTensor] failed."); return FAILED; } if (!AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, const_tensor_ptr)) { REPORT_CALL_ERROR("E19999", "Set Attr:%s to op:%s(%s) failed", ATTR_NAME_WEIGHTS.c_str(), op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "get ATTR_NAME_WEIGHTS failed"); + GELOGE(INTERNAL_ERROR, "[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 - GE_CHK_STATUS_RET(op_desc->AddOutputDesc(original_desc), "add out put desc failed"); + GE_CHK_STATUS_RET(op_desc->AddOutputDesc(original_desc), + "[Add][OutputDesc] to op:%s(%s) failed", + op_desc->GetName().c_str(), op_desc->GetType().c_str()); return SUCCESS; } @@ -142,12 +145,11 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) if ((in_anchors.size() != kVarIsInitializedIOCnt) || (out_anchors.size() != kVarIsInitializedIOCnt)) { REPORT_INNER_ERROR("E19999", "In data anchor num:%zu and out data anchor num:%zu of node:%s(%s), " - "must botch equal to %d, check invalid", in_anchors.size(), out_anchors.size(), + "must be equal to %d, check invalid", in_anchors.size(), out_anchors.size(), node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt); - GELOGE(FAILED, - "[%s] Node input/output data anchors" - " size [%lu][%lu] is not all equal 1.", - node->GetName().c_str(), in_anchors.size(), out_anchors.size()); + GELOGE(FAILED, "[Check][Param] In data anchor num:%zu and out data anchor num:%zu of node:%s(%s), " + "must be equal to %d.", in_anchors.size(), out_anchors.size(), + node->GetName().c_str(), node->GetType().c_str(), kVarIsInitializedIOCnt); return FAILED; } @@ -159,10 +161,12 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) if (GraphUtils::RemoveEdge(in_anchor, peer_out_anchor) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove edge between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(), - in_anchor->GetIdx(), - peer_out_anchor->GetOwnerNode()->GetName().c_str(), + in_anchor->GetIdx(), peer_out_anchor->GetOwnerNode()->GetName().c_str(), peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx()); - GELOGE(FAILED, "[%s] Remove in data edge failed.", node->GetName().c_str()); + GELOGE(FAILED, "[Remove][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:%d) failed", + in_anchor->GetOwnerNode()->GetName().c_str(), in_anchor->GetOwnerNode()->GetType().c_str(), + in_anchor->GetIdx(), peer_out_anchor->GetOwnerNode()->GetName().c_str(), + peer_out_anchor->GetOwnerNode()->GetType().c_str(), peer_out_anchor->GetIdx()); return FAILED; } auto src_node = peer_out_anchor->GetOwnerNode(); @@ -170,8 +174,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) REPORT_CALL_ERROR("E19999", "Add control edge between op:%s(%s) and op:%s(%s) failed", src_node->GetName().c_str(), src_node->GetType().c_str(), new_node->GetName().c_str(), new_node->GetType().c_str()); - GELOGE(FAILED, "Failed to link control edges from var %s to new const %s", - src_node->GetName().c_str(), new_node->GetName().c_str()); + GELOGE(FAILED, "[Add][ControlEdge] between op:%s(%s) and op:%s(%s) failed", + src_node->GetName().c_str(), src_node->GetType().c_str(), + new_node->GetName().c_str(), new_node->GetType().c_str()); return FAILED; } @@ -179,7 +184,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) REPORT_CALL_ERROR("E19999", "Move in control edge from node:%s(%s) to node:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str(), new_node->GetName().c_str(), new_node->GetType().c_str()); - GELOGE(FAILED, "Failed to move in ctrl edges from %s to new const", node->GetName().c_str()); + GELOGE(FAILED, "[Move][InCtrlEdges] from node:%s(%s) to node:%s(%s) failed", + node->GetName().c_str(), node->GetType().c_str(), + new_node->GetName().c_str(), new_node->GetType().c_str()); return FAILED; } @@ -187,7 +194,9 @@ Status VarIsInitializedOpPass::ProcessInAnchor(NodePtr &node, NodePtr &new_node) REPORT_CALL_ERROR("E19999", "Move out control edge from node:%s(%s) to node:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str(), new_node->GetName().c_str(), new_node->GetType().c_str()); - GELOGE(FAILED, "Failed to move out ctrl edges from %s to new const", node->GetName().c_str()); + GELOGE(FAILED, "[Move][OutCtrlEdges] from node:%s(%s) to node:%s(%s) failed", + node->GetName().c_str(), node->GetType().c_str(), + new_node->GetName().c_str(), new_node->GetType().c_str()); return FAILED; } @@ -199,6 +208,7 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited) ComputeGraphPtr graph = node->GetOwnerComputeGraph(); OpDescPtr constant_op_desc = nullptr; if (CreateConstant(node, constant_op_desc, inited) != SUCCESS) { + GELOGE(FAILED, "[Create][Constant] failed, node:%s", node->GetName().c_str()); return FAILED; } @@ -207,10 +217,13 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited) REPORT_CALL_ERROR("E19999", "Add node:%s(%s) to graph:%s front failed", constant_op_desc->GetName().c_str(), constant_op_desc->GetType().c_str(), graph->GetName().c_str()); + GELOGE(FAILED, "[Add][Node] %s(%s) to graph:%s front failed", + constant_op_desc->GetName().c_str(), constant_op_desc->GetType().c_str(), graph->GetName().c_str()); return FAILED; } if (ProcessInAnchor(node, const_node) != SUCCESS) { + GELOGE(FAILED, "[Process][InAnchor] failed, node:%s", node->GetName().c_str()); return FAILED; } @@ -218,14 +231,17 @@ Status VarIsInitializedOpPass::ChangeNodeToConstant(NodePtr &node, bool inited) REPORT_CALL_ERROR("E19999", "Move out edge from node:%s(%s) to node:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str(), const_node->GetName().c_str(), const_node->GetType().c_str()); - GELOGE(FAILED, "[%s] Move output edges to new node failed.", node->GetName().c_str()); + GELOGE(FAILED, "[Move][OutputEdges] from node:%s(%s) to node:%s(%s) failed", + node->GetName().c_str(), node->GetType().c_str(), + const_node->GetName().c_str(), const_node->GetType().c_str()); return FAILED; } if (GraphUtils::RemoveNodeWithoutRelink(graph, node) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); - GELOGE(FAILED, "[%s] RemoveNodeWithoutRelink failed.", node->GetName().c_str()); + GELOGE(FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed", + node->GetName().c_str(), node->GetType().c_str(), graph->GetName().c_str()); return FAILED; } @@ -299,7 +315,7 @@ std::set *VarIsInitializedOpPass::CreateInitedVars() { std::unique_ptr> inited_vars_keeper(new(std::nothrow) std::set()); if (inited_vars_keeper == nullptr) { REPORT_CALL_ERROR("E19999", "New set failed"); - GELOGE(OUT_OF_MEMORY, "Failed to alloc set memory"); + GELOGE(OUT_OF_MEMORY, "[New][Set] failed"); return nullptr; } auto inited_vars = inited_vars_keeper.get(); diff --git a/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc index 3b3328a3..862b7016 100644 --- a/ge/graph/passes/variable_op_pass.cc +++ b/ge/graph/passes/variable_op_pass.cc @@ -50,19 +50,16 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) { REPORT_CALL_ERROR("E19999", "Copy in control edge from node:%s(%s) to node:%s(%s) failed", trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str(), ref_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, - "Failed to move control edges from trans " - "node %s to var-ref %s", - trans_node->GetName().c_str(), ref_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Copy][InCtrlEdges] from node:%s(%s) to node:%s(%s) failed", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), + ref_node->GetName().c_str(), ref_node->GetType().c_str()); return INTERNAL_ERROR; } auto ref_in_anchor = ref_node->GetInDataAnchor(0); if (ref_in_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid", ref_node->GetName().c_str(), ref_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, - "The variable ref node %s does not have an " - "input anchor", + GELOGE(INTERNAL_ERROR, "[Get][InDataAnchor] failed, The variable ref node %s does not have an input anchor", ref_node->GetName().c_str()); return INTERNAL_ERROR; } @@ -71,9 +68,7 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) { if (trans_in_anchor == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid", trans_node->GetName().c_str(), trans_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, - "Failed to get the in data anchor from trans" - " node %s type %s", + GELOGE(INTERNAL_ERROR, "[Get][InDataAnchor] failed, Node:%s(%s) has no input anchor", trans_node->GetName().c_str(), trans_node->GetType().c_str()); return INTERNAL_ERROR; } @@ -91,10 +86,10 @@ Status ByPassTransNode(NodePtr &trans_node, NodePtr &ref_node) { prev_trans_node_out_anchor->GetOwnerNode()->GetType().c_str(), prev_trans_node_out_anchor->GetIdx(), ref_node->GetName().c_str(), ref_node->GetType().c_str()); - GELOGE(INTERNAL_ERROR, - "Failed to add edge between ref node %s " - "and the prev node of trans node %s", - ref_node->GetName().c_str(), trans_node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Add][Edge] between op:%s(%s)(index:%d) and op:%s(%s)(index:0) failed", + prev_trans_node_out_anchor->GetOwnerNode()->GetName().c_str(), + prev_trans_node_out_anchor->GetOwnerNode()->GetType().c_str(), + prev_trans_node_out_anchor->GetIdx(), ref_node->GetName().c_str(), ref_node->GetType().c_str()); return INTERNAL_ERROR; } } @@ -128,7 +123,7 @@ bool IsTransSupport(const TransNodeInfo &trans_info) { Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { if (graph == nullptr) { REPORT_INNER_ERROR("E19999", "Param graph is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "Failed to run variable op pass, null graph"); + GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to run variable op pass, null graph"); return INTERNAL_ERROR; } @@ -138,18 +133,18 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { if (var_accelerate_ctrl_ == nullptr) { REPORT_INNER_ERROR("E19999", "The variable accelerate control is nullptr, check invalid"); - GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null"); + GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to run var op pass, the variable accelerate control is null"); return INTERNAL_ERROR; } GELOGD("Begin to generate ref map for variable and refs, graph name:%s.", graph->GetName().c_str()); if (RenewVarDesc(graph) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to renew var desc on graph"); + GELOGE(INTERNAL_ERROR, "[Renew][VarDesc] on graph:%s failed", graph->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } if (GenerateVariableVariableRefMap(graph) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Generate][VariableMap] for graph:%s failed", graph->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } @@ -166,6 +161,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { VarTransRoad fusion_road; auto ret = FusionIfNeed(node, fusion_road); if (ret != SUCCESS) { + GELOGE(FAILED, "[Call][FusionIfNeed] for node:%s failed", node->GetName().c_str()); return ret; } @@ -190,14 +186,16 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Set Trans road for node:%s(%s) failed, session_id:%lu", node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); - GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Set][TransRoad] for node:%s(%s) failed, session_id:%lu", + node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); return INTERNAL_ERROR; } ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph_id); if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Update graph_id:%u for node:%s(%s) failed, session_id:%lu", graph_id, node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); - GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Update][GraphId] %u for node:%s(%s) failed, session_id:%lu", + graph_id, node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); return INTERNAL_ERROR; } var_accelerate_ctrl_->SetVarChanged(node->GetName()); @@ -211,7 +209,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { // renew var desc if the trans_road is all reshape or reformat ret = RenewVarDesc(graph->GetSessionID(), node, fusion_road); if (ret != SUCCESS) { - GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); + GELOGE(FAILED, "[Renew][VarDesc] for var[%s] failed!", node->GetName().c_str()); return FAILED; } } @@ -230,12 +228,16 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed", trans_node->GetName().c_str(), trans_node->GetType().c_str()); + GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[Isolate][Node] %s(%s) failed", + trans_node->GetName().c_str(), trans_node->GetType().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str()); + GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } } @@ -257,7 +259,7 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { " than one output data nodes, unlink the edge between them", trans_node->GetName().c_str(), trans_node->GetType().c_str(), ref_node->GetName().c_str()); if (ByPassTransNode(trans_node, ref_node) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to bypass trans node %s to ref %s", trans_node->GetName().c_str(), + GELOGE(INTERNAL_ERROR, "[ByPass][TransNode] %s to ref %s failed", trans_node->GetName().c_str(), ref_node->GetName().c_str()); return INTERNAL_ERROR; } @@ -269,11 +271,15 @@ Status VariableOpPass::DealFusion(const ge::NodePtr &var_node) { if (GraphUtils::IsolateNode(trans_node, {0}) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed", trans_node->GetName().c_str(), trans_node->GetType().c_str()); + GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[Isolate][Node] %s(%s) failed", + trans_node->GetName().c_str(), trans_node->GetType().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } if (GraphUtils::RemoveNodeWithoutRelink(graph, trans_node) != SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str()); + GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[Remove][Node] %s(%s) without relink in graph:%s failed", + trans_node->GetName().c_str(), trans_node->GetType().c_str(), graph->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } } @@ -377,6 +383,7 @@ Status VariableOpPass::CheckVariableRefLegally(const ge::NodePtr &var_node, bool for (const auto &var_ref_node : iterator->second) { if (CheckVarAndVarRefAreAlike(var_node, var_ref_node, is_var_ref_legally) != SUCCESS) { + GELOGE(FAILED, "[Call][CheckVarAndVarRefAreAlike] for node:%s failed", var_node->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } @@ -392,7 +399,7 @@ Status VariableOpPass::CheckVariableRefLegally(const ge::NodePtr &var_node, bool Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final_output, const ge::NodePtr &node) { if (node == nullptr || node->GetOpDesc() == nullptr) { REPORT_INNER_ERROR("E19999", "Param node or its op_desc is nullptr, check invalid"); - GELOGE(FAILED, "node or opdesc is nullptr"); + GELOGE(FAILED, "[Check][Param] node or its opdesc is nullptr"); return FAILED; } const Format &format = final_output.GetFormat(); @@ -406,7 +413,8 @@ Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final if (node->GetOpDesc()->UpdateOutputDesc(0, node_desc) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Update ouput:0 desc in op:%s(%s) failed", node->GetName().c_str(), node->GetType().c_str()); - GELOGE(FAILED, "update output desc fail."); + GELOGE(FAILED, "[Update][OutputDesc] in op:%s(%s) failed, index:0", + node->GetName().c_str(), node->GetType().c_str()); return FAILED; } GELOGD("node ref is (%s, %s, %lu), var_ref_name is %s.", @@ -418,7 +426,7 @@ Status VariableOpPass::UpdateVarAndRefOutputFormatInfo(const GeTensorDesc &final if (iterator == var_and_var_ref_map_.end()) { auto graph = node->GetOwnerComputeGraph(); if (GenerateVariableVariableRefMap(graph) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to generate variable map for graph %s", graph->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Generate][VariableMap] for graph:%s failed", graph->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } } @@ -493,7 +501,8 @@ Status VariableOpPass::CheckVarAndVarRefAreAlike(const NodePtr &var_node, const var_ref_node_trans_nodes.size(), var_ref_node->GetName().c_str(), var_ref_node->GetType().c_str()); - GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "var_ref_node_trans_nodes.size() > 1."); + GELOGE(GE_GRAPH_VARIABLE_OP_PASS_FAILED, "[Check][Param] In data node num:%zu of node:%s(%s) bigger than 1.", + var_ref_node_trans_nodes.size(), var_ref_node->GetName().c_str(), var_ref_node->GetType().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } @@ -502,6 +511,7 @@ Status VariableOpPass::CheckVarAndVarRefAreAlike(const NodePtr &var_node, const if (CheckTransNodeAreInverse(var_node_trans_node, var_ref_node_trans_node, is_var_and_variable_ref_are_alike) != SUCCESS) { + GELOGE(FAILED, "[Call][CheckTransNodeAreInverse] failed"); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } @@ -559,11 +569,13 @@ void VariableOpPass::CopyVariableFormatDataTypeAndShape(const GeTensorDesc &src_ Status VariableOpPass::CheckIfCouldBeOptimized(const ge::NodePtr &node, bool &flag, VarTransRoad &fusion_road) { if (node == nullptr) { REPORT_INNER_ERROR("E19999", "Param node is nullptr, check invalid"); + GELOGE(FAILED, "[Check][Param] param node is nullptr."); return FAILED; } bool is_matched = false; auto ret = CheckSameAndTransOp(node, is_matched, fusion_road); if (ret != SUCCESS) { + GELOGE(FAILED, "[Call][CheckSameAndTransOp] failed, node:%s", node->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } if (!is_matched) { @@ -574,6 +586,7 @@ Status VariableOpPass::CheckIfCouldBeOptimized(const ge::NodePtr &node, bool &fl bool is_var_ref_legally = false; ret = CheckVariableRefLegally(node, is_var_ref_legally); if (ret != SUCCESS) { + GELOGE(FAILED, "[Call][CheckVariableRefLegally] failed, node:%s", node->GetName().c_str()); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } GELOGD("is_var_ref_legally is %d.", is_var_ref_legally); @@ -596,6 +609,7 @@ Status VariableOpPass::FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_roa while (true) { auto ret = CheckIfCouldBeOptimized(var, can_fusion, fusion_road); if (ret != SUCCESS) { + GELOGE(FAILED, "[Call][CheckIfCouldBeOptimized] failed"); return ret; } if (!can_fusion) { @@ -604,6 +618,7 @@ Status VariableOpPass::FusionIfNeed(const NodePtr &var, VarTransRoad &fusion_roa ret = DealFusion(var); if (ret != SUCCESS) { + GELOGE(FAILED, "[Call][DealFusion] failed"); return ret; } } @@ -614,6 +629,7 @@ Status VariableOpPass::UpdateIOFormatInfo(const GeTensorDesc &final_output, std: for (auto &need_set_node : nodes) { auto ret = UpdateVarAndRefOutputFormatInfo(final_output, need_set_node); if (ret != SUCCESS) { + GELOGE(FAILED, "[Call][UpdateVarAndRefOutputFormatInfo] failed"); return GE_GRAPH_VARIABLE_OP_PASS_FAILED; } } @@ -638,7 +654,8 @@ Status VariableOpPass::RenewVarDesc(ge::ComputeGraphPtr &graph) { if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu", node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); - GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); + GELOGE(FAILED, "[Renew][Descriptor] for node:%s(%s) failed, session_id:%lu", + node->GetName().c_str(), node->GetType().c_str(), graph->GetSessionID()); return FAILED; } } @@ -664,7 +681,8 @@ Status VariableOpPass::RenewVarDesc(uint64_t session_id, const NodePtr &node, co if (ret != SUCCESS) { REPORT_CALL_ERROR("E19999", "Renew descriptor for node:%s(%s) failed, session_id:%lu", node->GetName().c_str(), node->GetType().c_str(), session_id); - GELOGE(FAILED, "var manager renew var[%s] descriptor failed!", node->GetName().c_str()); + GELOGE(FAILED, "[Renew][Descriptor] for node:%s(%s) failed, session_id:%lu", + node->GetName().c_str(), node->GetType().c_str(), session_id); return FAILED; } diff --git a/ge/graph/passes/variable_prepare_op_pass.cc b/ge/graph/passes/variable_prepare_op_pass.cc index 9231e4eb..3bb9a2fa 100644 --- a/ge/graph/passes/variable_prepare_op_pass.cc +++ b/ge/graph/passes/variable_prepare_op_pass.cc @@ -49,7 +49,7 @@ Status VariablePrepareOpPass::Run(ComputeGraphPtr graph) { if (node->GetOpDesc()->GetType() == VARIABLE) { Status ret = DealVariableNode(node); if (ret != SUCCESS) { - GELOGE(ret, "variable add back edge failed"); + GELOGE(ret, "[Deal][VariableNode] failed, node:%s(%s)", node->GetName().c_str(), node->GetType().c_str()); return FAILED; } } @@ -71,8 +71,8 @@ Status VariablePrepareOpPass::DealVariableNode(NodePtr &var_node) { for (auto output_index : ref_output_indexes) { Status ret = DealWritableNode(dst_node, input_index, output_index, var_node); if (ret != SUCCESS) { - GELOGE(FAILED, "Deal writable node[%s] failed, input index: %d, var: %s.", dst_node->GetName().c_str(), - input_index, var_node->GetName().c_str()); + GELOGE(FAILED, "[Deal][WritableNode] [%s] failed, input index:%d, output index:%d var:%s.", + dst_node->GetName().c_str(), output_index, input_index, var_node->GetName().c_str()); return FAILED; } } @@ -99,7 +99,8 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node, const auto nodes_size = nodes_to_check.size(); // Add peer ref output node of current node to stack CHECK_FALSE_EXEC(GetPeerNodeOfRefOutput(cur_node, cur_output_index, nodes_to_check) == SUCCESS, - GELOGE(FAILED, "GetPeerNodeOfRefOutput for node[%s] failed.", cur_node->GetName().c_str()); + GELOGE(FAILED, "[Get][PeerNode] Of Ref Output for node[%s] failed, output index:%d.", + cur_node->GetName().c_str(), cur_output_index); return FAILED); if (nodes_size == nodes_to_check.size()) { const auto &op_desc = cur_node->GetOpDesc(); @@ -112,12 +113,14 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node, if (static_cast(cur_output_index) < op_desc->GetOutputsSize()) { // Add variable ref node after ref output for final ref node CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS, - GELOGE(FAILED, "Add variable ref failed"); + GELOGE(FAILED, "[Add][VariableRef] for node:%s failed, output index:%d var:%s", + cur_node->GetName().c_str(), cur_output_index, var_node->GetName().c_str()); return FAILED); } else { // Insert variable ref node before ref input without corresponding ref output CHECK_FALSE_EXEC(InsertVariableRef(cur_node, cur_input_index, var_node) == SUCCESS, - GELOGE(FAILED, "Insert variable ref and ref identity failed"); + GELOGE(FAILED, "[Insert][VariableRef] and ref identity failed, node:%s, in index:%d, var:%s", + cur_node->GetName().c_str(), cur_input_index, var_node->GetName().c_str()); return FAILED); } continue; @@ -125,7 +128,8 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node, if (HasControlOut(cur_node)) { // Add variable ref node after ref output for ref node has control output. CHECK_FALSE_EXEC(AddVariableRef(cur_node, var_node, cur_output_index) == SUCCESS, - GELOGE(FAILED, "Add variable ref failed"); + GELOGE(FAILED, "[Add][VariableRef] for node:%s failed, var:%s output index:%d", + cur_node->GetName().c_str(), var_node->GetName().c_str(), cur_output_index); return FAILED); } } @@ -135,7 +139,8 @@ Status VariablePrepareOpPass::DealWritableNode(const ge::NodePtr &writable_node, Status VariablePrepareOpPass::GetPeerNodeOfRefOutput(const ge::NodePtr &node, int output_index, std::stack>> &nodes) { if (output_index < 0) { - GELOGE(PARAM_INVALID, "Invalid ref output index: %s-%d.", node->GetName().c_str(), output_index); + REPORT_INNER_ERROR("E19999", "Param output_index:%d < 0, check invalid", output_index); + GELOGE(PARAM_INVALID, "[Check][Param] Invalid ref output index: %s-%d.", node->GetName().c_str(), output_index); return PARAM_INVALID; } const auto &op_desc = node->GetOpDesc(); @@ -192,7 +197,8 @@ Status VariablePrepareOpPass::AddVariableRef(ge::NodePtr &final_writable_node, c GE_CHECK_NOTNULL(variable_ref_node); Status ret_check = CheckStreamLabel(variable_ref_node, final_writable_node); if (ret_check != SUCCESS) { - GELOGE(FAILED, "check stream lable failed"); + GELOGE(FAILED, "[Check][StreamLabel] failed, var ref node:%s, writable node:%s", + variable_ref_node->GetName().c_str(), final_writable_node->GetName().c_str()); return FAILED; } @@ -200,12 +206,17 @@ Status VariablePrepareOpPass::AddVariableRef(ge::NodePtr &final_writable_node, c // add control anchor between variable_ref and final peer node // variable_ref_node need to execute before other nodes CHECK_FALSE_EXEC(AddControlEdge(final_writable_node, variable_ref_node) == SUCCESS, - GELOGE(FAILED, "Add control edges between variable ref node and output nodes of ref node failed"); + GELOGE(FAILED, "[Add][ControlEdge] between variable ref node:%s and final peer node:%s failed", + var_node->GetName().c_str(), variable_ref_node->GetName().c_str()); return FAILED); graphStatus ret = ge::GraphUtils::AddEdge(out_anchor, variable_ref_node->GetInDataAnchor(0)); if (ret != GRAPH_SUCCESS) { - GELOGE(FAILED, "add data anchor between variable_ref and final_writable peer node failed"); + REPORT_CALL_ERROR("E19999", + "add edge between variable_ref:%s(index:0) and final_writable peer node:%s(index:%d) failed", + variable_ref_node->GetName().c_str(), final_writable_node->GetName().c_str(), index); + GELOGE(FAILED, "[Add][Edge] between variable_ref:%s(index:0) and final_writable peer node:%s(index:%d) failed", + variable_ref_node->GetName().c_str(), final_writable_node->GetName().c_str(), index); return FAILED; } return SUCCESS; @@ -236,7 +247,8 @@ Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index, GE_CHECK_NOTNULL(variable_ref_node); Status ret_check = CheckStreamLabel(variable_ref_node, node); if (ret_check != SUCCESS) { - GELOGE(FAILED, "check stream lable failed"); + GELOGE(FAILED, "[Check][StreamLabel] failed, ref node:%s, writable node:%s", + variable_ref_node->GetName().c_str(), node->GetName().c_str()); return FAILED; } @@ -245,29 +257,45 @@ Status VariablePrepareOpPass::InsertVariableRef(ge::NodePtr &node, int in_index, // add control anchor between variable_ref and node // variable_ref_node need to execute before other nodes CHECK_FALSE_EXEC(AddControlEdge(node, variable_ref_node) == SUCCESS, - GELOGE(FAILED, "Add control edges between variable ref node and output nodes of ref node failed"); + GELOGE(FAILED, "[Add][ControlEdge] between variable ref node:%s and ref node:%s failed", + variable_ref_node->GetName().c_str(), node->GetName().c_str()); return FAILED); // Insert variable ref node between two nodes and remove the original edge. CHECK_FALSE_EXEC(ge::GraphUtils::RemoveEdge(peer_out_anchor, in_anchor) == SUCCESS, - GELOGE(FAILED, "Remove edge between ref node and its peer node failed"); + REPORT_CALL_ERROR("E19999", "remove edge between ref node:%s and its peer node:%s failed", + node->GetName().c_str(), peer_in_node->GetName().c_str()); + GELOGE(FAILED, "[Remove][Edge] between ref node:%s and its peer node:%s failed", + node->GetName().c_str(), peer_in_node->GetName().c_str()); return FAILED); CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(peer_out_anchor, ref_identity_node->GetInDataAnchor(0)) == SUCCESS, - GELOGE(FAILED, "Add data edge between pre node and ref_identity failed"); + REPORT_CALL_ERROR("E19999", "Add edge between pre node:%s and ref_identity:%s failed", + peer_in_node->GetName().c_str(), ref_identity_node->GetName().c_str()); + GELOGE(FAILED, "[Add][Edge] between pre node:%s and ref_identity:%s failed", + peer_in_node->GetName().c_str(), ref_identity_node->GetName().c_str()); return FAILED); CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), in_anchor) == SUCCESS, - GELOGE(FAILED, "Add data edge between ref_identity and ref node failed"); + REPORT_CALL_ERROR("E19999", "Add edge between ref_identity:%s and ref node:%s failed", + ref_identity_node->GetName().c_str(), node->GetName().c_str()); + GELOGE(FAILED, "[Add][Edge] between ref_identity:%s and ref node:%s failed", + ref_identity_node->GetName().c_str(), node->GetName().c_str()); return FAILED); // Add edge from ref identity node to variable ref node. - CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), variable_ref_node->GetInDataAnchor(0)) == SUCCESS, - GELOGE(FAILED, "Add data edge between ref_identity and variable_ref failed"); - return FAILED); - CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), variable_ref_node->GetInControlAnchor()) == SUCCESS, - GELOGE(FAILED, "Add control edge between ref_identity and variable_ref failed"); - return FAILED); + CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(ref_identity_node->GetOutDataAnchor(0), + variable_ref_node->GetInDataAnchor(0)) == SUCCESS, + REPORT_CALL_ERROR("E19999", "Add edge between ref_identity:%s and variable_ref:%s failed", + ref_identity_node->GetName().c_str(), variable_ref_node->GetName().c_str()); + GELOGE(FAILED, "[Add][Edge] between ref_identity:%s and variable_ref:%s failed", + ref_identity_node->GetName().c_str(), variable_ref_node->GetName().c_str()); + return FAILED); + CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(node->GetOutControlAnchor(), + variable_ref_node->GetInControlAnchor()) == SUCCESS, + REPORT_CALL_ERROR("E19999", "Add control edge between ref node:%s and variable_ref:%s failed", + node->GetName().c_str(), variable_ref_node->GetName().c_str()); + GELOGE(FAILED, "[Add][ControlEdge] between ref node:%s and variable_ref:%s failed", + node->GetName().c_str(), variable_ref_node->GetName().c_str()); + return FAILED); return SUCCESS; } @@ -279,10 +307,14 @@ Status VariablePrepareOpPass::AddControlEdge(const ge::NodePtr &node, const ge:: GE_CHECK_NOTNULL(peer_in_anchor); NodePtr peer_node = peer_in_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(peer_node); - CHECK_FALSE_EXEC( - ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), peer_node->GetInControlAnchor()) == SUCCESS, - GELOGE(FAILED, "Add control edge between variable_ref and ref node's peer node failed"); - return FAILED); + CHECK_FALSE_EXEC(ge::GraphUtils::AddEdge(variable_ref_node->GetOutControlAnchor(), + peer_node->GetInControlAnchor()) == SUCCESS, + REPORT_CALL_ERROR("E19999", + "Add control edge between variable_ref:%s and ref node's peer node:%s failed", + variable_ref_node->GetName().c_str(), peer_node->GetName().c_str()); + GELOGE(FAILED, "[Add][ControlEdge] between variable_ref:%s and ref node's peer node:%s failed", + variable_ref_node->GetName().c_str(), peer_node->GetName().c_str()); + return FAILED); } } return SUCCESS; @@ -292,13 +324,15 @@ ge::NodePtr VariablePrepareOpPass::CreateRefIdentity(const std::string &ref_iden uint32_t input_index) { OpDescPtr op_desc = node->GetOpDesc(); if (op_desc == nullptr) { - GELOGE(FAILED, "opdesc is nullptr"); + REPORT_INNER_ERROR("E19999", "opdesc of param node is nullptr, check invalid"); + GELOGE(FAILED, "[Get][OpDesc] failed, opdesc of param node is nullptr"); return nullptr; } OpDescPtr ref_identity_op_desc = MakeShared(ref_identity_name.c_str(), REFIDENTITY); if (ref_identity_op_desc == nullptr) { - GELOGE(FAILED, "ref_identity op desc is nullptr"); + REPORT_CALL_ERROR("E19999", "New OpDesc failed."); + GELOGE(FAILED, "[New][OpDesc] failed"); return nullptr; } @@ -317,13 +351,15 @@ ge::NodePtr VariablePrepareOpPass::CreateVariableRef(const std::string &variable const ge::NodePtr &var_node) { OpDescPtr var_op_desc = var_node->GetOpDesc(); if (var_op_desc == nullptr) { - GELOGE(FAILED, "get var opdesc is nullptr"); + REPORT_INNER_ERROR("E19999", "param var_node's opdesc is nullptr, check invalid"); + GELOGE(FAILED, "[Get][OpDesc] failed, var opdesc is nullptr"); return nullptr; } OpDescPtr var_ref_op_desc = MakeShared(variable_ref_name.c_str(), var_op_desc->GetType()); if (var_ref_op_desc == nullptr) { - GELOGE(FAILED, "var_ref opdesc is nullptr"); + REPORT_CALL_ERROR("E19999", "New OpDesc failed"); + GELOGE(FAILED, "New OpDesc failed"); return nullptr; } @@ -410,7 +446,8 @@ Status VariablePrepareOpPass::CheckStreamLabel(const ge::NodePtr &var_ref_node, std::string stream_label; (void)AttrUtils::GetStr(writable_desc, ATTR_NAME_STREAM_LABEL, stream_label); if (!stream_label.empty()) { - GE_CHK_STATUS_RET(SetStreamLabel(var_ref_node, stream_label), "set stream label failed"); + GE_CHK_STATUS_RET(SetStreamLabel(var_ref_node, stream_label), + "[Set][StreamLabel] %s failed", stream_label.c_str()); } return SUCCESS; } diff --git a/ge/graph/passes/variable_ref_delete_op_pass.cc b/ge/graph/passes/variable_ref_delete_op_pass.cc index a0e0bcba..be1edfda 100644 --- a/ge/graph/passes/variable_ref_delete_op_pass.cc +++ b/ge/graph/passes/variable_ref_delete_op_pass.cc @@ -37,13 +37,13 @@ Status VariableRefDeleteOpPass::Run(ge::ComputeGraphPtr graph) { if (all_var_names.count(ref_var_src_var_name) == 0) { REPORT_INNER_ERROR("E19999", "Can not find source variable[%s] of variable ref[%s], check invalid", ref_var_src_var_name.c_str(), node->GetName().c_str()); - GELOGE(FAILED, "Can not find source variable[%s] of variable ref[%s]", ref_var_src_var_name.c_str(), - node->GetName().c_str()); + GELOGE(FAILED, "[Check][Param] Can not find source variable[%s] of variable ref[%s]", + ref_var_src_var_name.c_str(), node->GetName().c_str()); return FAILED; } Status ret = DealVariableRef(graph, node, ref_var_src_var_name); if (ret != SUCCESS) { - GELOGE(ret, "variable ref [%s] delete failed", node->GetName().c_str()); + GELOGE(ret, "[Deal][VariableRef] [%s] in graph:%s failed", node->GetName().c_str(), graph->GetName().c_str()); return FAILED; } } @@ -57,7 +57,7 @@ Status VariableRefDeleteOpPass::DealVariableRef(ge::ComputeGraphPtr &graph, ge:: if (inAnchor0 == nullptr) { REPORT_INNER_ERROR("E19999", "Node:%s(%s) has no input anchor, check invalid", variable_ref->GetName().c_str(), variable_ref->GetType().c_str()); - GELOGE(FAILED, "variable_ref [%s] no input", variable_ref->GetName().c_str()); + GELOGE(FAILED, "[Get][InDataAnchor] failed, variable_ref [%s] no input", variable_ref->GetName().c_str()); return FAILED; } GE_CHECK_NOTNULL(inAnchor0->GetPeerOutAnchor()); @@ -79,23 +79,23 @@ Status VariableRefDeleteOpPass::DealVariableRef(ge::ComputeGraphPtr &graph, ge:: } else { REPORT_CALL_ERROR("E19999", "Set Attr:%s to output:%d desc of op:%s(%s) failed", REF_VAR_SRC_VAR_NAME.c_str(), index, op_desc->GetName().c_str(), op_desc->GetType().c_str()); - GELOGE(FAILED, "[%s-%d]: add attr [REF_VAR_SRC_VAR_NAME: %s ] failed", peer_node->GetName().c_str(), index, - ref_var_src_var_name.c_str()); + GELOGE(FAILED, "[Set][Attr] %s to output:%d desc of op:%s(%s) failed", REF_VAR_SRC_VAR_NAME.c_str(), + index, op_desc->GetName().c_str(), op_desc->GetType().c_str()); return FAILED; } // remove variable_ref if (GraphUtils::IsolateNode(variable_ref, {0}) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Isolate node:%s(%s) failed", variable_ref->GetName().c_str(), variable_ref->GetType().c_str()); - GELOGE(INTERNAL_ERROR, "Isolate removed node: %s, type: %s failed", variable_ref->GetName().c_str(), + GELOGE(INTERNAL_ERROR, "[Isolate][Node] name:%s, type:%s failed", variable_ref->GetName().c_str(), variable_ref->GetType().c_str()); return FAILED; } if (GraphUtils::RemoveNodeWithoutRelink(graph, variable_ref) != GRAPH_SUCCESS) { REPORT_CALL_ERROR("E19999", "Remove node:%s(%s) without relink in graph:%s failed", variable_ref->GetName().c_str(), variable_ref->GetType().c_str(), graph->GetName().c_str()); - GELOGE(INTERNAL_ERROR, "Remove node: %s, type: %s without relink failed", variable_ref->GetName().c_str(), - variable_ref->GetType().c_str()); + GELOGE(INTERNAL_ERROR, "[Remove][Node] %s(%s) without relink in graph:%s failed", + variable_ref->GetName().c_str(), variable_ref->GetType().c_str(), graph->GetName().c_str()); return FAILED; } return SUCCESS; diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index e1921f29..0c4adeea 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -195,9 +195,8 @@ NodePtr CreateTransNode(const std::string &name, const std::string &node_type, c auto index = TransOpUtil::GetTransOpDataIndex(node_type); if (index < 0) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19025", {"situation", "reason"}, - {"The trans node type[" + node_type + "]", "it must be " + TransOpUtil::TransopMapToString()}); + REPORT_INNER_ERROR("E19999", "The trans node type %s does not exists, it must be %s", + node_type.c_str(), TransOpUtil::TransopMapToString().c_str()); GELOGE(INTERNAL_ERROR, "[Check][Param] The trans node type %s does not exists", node_type.c_str()); return nullptr; } @@ -421,8 +420,8 @@ Status RecoverTransRoadForVar(const NodePtr &var, const VarTransRoad &road) { auto trans_name = var->GetName() + "_trans_" + std::to_string(index++); auto ret = RecoverOneTransNodeForVar(trans_name, *iter, last_node, last_node); if (ret != SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E15001", {"variable", "index", "type"}, {var->GetName(), std::to_string(index), iter->node_type}); + REPORT_CALL_ERROR("E19999", "Failed to recover trans node for variable %s, index %d, type %s", + var->GetName().c_str(), index, iter->node_type.c_str()); GELOGE(INTERNAL_ERROR, "[Recover][TransNode] for variable %s, index %d, type %s", var->GetName().c_str(), index, iter->node_type.c_str()); return INTERNAL_ERROR; @@ -467,8 +466,8 @@ Status RecoverTransRoadForVarRef(const std::set &nodes, const VarTransR auto trans_name = var->GetName() + "_trans_" + std::to_string(index++); auto ret = RecoverOneTransNodeForVarRef(trans_name, *iter, last_node, last_node); if (ret != SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E15001", {"variable", "index", "type"}, {var->GetName(), std::to_string(index), iter->node_type}); + REPORT_CALL_ERROR("E19999", "Failed to recover trans node for variable %s, index %d, type %s", + var->GetName().c_str(), index, iter->node_type.c_str()); GELOGE(INTERNAL_ERROR, "[Recover][TransNode] for variable %s failed, index %d, type %s", var->GetName().c_str(), index, iter->node_type.c_str()); return INTERNAL_ERROR; @@ -643,8 +642,8 @@ Status CheckIfDynamicBatchScene(NodePtr &data_node, bool &is_dynamic_batch, Node std::string related_node_name; if (AttrUtils::GetStr(data_node->GetOpDesc(), kMbatchSwitchnName, related_node_name)) { if (related_node_name.empty()) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E15002", {"opname", "value", "reason"}, {data_node->GetName(), "flag", "but the value is empty"}); + REPORT_INNER_ERROR("E19999", "The data node %s has switchn node flag, but the value is empty", + data_node->GetName().c_str()); GELOGE(INTERNAL_ERROR, "[Check][Param] The data node %s has switchn node flag, but the value is empty", data_node->GetName().c_str()); return INTERNAL_ERROR; @@ -660,9 +659,8 @@ Status CheckIfDynamicBatchScene(NodePtr &data_node, bool &is_dynamic_batch, Node } if (mbatch_node == nullptr) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E15002", {"opname", "value", "reason"}, - {data_node->GetName(), related_node_name, "but can not find it on the graph"}); + REPORT_INNER_ERROR("E19999", "The data node %s has switchn node %s, but can not find it on the graph", + data_node->GetName().c_str(), related_node_name.c_str()); GELOGE(INTERNAL_ERROR, "[Check][Param] The data node %s has switchn node %s, but can not find it on the graph", data_node->GetName().c_str(), related_node_name.c_str()); return INTERNAL_ERROR; @@ -836,10 +834,10 @@ Status ProcessInputNC1HWC0DynShape(NodePtr &node_ptr, bool &is_dynamic_batch, No ge::GeShape old_shape = input->GetShape(); bool support = ((old_format == FORMAT_NC1HWC0) || (old_format == FORMAT_NCHW) || (old_format == FORMAT_NHWC)); if (!support) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, - {op_desc->GetName(), "format[" + TypeUtils::FormatToSerialString(old_format) + "]", - "only support FORMAT_NC1HWC0,FORMAT_NCHW,FORMAT_NHWC"}); + REPORT_INNER_ERROR("E19999", + "The format:%s of op:%s(%s) is unsupported, only support FORMAT_NC1HWC0,FORMAT_NCHW,FORMAT_NHWC", + TypeUtils::FormatToSerialString(old_format).c_str(), + op_desc->GetName().c_str(), op_desc->GetType().c_str()); GELOGE(INTERNAL_ERROR, "[Check][Param] The format [%s] is unsupported, op:%s", TypeUtils::FormatToSerialString(old_format).c_str(), op_desc->GetName().c_str()); return FAILED; @@ -1086,10 +1084,9 @@ Status ProcessNetoutputNodeDynShape(NodePtr &node) { // check if is_output_adjust_hw_layout is set if (NeedUpdateFormatByOutputTypeParm(op_desc, index)) { if ((old_format != FORMAT_NCHW) && (old_format != FORMAT_NHWC) && (old_format != FORMAT_NC1HWC0)) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19014", {"opname", "value", "reason"}, - {op_desc->GetName(), "format[" + TypeUtils::FormatToSerialString(old_format) + "]", - "only support FORMAT_NC1HWC0,FORMAT_NCHW,FORMAT_NHWC"}); + REPORT_INNER_ERROR("E19999", "Format:%s of op:%s(%s) is not one of NCHW, NHWC, NC1HWC0.", + TypeUtils::FormatToSerialString(old_format).c_str(), + op_desc->GetName().c_str(), op_desc->GetType().c_str()); GELOGE(INTERNAL_ERROR, "[Check][Param] Format is not one of NCHW, NHWC, NC1HWC0."); return FAILED; } @@ -1148,6 +1145,10 @@ Status UpdateDynamicInputShapeRange(const ge::GeAttrValue::INT index, GeTensorDesc &desc) { auto origin_shape = desc.GetShape(); auto current_shape_range_vec = range_vec.at(index); + if (origin_shape.IsScalar()) { + GELOGI("Cur input %ld is scalar, no need set shape range.", index); + return SUCCESS; + } if (current_shape_range_vec.size() != origin_shape.GetDimNum()) { REPORT_INNER_ERROR("E19999", "Given shape_range dim num is %zu, current dim:%s num is %zu, not match, " "check invalid", current_shape_range_vec.size(), origin_shape.ToString().c_str(), @@ -1325,9 +1326,9 @@ Status GraphPrepare::CheckRefInputNode(const NodePtr &node, const std::string &i } bool is_acceptable = (acceptable_types.find(input_type) != acceptable_types.end()); if (!is_acceptable) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E15005", {"opname", "optype", "opname1", "optype1"}, - {op_desc->GetName(), node->GetType(), input_op_desc->GetName(), input_op_desc->GetType()}); + REPORT_INNER_ERROR("E19999", "The ref input of ref node %s[%s] must be ref node or variable, but %s[%s]isn't.", + node->GetName().c_str(), node->GetType().c_str(), input_op_desc->GetName().c_str(), + input_op_desc->GetType().c_str()); GELOGE(PARAM_INVALID, "[Check][Param] The ref input of ref node %s[%s] must be ref node or variable, " "but %s[%s]isn't.", node->GetName().c_str(), node->GetType().c_str(), input_op_desc->GetName().c_str(), input_op_desc->GetType().c_str()); @@ -1402,8 +1403,8 @@ Status GraphPrepare::AdjustDataOpOutput(const NodePtr &node) { int64_t tensor_size = 0; graphStatus graph_status = TensorUtils::GetTensorMemorySizeInBytes(output, tensor_size); if (graph_status != GRAPH_SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, {"GetTensorMemorySizeInBytes", "opname is " + node->GetName()}); + REPORT_CALL_ERROR("E19999", "GetTensorMemorySize by ouput index:0 of op:%s(%s) failed", + op_desc_ptr->GetName().c_str(), op_desc_ptr->GetType().c_str()); GELOGE(graph_status, "[Call][GetTensorMemorySizeInBytes] failed, op:%s", node->GetName().c_str()); return FAILED; } @@ -1419,6 +1420,25 @@ Status GraphPrepare::AdjustDataOpOutput(const NodePtr &node) { return SUCCESS; } +Status GraphPrepare::CheckInternalFormat(const NodePtr &input_node, const GeTensorDesc &desc, bool tune_flag) { + auto format = desc.GetFormat(); + auto origin_format = desc.GetOriginFormat(); + bool need_check_internal_format = (!IsTansDataOpData(input_node)) && (!options_.is_single_op) && (!tune_flag); + if (need_check_internal_format) { + bool is_internal = TypeUtils::IsInternalFormat(format) || TypeUtils::IsInternalFormat(origin_format); + if (is_internal) { + std::string reason = "Input format[" + TypeUtils::FormatToSerialString(format) + "] or origin_format[" + + TypeUtils::FormatToSerialString(origin_format) + "] of op:" + input_node->GetName() + + " is not support"; + REPORT_INPUT_ERROR("E19025", std::vector({"reason"}), std::vector({reason})); + GELOGE(PARAM_INVALID, "[Check][Param] Input format %s or origin_format %s is not support.", + TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::FormatToSerialString(origin_format).c_str()); + return FAILED; + } + } + return SUCCESS; +} + Status GraphPrepare::UpdateInput(const std::vector &user_input, const std::map &graph_option) { // Get shape range of input in dynamic_execute mode @@ -1438,9 +1458,9 @@ Status GraphPrepare::UpdateInput(const std::vector &user_input, } if ((index < 0) || (static_cast(index) >= user_input.size())) { - std::string situation = "data op index[" + std::to_string(index) + "]"; - std::string reason = "it must less than user_input size[" + std::to_string(user_input.size()) + "]"; - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, {situation, reason}); + std::string reason = "exist data op:" + input_node->GetName() + " index " + std::to_string(index) + + " bigger than input tensor size[" + std::to_string(user_input.size()) + "], check invalid"; + REPORT_INPUT_ERROR("E19025", std::vector({"reason"}), std::vector({reason})); GELOGE(PARAM_INVALID, "[Check][Param] user_input size = %zu, graph data op index = %ld.", user_input.size(), index); return FAILED; @@ -1450,30 +1470,20 @@ Status GraphPrepare::UpdateInput(const std::vector &user_input, continue; } GeTensorDesc desc(user_input[index].GetTensorDesc()); - auto format = desc.GetFormat(); - auto origin_format = desc.GetOriginFormat(); // data maybe internal format [FRACTAL_NZ] at singleop process such as GEMM. auto tune_flag = (options_.build_mode == BUILD_MODE_TUNING) && (options_.build_step == BUILD_STEP_AFTER_BUILDER); - bool need_check_internal_format = (!IsTansDataOpData(input_node)) && (!options_.is_single_op) && (!tune_flag); - if (need_check_internal_format) { - bool is_internal = TypeUtils::IsInternalFormat(format) || TypeUtils::IsInternalFormat(origin_format); - if (is_internal) { - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, - {"Input format[" + TypeUtils::FormatToSerialString(format) + "] or origin_format[" + - TypeUtils::FormatToSerialString(origin_format) + "]", "it is not support"}); - GELOGE(PARAM_INVALID, "[Check][Param] Input format %s or origin_format %s is not support.", - TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::FormatToSerialString(origin_format).c_str()); - return FAILED; - } + ret = CheckInternalFormat(input_node, desc, tune_flag); + if (ret != SUCCESS) { + GELOGE(INTERNAL_ERROR, "[Check][InternalFormat] on %s failed", op->GetName().c_str()); + return ret; } - auto data_type = desc.GetDataType(); uint32_t length = 1; bool type_ret = TypeUtils::GetDataTypeLength(data_type, length); if (!type_ret) { - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, - {"Input datatype[" + TypeUtils::DataTypeToSerialString(data_type) + "]", "it is not support"}); + std::string reason = "Input datatype[" + TypeUtils::DataTypeToSerialString(data_type) + "] of index:" + + std::to_string(index) + " input tensor is not support"; + REPORT_INPUT_ERROR("E19025", std::vector({"reason"}), std::vector({reason})); GELOGE(PARAM_INVALID, "[Check][Param] Input datatype %s is not support.", TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; @@ -1489,10 +1499,9 @@ Status GraphPrepare::UpdateInput(const std::vector &user_input, return FAILED); bool size_check = (size != 0 && shape_size != size); if (size_check) { - std::string situation = "input data size[" + std::to_string(size) + - "] and shape_size[" + std::to_string(size) + "]"; - std::string reason = "because size != 0 and shape_size != size"; - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, {situation, reason}); + std::string reason = "input tensor[index:" + std::to_string(index) + "]'s data size[" + std::to_string(size) + + "] != shape_size[" + std::to_string(size) + "], check invalid"; + REPORT_INPUT_ERROR("E19025", std::vector({"reason"}), std::vector({reason})); GELOGE(PARAM_INVALID, "[Check][Param] input data size = %ld, shape_size = %ld.", size, shape_size); return FAILED; } @@ -1872,8 +1881,8 @@ Status GraphPrepare::VerifyConstOp(const NodePtr &node) { uint32_t length = 1; bool type_ret = TypeUtils::GetDataTypeLength(data_type, length); if (!type_ret) { - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, - {"Input datatype[" + TypeUtils::DataTypeToSerialString(data_type) + "]", "it is not support"}); + REPORT_INNER_ERROR("E19999", "const node:%s's input datatype:%s it is not support", + node->GetName().c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); GELOGE(PARAM_INVALID, "[Check][Param] Input datatype %s is not support.", TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; @@ -1885,19 +1894,22 @@ Status GraphPrepare::VerifyConstOp(const NodePtr &node) { if (ge_tensor_desc.GetShape().GetDims().size() == 0) { // shape = [], means it's a sclar tensor. GE_CHK_BOOL_EXEC(data_size / length == 1, - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {"Const is invalid scalar tensor."}); + REPORT_INNER_ERROR("E19999", "Const Node:%s is invalid, data size:%zu not equal to tensor size:%u", + node->GetName().c_str(), data_size, length); return PARAM_INVALID, "[Check][Param] Const is invalid scalar tensor."); } else { // shape = [x, y, 0,...], means it's a vector tensor that value is []. GE_CHK_BOOL_EXEC(data_size == 0, - ErrorManager::GetInstance().ATCReportErrMessage("E10043", {"reason"}, {"Const is invalid vector scalar."}); + REPORT_INNER_ERROR("E19999", "Const Node:%s is invalid, data size:%zu not equal to tensor size:0", + node->GetName().c_str(), data_size); return PARAM_INVALID, "[Check][Param] Const is invalid vector scalar."); } } else { - GE_CHK_BOOL_EXEC(data_size == static_cast(shape_size * length) && data_size != 0, - ErrorManager::GetInstance().ATCReportErrMessage( - "E10043", {"reason"}, {"Const input data size is not equal with tensor desc shape"}); - return PARAM_INVALID, "[Check][Param] Const input data size is not equal with tensor desc shape"); + GE_CHK_BOOL_EXEC( + data_size == static_cast(shape_size * length) && data_size != 0, + REPORT_INNER_ERROR("E19999", "Const Node:%s is invalid, data size:%zu not equal to tensor size:%ld", + node->GetName().c_str(), data_size, shape_size * length); + return PARAM_INVALID, "[Check][Param] Const input data size is not equal with tensor desc shape"); } return SUCCESS; } @@ -1940,9 +1952,9 @@ Status GraphPrepare::CheckUserInput(const std::vector &user_input) { return GE_GRAPH_INIT_FAILED; } if ((index < 0) || (static_cast(index) >= user_input.size())) { - std::string situation = "data op index[" + std::to_string(index) + "]"; - std::string reason = "it must less than user_input size[" + std::to_string(user_input.size()) + "]"; - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, {situation, reason}); + std::string reason = "exist data op:" + input_node->GetName() + " index " + std::to_string(index) + + " bigger than input tensor size[" + std::to_string(user_input.size()) + "], check invalid"; + REPORT_INPUT_ERROR("E19025", std::vector({"reason"}), std::vector({reason})); GELOGE(GE_GRAPH_INIT_FAILED, "[Check][Param] user_input size:%zu must larger than data op index:%ld.", user_input.size(), index); return GE_GRAPH_INIT_FAILED; @@ -1955,10 +1967,10 @@ Status GraphPrepare::CheckUserInput(const std::vector &user_input) { for (size_t i = 0; i < desc.GetShape().GetDimNum(); ++i) { int64_t dim = desc.GetShape().GetDim(i); if (dim < UNKNOWN_DIM_NUM) { - std::string situation = "data dim[" + std::to_string(i) + "][" + std::to_string(dim) + "]" ; - std::string reason = "it need >= -2"; + std::string reason = "data dim[" + std::to_string(i) + "][" + std::to_string(dim) + "] of index:" + + std::to_string(index) + " input tensor it need >= -2"; REPORT_INPUT_ERROR( - "E19025", std::vector({"situation", "reason"}), std::vector({situation, reason})); + "E19025", std::vector({"reason"}), std::vector({reason})); GELOGE(GE_GRAPH_INIT_FAILED, "[Check][InputDim]data dim %zu is not supported, need >= -2, real:%ld.", i, dim); return GE_GRAPH_INIT_FAILED; } diff --git a/ge/graph/preprocess/graph_preprocess.h b/ge/graph/preprocess/graph_preprocess.h index 3eb5e03a..584f4d16 100755 --- a/ge/graph/preprocess/graph_preprocess.h +++ b/ge/graph/preprocess/graph_preprocess.h @@ -63,6 +63,7 @@ class GraphPrepare { Status CheckRefOp(); Status SetRtContext(rtContext_t rt_context, rtCtxMode_t mode); Status AdjustDataOpOutput(const NodePtr &node); + Status CheckInternalFormat(const NodePtr &input_node, const GeTensorDesc &desc, bool tune_flag); Status UpdateInput(const std::vector &user_input, const std::map &graph_option); Status CheckAndUpdateInput(const std::vector &user_input, const std::map &graph_option); Status CheckConstOp(); diff --git a/ge/graph/preprocess/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index 1086b842..5c191af7 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -114,8 +114,9 @@ Status GetDataDimN(const ge::NodePtr &data_node, ge::Format format, int64_t &bat std::vector({ data_node->GetName() + " format", TypeUtils::FormatToSerialString(format), - "only format " + TypeUtils::FormatToSerialString(FORMAT_NCHW) + " and " - + TypeUtils::FormatToSerialString(FORMAT_NHWC) + " supported"})); + "only format " + TypeUtils::FormatToSerialString(FORMAT_NCHW) + " and "+ + TypeUtils::FormatToSerialString(FORMAT_NHWC) + + " supported which dynamic aipp is linked"})); GELOGE(PARAM_INVALID, "[Check][Param] Not support data format:%s, node:%s", TypeUtils::FormatToSerialString(format).c_str(), data_node->GetName().c_str()); return PARAM_INVALID; @@ -475,7 +476,7 @@ Status AippOp::ConvertRelatedInputNameToRank() { string error_msg = "Top name " + related_input_name + "convert rank failed, Please" " ensure top name in aipp config is the top name of data node."; GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); - REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); + REPORT_INPUT_ERROR("E10052", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } diff --git a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc index 4164a872..d76b79b9 100755 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -126,14 +126,14 @@ Status InsertNewOpUtil::CheckInputNamePositionNotRepeat() { string error_msg = "Can not both set related_input_name and related_input_rank!" " Please ensure param is the same with the first aipp config(related_input_name)."; GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); - REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); + REPORT_INPUT_ERROR("E10052", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } if (item->related_input_name() == another_item->related_input_name()) { string error_msg = "Can not insert aipp to the same postion! Please ensure related_input_name" " param is different in different aipp config."; GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); - REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); + REPORT_INPUT_ERROR("E10052", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } } @@ -154,14 +154,14 @@ Status InsertNewOpUtil::CheckInputRankPositionNoRepeat() { string error_msg = "Can not both set related_input_rank and related_input_name!" " Please ensure param is the same with the first aipp config(related_input_rank)."; GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); - REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); + REPORT_INPUT_ERROR("E10052", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } if (item->related_input_rank() == another_item->related_input_rank()) { string error_msg = "Can not insert aipp to the same postion! Please ensure related_input_rank" " param is different in different aipp config."; GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); - REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); + REPORT_INPUT_ERROR("E10052", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } } diff --git a/ge/graph/preprocess/multi_batch_copy_graph.cc b/ge/graph/preprocess/multi_batch_copy_graph.cc index 610b0137..1634c8ce 100644 --- a/ge/graph/preprocess/multi_batch_copy_graph.cc +++ b/ge/graph/preprocess/multi_batch_copy_graph.cc @@ -764,8 +764,8 @@ Status MultiBatchGraphCopyer::CheckAndParseDynamicData(){ data_name.c_str()); return PARAM_INVALID); } else if (dynamic_type_ == DynamicType::kDynamicDims) { ErrorManager::GetInstance().ATCReportErrMessage("E10001", - {"parameter", "reason"}, - {"--input_shape", + {"parameter", "value" "reason"}, + {"--dynamic_dims", data_name, "all dynamic data must be set in --input_shape"}); GELOGE(INTERNAL_ERROR, "[Check][Param] data:%s shape:%s must be set int --input_shape", node->GetName().c_str(), data_shape.ToString().c_str()); @@ -1205,8 +1205,8 @@ Status MultiBatchGraphCopyer::CheckCopyResult(const std::vector &start_ } auto dims = NodeUtils::GetOutputDesc(*node, kDataOutIndex).GetShape().GetDims(); if (!IsAllDimsPositive(dims)) { - ErrorManager::GetInstance().ATCReportErrMessage("E15004", {"opname", "shape"}, - {node->GetName(), formats::ShapeToString(dims)}); + REPORT_CALL_ERROR("E19999", "Failed to copy multi batch graph, the node %s still has unknown shape %s", + node->GetName().c_str(), formats::ShapeToString(dims).c_str()); GELOGE(INTERNAL_ERROR, "[Check][Param] Failed to copy multi batch graph, the node %s still has unknown shape %s", node->GetName().c_str(), formats::ShapeToString(dims).c_str()); return INTERNAL_ERROR; diff --git a/ge/graph/preprocess/multi_batch_options.cc b/ge/graph/preprocess/multi_batch_options.cc index 058b720d..b3e5b616 100644 --- a/ge/graph/preprocess/multi_batch_options.cc +++ b/ge/graph/preprocess/multi_batch_options.cc @@ -550,10 +550,8 @@ Status CalcShape(const std::vector &batch_shape, GeShape &data_shape) { for (size_t i = 0; i < data_shape.GetDimNum(); ++i) { if (data_shape.GetDim(i) < 0) { if (batch_shape_index >= batch_shape.size()) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, - {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + - " does not match the data shape " + data_shape.ToString()}); + REPORT_INNER_ERROR("E19999", "the batch shape count %zu, does not match the data shape %s", + batch_shape.size(), data_shape.ToString().c_str()); GELOGE(PARAM_INVALID, "[Check][Param] Failed to calc tensor shape, the batch shape count %zu, " "does not match the data shape %s", batch_shape.size(), data_shape.ToString().c_str()); return PARAM_INVALID; @@ -563,9 +561,8 @@ Status CalcShape(const std::vector &batch_shape, GeShape &data_shape) { } GELOGI("CalcShape size of batch_shape is %zu, batch_shape_index is %zu.", batch_shape.size(), batch_shape_index); if (batch_shape_index != batch_shape.size()) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E19012", {"function", "reason"}, {"CalcShape", "the batch shape count " + std::to_string(batch_shape.size()) + - " does not match the data shape " + data_shape.ToString()}); + REPORT_INNER_ERROR("E19999", "the batch shape count %zu, does not match the data shape %s", + batch_shape.size(), data_shape.ToString().c_str()); GELOGE(PARAM_INVALID, "[Check][Param] Failed to calc tensor shape, the batch shape count %zu, " "does not match the data shape %s", batch_shape.size(), data_shape.ToString().c_str()); return PARAM_INVALID; diff --git a/ge/host_cpu_engine/CMakeLists.txt b/ge/host_cpu_engine/CMakeLists.txt deleted file mode 100644 index d54dacf7..00000000 --- a/ge/host_cpu_engine/CMakeLists.txt +++ /dev/null @@ -1,272 +0,0 @@ -set(SRC_LIST - "engine/host_cpu_engine.cc" - "ops_kernel_store/host_cpu_ops_kernel_info.cc" - "ops_kernel_store/op/op_factory.cc" - "ops_kernel_store/op/host_op.cc" -) - -set(CPU_OPS_KERNEL_LIST - "ops_kernel_store/host_cpu_ops_kernel_builder.cc" -) - -############ libhost_cpu_engine.so ############ -add_library(host_cpu_engine SHARED ${SRC_LIST}) - -add_dependencies(host_cpu_engine - graphengine_protos -) - -target_compile_options(host_cpu_engine PRIVATE - -Werror - -fno-common - -fvisibility=hidden -) - -target_compile_definitions(host_cpu_engine PRIVATE - google=ascend_private - FUNC_VISIBILITY -) - -target_include_directories(host_cpu_engine PRIVATE - ${CMAKE_CURRENT_LIST_DIR} - ${GE_CODE_DIR}/ge - ${GE_CODE_DIR}/inc - ${GE_CODE_DIR}/inc/external - ${GE_CODE_DIR}/inc/framework - ${METADEF_DIR}/inc - ${METADEF_DIR}/inc/external - ${METADEF_DIR}/inc/external/graph - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/graphengine_protos - #### yellow zone #### - ${GE_CODE_DIR}/../inc - #### blue zone #### - ${GE_CODE_DIR}/third_party/fwkacllib/inc -) - -target_link_options(host_cpu_engine PRIVATE - -Wl,-Bsymbolic -) - -target_link_libraries(host_cpu_engine PRIVATE - $ - -Wl,--no-as-needed - ascend_protobuf - c_sec - graph - slog - -Wl,--as-needed -) - -############ atcstub/libhost_cpu_engine.so ############ -add_library(atc_host_cpu_engine SHARED ${SRC_LIST}) - -add_dependencies(atc_host_cpu_engine - graphengine_protos -) - -target_compile_options(atc_host_cpu_engine PRIVATE - -Werror - -fno-common - -fvisibility=hidden -) - -target_compile_definitions(atc_host_cpu_engine PRIVATE - google=ascend_private - FUNC_VISIBILITY -) - -target_include_directories(atc_host_cpu_engine PRIVATE - ${CMAKE_CURRENT_LIST_DIR} - ${GE_CODE_DIR}/ge - ${GE_CODE_DIR}/inc - ${GE_CODE_DIR}/inc/external - ${GE_CODE_DIR}/inc/framework - ${METADEF_DIR}/inc - ${METADEF_DIR}/inc/external - ${METADEF_DIR}/inc/external/graph - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/graphengine_protos - #### yellow zone #### - ${GE_CODE_DIR}/../inc - #### blue zone #### - ${GE_CODE_DIR}/third_party/fwkacllib/inc -) - -target_link_options(atc_host_cpu_engine PRIVATE - -Wl,-Bsymbolic -) - -target_link_libraries(atc_host_cpu_engine PRIVATE - $ - -Wl,--no-as-needed - ascend_protobuf - c_sec - graph - slog - -Wl,--as-needed -) - -set_target_properties(atc_host_cpu_engine PROPERTIES - OUTPUT_NAME host_cpu_engine - LIBRARY_OUTPUT_DIRECTORY atclib -) - -############ libhost_cpu_opskernel_builder.so ############ -add_library(host_cpu_opskernel_builder SHARED ${CPU_OPS_KERNEL_LIST}) - -add_dependencies(host_cpu_opskernel_builder - graphengine_protos -) - -target_compile_options(host_cpu_opskernel_builder PRIVATE - -Werror - -fno-common - -fvisibility=hidden -) - -target_compile_definitions(host_cpu_opskernel_builder PRIVATE - google=ascend_private - FUNC_VISIBILITY -) - -target_include_directories(host_cpu_opskernel_builder PRIVATE - ${CMAKE_CURRENT_LIST_DIR} - ${GE_CODE_DIR}/ge - ${GE_CODE_DIR}/inc - ${GE_CODE_DIR}/inc/external - ${GE_CODE_DIR}/inc/framework - ${METADEF_DIR}/inc - ${METADEF_DIR}/inc/external - ${METADEF_DIR}/inc/external/graph - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/graphengine_protos - #### yellow zone #### - ${GE_CODE_DIR}/../inc - #### blue zone #### - ${GE_CODE_DIR}/third_party/fwkacllib/inc -) - -target_link_options(host_cpu_opskernel_builder PRIVATE - -Wl,-Bsymbolic -) - -target_link_libraries(host_cpu_opskernel_builder PRIVATE - $ - -Wl,--no-as-needed - ascend_protobuf - c_sec - slog - graph - register - -Wl,--as-needed -) - -############ atclib/libhost_cpu_opskernel_builder.so ############ -add_library(atc_host_cpu_opskernel_builder SHARED ${CPU_OPS_KERNEL_LIST}) - -add_dependencies(atc_host_cpu_opskernel_builder - graphengine_protos -) - -target_compile_options(atc_host_cpu_opskernel_builder PRIVATE - -Werror - -fno-common - -fvisibility=hidden -) - -target_compile_definitions(atc_host_cpu_opskernel_builder PRIVATE - google=ascend_private - FUNC_VISIBILITY -) - -target_include_directories(atc_host_cpu_opskernel_builder PRIVATE - ${CMAKE_CURRENT_LIST_DIR} - ${GE_CODE_DIR}/ge - ${GE_CODE_DIR}/inc - ${GE_CODE_DIR}/inc/external - ${GE_CODE_DIR}/inc/framework - ${METADEF_DIR}/inc - ${METADEF_DIR}/inc/external - ${METADEF_DIR}/inc/external/graph - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/graphengine_protos - #### yellow zone #### - ${GE_CODE_DIR}/../inc - #### blue zone #### - ${GE_CODE_DIR}/third_party/fwkacllib/inc -) - -target_link_options(atc_host_cpu_opskernel_builder PRIVATE - -Wl,-Bsymbolic -) - -target_link_libraries(atc_host_cpu_opskernel_builder PRIVATE - $ - -Wl,--no-as-needed - ascend_protobuf - c_sec - slog - graph - register - -Wl,--as-needed -) - -set_target_properties(atc_host_cpu_opskernel_builder PROPERTIES - OUTPUT_NAME host_cpu_opskernel_builder - LIBRARY_OUTPUT_DIRECTORY atclib -) - -############ libhost_cpu_opskernel_builder.a ############ -add_library(host_cpu_opskernel_builder_static STATIC ${CPU_OPS_KERNEL_LIST}) - -add_dependencies(host_cpu_opskernel_builder_static - graphengine_protos -) - -target_compile_options(host_cpu_opskernel_builder_static PRIVATE - -Werror - -fno-common - -fvisibility=hidden -) - -target_compile_definitions(host_cpu_opskernel_builder_static PRIVATE - google=ascend_private - LOG_CPP - FUNC_VISIBILITY -) - -target_include_directories(host_cpu_opskernel_builder_static PRIVATE - ${CMAKE_CURRENT_LIST_DIR} - ${GE_CODE_DIR}/ge - ${GE_CODE_DIR}/inc - ${GE_CODE_DIR}/inc/external - ${GE_CODE_DIR}/inc/framework - ${METADEF_DIR}/inc - ${METADEF_DIR}/inc/external - ${METADEF_DIR}/inc/external/graph - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/graphengine_protos - #### yellow zone #### - ${GE_CODE_DIR}/../inc - #### blue zone #### - ${GE_CODE_DIR}/third_party/fwkacllib/inc -) - -target_link_libraries(host_cpu_opskernel_builder_static PRIVATE - $ - ascend_protobuf - c_sec -) - -############ install ############ -set(INSTALL_BASE_DIR "") -set(INSTALL_LIBRARY_DIR lib) - -install(TARGETS host_cpu_engine host_cpu_opskernel_builder OPTIONAL - LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR} -) - -install(TARGETS atc_host_cpu_engine atc_host_cpu_opskernel_builder OPTIONAL - LIBRARY DESTINATION ${INSTALL_LIBRARY_DIR}/atclib -) diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc deleted file mode 100644 index 5e8394f0..00000000 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "host_cpu_engine/engine/host_cpu_engine.h" -#include -#include -#include -#include -#include "framework/common/debug/ge_log.h" -#include "common/ge/ge_util.h" -#include "host_cpu_engine/common/constant/constant.h" -#include "host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h" - -namespace ge { -namespace host_cpu { -HostCpuEngine &HostCpuEngine::Instance() { - static HostCpuEngine instance; - return instance; -} - -Status HostCpuEngine::Initialize(const std::map &options) { - if (ops_kernel_store_ == nullptr) { - ops_kernel_store_ = MakeShared(); - if (ops_kernel_store_ == nullptr) { - GELOGE(FAILED, "[Create][HostCpuEngine]Make HostCpuOpsKernelInfoStore failed."); - REPORT_INNER_ERROR("E19999", "HostCpuEngine::Initialize failed for new HostCpuEngine."); - return FAILED; - } - } - return SUCCESS; -} - -void HostCpuEngine::GetOpsKernelInfoStores(std::map &ops_kernel_map) { - if (ops_kernel_store_ != nullptr) { - // add buildin opsKernel to opsKernelInfoMap - ops_kernel_map[kHostCpuOpKernelLibName] = ops_kernel_store_; - } -} - -void HostCpuEngine::GetGraphOptimizerObjs(std::map &) { - // no optimizer for host cpu engine -} - -Status HostCpuEngine::Finalize() { - ops_kernel_store_ = nullptr; - return SUCCESS; -} -} // namespace host_cpu -} // namespace ge - -ge::Status Initialize(const std::map &options) { - return ge::host_cpu::HostCpuEngine::Instance().Initialize(options); -} - -void GetOpsKernelInfoStores(std::map &ops_kernel_map) { - ge::host_cpu::HostCpuEngine::Instance().GetOpsKernelInfoStores(ops_kernel_map); -} - -void GetGraphOptimizerObjs(std::map &graph_optimizers) { - ge::host_cpu::HostCpuEngine::Instance().GetGraphOptimizerObjs(graph_optimizers); -} - -ge::Status Finalize() { return ge::host_cpu::HostCpuEngine::Instance().Finalize(); } diff --git a/ge/host_cpu_engine/module.mk b/ge/host_cpu_engine/module.mk deleted file mode 100644 index 861ab19b..00000000 --- a/ge/host_cpu_engine/module.mk +++ /dev/null @@ -1,161 +0,0 @@ -LOCAL_PATH := $(call my-dir) - - -local_lib_src_files := engine/host_cpu_engine.cc \ - ops_kernel_store/host_cpu_ops_kernel_info.cc \ - ops_kernel_store/op/op_factory.cc \ - ops_kernel_store/op/host_op.cc \ - -local_lib_inc_path := proto/task.proto \ - ${LOCAL_PATH} \ - ${TOPDIR}inc \ - ${TOPDIR}metadef/inc \ - ${TOPDIR}graphengine/inc \ - ${TOPDIR}inc/external \ - ${TOPDIR}metadef/inc/external \ - ${TOPDIR}graphengine/inc/external \ - ${TOPDIR}metadef/inc/external/graph \ - $(TOPDIR)libc_sec/include \ - ${TOPDIR}third_party/protobuf/include \ - ${TOPDIR}graphengine/inc/framework \ - $(TOPDIR)graphengine/ge \ - -#compiler for host -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_engine -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libascend_protobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - libruntime - -LOCAL_SRC_FILES := $(local_lib_src_files) -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for atc -include $(CLEAR_VARS) -LOCAL_MODULE := atclib/libhost_cpu_engine -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -DCOMPILE_OMG_PACKAGE -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libascend_protobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - libruntime_compile - -LOCAL_SRC_FILES := $(local_lib_src_files) -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for host ops kernel builder -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libascend_protobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} - -#compiler for device ops kernel builder -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libascend_protobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_SHARED_LIBRARY} - -#compiler for host static lib -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := libascend_protobuf \ - libgraph \ - libregister \ - -LOCAL_SHARED_LIBRARIES := libc_sec \ - libslog \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_STATIC_LIBRARY} - -#compiler for device static lib -include $(CLEAR_VARS) -LOCAL_MODULE := libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := libascend_protobuf \ - libgraph \ - libregister \ - -LOCAL_SHARED_LIBRARIES := libc_sec \ - libslog \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_STATIC_LIBRARY} - -#compiler for atc ops kernel builder -include $(CLEAR_VARS) -LOCAL_MODULE := atclib/libhost_cpu_opskernel_builder -LOCAL_CFLAGS += -Werror -LOCAL_CFLAGS += -std=c++11 -Dgoogle=ascend_private -LOCAL_LDFLAGS := - -LOCAL_STATIC_LIBRARIES := -LOCAL_SHARED_LIBRARIES := libascend_protobuf \ - libc_sec \ - libslog \ - libgraph \ - libregister \ - -LOCAL_SRC_FILES := ops_kernel_store/host_cpu_ops_kernel_builder.cc - -LOCAL_C_INCLUDES := $(local_lib_inc_path) - -include ${BUILD_HOST_SHARED_LIBRARY} diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc b/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc deleted file mode 100644 index 3e619635..00000000 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.cc +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "host_cpu_engine/ops_kernel_store/op/host_op.h" -#include "framework/common/util.h" -#include "host_cpu_engine/ops_kernel_store/op/op_factory.h" - -namespace ge { -namespace host_cpu { -Status HostOp::Run() { - // no need to generate device task - return SUCCESS; -} - -REGISTER_OP_CREATOR(NoOp, HostOp); -REGISTER_OP_CREATOR(Variable, HostOp); -REGISTER_OP_CREATOR(Constant, HostOp); -REGISTER_OP_CREATOR(Assign, HostOp); -REGISTER_OP_CREATOR(RandomUniform, HostOp); -REGISTER_OP_CREATOR(Add, HostOp); -REGISTER_OP_CREATOR(Mul, HostOp); -REGISTER_OP_CREATOR(ConcatV2, HostOp); -REGISTER_OP_CREATOR(Data, HostOp); -REGISTER_OP_CREATOR(Fill, HostOp); -REGISTER_OP_CREATOR(NetOutput, HostOp); -} // namespace host_cpu -} // namespace ge diff --git a/ge/host_cpu_engine/proto/task.proto b/ge/host_cpu_engine/proto/task.proto deleted file mode 100644 index 0da5631e..00000000 --- a/ge/host_cpu_engine/proto/task.proto +++ /dev/null @@ -1,179 +0,0 @@ -/* Copyright (C) 2018. Huawei Technologies Co., Ltd. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the Apache License Version 2.0.You may not use this file except in compliance with the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * Apache License for more details at - * http://www.apache.org/licenses/LICENSE-2.0 - */ -syntax = "proto3"; - -package domi; - -message ModelTaskDef { - string version = 1; - - map attr = 9; // Extended field - repeated TaskDef task = 10; - - uint64 memory_size = 11; - uint32 stream_num = 12; - uint32 event_num = 13; - uint64 weight_size = 14; - - repeated bytes op = 15; // input/output opdef in bytes - - uint64 base_addr = 16; // base addr - uint64 weight_addr = 17; // weight addr - uint32 batch_num = 18; -} - - -message TaskDef { - uint32 id = 1; - uint32 type = 2; - - uint32 stream_id = 10; - uint32 event_id = 11; - - KernelDef kernel = 20; - KernelExDef kernel_ex = 21; - KernelHcclDef kernel_hccl = 25; - EventExDef event_ex = 26; - LogTimeStampDef log_timestamp = 28; - - uint32 label_id = 30; - - MemcpyAsyncDef memcpy_async = 31; - StreamSwitchDef stream_switch = 32; - StreamActiveDef stream_active = 33; - bytes private_def = 34; - uint64 ops_kernel_store_ptr = 35; // adjustments to other fields in the future - StreamSwitchNDef stream_switch_n = 36; - - LabelSetDef label_set = 37; - LabelGotoExDef label_goto_ex = 38; - LabelSwitchByIndexDef label_switch_by_index = 39; - KernelDefWithHandle kernel_with_handle = 40; -} - -message KernelDef { - KernelContext context = 1; - - string stub_func = 10; - uint32 block_dim = 11; - uint32 args_size = 12; - bytes args = 13; - bytes sm_desc = 14; - bytes flowtable = 15; - string so_name = 16; - string kernel_name = 17; - bytes kernel_ext_info = 18; - uint32 kernel_ext_info_size = 19; -} - -message KernelDefWithHandle { - KernelContext context = 1; - - uint64 handle = 10; - string dev_func = 11; - uint32 block_dim = 12; - uint32 args_size = 13; - bytes args = 14; - bytes sm_desc = 15; - string original_kernel_key = 16; - string node_info = 17; -} - -message KernelContext { - uint32 kernel_type = 1; - uint32 op_id = 2; // OP type in CCE - uint32 kernel_func_id = 3; - uint32 op_index = 4; // TE/Custom operator - bool is_flowtable = 5; // Identify whether args is a flowtable structure - bytes args_offset = 6; // args offset information - uint32 args_count = 7; // args count - repeated uint32 origin_op_index = 8; -} - - -message KernelExDef { - uint32 flags = 1; - - uint32 op_index = 4; - uint32 args_size = 12; - bytes args = 13; - bytes task_info = 14; // serialized nodeDef, funcDef, inputoutput - uint32 task_info_size = 15; - bytes kernel_ext_info = 16; - uint32 kernel_ext_info_size = 17; -} - - -message KernelHcclDef { - uint32 op_index = 8; - string hccl_type = 9; -} - - -message EventExDef { - uint32 op_index = 1; - uint32 event_type = 2; -} - -message LogTimeStampDef { - uint64 logid = 1; - bool notify = 2; - uint32 flat = 3; -} - -message MemcpyAsyncDef { - uint64 dst = 1; - uint64 dst_max = 2; - uint64 src = 3; - uint64 count = 4; - uint32 kind = 5; - uint32 op_index = 6; -} - -message StreamSwitchDef { - uint32 op_index = 1; - uint32 true_stream_id = 2; - int64 value = 3; - uint64 value_ptr = 4; - uint32 data_type = 5; -} - -message StreamActiveDef { - uint32 op_index = 1; - uint32 active_stream_id = 2; -} - -message StreamSwitchNDef { - uint32 op_index = 1; - uint32 size = 2; - repeated int64 target_value = 3; - repeated uint32 true_stream_id = 4; - uint32 element_size = 5; - uint32 data_type = 6; -} - -message LabelSetDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelGotoExDef { - uint32 op_index = 1; - uint32 label_id = 2; - uint32 model_id = 3; -} - -message LabelSwitchByIndexDef { - uint32 op_index = 1; - uint32 label_max = 2; -} diff --git a/ge/host_kernels/slice_kernel.cc b/ge/host_kernels/slice_kernel.cc index 025d7f66..6e398e96 100644 --- a/ge/host_kernels/slice_kernel.cc +++ b/ge/host_kernels/slice_kernel.cc @@ -71,15 +71,13 @@ Status SliceKernel::Compute(const OpDescPtr attr, const std::vectorGetTensorDesc().GetDataType(); // check supported @@ -92,11 +90,7 @@ Status SliceKernel::Compute(const OpDescPtr attr, const std::vectorGetTensorDesc().GetDataType() != DT_INT32 || size->GetTensorDesc().GetDataType() != DT_INT32) { - GELOGW("Data type of begin and size for slice are not DT_INT32."); - return NOT_CHANGED; - } + void *data = reinterpret_cast(const_cast(x_->GetData().data())); int32_t *begin_data = const_cast(reinterpret_cast(begin->GetData().GetData())); @@ -145,7 +139,7 @@ Status SliceKernel::Compute(const OpDescPtr attr, const std::vectorGetTensorDesc().GetDataType() != DT_INT32 || size->GetTensorDesc().GetDataType() != DT_INT32) { + GELOGW("Data type of begin and size for slice are not DT_INT32."); + return NOT_CHANGED; + } + return SUCCESS; +} + Status SliceKernel::CheckOutputDims(const std::vector &output_dims, const OpDescPtr attr) { // check dim not all less than 0 for (auto dim : output_dims) { diff --git a/ge/host_kernels/slice_kernel.h b/ge/host_kernels/slice_kernel.h index 4c059b18..21142613 100755 --- a/ge/host_kernels/slice_kernel.h +++ b/ge/host_kernels/slice_kernel.h @@ -28,6 +28,7 @@ class SliceKernel : public Kernel { vector &v_output) override; Status CheckOutputDims(const std::vector &output_dims, const OpDescPtr attr); + Status CheckInput(const ConstGeTensorPtr &x_, const ConstGeTensorPtr &begin, const ConstGeTensorPtr &size); }; } // namespace ge diff --git a/ge/hybrid/executor/node_state.cc b/ge/hybrid/executor/node_state.cc index fd47cfb2..313a2934 100644 --- a/ge/hybrid/executor/node_state.cc +++ b/ge/hybrid/executor/node_state.cc @@ -22,6 +22,14 @@ #include "hybrid_execution_context.h" #include "subgraph_context.h" +#define INC_ITERATION_COUNT(iteration) \ +do { \ + ++iteration; \ + if (iteration == UINT64_MAX) { \ + iteration = 1; \ + } \ +} while (0) + namespace ge { namespace hybrid { namespace { @@ -306,15 +314,45 @@ std::shared_ptr NodeState::GetTaskContext() { return task_context_; } -void NodeState::ResetContext(uint64_t loop_count) { - loop_count_ = loop_count; - +void NodeState::ResetContext(uint64_t iteration) { switch_index_ = -1; subgraph_context_->ResetContext(node_item_->node); - data_scheduled_ = static_cast(node_item_->root_data_.size()); - ctrl_scheduled_ = static_cast(node_item_->root_ctrl_.size()); - GELOGD("[%s] in while loop, loop count: %lu, data scheduled: %u, ctrl scheduled: %u, merge index: %d", - GetName().c_str(), loop_count_, data_scheduled_, ctrl_scheduled_, merge_index_); + if (iteration == 0) { + data_scheduled_ = static_cast(node_item_->root_data_.size()); + ctrl_scheduled_ = static_cast(node_item_->root_ctrl_.size()); + } else { + data_scheduled_ = static_cast(node_item_->root_data_.size() + node_item_->enter_data_.size()); + ctrl_scheduled_ = static_cast(node_item_->root_ctrl_.size() + node_item_->enter_ctrl_.size()); + } + + iteration_count_ = iteration; + GELOGD("[%s] in while loop, current iteration: %lu, data scheduled: %u, ctrl scheduled: %u, merge index: %d", + GetName().c_str(), iteration_count_, data_scheduled_, ctrl_scheduled_, merge_index_); +} + +void NodeState::ScheduleContext(const NodeState &node_state) { + if (node_state.node_item_->IsEnterOp()) { + GELOGD("[%s]{active: %lu, iteration: %lu}, frame{active: %lu, iteration: %lu} [%s]{active: %lu, iteration: %lu}", + GetName().c_str(), active_count_, iteration_count_, frame_state_->active_count_, + frame_state_->iteration_count_, node_state.GetName().c_str(), node_state.frame_state_->active_count_, + node_state.frame_state_->iteration_count_); + if (frame_state_->active_count_ != active_count_) { + ResetContext(0); + active_count_ = frame_state_->active_count_; + } + } else if (node_state.node_item_->IsExitOp()) { + GELOGD("[%s]{active: %lu, iteration: %lu} frame{active: %lu, iteration: %lu} " + "[%s]{active: %lu, iteration: %lu} parent{active: %lu, iteration: %lu}", + GetName().c_str(), active_count_, iteration_count_, frame_state_->active_count_, + frame_state_->iteration_count_, node_state.GetName().c_str(), node_state.frame_state_->active_count_, + node_state.frame_state_->iteration_count_, node_state.frame_state_->parent_frame_->active_count_, + node_state.frame_state_->parent_frame_->iteration_count_); + if (node_state.frame_state_->parent_frame_->iteration_count_ != iteration_count_) { + ResetContext(node_state.frame_state_->parent_frame_->iteration_count_); + } + } else if (node_state.iteration_count_ != iteration_count_) { + ResetContext(node_state.iteration_count_); + } } Status NodeState::NodeScheduled(const std::function &ready) const { @@ -346,11 +384,11 @@ Status NodeState::NodeScheduled(const std::function &rea } bool NodeState::IsScheduleReady() const { - GELOGD("[%s] loop[%lu] data[input: %zu, scheduled: %u], ctrl[input: %zu+%zu, scheduled: %u]", - GetName().c_str(), loop_count_, node_item_->data_recv_.size(), data_scheduled_, - node_item_->ctrl_recv_.size(), node_item_->GetMergeCtrl(loop_count_ == 0 ? 0 : 1), ctrl_scheduled_); + GELOGD("[%s] iteration[%lu] data[input: %zu, scheduled: %u], ctrl[input: %zu+%zu, scheduled: %u]", + GetName().c_str(), iteration_count_, node_item_->data_recv_.size(), data_scheduled_, + node_item_->ctrl_recv_.size(), node_item_->GetMergeCtrl(iteration_count_ == 0 ? 0 : 1), ctrl_scheduled_); if (node_item_->IsMergeOp()) { - if (ctrl_scheduled_ != node_item_->GetMergeCtrl(loop_count_ == 0 ? 0 : 1) + node_item_->ctrl_recv_.size()) { + if (ctrl_scheduled_ != node_item_->GetMergeCtrl(iteration_count_ == 0 ? 0 : 1) + node_item_->ctrl_recv_.size()) { return false; } @@ -366,15 +404,13 @@ bool NodeState::IsScheduleReady() const { } void NodeState::SetDataSchedule(const NodeState &node_state, const std::function &ready) { - GELOGD("[%s] schedule [%s], loop[%lu -> %lu], data[num: %zu, scheduled: %u], ctrl[num: %zu+%zu, scheduled: %u]", - node_state.GetName().c_str(), GetName().c_str(), loop_count_, node_state.loop_count_, + GELOGD("[%s] schedule [%s], iteration[%lu -> %lu], data[num: %zu, scheduled: %u], ctrl[num: %zu+%zu, scheduled: %u]", + node_state.GetName().c_str(), GetName().c_str(), iteration_count_, node_state.iteration_count_, node_item_->data_recv_.size(), data_scheduled_, node_item_->ctrl_recv_.size(), - node_item_->GetMergeCtrl(loop_count_ == 0 ? 0 : 1), ctrl_scheduled_); + node_item_->GetMergeCtrl(iteration_count_ == 0 ? 0 : 1), ctrl_scheduled_); std::lock_guard lk(mu_); - if (loop_count_ != node_state.loop_count_) { - ResetContext(node_state.loop_count_); - } + ScheduleContext(node_state); ++data_scheduled_; if (node_item_->IsMergeOp()) { @@ -394,15 +430,13 @@ void NodeState::SetDataSchedule(const NodeState &node_state, const std::function } void NodeState::SetCtrlSchedule(const NodeState &node_state, const std::function &ready) { - GELOGD("[%s] schedule [%s], loop[%lu -> %lu], data[num: %zu, scheduled: %u], ctrl[num: %zu+%zu, scheduled: %u]", - node_state.GetName().c_str(), GetName().c_str(), loop_count_, node_state.loop_count_, + GELOGD("[%s] schedule [%s], iteration[%lu -> %lu], data[num: %zu, scheduled: %u], ctrl[num: %zu+%zu, scheduled: %u]", + node_state.GetName().c_str(), GetName().c_str(), iteration_count_, node_state.iteration_count_, node_item_->data_recv_.size(), data_scheduled_, node_item_->ctrl_recv_.size(), - node_item_->GetMergeCtrl(loop_count_ == 0 ? 0 : 1), ctrl_scheduled_); + node_item_->GetMergeCtrl(iteration_count_ == 0 ? 0 : 1), ctrl_scheduled_); std::lock_guard lk(mu_); - if (loop_count_ != node_state.loop_count_) { - ResetContext(node_state.loop_count_); - } + ScheduleContext(node_state); ++ctrl_scheduled_; if (IsScheduleReady()) { @@ -410,21 +444,28 @@ void NodeState::SetCtrlSchedule(const NodeState &node_state, const std::function } } -void NodeState::RunLoopNext() { - GELOGD("Node[%s] run in loop, current count: %lu", GetName().c_str(), loop_count_); +void NodeState::RunNextIteration() { std::lock_guard lk(mu_); - ++loop_count_; - if (loop_count_ == UINT64_MAX) { - loop_count_ = 1; - } - - ResetContext(loop_count_); + INC_ITERATION_COUNT(iteration_count_); + ResetContext(iteration_count_); } -void NodeState::RunLoopExit() { - GELOGD("Node[%s] run in loop, current count: %lu", GetName().c_str(), loop_count_); +void NodeState::RunStreamActive() { std::lock_guard lk(mu_); - loop_count_ = 0; + if (node_item_->ctrl_send_.empty()) { // Not for Loop Enter or Loop Next. + return; + } + switch_index_ = 0; + data_scheduled_ = 0; + ctrl_scheduled_ = 0; + if (node_item_->is_enter_active_) { + frame_state_->iteration_count_ = 0; + INC_ITERATION_COUNT(frame_state_->active_count_); + } else { + INC_ITERATION_COUNT(frame_state_->iteration_count_); + } + GELOGD("Node[%s] current iteration: %lu, frame active: %lu, frame iteration: %lu", + GetName().c_str(), iteration_count_, frame_state_->active_count_, frame_state_->iteration_count_); } void NodeState::SetScheduleFuture(std::future &&future) { diff --git a/ge/hybrid/executor/node_state.h b/ge/hybrid/executor/node_state.h index e4afdb9f..9dd29846 100644 --- a/ge/hybrid/executor/node_state.h +++ b/ge/hybrid/executor/node_state.h @@ -33,8 +33,10 @@ struct GraphExecutionContext; class SubgraphContext; class TaskContext; struct NodeState; +struct FrameState; using NodeStatePtr = std::shared_ptr; +using FrameStatePtr = std::shared_ptr; class ShapeFuture { public: @@ -80,6 +82,18 @@ struct ShapeInferenceState { std::mutex mu_; }; +struct FrameState { + public: + FrameState(int64_t id) : frame_id_(id) {} + ~FrameState() = default; + + int64_t frame_id_{0}; + uint64_t active_count_{0}; + uint64_t iteration_count_{0}; + + std::shared_ptr parent_frame_; +}; + // saving sth. dynamic during execution struct NodeState { public: @@ -112,8 +126,8 @@ struct NodeState { return node_item_->IsControlFlowOp() || node_item_->shape_inference_type >= DEPEND_SHAPE_RANGE; } - void RunLoopNext(); - void RunLoopExit(); + void RunStreamActive(); + void RunNextIteration(); Status NodeScheduled(const std::function &ready) const; @@ -144,6 +158,10 @@ struct NodeState { return group_; } + void SetFrameState(const shared_ptr &frame_state) { + frame_state_ = frame_state; + } + const shared_ptr &GetKernelTask() const { return kernel_task_; } @@ -167,7 +185,8 @@ struct NodeState { bool IsScheduleReady() const; void SetDataSchedule(const NodeState &node_state, const std::function &ready); void SetCtrlSchedule(const NodeState &node_state, const std::function &ready); - void ResetContext(uint64_t loop_count); + void ResetContext(uint64_t iteration); + void ScheduleContext(const NodeState &node_state); const NodeItem *node_item_ = nullptr; std::shared_ptr kernel_task_ = nullptr; @@ -179,7 +198,9 @@ struct NodeState { std::mutex mu_; std::future schedule_future_; - uint64_t loop_count_ = 0; + std::shared_ptr frame_state_; + uint64_t active_count_ = 0; + uint64_t iteration_count_ = 0; uint32_t ctrl_scheduled_ = 0; uint32_t data_scheduled_ = 0; int merge_index_ = -1; // Use for Execute (Reset after Executed). diff --git a/ge/hybrid/executor/subgraph_context.cc b/ge/hybrid/executor/subgraph_context.cc index afd8ca79..b6763ffd 100644 --- a/ge/hybrid/executor/subgraph_context.cc +++ b/ge/hybrid/executor/subgraph_context.cc @@ -89,6 +89,7 @@ NodeStatePtr SubgraphContext::GetOrCreateNodeState(const NodeItem *node_item) { if (node_state == nullptr) { const auto &guard = node_item->MutexGuard("GetOrCreateNodeState"); node_state.reset(new(std::nothrow)NodeState(*node_item, this)); + node_state->SetFrameState(GetOrCreateFrameState(*node_item)); node_state->SetGroup(group_); (void)guard; } @@ -102,6 +103,20 @@ NodeStatePtr SubgraphContext::GetOrCreateNodeState(const NodeItem *node_item) { return node_state; } +FrameStatePtr SubgraphContext::GetOrCreateFrameState(const NodeItem &node_item) { + auto &frame_state = frame_states_[node_item.frame_index_]; + if (frame_state == nullptr) { + GELOGD("[%s] Create FrameState, frame index: %ld, parent frame index: %ld", + node_item.node_name.c_str(), node_item.frame_index_, node_item.parent_frame_); + frame_state.reset(new(std::nothrow)FrameState(node_item.frame_index_)); + if (node_item.frame_index_ != -1) { // -1 is root frame. + frame_state->parent_frame_ = frame_states_[node_item.parent_frame_]; + } + } + + return frame_state; +} + Status SubgraphContext::SetInput(int index, const TensorValue &tensor) { if (static_cast(index) >= all_inputs_.size()) { GELOGE(INTERNAL_ERROR, diff --git a/ge/hybrid/executor/subgraph_context.h b/ge/hybrid/executor/subgraph_context.h index 303382c1..a43cd210 100644 --- a/ge/hybrid/executor/subgraph_context.h +++ b/ge/hybrid/executor/subgraph_context.h @@ -51,6 +51,7 @@ class SubgraphContext { void NodeDone(const NodePtr &node); private: + FrameStatePtr GetOrCreateFrameState(const NodeItem &node_item); // no lock friend class TaskContext; const GraphItem *graph_item_; const GraphExecutionContext *execution_context_; @@ -59,6 +60,7 @@ class SubgraphContext { std::vector all_outputs_; NodeDoneManager node_done_manager_; std::unordered_map node_states_; + std::unordered_map frame_states_; int group_ = -1; }; } // namespace hybrid diff --git a/ge/hybrid/executor/worker/execution_engine.cc b/ge/hybrid/executor/worker/execution_engine.cc index 32758f61..8eecbc80 100755 --- a/ge/hybrid/executor/worker/execution_engine.cc +++ b/ge/hybrid/executor/worker/execution_engine.cc @@ -428,7 +428,7 @@ Status ExecutionEngine::ValidateInputTensors(const NodeState &node_state, const } int64_t expected_size; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetTensorMemorySizeInBytes(*tensor_desc, expected_size)); + (void)TensorUtils::GetSize(*tensor_desc, expected_size); GELOGD("[%s] Input[%d] expects [%ld] bytes.", task_context.GetNodeName(), i, expected_size); auto size_diff = expected_size - static_cast(input_tensor->GetSize()); if (size_diff > 0) { diff --git a/ge/hybrid/model/hybrid_model_builder.cc b/ge/hybrid/model/hybrid_model_builder.cc index b00b8ec8..5337a0cf 100755 --- a/ge/hybrid/model/hybrid_model_builder.cc +++ b/ge/hybrid/model/hybrid_model_builder.cc @@ -1074,21 +1074,25 @@ Status HybridModelBuilder::InitVariableTensors() { GELOGE(INTERNAL_ERROR, "[Calculate][TensorMemSize] failed, node name:%s", it.first.c_str()); return INTERNAL_ERROR; } - SharedMemInfo mem_info(it.first, tensor_size); - if (HostMemManager::Instance().MallocSharedMemory(mem_info) != SUCCESS) { - GELOGE(GE_GRAPH_MALLOC_FAILED, "[Malloc][SharedMemory] failed, Host variable [%s].", it.first.c_str()); - return GE_GRAPH_MALLOC_FAILED; - } - if (MemManager::Instance().HostMemInstance(RT_MEMORY_HBM).Malloc(mem_info.host_aligned_ptr, - tensor_size) == nullptr) { - GELOGE(MEMALLOC_FAILED, "[Malloc][HostMem] for an existed GeTensor failed, Host variable [%s].", - it.first.c_str()); + + // Host variable will be assigned to allocated shared memory first. + SharedMemInfo mem_info; + void *mem_addr = nullptr; + if (HostMemManager::Instance().QueryVarMemInfo(it.first, mem_info)) { + mem_addr = const_cast(MemManager::Instance().HostMemInstance(RT_MEMORY_HBM) + .Malloc(mem_info.host_aligned_ptr, tensor_size)); + } else { + mem_addr = MemManager::Instance().HostMemInstance(RT_MEMORY_HBM).Malloc(tensor_size); + } + + if (mem_addr == nullptr) { + REPORT_INNER_ERROR("E19999", "[Malloc][HostMem] for variable [%s] failed.", it.first.c_str()); + GELOGE(MEMALLOC_FAILED, "[Malloc][HostMem] for variable [%s] failed.", it.first.c_str()); return MEMALLOC_FAILED; } GELOGD("Host variable [%s] malloc success, size=%ld.", it.first.c_str(), tensor_size); - std::unique_ptr tensor(new (std::nothrow) TensorValue(mem_info.host_aligned_ptr->MutableGet(), - tensor_size)); + std::unique_ptr tensor(new (std::nothrow) TensorValue(mem_addr, tensor_size)); GE_CHECK_NOTNULL(tensor); hybrid_model_.variable_tensors_.emplace(it.first, std::move(tensor)); } @@ -1278,7 +1282,8 @@ Status HybridModelBuilder::IndexTaskDefs(const ComputeGraphPtr &sub_graph, const } Status HybridModelBuilder::IndexTaskDefs() { - const auto &root_graph = ge_root_model_->GetRootGraph(); + const auto root_graph = ge_root_model_->GetRootGraph(); + const auto &root_graph_name = root_graph->GetName(); if (SetOutputNameAttr(*root_graph) != SUCCESS) { GELOGW("Set output name attr failed."); } @@ -1288,62 +1293,22 @@ Status HybridModelBuilder::IndexTaskDefs() { auto &ge_model = it.second; GE_CHECK_NOTNULL(ge_model); - const auto &sub_graph = root_graph->GetSubgraph(name); - if (sub_graph == nullptr) { - continue; - } - - bool is_unknown_shape = sub_graph->GetGraphUnknownFlag(); - if (!is_unknown_shape) { - GE_CHK_STATUS_RET_NOLOG(LoadGeModel(*sub_graph, ge_model)); - continue; - } - - // index task defs - GELOGD("To index tasks for subgraph: %s", name.c_str()); - std::unordered_map node_map; - for (const auto &node : sub_graph->GetDirectNode()) { - GE_CHECK_NOTNULL(node); - GE_CHECK_NOTNULL(node->GetOpDesc()); - auto node_id = node->GetOpDesc()->GetId(); - GELOGD("op_index = %ld, node_name = %s", node_id, node->GetName().c_str()); - node_map.emplace(node_id, node); - } - - auto tasks = ge_model->GetModelTaskDefPtr()->task(); - for (int i = 0; i < tasks.size(); ++i) { - const domi::TaskDef &task_def = tasks[i]; - GELOGI("Task id = %d, task type = %d", i, task_def.type()); - auto task_type = static_cast(task_def.type()); - uint32_t op_index = -1; - if (task_type == RT_MODEL_TASK_KERNEL) { - op_index = task_def.kernel().context().op_index(); - } else if (task_type == RT_MODEL_TASK_KERNEL_EX) { - op_index = task_def.kernel_ex().op_index(); - } else if (task_type == RT_MODEL_TASK_HCCL) { - op_index = task_def.kernel_hccl().op_index(); - } else if (task_type == RT_MODEL_TASK_ALL_KERNEL) { - op_index = task_def.kernel_with_handle().context().op_index(); - } else { - GELOGD("Skip task type: %d", static_cast(task_type)); + auto sub_graph = root_graph->GetSubgraph(name); + if (name != root_graph_name) { + if (sub_graph == nullptr) { continue; } - auto iter = node_map.find(op_index); - if (iter == node_map.end()) { - GELOGE(INTERNAL_ERROR, "[Find][Node]Failed to get node by index = %u.", op_index); - REPORT_INNER_ERROR("E19999", "Failed to get node by index = %u.", op_index); - return INTERNAL_ERROR; - } - - auto &node = iter->second; - if (task_type == RT_MODEL_TASK_KERNEL || task_type == RT_MODEL_TASK_ALL_KERNEL) { - ge_model->GetTBEKernelStore().LoadTBEKernelBinToOpDesc(node->GetOpDesc()); + bool is_unknown_shape = sub_graph->GetGraphUnknownFlag(); + if (!is_unknown_shape) { + GE_CHK_STATUS_RET_NOLOG(LoadGeModel(*sub_graph, ge_model)); + continue; } - - GELOGD("Task loaded for node: %s, task type = %d, op_index = %u", node->GetName().c_str(), task_type, op_index); - hybrid_model_.task_defs_[node].emplace_back(task_def); + } else { + sub_graph = root_graph; } + + GE_CHK_STATUS_RET_NOLOG(IndexTaskDefs(sub_graph, ge_model)); } return SUCCESS; @@ -1980,6 +1945,7 @@ Status HybridModelBuilder::LoadDynamicSubgraph(ComputeGraph &graph, bool is_root GE_CHK_STATUS_RET_NOLOG(BuildNodeItem(node, *node_item)); GE_CHK_STATUS_RET_NOLOG(UpdateAnchorStatus(node)); // needed by FE generate task + GE_CHK_STATUS_RET_NOLOG(BuildFrameGroupIndex(*node_item)); GE_CHK_STATUS_RET_NOLOG(BuildControlFlowGroup(*graph_item, node, node_item)); if (node->GetInAllNodes().empty()) { graph_item->root_items_.emplace_back(node_item); @@ -2343,6 +2309,62 @@ Status HybridModelBuilder::BuildProfilingControl(GraphItem &graph_item, return SUCCESS; } +Status HybridModelBuilder::BuildFrameGroupIndex(NodeItem &node_item) { + if (node_item.is_root_node_) { + GELOGD("[%s] control flow frame group: %ld, parent frame: %ld", + node_item.node_name.c_str(), node_item.frame_index_, node_item.parent_frame_); + return SUCCESS; + } + + int64_t ctrl_flow_group = -1; + if (node_item.IsEnterOp() && AttrUtils::GetInt(node_item.op_desc, ATTR_NAME_CONTROL_FLOW_GROUP, ctrl_flow_group)) { + node_item.frame_index_ = ctrl_flow_group; + for (const auto src_node : node_item.node->GetInAllNodes()) { + NodeItem *src_node_item = nullptr; + GE_CHK_STATUS_RET(GetOrCreateNodeItem(src_node, &src_node_item), + "[%s] failed to get or create node item", src_node->GetName().c_str()); + if (!src_node_item->is_root_node_) { + GELOGD("[%s] frame index: %ld, [%s] parent frame index: %ld", node_item.node_name.c_str(), + node_item.frame_index_, src_node_item->node_name.c_str(), src_node_item->frame_index_); + parent_frame_group_[node_item.frame_index_] = src_node_item->frame_index_; + break; + } + } + + const auto it = parent_frame_group_.find(node_item.frame_index_); + node_item.parent_frame_ = (it != parent_frame_group_.end()) ? it->second : -1; + GELOGD("[%s] control flow frame group: %ld, parent frame: %ld", + node_item.node_name.c_str(), node_item.frame_index_, node_item.parent_frame_); + return SUCCESS; + } + + for (const auto src_node : node_item.node->GetInAllNodes()) { + NodeItem *src_node_item = nullptr; + GE_CHK_STATUS_RET(GetOrCreateNodeItem(src_node, &src_node_item), + "[%s] failed to get or create node item", src_node->GetName().c_str()); + if (src_node_item->is_root_node_) { + continue; + } + + if (src_node_item->IsExitOp()) { + const auto it = parent_frame_group_.find(src_node_item->frame_index_); + node_item.frame_index_ = (it != parent_frame_group_.end()) ? it->second : -1; + } else { + node_item.frame_index_ = src_node_item->frame_index_; + } + + const auto it = parent_frame_group_.find(node_item.frame_index_); + node_item.parent_frame_ = (it != parent_frame_group_.end()) ? it->second : -1; + GELOGD("[%s] control flow frame group: %ld, parent frame: %ld", + node_item.node_name.c_str(), node_item.frame_index_, node_item.parent_frame_); + return SUCCESS; + } + + GELOGD("[%s] control flow frame group: %ld, parent frame: %ld", + node_item.node_name.c_str(), node_item.frame_index_, node_item.parent_frame_); + return SUCCESS; +} + Status HybridModelBuilder::BuildControlFlowGroup(GraphItem &graph_item, const NodePtr &node, NodeItem *node_item) { GELOGD("Build control flow for node %s", node->GetName().c_str()); using GroupBuilder = std::function; @@ -2462,6 +2484,7 @@ Status HybridModelBuilder::CreateStreamActiveGroup(const NodePtr &node, NodeItem if (std::any_of(ctrl_nodes.begin(), ctrl_nodes.end(), IsEnterNode)) { // Enter --> StreamActive --> StreamMerge + node_item->is_enter_active_ = true; return CreateMergeEnterGroup(node, node_item); } else if (std::any_of(ctrl_nodes.begin(), ctrl_nodes.end(), IsIterationNode)) { // NextIteration --> StreamActive {-->} StreamMerge diff --git a/ge/hybrid/model/hybrid_model_builder.h b/ge/hybrid/model/hybrid_model_builder.h index d0ee54ed..92974441 100644 --- a/ge/hybrid/model/hybrid_model_builder.h +++ b/ge/hybrid/model/hybrid_model_builder.h @@ -97,6 +97,7 @@ class HybridModelBuilder { Status RelinkNextIteration(); Status BuildProfilingControl(GraphItem &graph_item, const std::map> &nodes); + Status BuildFrameGroupIndex(NodeItem &node_item); Status BuildControlFlowGroup(GraphItem &graph_item, const NodePtr &node, NodeItem *node_item); Status CreateNormalNodeGroup(const NodePtr &node, NodeItem *node_item); Status CreateMergeEnterGroup(const NodePtr &node, NodeItem *node_item); @@ -123,6 +124,7 @@ class HybridModelBuilder { std::map constant_op_nodes_; std::map stream_merge_op_nodes_; std::map next_iteration_op_nodes_; + std::map parent_frame_group_; std::map> parallel_group_to_nodes_; std::map> node_to_parallel_groups_; diff --git a/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc index 7054fd46..b339e630 100644 --- a/ge/hybrid/model/node_item.cc +++ b/ge/hybrid/model/node_item.cc @@ -20,7 +20,6 @@ #include "graph/common/omg_util.h" #include "graph/compute_graph.h" #include "graph/debug/ge_attr_define.h" -#include "graph/utils/node_utils.h" #include "hybrid/executor/worker/shape_inference_engine.h" #include "hybrid/node_executor/node_executor.h" @@ -34,7 +33,7 @@ const std::set kControlOpTypes{ }; const std::set kControlFlowOpTypes{ - STREAMACTIVE, STREAMSWITCH, STREAMSWITCHN, NEXTITERATION, REFNEXTITERATION, EXIT, REFEXIT, + STREAMACTIVE, STREAMSWITCH, STREAMSWITCHN, ENTER, REFENTER, NEXTITERATION, REFNEXTITERATION, EXIT, REFEXIT, LABELGOTO, LABELGOTOEX, LABELSWITCH, LABELSWITCHBYINDEX }; @@ -402,8 +401,8 @@ void NodeItem::SetDataSend(NodeItem *node_item, int anchor_index) { node_item->root_data_.emplace(this); } // If Enter feed Not Merge, take as root Node. - if ((kEnterOpTypes.count(node_type) > 0) && (node_item->node_type != STREAMMERGE)) { - node_item->root_data_.emplace(this); + if (IsEnterOp() && (node_item->node_type != STREAMMERGE)) { + node_item->enter_data_.emplace(this); node_item->enter_inside_.emplace(anchor_index); } GELOGI("Node[%s] will control node[%s]", NodeName().c_str(), node_item->NodeName().c_str()); @@ -422,8 +421,8 @@ void NodeItem::SetCtrlSend(NodeItem *node_item, uint32_t switch_index) { node_item->root_ctrl_.emplace(this); } // If Enter feed control signal, take as root Node. - if (kEnterOpTypes.count(node_type) > 0) { - node_item->root_ctrl_.emplace(this); + if (IsEnterOp() && (node_item->node_type != STREAMMERGE && node_item->node_type != STREAMACTIVE)) { + node_item->enter_ctrl_.emplace(this); } GELOGI("Node[%s] will control node[%s]", NodeName().c_str(), node_item->NodeName().c_str()); } diff --git a/ge/hybrid/model/node_item.h b/ge/hybrid/model/node_item.h index 67f92868..8de15952 100644 --- a/ge/hybrid/model/node_item.h +++ b/ge/hybrid/model/node_item.h @@ -22,6 +22,7 @@ #include "external/ge/ge_api_error_codes.h" #include "graph/node.h" #include "graph/op_desc.h" +#include "graph/utils/node_utils.h" #include "framework/common/types.h" #include "hybrid/common/tensor_value.h" @@ -92,6 +93,14 @@ struct NodeItem { return is_merge_op_; } + bool IsEnterOp() const { + return kEnterOpTypes.count(node_type) > 0; + } + + bool IsExitOp() const { + return kExitOpTypes.count(node_type) > 0; + } + bool IsHcclOp() const; void SetToDynamic(); @@ -135,8 +144,13 @@ struct NodeItem { bool is_ctrl_flow_v2_op_ = false; bool is_ctrl_flow_op_ = false; bool is_merge_op_ = false; + bool is_enter_active_ = false; + int64_t frame_index_ = -1; + int64_t parent_frame_ = -1; std::set root_ctrl_; // Recv ctrl from root node std::set root_data_; // Recv data from root node + std::set enter_ctrl_; // Recv ctrl from Enter node + std::set enter_data_; // Recv data from Enter node std::set data_send_; // Send data notify to std::map data_recv_; // Recv data notify from std::set ctrl_send_; // Send ctrl notify to diff --git a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h index 19fb5ec7..7577d486 100644 --- a/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h +++ b/ge/hybrid/node_executor/aicpu/aicpu_node_executor.h @@ -166,7 +166,7 @@ class AicpuNodeTask : public AicpuNodeTaskBase { Status UpdateIoAddr(TaskContext &context) override; - private: + protected: // host mem std::unique_ptr args_; diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc index c46d5080..72092cd8 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.cc +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.cc @@ -20,11 +20,10 @@ #include "graph/attr_value.h" #include "graph/debug/ge_attr_define.h" #include "graph/manager/util/hcom_util.h" -#include "graph/runtime_inference_context.h" #include "graph/utils/type_utils.h" #include "graph/types.h" -#include "hccl/hcom.h" #include "hybrid/executor/hybrid_execution_context.h" +#include "hccl/hcom.h" namespace ge { namespace { @@ -32,9 +31,14 @@ constexpr size_t kVarTableDims = 2; constexpr size_t kVarTableRowCnt = 3; constexpr size_t kVarTableIdxAddr = 1; constexpr size_t kVarTableIdxLen = 2; +// input anchor nums according to IR +constexpr size_t kAllToAllVInputNums = 5; +constexpr size_t kGatherAllToAllVInputNums = 4; + const std::set kRdmaReadTypes = { HCOMREMOTEREAD, HCOMREMOTEREFREAD }; const std::set kRdmaWriteTypes = { HCOMREMOTEWRITE, HCOMREMOTESCATTERWRITE }; const std::set kRdmaScatterTypes = { HCOMREMOTEREFREAD, HCOMREMOTESCATTERWRITE }; +const std::set kAllToAllTypes = {HCOMALLTOALLV, HCOMGATHERALLTOALLV}; } // namespace namespace hybrid { @@ -95,8 +99,8 @@ Status HcclNodeTask::ExecuteAsync(TaskContext &context, std::function do } op_info.dataType = iter->second; HcclReduceOp op_type = HCCL_REDUCE_SUM; - if (op_desc->GetType() == HCOMALLREDUCE || op_desc->GetType() == HCOMREDUCESCATTER || - op_desc->GetType() == HVDCALLBACKALLREDUCE || op_desc->GetType() == HCOMREDUCE) { + std::set hccl_types = { HCOMALLREDUCE, HCOMREDUCESCATTER, HVDCALLBACKALLREDUCE, HCOMREDUCE }; + if (hccl_types.count(op_desc->GetType()) > 0) { GE_CHK_STATUS_RET(HcomOmeUtil::GetHcclOperationType(op_desc, op_type), "[Get][HcclOperationType] failed for %s type:%s", op_desc->GetName().c_str(), op_desc->GetType().c_str()); @@ -177,69 +181,15 @@ Status RdmaNodeTask::Init(TaskContext &context) { return SUCCESS; } -Status RdmaNodeTask::ExtractTensor(TaskContext &context, vector &addr_infos) { - RuntimeInferenceContext *ctx = nullptr; - GE_CHK_STATUS_RET( - RuntimeInferenceContext::GetContext(std::to_string(context.GetExecutionContext()->context_id), &ctx)); - - ge::Tensor remote_tensor; - GE_CHK_STATUS_RET(ctx->GetTensor(remote_index_.first, remote_index_.second, remote_tensor)); - auto data = reinterpret_cast(remote_tensor.GetData()); - if (data == nullptr) { - if (kRdmaScatterTypes.count(context.GetNodeItem().NodeType()) > 0) { - GELOGD("data is null, no need to do rdma read/write, node=%s", context.GetNodeName()); - return SUCCESS; - } else { - REPORT_INNER_ERROR("E19999", "Tensor data is nullptr. and kRdmaScatterTypes not contain %s", - context.GetNodeItem().NodeType().c_str()); - GELOGE(FAILED, "[Find][NodeType]Tensor data is nullptr. and kRdmaScatterTypes not contain %s", - context.GetNodeItem().NodeType().c_str()); - return FAILED; - } - } - auto dims = remote_tensor.GetTensorDesc().GetShape().GetDims(); - if (dims.size() != kVarTableDims && dims.back() != kVarTableRowCnt) { - REPORT_INNER_ERROR("E19999", "Variable table shape check failed, number of shape dims:%zu not equal expect:%zu" - "and shape dims back:%zu not equal expect:%zu, node:%s(%s)", - dims.size(), kVarTableDims, dims.back(), kVarTableRowCnt, - context.GetNodeName(), context.GetNodeItem().NodeType().c_str()); - GELOGE(PARAM_INVALID, "[Check][Param]Variable table shape check failed," - "number of shape dims:%zu not equal expect:%zu and shape dims back:%zu not equal expect:%zu, node:%s(%s)", - dims.size(), kVarTableDims, dims.back(), kVarTableRowCnt, - context.GetNodeName(), context.GetNodeItem().NodeType().c_str()); - return PARAM_INVALID; - } - - if (context.GetNodeItem().NodeType() == HCOMREMOTEREAD) { - size_t remote_size = 0; - for (auto idx = 0; idx < dims.front(); ++idx) { - FMK_INT64_MULCHECK(idx, kVarTableRowCnt); - auto line_idx = idx * kVarTableRowCnt; - remote_size += data[line_idx + kVarTableIdxLen]; - } - auto allocator = NpuMemoryAllocator::GetAllocator(); - GE_CHECK_NOTNULL(allocator); - AllocationAttr attr; - attr.SetMemType(RDMA_HBM); - for (auto i = 0; i < context.NumOutputs(); ++i) { - GELOGD("Allocate rdma memory for node %s, size: %zu", context.GetNodeName(), remote_size); - auto tensor_buffer = TensorBuffer::Create(allocator, remote_size, &attr); - GE_CHK_STATUS_RET(context.SetOutput(i, TensorValue(std::shared_ptr(tensor_buffer.release())))); - } - } else if (context.GetNodeItem().NodeType() == HCOMREMOTEREFREAD) { - AllocationAttr attr; - attr.SetMemType(RDMA_HBM); - GE_CHK_STATUS_RET(context.AllocateOutputs(&attr)) - } - - TensorValue *tv; +Status RdmaNodeTask::SetAddrInfo(TaskContext &context, RuntimeInferenceContext *ctx, uint64_t *data, int64_t row_num, + vector &addr_infos) { + TensorValue *tv = nullptr; if (kRdmaReadTypes.count(context.GetNodeItem().NodeType()) > 0) { tv = context.MutableOutput(local_index_); } else { tv = context.MutableInput(local_index_); } GE_CHECK_NOTNULL(tv); - auto row_num = dims.front(); addr_infos.resize(row_num); if (skip_flag_) { int32_t offset_idx = context.GetNodeItem().op_desc->GetInputIndexByName("local_offset"); @@ -294,6 +244,65 @@ Status RdmaNodeTask::ExtractTensor(TaskContext &context, vector &addr_infos) { + RuntimeInferenceContext *ctx = nullptr; + GE_CHK_STATUS_RET( + RuntimeInferenceContext::GetContext(std::to_string(context.GetExecutionContext()->context_id), &ctx)); + + ge::Tensor remote_tensor; + GE_CHK_STATUS_RET(ctx->GetTensor(remote_index_.first, remote_index_.second, remote_tensor)); + auto data = reinterpret_cast(remote_tensor.GetData()); + if (data == nullptr) { + if (kRdmaScatterTypes.count(context.GetNodeItem().NodeType()) > 0) { + GELOGD("data is null, no need to do rdma read/write, node=%s", context.GetNodeName()); + return SUCCESS; + } else { + REPORT_INNER_ERROR("E19999", "Tensor data is nullptr. and kRdmaScatterTypes not contain %s", + context.GetNodeItem().NodeType().c_str()); + GELOGE(FAILED, "[Find][NodeType]Tensor data is nullptr. and kRdmaScatterTypes not contain %s", + context.GetNodeItem().NodeType().c_str()); + return FAILED; + } + } + auto dims = remote_tensor.GetTensorDesc().GetShape().GetDims(); + if (dims.size() != kVarTableDims && dims.back() != kVarTableRowCnt) { + REPORT_INNER_ERROR("E19999", "Variable table shape check failed, number of shape dims:%zu not equal expect:%zu" + "and shape dims back:%zu not equal expect:%zu, node:%s(%s)", + dims.size(), kVarTableDims, dims.back(), kVarTableRowCnt, + context.GetNodeName(), context.GetNodeItem().NodeType().c_str()); + GELOGE(PARAM_INVALID, "[Check][Param]Variable table shape check failed," + "number of shape dims:%zu not equal expect:%zu and shape dims back:%zu not equal expect:%zu, node:%s(%s)", + dims.size(), kVarTableDims, dims.back(), kVarTableRowCnt, + context.GetNodeName(), context.GetNodeItem().NodeType().c_str()); + return PARAM_INVALID; + } + + if (context.GetNodeItem().NodeType() == HCOMREMOTEREAD) { + size_t remote_size = 0; + for (auto idx = 0; idx < dims.front(); ++idx) { + FMK_INT64_MULCHECK(idx, kVarTableRowCnt); + auto line_idx = idx * kVarTableRowCnt; + remote_size += data[line_idx + kVarTableIdxLen]; + } + auto allocator = NpuMemoryAllocator::GetAllocator(); + GE_CHECK_NOTNULL(allocator); + AllocationAttr attr; + attr.SetMemType(RDMA_HBM); + for (auto i = 0; i < context.NumOutputs(); ++i) { + GELOGD("Allocate rdma memory for node %s, size: %zu", context.GetNodeName(), remote_size); + auto tensor_buffer = TensorBuffer::Create(allocator, remote_size, &attr); + GE_CHK_STATUS_RET(context.SetOutput(i, TensorValue(std::shared_ptr(tensor_buffer.release())))); + } + } else if (context.GetNodeItem().NodeType() == HCOMREMOTEREFREAD) { + AllocationAttr attr; + attr.SetMemType(RDMA_HBM); + GE_CHK_STATUS_RET(context.AllocateOutputs(&attr)) + } + + auto row_num = dims.front(); + return SetAddrInfo(context, ctx, data, row_num, addr_infos); +} + Status RdmaNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { GELOGI("[%s] RdmaNodeTask::ExecuteAsync in.", context.GetNodeName()); auto HcomExecEnqueueRemoteAccess = @@ -345,6 +354,121 @@ Status RdmaNodeTask::ExecuteAsync(TaskContext &context, std::function do return SUCCESS; } +Status BuildAllToAllVparams(TaskContext &context, HcomAllToAllVParams ¶ms) { + void **input_addrs[kAllToAllVInputNums] = {¶ms.sendbuf, ¶ms.sendcounts, ¶ms.sdispls, + ¶ms.recvcounts, ¶ms.rdispls}; + for (size_t i = 0; i < kAllToAllVInputNums; ++i) { + auto addr = context.MutableInput(i); + GE_CHECK_NOTNULL(addr); + *input_addrs[i] = addr->MutableData(); + } + auto recv_tv = context.MutableOutput(0); + GE_CHECK_NOTNULL(recv_tv); + params.recvbuf = recv_tv->MutableData(); + + const NodeItem &node_item = context.GetNodeItem(); + const OpDescPtr op_desc = node_item.GetOpDesc(); + auto input_desc = node_item.MutableInputDesc(0); + GE_CHECK_NOTNULL(input_desc); + ge::DataType src_data_type = input_desc->GetDataType(); + auto iter = kConstOpHcclDataType.find(static_cast(src_data_type)); + if (iter == kConstOpHcclDataType.end()) { + REPORT_INNER_ERROR("E19999", "%s alltoallv datatype:%s not support.", op_desc->GetName().c_str(), + TypeUtils::DataTypeToSerialString(src_data_type).c_str()); + GELOGE(PARAM_INVALID, "[Find][DataType]%s alltoallv datatype:%s not support.", op_desc->GetName().c_str(), + TypeUtils::DataTypeToSerialString(src_data_type).c_str()); + return PARAM_INVALID; + } + params.sendtype = iter->second; + params.recvtype = iter->second; + + return SUCCESS; +} + +Status BuildGatherAllToAllParams(TaskContext &context, HcomGatherAllToAllVParams ¶ms) { + void **input_addrs[kGatherAllToAllVInputNums] = {¶ms.addrInfo, ¶ms.addrInfoCountPerRank, + ¶ms.recvcounts, ¶ms.rdispls}; + for (size_t i = 0; i < kGatherAllToAllVInputNums; ++i) { + auto addr = context.MutableInput(i); + GE_CHECK_NOTNULL(addr); + *input_addrs[i] = addr->MutableData(); + } + auto recv_tv = context.MutableOutput(0); + GE_CHECK_NOTNULL(recv_tv); + params.recvbuf = recv_tv->MutableData(); + auto gathered_tv = context.MutableOutput(1); + GE_CHECK_NOTNULL(gathered_tv); + params.gatheredbuf = gathered_tv->MutableData(); + + const NodeItem &node_item = context.GetNodeItem(); + const OpDescPtr op_desc = node_item.GetOpDesc(); + + ge::DataType data_type = ge::DT_FLOAT; + (void)ge::AttrUtils::GetDataType(op_desc, HCOM_ATTR_DATA_TYPE, data_type); + auto iter = kConstOpHcclDataType.find(static_cast(data_type)); + if (iter == kConstOpHcclDataType.end()) { + REPORT_INNER_ERROR("E19999", "%s received datatype:%s not support.", op_desc->GetName().c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGE(PARAM_INVALID, "[Find][DataType]%s received datatype:%s not support.", op_desc->GetName().c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + return PARAM_INVALID; + } + params.recvtype = iter->second; + + int64_t addr_len; + (void) ge::AttrUtils::GetInt(op_desc, "addr_length", addr_len); + params.addrLength = static_cast(addr_len); + + return SUCCESS; +} + +Status AllToAllNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { + GELOGI("[%s] AllToAllNodeTask::ExecuteAsync in.", context.GetNodeName()); + + TaskContext *p_ctx = &context; + auto callback = [p_ctx, done_callback](HcclResult status){ + if (status != HCCL_SUCCESS) { + GELOGE(HCCL_E_INTERNAL, "[%s] AllToAllNodeTask execute failed.", p_ctx->GetNodeName()); + p_ctx->SetStatus(FAILED); + } + done_callback(); + GELOGI("[%s] AllToAllNodeTask callback successfully.", p_ctx->GetNodeName()); + }; + + if (context.GetNodeItem().NodeType() == HCOMALLTOALLV) { + auto HcomExecEnqueueAllToAllV = (HcclResult(*)(HcomAllToAllVParams, std::function))dlsym( + context.handle_, "HcomExecEnqueueAllToAllV"); + if (HcomExecEnqueueAllToAllV == nullptr) { + GELOGE(FAILED, "Failed to invoke function [HcomExecEnqueueAllToAllV] for node:%s.",context.GetNodeName()); + return FAILED; + } + HcomAllToAllVParams params; + GE_CHK_STATUS_RET(BuildAllToAllVparams(context, params)); + HcclResult hccl_ret = HcomExecEnqueueAllToAllV(params, callback); + if (hccl_ret != HCCL_SUCCESS) { + GELOGE(HCCL_E_INTERNAL, "AllToAllV teak enqueue failed for node [%s].", context.GetNodeName()); + return HCCL_E_INTERNAL; + } + } else { + auto HcomExecEnqueueGatherAllToAllV = + (HcclResult(*)(HcomGatherAllToAllVParams, std::function))dlsym( + context.handle_, "HcomExecEnqueueGatherAllToAllV"); + if (HcomExecEnqueueGatherAllToAllV == nullptr) { + GELOGE(FAILED, "Failed to invoke function [HcomExecEnqueueGatherAllToAllV] for node:%s.", context.GetNodeName()); + return FAILED; + } + HcomGatherAllToAllVParams params; + GE_CHK_STATUS_RET(BuildGatherAllToAllParams(context, params)); + HcclResult hccl_ret = HcomExecEnqueueGatherAllToAllV(params, callback); + if (hccl_ret != HCCL_SUCCESS) { + GELOGE(HCCL_E_INTERNAL, "GatherAllToAllV teak enqueue failed for node [%s].", context.GetNodeName()); + return HCCL_E_INTERNAL; + } + } + GELOGI("[%s] AllToAllNodeTask::ExecuteAsync success.", context.GetNodeName()); + return SUCCESS; +} + Status HcclNodeTask::UpdateArgs(TaskContext &context) { return SUCCESS; } Status HcclNodeTask::Init(TaskContext &context) { @@ -375,6 +499,8 @@ Status HcclNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, GE_CHECK_NOTNULL(node); if ((kRdmaReadTypes.count(node->GetType()) > 0) || (kRdmaWriteTypes.count(node->GetType()) > 0)) { task = MakeShared(); + } else if (kAllToAllTypes.count(node->GetType()) > 0) { + task = MakeShared(); } else { task = MakeShared(); } diff --git a/ge/hybrid/node_executor/hccl/hccl_node_executor.h b/ge/hybrid/node_executor/hccl/hccl_node_executor.h index 873f259f..b020208d 100644 --- a/ge/hybrid/node_executor/hccl/hccl_node_executor.h +++ b/ge/hybrid/node_executor/hccl/hccl_node_executor.h @@ -18,6 +18,7 @@ #define HYBRID_HCCL_NODE_EXECUTOR_H_ #include "common/opskernel/ge_task_info.h" #include "graph/op_desc.h" +#include "graph/runtime_inference_context.h" #include "hybrid/model/hybrid_model.h" #include "hybrid/node_executor/node_executor.h" @@ -53,6 +54,8 @@ class RdmaNodeTask : public NodeTask { Status Init(TaskContext &context) override; private: + Status SetAddrInfo(TaskContext &context, RuntimeInferenceContext *ctx, uint64_t *data, int64_t row_num, + vector &addr_infos); Status ExtractTensor(TaskContext &context, vector &addr_infos); std::pair remote_index_; std::pair offset_index_; @@ -62,6 +65,22 @@ class RdmaNodeTask : public NodeTask { bool skip_flag_; }; + +class AllToAllNodeTask : public NodeTask { + public: + AllToAllNodeTask() = default; + + ~AllToAllNodeTask() = default; + + Status UpdateArgs(TaskContext &context) override { return SUCCESS; } + Status ExecuteAsync(TaskContext &context, std::function done_callback) override; + Status Init(TaskContext &context) override { return SUCCESS; } + + private: + std::mutex hccl_mutex_; + std::condition_variable cond_; +}; + class HcclNodeExecutor : public NodeExecutor { public: Status LoadTask(const HybridModel &model, const NodePtr &node, shared_ptr &task) const; diff --git a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc index d35989a1..7e93c1c6 100755 --- a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc +++ b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc @@ -15,60 +15,38 @@ */ #include "hybrid/node_executor/host_cpu/host_cpu_node_executor.h" -#include "hybrid/node_executor/host_cpu/kernel_factory.h" #include "graph/passes/folding_pass.h" #include "hybrid/model/hybrid_model.h" #include "graph/manager/graph_mem_manager.h" #include "ge_local_engine/engine/host_cpu_engine.h" +#include "aicpu/common/aicpu_task_struct.h" namespace ge { namespace hybrid { REGISTER_NODE_EXECUTOR_BUILDER(NodeExecutorManager::ExecutorType::HOST_CPU, HostCpuNodeExecutor); -Status HostNodeTaskBase::UpdateArgs(TaskContext &) { - // no need update args - return SUCCESS; -} - -Status HostNodeTaskBase::ExecuteAsync(TaskContext &context, std::function done_callback) { - GELOGD("[%s] Start execute.", context.GetNodeName()); - GE_CHK_STATUS_RET(Execute(context), "[Invoke][Execute] failed for node:%s type:%s.", - node_->GetName().c_str(), node_->GetType().c_str()) - if (done_callback) { - GELOGD("[%s] Start invoke callback.", context.GetNodeName()); - done_callback(); +Status HostAicpuNodeTask::UpdateArgs(TaskContext &context) { + if (context.NumInputs() == 0 && context.NumOutputs() == 0) { + GELOGD("Node[%s] has no input and output, no need to update args.", node_name_.c_str()); + return SUCCESS; } - GELOGD("[%s] Done execute successfully.", context.GetNodeName()); - return SUCCESS; -} -Status CpuKernelNodeTask::Execute(TaskContext &context) { - const auto &op_desc = node_->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - - std::vector inputs; + vector io_addrs; + io_addrs.reserve(context.NumInputs() + context.NumOutputs()); for (int32_t i = 0; i < context.NumInputs(); ++i) { - auto input_desc_ptr = context.GetInputDesc(i); - GE_CHECK_NOTNULL(input_desc_ptr); - const auto &input_desc = *input_desc_ptr; auto tensor = context.GetInput(i); GE_CHECK_NOTNULL(tensor); auto item = MemManager::Instance().HostMemInstance(RT_MEMORY_HBM).GetAlignedPtr(tensor->GetData()); GE_CHECK_NOTNULL(item.second); - auto in_tensor = MakeShared(input_desc, item.second, item.first); - GE_CHECK_NOTNULL(in_tensor); - in_tensor->MutableTensorDesc().SetDataType(input_desc.GetDataType()); - in_tensor->MutableTensorDesc().SetShape(input_desc.GetShape()); - inputs.emplace_back(in_tensor); - GELOGD("node:%s allocate input %d, size=%zu", op_desc->GetName().c_str(), i, in_tensor->GetData().size()); + io_addrs.emplace_back(reinterpret_cast(item.second->MutableGet())); } - std::vector outputs; for (int32_t i = 0; i < context.NumOutputs(); ++i) { - const auto &output_desc = op_desc->GetOutputDesc(i); + const auto &output_desc = context.GetOutputDesc(i); + GE_CHECK_NOTNULL(output_desc); AllocationAttr attr; attr.SetMemType(HOST_DDR); - if (context.AllocateOutput(i, output_desc, nullptr, &attr) != SUCCESS) { + if (context.AllocateOutput(i, *output_desc, nullptr, &attr) != SUCCESS) { REPORT_CALL_ERROR("E19999", "node:%s Failed to allocate output %d", context.GetNodeName(), i); GELOGE(FAILED, "[Invoke][AllocateOutput]node:%s Failed to allocate output %d", context.GetNodeName(), i); return FAILED; @@ -77,37 +55,61 @@ Status CpuKernelNodeTask::Execute(TaskContext &context) { GE_CHECK_NOTNULL(tensor); auto item = MemManager::Instance().HostMemInstance(RT_MEMORY_HBM).GetAlignedPtr(tensor->GetData()); GE_CHECK_NOTNULL(item.second); - auto out_tensor = MakeShared(output_desc, item.second, item.first); - GE_CHECK_NOTNULL(out_tensor); - out_tensor->MutableTensorDesc().SetDataType(output_desc.GetDataType()); - out_tensor->MutableTensorDesc().SetShape(output_desc.GetShape()); - outputs.emplace_back(out_tensor); - GELOGD("node:%s allocate output %d, size=%zu", op_desc->GetName().c_str(), i, out_tensor->GetData().size()); + io_addrs.emplace_back(reinterpret_cast(item.second->MutableGet())); } + auto io_addr = args_.get() + sizeof(aicpu::AicpuParamHead); - return HostCpuEngine::GetInstance().Run(node_, inputs, outputs); + // if has input and output, need copy to ioaddr + int cpy_ret = memcpy_s(io_addr, args_size_ - sizeof(aicpu::AicpuParamHead), + &io_addrs[0], sizeof(uint64_t) * io_addrs.size()); + if (cpy_ret != EOK) { + REPORT_INNER_ERROR("E19999", "Node[%s] memcpy io addr to AicpuParamHead failed," + "ret=%d, args_size=%u, io nums=%zu.", + node_name_.c_str(), cpy_ret, args_size_, io_addrs.size()); + GELOGE(INTERNAL_ERROR, "[Update][io_addr]Node[%s] memcpy io addr to AicpuParamHead failed," + "ret=%d, args_size=%u, io nums=%zu.", + node_name_.c_str(), cpy_ret, args_size_, io_addrs.size()); + return INTERNAL_ERROR; + } + return SUCCESS; } -Status HostCpuNodeTask::Execute(TaskContext &context) { - RunContext run_context; - auto host_kernel = hybrid::host_cpu::KernelFactory::Instance().CreateKernel(node_); - if (host_kernel == nullptr) { - REPORT_CALL_ERROR("E19999", "CreateKernel failed for node %s type %s is not supported by host kernel.", - node_->GetName().c_str(), node_->GetType().c_str()); - GELOGE(UNSUPPORTED, "[Create][Kernel]node %s type %s is not supported by host kernel.", - node_->GetName().c_str(), node_->GetType().c_str()); - return UNSUPPORTED; +Status HostAicpuNodeTask::ExecuteAsync(TaskContext &context, std::function done_callback) { + GELOGD("[%s] Start execute.", context.GetNodeName()); + GE_CHK_STATUS_RET(Execute(context), "[Invoke][Execute] failed for node:%s.", node_name_.c_str()); + if (done_callback) { + GELOGD("[%s] Start invoke callback.", context.GetNodeName()); + done_callback(); } + GELOGD("[%s] Done execute successfully.", context.GetNodeName()); + return SUCCESS; +} - Status compute_ret = host_kernel->Compute(context); - if (compute_ret != SUCCESS) { - REPORT_CALL_ERROR("E19999", "node %s type %s compute failed.", - node_->GetName().c_str(), node_->GetType().c_str()); - GELOGE(compute_ret, "[Invoke][Compute]node %s type %s compute failed or not imply.", - node_->GetName().c_str(), node_->GetType().c_str()); - return compute_ret; +Status HostAicpuNodeTask::Execute(TaskContext &context) { + GELOGD("Node[%s] launch task start.", node_name_.c_str()); + if (run_cpu_kernel_) { + GE_CHK_STATUS_RET(run_cpu_kernel_(args_.get()), "[Run][CpuKernel] failed for node:%s.", node_name_.c_str()); + } else { + REPORT_CALL_ERROR("E19999", "Run cpu kernel failed node:%s, cpu kernel is not initialized.", node_name_.c_str()); + GELOGE(INTERNAL_ERROR, + "[Run][Kernel]Run cpu kernel failed node:%s, cpu kernel is not initialized.", node_name_.c_str()); + return INTERNAL_ERROR; } + GELOGD("Node[%s] launch task successfully.", node_name_.c_str()); + return SUCCESS; +} + +Status HostAicpuNodeTask::SetHostExtInfo() { + if (aicpu_ext_handle_.GetExtInfoLen() == 0) { + GELOGD("Node[%s] don't have ext info, no need update.", node_name_.c_str()); + return SUCCESS; + } + + auto aicpu_param_head = reinterpret_cast(args_.get()); + GE_CHECK_NOTNULL(aicpu_param_head); + aicpu_param_head->extInfoLength = aicpu_ext_handle_.GetExtInfoLen(); + aicpu_param_head->extInfoAddr = reinterpret_cast(aicpu_ext_handle_.GetExtInfo()); return SUCCESS; } @@ -115,32 +117,71 @@ Status HostCpuNodeExecutor::PrepareTask(NodeTask &task, TaskContext &context) co return task.UpdateArgs(context); } +Status HostCpuNodeExecutor::ValidateTaskDef(const domi::TaskDef &task_def) { + auto task_type = static_cast(task_def.type()); + if (task_type != RT_MODEL_TASK_KERNEL) { + REPORT_CALL_ERROR("E19999", "[Check][TaskType]Invalid task type (%d) in host cpu excutor.", + static_cast(task_type)); + GELOGE(INTERNAL_ERROR, + "[Check][TaskType]Invalid task type (%d) in host cpu excutor.", static_cast(task_type)); + return INTERNAL_ERROR; + } + auto kernel_type = static_cast(task_def.kernel().context().kernel_type()); + if (kernel_type != ccKernelType::HOST_CPU) { + REPORT_INNER_ERROR("E19999", "Invalid kernel type(%d) in host cpu excutor.", + static_cast(kernel_type)); + GELOGE(INTERNAL_ERROR, + "[Check][TaskType]Invalid kernel type(%d) in host cpu excutor.", static_cast(kernel_type)); + return INTERNAL_ERROR; + } + + return SUCCESS; +} + Status HostCpuNodeExecutor::LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const { GE_CHECK_NOTNULL(node); - auto op_desc = node->GetOpDesc(); - GE_CHECK_NOTNULL(op_desc); - auto mem_type = static_cast(HOST_DDR); - for (size_t i = 0; i < op_desc->GetOutputsSize(); i++) { - (void)AttrUtils::SetInt(op_desc->MutableOutputDesc(i), ATTR_OUTPUT_MEMORY_TYPE, mem_type); + auto node_item = model.GetNodeItem(node); + GE_CHECK_NOTNULL(node_item); + auto task_defs = model.GetTaskDefs(node); + GE_CHECK_NOTNULL(task_defs); + + if ((*task_defs).size() != 1) { + REPORT_CALL_ERROR("E19999", "[Check][Size]Node[%s] task_def num[%zu] != 1", + node->GetName().c_str(), (*task_defs).size()); + GELOGE(PARAM_INVALID, "[Check][Size]Node[%s] task_def num[%zu] != 1", + node->GetName().c_str(), (*task_defs).size()); + return PARAM_INVALID; } - const std::string &name = node->GetName(); - const std::string &type = node->GetType(); - if (HostCpuEngine::GetInstance().CheckSupported(type)) { - GELOGI("create CpuKernelNodeTask for node %s, type %s.", name.c_str(), type.c_str()); - task = MakeShared(node); - GE_CHECK_NOTNULL(task); - } else if (hybrid::host_cpu::KernelFactory::Instance().CreateKernel(node) != nullptr) { - GELOGI("create HostCpuNodeTask for node %s, type %s.", name.c_str(), type.c_str()); - task = MakeShared(node); - GE_CHECK_NOTNULL(task); + const auto &task_def = (*task_defs)[0]; + GE_CHK_STATUS_RET(ValidateTaskDef(task_def), + "[Validate][TaskDef] failed for Node[%s].", node->GetName().c_str()); + auto host_aicpu_task = MakeShared(node_item, task_def); + GE_CHK_BOOL_RET_STATUS(host_aicpu_task != nullptr, MEMALLOC_FAILED, + "[Check][State]Load task for node %s failed.", node->GetName().c_str()); + GE_CHK_STATUS_RET(host_aicpu_task->Init(model), + "[Init][AicpuNodeTaskBase] failed for Node[%s].", node->GetName().c_str()); + GE_CHK_STATUS_RET(host_aicpu_task->SetHostExtInfo(), + "[Set][HostExtInfo] failed for Node[%s].", node->GetName().c_str()); + + auto handle = HostCpuEngine::GetInstance().GetConstantFoldingHandle(); + if (handle == nullptr) { + REPORT_CALL_ERROR("E19999", "Get constant folding handle failed."); + GELOGE(INTERNAL_ERROR, "[Get][Handle]Get constant folding handle failed."); + return INTERNAL_ERROR; + } + auto run_cpu_kernel = (uint32_t (*)(void *))mmDlsym(handle, "RunHostCpuKernel"); + if (run_cpu_kernel != nullptr) { + host_aicpu_task->SetRunKernel(run_cpu_kernel); } else { - REPORT_INNER_ERROR("E19999", "Create NodeTask failed for node %s type %s.", - name.c_str(), type.c_str()); - GELOGE(UNSUPPORTED, "[Create][NodeTask]node %s type %s is not support in HostCpuNodeExecutor now.", - name.c_str(), type.c_str()); - return UNSUPPORTED; + REPORT_CALL_ERROR("E19999", "Get run cpu kernel failed."); + GELOGE(INTERNAL_ERROR, "[Get][Kernel]Get run cpu kernel failed."); + return INTERNAL_ERROR; } + + task = std::move(host_aicpu_task); + GELOGD("Node[%s] load task end.", node->GetName().c_str()); + return SUCCESS; } } // namespace hybrid diff --git a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h index 10657379..759bf220 100644 --- a/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h +++ b/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.h @@ -19,39 +19,29 @@ #include "hybrid/node_executor/node_executor.h" #include "inc/kernel.h" +#include "hybrid/node_executor/aicpu/aicpu_node_executor.h" namespace ge { namespace hybrid { -class HostNodeTaskBase : public NodeTask { + +class HostAicpuNodeTask : public AicpuNodeTask { public: - explicit HostNodeTaskBase(const NodePtr &node) : node_(node) {} - ~HostNodeTaskBase() override = default; - Status UpdateArgs(TaskContext &context) override; + HostAicpuNodeTask(const NodeItem *node_item, const domi::TaskDef &task_def) + : AicpuNodeTask(node_item, task_def) {} + ~HostAicpuNodeTask() override = default; + Status ExecuteAsync(TaskContext &context, std::function done_callback) override; - protected: - NodePtr node_; + Status UpdateArgs(TaskContext &context) override; - private: - virtual Status Execute(TaskContext &context) = 0; -}; + void SetRunKernel(std::function run_cpu_kernel) { run_cpu_kernel_ = run_cpu_kernel; } -class CpuKernelNodeTask : public HostNodeTaskBase { - public: - explicit CpuKernelNodeTask(const NodePtr &node) : HostNodeTaskBase(node) {} - ~CpuKernelNodeTask() override = default; + Status SetHostExtInfo(); private: - Status Execute(TaskContext &context) override; -}; - -class HostCpuNodeTask : public HostNodeTaskBase { - public: - explicit HostCpuNodeTask(const NodePtr &node) : HostNodeTaskBase(node) {} - ~HostCpuNodeTask() override = default; + Status Execute(TaskContext &context); - private: - Status Execute(TaskContext &context) override; + std::function run_cpu_kernel_ = nullptr; }; class HostCpuNodeExecutor : public NodeExecutor { @@ -61,6 +51,9 @@ class HostCpuNodeExecutor : public NodeExecutor { Status LoadTask(const HybridModel &model, const NodePtr &node, std::shared_ptr &task) const override; + + private: + static Status ValidateTaskDef(const domi::TaskDef &task_def); }; } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc deleted file mode 100644 index 9d196a45..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hybrid/node_executor/host_cpu/kernel/assign_kernel.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/util.h" -#include "hybrid/node_executor/host_cpu/kernel_factory.h" - -namespace { -const size_t kAssignRefInputIndex = 0; -const size_t kAssignValueInputIndex = 1; -const size_t kAssignRefOutputIndex = 0; -} - -namespace ge { -namespace hybrid { -namespace host_cpu { -Status AssignKernel::Compute(TaskContext& context) { - auto ref_tensor = context.MutableInput(kAssignRefInputIndex); - GE_CHECK_NOTNULL(ref_tensor); - const auto value_tensor = context.GetInput(kAssignValueInputIndex); - GE_CHECK_NOTNULL(value_tensor); - if (value_tensor->GetSize() > ref_tensor->GetSize()) { - REPORT_INNER_ERROR("E19999", "[%s] value_input_size=%zu bigger than ref_input_size=%zu. check invalid", - node_->GetName().c_str(), value_tensor->GetSize(), ref_tensor->GetSize()); - GELOGE(INTERNAL_ERROR, "[Check][Size][%s] value_input_size=%zu, but ref_input_size=%zu.", - node_->GetName().c_str(), value_tensor->GetSize(), ref_tensor->GetSize()); - return INTERNAL_ERROR; - } - - GELOGI("[%s] value_input_data=%p, ref_input_size=%zu, value_input_size=%zu.", - node_->GetName().c_str(), ref_tensor->GetData(), ref_tensor->GetSize(), value_tensor->GetSize()); - if (value_tensor->GetSize() > 0) { - GE_CHK_RT_RET(rtMemcpy(ref_tensor->MutableData(), ref_tensor->GetSize(), value_tensor->GetData(), - value_tensor->GetSize(), RT_MEMCPY_HOST_TO_HOST)); - } - GE_CHK_STATUS_RET(context.SetOutput(kAssignRefOutputIndex, *ref_tensor), - "[Set][Output] failed for[%s].", context.GetNodeName()); - - GELOGD("[%s] compute success.", node_->GetName().c_str()); - return SUCCESS; -} - -REGISTER_KERNEL_CREATOR(Assign, AssignKernel); -} // namespace host_cpu -} // namespace hybrid -} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h deleted file mode 100644 index bfa24325..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_HOST_CPU_KERNEL_ASSIGN_KERNEL_H_ -#define GE_HYBRID_HOST_CPU_KERNEL_ASSIGN_KERNEL_H_ - -#include "hybrid/node_executor/host_cpu/kernel/kernel.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -class AssignKernel : public Kernel { - public: - AssignKernel(const NodePtr &node) : Kernel(node) {} - ~AssignKernel() override = default; - AssignKernel &operator=(const AssignKernel &op) = delete; - AssignKernel(const AssignKernel &op) = delete; - - /** - * @brief compute for node_task. - * @return result - */ - Status Compute(TaskContext& context) override; -}; -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_HOST_CPU_KERNEL_ASSIGN_KERNEL_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.cc deleted file mode 100644 index 8bf50096..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.cc +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hybrid/node_executor/host_cpu/kernel/data_kernel.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/util.h" -#include "hybrid/node_executor/host_cpu/kernel_factory.h" - -namespace { -constexpr size_t kDataInputIndex = 0; -constexpr size_t kDataOutputIndex = 0; -} - -namespace ge { -namespace hybrid { -namespace host_cpu { -Status DataKernel::Compute(TaskContext& context) { - auto input = context.MutableInput(kDataInputIndex); - GE_CHECK_NOTNULL(input); - GE_CHK_STATUS_RET(context.SetOutput(kDataOutputIndex, *input), - "[Set][Output] failed for [%s].", context.GetNodeName()) - GELOGD("[%s] compute success.", node_->GetName().c_str()); - return SUCCESS; -} - -REGISTER_KERNEL_CREATOR(Data, DataKernel); -} // namespace host_cpu -} // namespace hybrid -} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.h deleted file mode 100644 index ca42d647..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_HOST_CPU_KERNEL_DATA_KERNEL_H_ -#define GE_HYBRID_HOST_CPU_KERNEL_DATA_KERNEL_H_ - -#include "hybrid/node_executor/host_cpu/kernel/kernel.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -class DataKernel : public Kernel { - public: - DataKernel(const NodePtr &node) : Kernel(node) {} - ~DataKernel() override = default; - DataKernel &operator=(const DataKernel &op) = delete; - DataKernel(const DataKernel &op) = delete; - - /** - * @brief compute for node_task. - * @return result - */ - Status Compute(TaskContext& context) override; -}; -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_HOST_CPU_KERNEL_DATA_KERNEL_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/kernel.h deleted file mode 100644 index 0a9f32b7..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/kernel.h +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_HOST_CPU_KERNEL_KERNEL_H_ -#define GE_HYBRID_HOST_CPU_KERNEL_KERNEL_H_ - -#include "common/ge_inner_error_codes.h" -#include "graph/node.h" -#include "hybrid/node_executor/task_context.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -/** - * The base class for all host_kernel. - */ -class Kernel { - public: - Kernel(const NodePtr &node) : node_(node) {} - virtual ~Kernel() = default; - virtual Status Compute(TaskContext& context) = 0; - - protected: - const NodePtr &node_; -}; -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_HOST_CPU_KERNEL_KERNEL_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc deleted file mode 100644 index 1d450166..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hybrid/node_executor/host_cpu/kernel/no_op_kernel.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/util.h" -#include "hybrid/node_executor/host_cpu/kernel_factory.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -Status NoOpKernel::Compute(TaskContext& context) { - GELOGD("[%s] no need to compute.", node_->GetName().c_str()); - return SUCCESS; -} - -REGISTER_KERNEL_CREATOR(NoOp, NoOpKernel); -REGISTER_KERNEL_CREATOR(NetOutput, NoOpKernel); -} // namespace host_cpu -} // namespace hybrid -} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h deleted file mode 100644 index 6677ce4a..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_HOST_CPU_KERNEL_NO_OP_KERNEL_H_ -#define GE_HYBRID_HOST_CPU_KERNEL_NO_OP_KERNEL_H_ - -#include "hybrid/node_executor/host_cpu/kernel/kernel.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -class NoOpKernel : public Kernel { - public: - NoOpKernel(const NodePtr &node) : Kernel(node) {} - ~NoOpKernel() override = default; - NoOpKernel &operator=(const NoOpKernel &op) = delete; - NoOpKernel(const NoOpKernel &op) = delete; - - /** - * @brief compute for node_task. - * @return result - */ - Status Compute(TaskContext& context) override; -}; -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_HOST_CPU_KERNEL_NO_OP_KERNEL_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc deleted file mode 100755 index 17692f36..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h" -#include -#include "common/fp16_t.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/util.h" -#include "graph/utils/type_utils.h" -#include "hybrid/node_executor/host_cpu/kernel_factory.h" - -namespace { -const char *const kAttrDtype = "dtype"; -} - -namespace ge { -namespace hybrid { -namespace host_cpu { -Status RandomUniformKernel::Compute(TaskContext& context) { - int64_t seed = 0; - int64_t seed2 = 0; - (void)AttrUtils::GetInt(node_->GetOpDesc(), "seed", seed); - (void)AttrUtils::GetInt(node_->GetOpDesc(), "seed2", seed2); - DataType data_type = DT_FLOAT; - if (!AttrUtils::GetDataType(node_->GetOpDesc(), kAttrDtype, data_type)) { - REPORT_CALL_ERROR("E19999", "GetDataType failed for [%s].", node_->GetName().c_str()); - GELOGE(PARAM_INVALID, "[Get][DataType] failed for [%s].", node_->GetName().c_str()); - return PARAM_INVALID; - } - switch (data_type) { - case DT_FLOAT16: - if (GenerateFP16(node_->GetOpDesc(), seed, seed2, context) != SUCCESS) { - GELOGE(FAILED, "[Invoke][GenerateFP16]Generate random_distribution failed for %s, data_type=DT_FLOAT16", - node_->GetName().c_str()); - return FAILED; - } - break; - case DT_FLOAT: - if (Generate(node_->GetOpDesc(), seed, seed2, context) != SUCCESS) { - GELOGE(FAILED, "[Invoke][Generate]Generate random_distribution failed for %s, data_type=DT_FLOAT", - node_->GetName().c_str()); - return FAILED; - } - break; - case DT_DOUBLE: - if (Generate(node_->GetOpDesc(), seed, seed2, context) != SUCCESS) { - GELOGE(FAILED, "[Invoke][Generate]Generate random_distribution failed for %s, data_type=DT_DOUBLE", - node_->GetName().c_str()); - return FAILED; - } - break; - default: - REPORT_INNER_ERROR("E19999", "[Check][DataType]Supported DataType is DT_FLOAT16 / DT_FLOAT / DT_DOUBLE," - "but data_type=%s, node:%s", - TypeUtils::DataTypeToSerialString(data_type).c_str(), - node_->GetName().c_str()); - GELOGE(UNSUPPORTED, "[Check][DataType]Supported DataType is DT_FLOAT16 / DT_FLOAT / DT_DOUBLE," - "but data_type=%s, node:%s", - TypeUtils::DataTypeToSerialString(data_type).c_str(), - node_->GetName().c_str()); - return UNSUPPORTED; - } - - GELOGD("[%s] compute success.", node_->GetName().c_str()); - return SUCCESS; -} - -template -Status RandomUniformKernel::Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, - TaskContext& context) { - GE_CHECK_NOTNULL(op_desc_ptr); - // RandomUniformOp has and only has one output - int64_t data_num = op_desc_ptr->GetOutputDesc(0).GetShape().GetShapeSize(); - AllocationAttr attr; - attr.SetMemType(HOST_DDR); - auto tensor_size = data_num * sizeof(T); - TensorValue tensor; - GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), - "[Invoke][AllocateTensor][%s] Failed to allocate output of size %zu", - context.GetNodeName(), - tensor_size); - - auto *buf = reinterpret_cast(tensor.MutableData()); - int64_t final_seed; - if (seed == 0) { - if (seed2 == 0) { - std::random_device rd; - final_seed = rd(); - } else { - final_seed = seed2; - } - } else { - final_seed = seed; - } - std::mt19937_64 gen(final_seed); - std::uniform_real_distribution distribution(0, 1); - for (int64_t i = 0; i < data_num; i++) { - *(buf + i) = distribution(gen); - } - - GE_CHK_STATUS_RET(context.SetOutput(0, tensor), "[Set][Output] failed for [%s].", context.GetNodeName()); - return SUCCESS; -} - -Status RandomUniformKernel::GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, - TaskContext& context) { - GE_CHECK_NOTNULL(op_desc_ptr); - // RandomUniformOp has and only has one output - int64_t data_num = op_desc_ptr->GetOutputDesc(0).GetShape().GetShapeSize(); - AllocationAttr attr; - attr.SetMemType(HOST_DDR); - auto tensor_size = data_num * sizeof(fp16_t); - TensorValue tensor; - GE_CHK_STATUS_RET(context.AllocateTensor(tensor_size, tensor, &attr), - "[Invoke][AllocateTensor][%s] Failed to allocate output of size %zu", - context.GetNodeName(), - tensor_size); - - auto *buf = reinterpret_cast(tensor.MutableData()); - int64_t final_seed; - if (seed == 0) { - if (seed2 == 0) { - std::random_device rd; - final_seed = rd(); - } else { - final_seed = seed2; - } - } else { - final_seed = seed; - } - std::mt19937_64 gen(final_seed); - std::uniform_real_distribution distribution(0, 1); - for (int64_t i = 0; i < data_num; i++) { - *(buf + i) = static_cast(distribution(gen)); - } - - GE_CHK_STATUS_RET(context.SetOutput(0, tensor), "[Set][Output]failed for [%s].", context.GetNodeName()); - return SUCCESS; -} - -REGISTER_KERNEL_CREATOR(RandomUniform, RandomUniformKernel); -} // namespace host_cpu -} // namespace hybrid -} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h deleted file mode 100755 index 30557064..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.h +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_HOST_CPU_KERNEL_RANDOM_UNIFORM_KERNEL_H_ -#define GE_HYBRID_HOST_CPU_KERNEL_RANDOM_UNIFORM_KERNEL_H_ - -#include "hybrid/node_executor/host_cpu/kernel/kernel.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -class RandomUniformKernel : public Kernel { - public: - RandomUniformKernel(const NodePtr &node) : Kernel(node) {} - ~RandomUniformKernel() override = default; - RandomUniformKernel &operator=(const RandomUniformKernel &op) = delete; - RandomUniformKernel(const RandomUniformKernel &op) = delete; - - /** - * @brief compute for node_task. - * @return result - */ - Status Compute(TaskContext& context) override; - - private: - template - Status Generate(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext& context); - - static Status GenerateFP16(const ge::OpDescPtr &op_desc_ptr, int64_t seed, int64_t seed2, TaskContext& context); -}; -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_HOST_CPU_KERNEL_RANDOM_UNIFORM_KERNEL_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc deleted file mode 100644 index 902a07c2..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hybrid/node_executor/host_cpu/kernel/variable_kernel.h" -#include "framework/common/debug/ge_log.h" -#include "framework/common/util.h" -#include "hybrid/node_executor/host_cpu/kernel_factory.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -Status VariableKernel::Compute(TaskContext& context) { - auto tensor = context.GetVariable(node_->GetName()); - if (tensor == nullptr) { - REPORT_INNER_ERROR("E19999", "Get Variable from task context for node:%s failed.", context.GetNodeName()); - GELOGE(PARAM_INVALID, "[Check][Param]Get Variable from task context for node:%s failed.", context.GetNodeName()); - return PARAM_INVALID; - } - // Constant & Variable Op has and only has one output - GE_CHK_STATUS_RET(context.SetOutput(0, *tensor), "[Set][Output] failed for [%s].", context.GetNodeName()); - GELOGD("[%s] compute success.", node_->GetName().c_str()); - return SUCCESS; -} - -REGISTER_KERNEL_CREATOR(Variable, VariableKernel); -REGISTER_KERNEL_CREATOR(Constant, VariableKernel); -} // namespace host_cpu -} // namespace hybrid -} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h b/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h deleted file mode 100644 index f20d6221..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.h +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_HOST_CPU_KERNEL_VARIABLE_KERNEL_H_ -#define GE_HYBRID_HOST_CPU_KERNEL_VARIABLE_KERNEL_H_ - -#include "hybrid/node_executor/host_cpu/kernel/kernel.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -class VariableKernel : public Kernel { - public: - VariableKernel(const NodePtr &node) : Kernel(node) {} - ~VariableKernel() override = default; - VariableKernel &operator=(const VariableKernel &op) = delete; - VariableKernel(const VariableKernel &op) = delete; - - /** - * @brief compute for node_task. - * @return result - */ - Status Compute(TaskContext& context) override; -}; -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_HOST_CPU_KERNEL_VARIABLE_KERNEL_H_ diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc b/ge/hybrid/node_executor/host_cpu/kernel_factory.cc deleted file mode 100644 index 7d3ef703..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.cc +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "hybrid/node_executor/host_cpu/kernel_factory.h" -#include "framework/common/debug/ge_log.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -KernelFactory &KernelFactory::Instance() { - static KernelFactory instance; - return instance; -} - -std::shared_ptr KernelFactory::CreateKernel(const NodePtr &node) { - if (node == nullptr) { - GELOGW("node is NULL."); - return nullptr; - } - auto iter = kernel_creator_map_.find(node->GetType()); - if (iter != kernel_creator_map_.end()) { - return iter->second(node); - } - REPORT_INNER_ERROR("E19999", "Not supported because kernel_creator_map_ not contain type:%s, name = %s", - node->GetType().c_str(), node->GetName().c_str()); - GELOGE(FAILED, "[Find][NodeType]Not supported because kernel_creator_map_ not contain type = %s, name = %s", - node->GetType().c_str(), node->GetName().c_str()); - return nullptr; -} - -void KernelFactory::RegisterCreator(const std::string &type, const KERNEL_CREATOR_FUNC &func) { - if (func == nullptr) { - GELOGW("Func is NULL."); - return; - } - auto iter = kernel_creator_map_.find(type); - if (iter != kernel_creator_map_.end()) { - GELOGW("%s creator already exist", type.c_str()); - return; - } - kernel_creator_map_[type] = func; -} -} // namespace host_cpu -} // namespace hybrid -} // namespace ge diff --git a/ge/hybrid/node_executor/host_cpu/kernel_factory.h b/ge/hybrid/node_executor/host_cpu/kernel_factory.h deleted file mode 100644 index d03f12fc..00000000 --- a/ge/hybrid/node_executor/host_cpu/kernel_factory.h +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright 2020 Huawei Technologies Co., Ltd - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef GE_HYBRID_NODE_EXECUTOR_HOST_CPU_KERNEL_FACTORY_H_ -#define GE_HYBRID_NODE_EXECUTOR_HOST_CPU_KERNEL_FACTORY_H_ - -#include -#include -#include -#include "common/ge/ge_util.h" -#include "hybrid/node_executor/host_cpu/kernel/kernel.h" - -namespace ge { -namespace hybrid { -namespace host_cpu { -using KERNEL_CREATOR_FUNC = std::function(const NodePtr &)>; - -/** - * manage all the host_cpu_kernel, support create kernel. - */ -class KernelFactory { - public: - static KernelFactory &Instance(); - - /** - * @brief create Kernel. - * @param [in] node - * @return not nullptr success - * @return nullptr fail - */ - std::shared_ptr CreateKernel(const NodePtr &node); - - /** - * @brief Register Kernel create function. - * @param [in] type: Kernel type - * @param [in] func: Kernel create func - */ - void RegisterCreator(const std::string &type, const KERNEL_CREATOR_FUNC &func); - - KernelFactory(const KernelFactory &) = delete; - KernelFactory &operator=(const KernelFactory &) = delete; - KernelFactory(KernelFactory &&) = delete; - KernelFactory &operator=(KernelFactory &&) = delete; - - private: - KernelFactory() = default; - ~KernelFactory() = default; - - // the kernel creator function map - std::map kernel_creator_map_; -}; - -class KernelRegistrar { - public: - KernelRegistrar(const std::string &type, const KERNEL_CREATOR_FUNC &func) { - KernelFactory::Instance().RegisterCreator(type, func); - } - ~KernelRegistrar() = default; - - KernelRegistrar(const KernelRegistrar &) = delete; - KernelRegistrar &operator=(const KernelRegistrar &) = delete; - KernelRegistrar(KernelRegistrar &&) = delete; - KernelRegistrar &operator=(KernelRegistrar &&) = delete; -}; - -#define REGISTER_KERNEL_CREATOR(type, clazz) \ - std::shared_ptr Creator_##type##Kernel(const NodePtr &node) { \ - return MakeShared(node); \ - } \ - KernelRegistrar g_##type##Kernel_creator(#type, Creator_##type##Kernel) -} // namespace host_cpu -} // namespace hybrid -} // namespace ge - -#endif // GE_HYBRID_NODE_EXECUTOR_HOST_CPU_KERNEL_FACTORY_H_ diff --git a/ge/hybrid/node_executor/rts/rts_node_task.cc b/ge/hybrid/node_executor/rts/rts_node_task.cc index 5ad8eaf4..104196ee 100644 --- a/ge/hybrid/node_executor/rts/rts_node_task.cc +++ b/ge/hybrid/node_executor/rts/rts_node_task.cc @@ -90,7 +90,7 @@ Status RtsNodeTask::GetScalarIndexValue(TaskContext &task_context, uint32_t inde Status StreamActiveNodeTask::ExecuteAsync(TaskContext &task_context, std::function done_callback) { GELOGD("[%s] Start to execute.", task_context.GetNodeName()); const auto &node_state = task_context.GetNodeState(); - node_state->SetSwitchIndex(0); + node_state->RunStreamActive(); if (done_callback) { GE_CHK_STATUS_RET(task_context.RegisterCallback(done_callback)); } @@ -204,9 +204,7 @@ Status PassThroughNodeTask::ExecuteAsync(TaskContext &task_context, std::functio const auto &node_state = task_context.GetNodeState(); if (kNextIterationOpTypes.count(node_state->GetType()) > 0) { - node_state->RunLoopNext(); - } else if (kExitOpTypes.count(node_state->GetType()) > 0) { - node_state->RunLoopExit(); + node_state->RunNextIteration(); } if (done_callback) { diff --git a/ge/ir_build/attr_options/keep_dtype_option.cc b/ge/ir_build/attr_options/keep_dtype_option.cc index c2d87d51..dfdd0df3 100644 --- a/ge/ir_build/attr_options/keep_dtype_option.cc +++ b/ge/ir_build/attr_options/keep_dtype_option.cc @@ -27,7 +27,7 @@ namespace { const size_t kMaxOpsNum = 10; } // namespace -void KeepDtypeReportError(const std::vector &invalid_list) { +void KeepDtypeReportError(const std::vector &invalid_list, const std::string &cfg_path) { std::stringstream err_msg; size_t list_size = invalid_list.size(); err_msg << "config file contains " << list_size; @@ -48,8 +48,9 @@ void KeepDtypeReportError(const std::vector &invalid_list) { } } - ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, {"keep_dtype", err_msg.str().c_str()}); + REPORT_INPUT_ERROR( + "E10003", std::vector({"parameter", "value", "reason"}), + std::vector({"keep_dtype", cfg_path, err_msg.str()})); GELOGE(FAILED, "%s", err_msg.str().c_str()); } @@ -95,7 +96,7 @@ graphStatus KeepDtypeFunc(ComputeGraphPtr &graph, const std::string &cfg_path) { ifs.close(); if (!invalid_list.empty()) { - KeepDtypeReportError(invalid_list); + KeepDtypeReportError(invalid_list, cfg_path); return GRAPH_PARAM_INVALID; } diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index c7e9522b..21db83aa 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -272,8 +272,7 @@ class Impl { graphStatus Init(const Graph &graph, const std::map &options); graphStatus BuildModel(const Graph &graph, const std::map &options, ModelBufferData &ge_models); - graphStatus InitDomiOmgContext(const string &input_shape, const string &input_format, const string &net_format, - bool is_dynamic_input); + graphStatus InitDomiOmgContext(const string &input_shape, const string &input_format, bool is_dynamic_input); graphStatus GetInputShapeRange(const string &input_shape_range, std::map>> &name_shape_range_map, std::vector>> &index_shape_range_map); @@ -283,6 +282,7 @@ class Impl { void SetRtSocVersion(); void UpdateThreadContext(); void LoadOpsProto(); + std::string GetParam(const std::string ¶m); public: ge::GeGenerator generator_; std::map options_; @@ -512,6 +512,10 @@ graphStatus Impl::CheckOptions(const std::map &options return GRAPH_SUCCESS; } +std::string Impl::GetParam(const std::string ¶m) { + return options_.find(param) == options_.end() ? "" : options_[param]; +} + graphStatus Impl::Init(const Graph &graph, const std::map &options) { // 1. check options graphStatus ret = CheckOptions(options); @@ -533,20 +537,13 @@ graphStatus Impl::Init(const Graph &graph, const std::mapInitDomiOmgContext(input_shape, input_format, net_format, is_dynamic_input_); + return this->InitDomiOmgContext(input_shape, input_format, is_dynamic_input_); } void Impl::SetRtSocVersion() { @@ -691,8 +685,7 @@ graphStatus Impl::BuildModel(const Graph &graph, const std::mapsecond; } else { - ErrorManager::GetInstance().ATCReportErrMessage("E19012", {"function", "reason"}, - {"AttrTypeToSerialString", "attr_type[" + std::to_string(attr_type) + "] is not support"}); + REPORT_INNER_ERROR("E19999", "attr_type:%u is not support", attr_type); GELOGE(GRAPH_FAILED, "[Check][AclgrphAttrType] attr_type not support %u", attr_type); return "UNDEFINED"; } diff --git a/ge/ir_build/option_utils.cc b/ge/ir_build/option_utils.cc index d7fccee3..cecc2588 100755 --- a/ge/ir_build/option_utils.cc +++ b/ge/ir_build/option_utils.cc @@ -39,7 +39,7 @@ const size_t kSquareBracketsSize = 2; const size_t kRangePairSize = 2; const size_t kShapeRangeSize = 2; const size_t kShapeRangeStrIndex = 2; -const size_t kShapeRangeStrSize = 3; +const size_t kShapeRangeStrSize = 1; // datatype/formats from user to GE, Unified to util interface file later const std::map kOutputTypeSupportDatatype = { {"FP32", ge::DT_FLOAT}, {"FP16", ge::DT_FLOAT16}, {"UINT8", ge::DT_UINT8}}; @@ -186,7 +186,8 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map for (char c : dynamic_batch_size) { if (!isdigit(c) && (c != ',') && (c != ' ')) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10033", {"value", "reason"}, {dynamic_batch_size, kDynamicBatchSizeError}); + "E10003", {"parameter", "value", "reason"}, + {"dynamic_batch_size", dynamic_batch_size, kDynamicBatchSizeError}); GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] --dynamic_batch_size:%s is invalid. reason: %s", dynamic_batch_size.c_str(), kDynamicBatchSizeError); return false; @@ -203,7 +204,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map if (!input_format.empty() && !ge::TypeUtils::IsFormatValid(input_format.c_str())) { GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape] input_format [%s] invalid, can not support now.", input_format.c_str()); - REPORT_INPUT_ERROR("E10414", std::vector({"input_format"}), std::vector({input_format})); + REPORT_INPUT_ERROR("E10003", std::vector({"parameter","value","reason"}), + std::vector({"input_format", input_format, "this format is not support"})); return false; } int32_t size = 0; @@ -242,8 +244,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map bool is_char_valid = isdigit(c) || (c == ',') || (c == ' ') || (c == ';'); if (!is_char_valid) { ErrorManager::GetInstance().ATCReportErrMessage( - "E10001", {"parameter", "value", "reason"}, - {"dynamic_image_size", dynamic_image_size.c_str(), kDynamicImageSizeError}); + "E10003", {"parameter", "value", "reason"}, + {"dynamic_image_size", dynamic_image_size, kDynamicImageSizeError}); GELOGE(ge::PARAM_INVALID, "[Check][DynamicImageSizeInputShape] --dynamic_image_size:%s is invalid. reason: %s", dynamic_image_size.c_str(), kDynamicImageSizeError); return false; @@ -256,7 +258,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map for (auto str : split_set) { split_dim = StringUtils::Split(str, ','); if (split_dim.size() != static_cast(kDynamicImageSizeNum)) { - ErrorManager::GetInstance().ATCReportErrMessage("E10020"); + REPORT_INPUT_ERROR("E10020", std::vector({"dynamic_image_size"}), + std::vector({dynamic_image_size})); GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape] invalid value:%s number of dimensions of each group must be %ld.", dynamic_image_size.c_str(), kDynamicImageSizeNum); @@ -320,8 +323,9 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims // Different parameter sets are split by ';' vector split_set = StringUtils::Split(dynamic_dims, ';'); if (split_set.size() > kMaxDynamicDimNum) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, {"dynamic_dims", "dynamic_dims's num of parameter set can not exceed 100"}); + REPORT_INPUT_ERROR( + "E10036", std::vector({"shapesize", "maxshapesize"}), + std::vector({std::to_string(split_set.size()), std::to_string(kMaxDynamicDimNum + 1)})); GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims]dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); return false; @@ -329,9 +333,10 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims for (auto split_dim : split_set) { vector one_set = StringUtils::Split(split_dim, ','); if (one_set.size() != static_cast(dynamic_dim_num)) { - ErrorManager::GetInstance().ATCReportErrMessage( - "E10042", {"parameter", "reason"}, - {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); + REPORT_INPUT_ERROR( + "E10003", std::vector({"parameter", "value", "reason"}), + std::vector({"dynamic_dims", dynamic_dims, + "Each gear setting needs to be consistent with the number of -1 in the inputshape"})); GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims] --dynamic_dims:%s invalid. " "reason: Each gear setting needs to be consistent with the number of -1 in the inputshape.", dynamic_dims.c_str()); @@ -456,8 +461,9 @@ Status ParseInputShapeRange(const std::string &shape_range, for (auto &shape_range_str : shape_range_set) { if (shape_range_str.size() < kShapeRangeStrSize) { // shape_range_str should be "[2~3,1" - // or ",[2~3,1". because we should trim '[' or ',[' - // so shape_range_str.size() < 3 is invalid + // or ",[2~3,1". because we should trim '[' or ',['. + // For scaler input, shape range should be "[]" + // so shape_range_str.size() < 1 is invalid continue; } // trim start bytes, after that, single input should be "1~20,3,3~6,-1" @@ -472,6 +478,11 @@ Status ParseInputShapeRange(const std::string &shape_range, std::vector> range_of_single_input; vector dim_range_set = ge::StringUtils::Split(shape_range_str, ','); for (const auto &range_pair_str : dim_range_set) { + if (range_pair_str.empty()) { + // for scaler input ,range is empty. use [0,0] as scaler range. + range_of_single_input.emplace_back(std::make_pair(0, 0)); + continue; + } vector range_pair_set = ge::StringUtils::Split(range_pair_str, '~'); pair range_pair; if (!ParseShapeRangePair(shape_range_str, range_pair_set, range_pair)) { @@ -490,8 +501,7 @@ Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_i int32_t param_size = static_cast(!dynamic_batch_size.empty()) + static_cast(!dynamic_image_size.empty()) + static_cast(!dynamic_dims.empty()); if (param_size > 1) { - ErrorManager::GetInstance().ATCReportErrMessage("E10009", {"parameter0", "parameter1", "parameter2"}, - {"dynamic_batch_size", "dynamic_image_size", "dynamic_dims"}); + REPORT_INPUT_ERROR("E10009", std::vector(), std::vector()); GELOGE(ge::PARAM_INVALID, "[Parse][Parameter]dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one"); return ge::PARAM_INVALID; @@ -602,17 +612,17 @@ bool ParseInputShape(const string &input_shape, map> &sh } catch (const std::out_of_range &) { ErrorManager::GetInstance().ATCReportErrMessage("E10013", {"parameter", "value"}, {"--input_shape", shape_value_str}); - GELOGW("Input parameter[--input_shape]’s value[%s] cause out of range execption!", shape_value_str.c_str()); + GELOGW("Input parameter[--input_shape]'s value[%s] cause out of range execption!", shape_value_str.c_str()); return false; } catch (const std::invalid_argument &) { ErrorManager::GetInstance().ATCReportErrMessage("E10014", {"parameter", "value"}, {"--input_shape", shape_value_str}); - GELOGW("Input parameter[--input_shape]’s value[%s] cause invalid argument!", shape_value_str.c_str()); + GELOGW("Input parameter[--input_shape]'s value[%s] cause invalid argument!", shape_value_str.c_str()); return false; } catch (...) { ErrorManager::GetInstance().ATCReportErrMessage("E10015", {"parameter", "value"}, {"--input_shape", shape_value_str}); - GELOGW("Input parameter[--input_shape]’s value[%s] cause unkown execption!", shape_value_str.c_str()); + GELOGW("Input parameter[--input_shape]'s value[%s] cause unkown execption!", shape_value_str.c_str()); return false; } int64_t result = left_result; @@ -621,7 +631,7 @@ bool ParseInputShape(const string &input_shape, map> &sh ErrorManager::GetInstance().ATCReportErrMessage("E10011", {"shape", "result"}, {shape, std::to_string(result)}); GELOGW( - "Input parameter[--input_shape]’s shape value[%s] is invalid, " + "Input parameter[--input_shape]'s shape value[%s] is invalid, " "expect positive integer, but value is %ld.", shape.c_str(), result); return false; @@ -719,13 +729,10 @@ int CheckLogParamValidAndSetLogLevel(const std::string log) { } else { GELOGE(ge::PARAM_INVALID, "[Check][LogParam]log:%s invalid, only support debug, info, warning, error, null", log.c_str()); - REPORT_INPUT_ERROR("E10417", std::vector({"loglevel"}), std::vector({log})); return ret; } if (ret != 0) { GELOGE(ge::PARAM_INVALID, "[Set][LogLevel] fail, level:%s.", log.c_str()); - REPORT_INPUT_ERROR("E10417", std::vector({"loglevel"}), std::vector({log})); - } return ret; } @@ -741,7 +748,8 @@ Status CheckInsertOpConfParamValid(const std::string insert_op_conf) { Status CheckDisableReuseMemoryParamValid(const std::string disable_reuse_memory) { if ((disable_reuse_memory != "") && (disable_reuse_memory != "0") && (disable_reuse_memory != "1")) { - ErrorManager::GetInstance().ATCReportErrMessage("E10006", {"parameter"}, {"disable_reuse_memory"}); + REPORT_INPUT_ERROR("E10006", std::vector({"parameter", "value"}), + std::vector({"disable_reuse_memory", disable_reuse_memory})); GELOGE(ge::PARAM_INVALID, "[Check][DisableReuseMemory]disable_reuse_memory must be 1 or 0."); return ge::PARAM_INVALID; } diff --git a/ge/offline/main.cc b/ge/offline/main.cc index 12e39680..a1ae476b 100755 --- a/ge/offline/main.cc +++ b/ge/offline/main.cc @@ -67,7 +67,7 @@ static bool is_dynamic_input = false; const char *const kModeSupport = "only support 0(model to framework model), " "1(framework model to json), 3(only pre-check), " "5(pbtxt to json), 6(display model info)"; -const char *const kModelToJsonSupport = "only support 0(Caffe) 3(TensorFlow) 5(Onnx)"; +const char *const kModelToJsonSupport = "only support 0(Caffe) 3(TensorFlow) 5(Onnx) when model set 1"; const char *const kCaffeFormatSupport = "only support NCHW, ND in Caffe model"; const char *const kTFFormatSupport = "only support NCHW, NHWC, ND, NCDHW, NDHWC in TF model"; const char *const kONNXFormatSupport = "only support NCHW, ND, NCDHW in ONNX model"; @@ -102,14 +102,6 @@ DEFINE_int32(mode, 0, "Optional; run mode, 0(default): model => framework model; 1: " "framework model => json; 3: only pre-check; 5: txt => json."); -#if !defined(__ANDROID__) && !defined(ANDROID) -DEFINE_int32(encrypt_mode, -1, "Optional; the encrypt flag. 0: encrypt; -1(default): not encrypt"); -DEFINE_string(encrypt_key, "", "Optional; the encrypt_key file."); -DEFINE_string(certificate, "", "Optional; the certificate file."); -DEFINE_string(hardware_key, "", "Optional; the ISV key file."); -DEFINE_string(private_key, "", "Optional; the private key file."); -#endif - DEFINE_string(out_nodes, "", "Optional; output nodes designated by users." "Format: \"node_name1:0;node_name1:1;node_name2:0\""); @@ -405,29 +397,6 @@ class GFlagUtils { "dynamic dims function does not support aipp"}); ret = ge::FAILED, "[Check][Param]dynamic dims function does not support aipp"); -#if !defined(__ANDROID__) && !defined(ANDROID) - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!CheckEncryptModeValid(FLAGS_encrypt_mode), ret = ge::FAILED, - "[Check][EncryptMode]value %d not valid!!", FLAGS_encrypt_mode); - - if (FLAGS_encrypt_mode == 0) { // Encryption mode - GELOGI("ge will run with encrypt!"); - - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_encrypt_key), ret = ge::FAILED, - "[Check][InputPath]encrypt_key file not found!!"); - - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_certificate), ret = ge::FAILED, - "[Check][InputPath]certificate file not found!!"); - - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_hardware_key), ret = ge::FAILED, - "[Check][InputPath]hardware_key file not found!!"); - - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(!ge::CheckInputPathValid(FLAGS_private_key), ret = ge::FAILED, - "[Check][InputPath]private_key file not found!!"); - } else { // No encryption - GELOGI("ge will run without encrypt!"); - } -#endif - /** * Check the validity of the I / O file path */ @@ -486,7 +455,8 @@ class GFlagUtils { ret = ge::FAILED, "[Check][EnableSingleStream]failed!"); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG((FLAGS_display_model_info != "0") && (FLAGS_display_model_info != "1"), - ErrorManager::GetInstance().ATCReportErrMessage("E10006", {"parameter"}, {"display_model_info"}); + REPORT_INPUT_ERROR("E10006", std::vector({"parameter", "value"}), + std::vector({"display_model_info", FLAGS_display_model_info})); ret = ge::FAILED, "[Check][Parameter]Input parameter[--display_model_info]'s value must be 1 or 0."); return ret; @@ -917,7 +887,8 @@ static Status ConvertModelToJson(int fwk_type, const string &model_file, const s } if (FLAGS_dump_mode != "0" && FLAGS_dump_mode != "1") { - ErrorManager::GetInstance().ATCReportErrMessage("E10006", {"parameter"}, {"dump_mode"}); + REPORT_INPUT_ERROR("E10006", std::vector({"parameter", "value"}), + std::vector({"dump_mode", FLAGS_dump_mode})); GELOGE(ge::FAILED, "[Convert][ModelToJson] Input parameter[--dump_mode]'s value must be 1 or 0."); ret = ge::FAILED; } @@ -982,7 +953,8 @@ domi::Status GenerateModel(std::map &options, std::string output ge::Model load_model = ge::Model("loadmodel", "version2"); auto ret1 = load_model.LoadFromFile(FLAGS_model); if (ret1 != ge::GRAPH_SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage("E10041", {"parameter"}, {FLAGS_model}); + REPORT_INPUT_ERROR("E10041", std::vector({"file"}), std::vector({FLAGS_model})); + REPORT_CALL_ERROR("E19999", "load from model file:%s failed", FLAGS_model.c_str()); DOMI_LOGE("Load model from %s failed, please check model file or " "input parameter[--framework] is correct", FLAGS_model.c_str()); (void)ge_generator.Finalize(); @@ -1186,11 +1158,6 @@ domi::Status GenerateOmModel() { options.insert(std::pair(string(ge::FRAMEWORK_TYPE), to_string(FLAGS_framework))); options.insert(std::pair(string(ge::STREAM_NUM), to_string(f_stream_num))); options.insert(std::pair(string(ge::CALIBRATION_CONF_FILE), FLAGS_cal_conf)); - options.insert(std::pair(string(ge::ENCRYPT_MODE), to_string(FLAGS_encrypt_mode))); - options.insert(std::pair(string(ge::EK_FILE), FLAGS_encrypt_key)); - options.insert(std::pair(string(ge::CERT_FILE), FLAGS_certificate)); - options.insert(std::pair(string(ge::HW_KEY_FILE), FLAGS_hardware_key)); - options.insert(std::pair(string(ge::PRIVATE_KEY_FILE), FLAGS_private_key)); options.insert(std::pair(string(ge::OUTPUT_NODE_NAME), FLAGS_out_nodes)); options.insert(std::pair(string(ge::INSERT_OP_FILE), FLAGS_insert_op_conf)); options.insert(std::pair(string(ge::PRECISION_MODE), FLAGS_precision_mode)); diff --git a/ge/offline/single_op_parser.cc b/ge/offline/single_op_parser.cc index ce9448d5..dac2e15c 100644 --- a/ge/offline/single_op_parser.cc +++ b/ge/offline/single_op_parser.cc @@ -89,6 +89,7 @@ map kDataTypeDict = { {"float", DT_FLOAT}, {"float32", DT_FLOAT}, {"double", DT_DOUBLE}, + {"complex64", DT_COMPLEX64} }; map kFormatDict = { @@ -161,9 +162,13 @@ std::string GenerateFileName(const SingleOpDesc &single_op_desc, int index) { } } // namespace -template -void SetAttrValue(const Json &j, SingleOpAttr &attr) { - attr.value.SetValue(j.at(kKeyValue).get()); +bool AttrValueIsString(const Json &j, const string &key) { + try { + string tmp_str = j.at(key).get(); + return true; + } catch (Json::type_error &e) { + return false; + } } template @@ -177,6 +182,20 @@ T GetValue(const map &dict, string &key, T default_val) { return it->second; } +template +void SetAttrValue(const Json &j, SingleOpAttr &attr) { + // when attr type is "data_type", we support two kinds of attr value. + // 1. value: "DT_FLOAT", "DT_INT32", "DT_INT8" ... + // 2. value: 1, 3 ... + if (j.at(kKeyType).get() == "data_type" && AttrValueIsString(j, kKeyValue)) { + string type_str = j.at(kKeyValue).get(); + DataType dtype = TypeUtils::SerialStringToDataType(type_str); + attr.value.SetValue(dtype); + return; + } + attr.value.SetValue(j.at(kKeyValue).get()); +} + void from_json(const Json &j, SingleOpTensorDesc &desc) { bool is_tensor_valid = true; desc.dims = j.at(kKeyShape).get>(); @@ -310,7 +329,7 @@ Status SingleOpParser::ReadJsonFile(const std::string &file, Json &json_obj) { ifs >> json_obj; } catch (const std::exception &e) { ErrorManager::GetInstance().ATCReportErrMessage("E10025", {"realpath", "errmsg"}, {real_path, e.what()}); - GELOGE(PARAM_INVALID, + GELOGE(PARAM_INVALID, "[Parse][JsonFile] fail for file[%s] provided in input parameter[--singleop], exception = %s.", real_path.c_str(), e.what()); return PARAM_INVALID; @@ -330,16 +349,16 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { int index = 0; for (auto &tensor_desc : op_desc.input_desc) { if (!tensor_desc.GetValidFlag()) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"intput", "datatype or format", std::to_string(index)}); - GELOGE(PARAM_INVALID, + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"op_name", "input", "type", "index"}, + {op_desc.op, "input", "tensor", std::to_string(index)}); + GELOGE(PARAM_INVALID, "[Check][Param] fail for Input's dataType or format is invalid when the index is %d", index); return false; } if ((tensor_desc.type == DT_UNDEFINED && tensor_desc.format != FORMAT_RESERVED) || (tensor_desc.type != DT_UNDEFINED && tensor_desc.format == FORMAT_RESERVED)){ - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"intput", "datatype or format", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"op_name", "input", "type", "index"}, + {op_desc.op, "input", "datatype or format", std::to_string(index)}); GELOGE(PARAM_INVALID, "[Check][Param]Input's dataType or format is invalid when the index is %d", index); return false; } @@ -349,21 +368,21 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { index = 0; for (auto &tensor_desc : op_desc.output_desc) { if (!tensor_desc.GetValidFlag()) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"output", "datatype", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"op_name", "input", "type", "index"}, + {op_desc.op, "output", "tensor", std::to_string(index)}); GELOGE(PARAM_INVALID, "[Check][Param]fail for Output's dataType is invalid when the index is %d", index); return false; } if (tensor_desc.type == DT_UNDEFINED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"output", "datatype", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"op_name", "input", "type", "index"}, + {op_desc.op, "output", "datatype", std::to_string(index)}); GELOGE(PARAM_INVALID, "[Check][Param]Output's dataType is invalid when the index is %d", index); return false; } if (tensor_desc.format == FORMAT_RESERVED) { - ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"input", "type", "index"}, - {"output", "format", std::to_string(index)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10027", {"op_name", "input", "type", "index"}, + {op_desc.op, "output", "format", std::to_string(index)}); GELOGE(PARAM_INVALID, "[Check][Param]Output's format is invalid when the index is %d", index); return false; } @@ -372,13 +391,13 @@ bool SingleOpParser::Validate(const SingleOpDesc &op_desc) { for (auto &attr : op_desc.attrs) { if (attr.name.empty()) { - ErrorManager::GetInstance().ATCReportErrMessage("E10029"); + ErrorManager::GetInstance().ATCReportErrMessage("E10029", {"op_name"}, {op_desc.op}); GELOGE(PARAM_INVALID, "[Parse][Attr]attr name is empty"); return false; } if (attr.value.IsEmpty()) { - ErrorManager::GetInstance().ATCReportErrMessage("E10030", {"attrname"}, {attr.name}); + ErrorManager::GetInstance().ATCReportErrMessage("E10030", {"op_name", "attrname"}, {op_desc.op, attr.name}); GELOGE(PARAM_INVALID, "[Parse][Attr] fail for vale of attr name:\"%s\" is empty. ", attr.name.c_str()); return false; } @@ -479,7 +498,7 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc string reason = "is smaller than the ir needed input size " + std::to_string(ir_opdesc_inputs_num); ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, {current_op_desc.GetName(), "input size " + std::to_string(current_opdesc_inputs_num), reason}); - GELOGE(PARAM_INVALID, + GELOGE(PARAM_INVALID, "[Verify][OpInputOutputSize]This op:%s input size %zu is smaller than the ir needed input size %zu", current_op_desc.GetName().c_str(), current_opdesc_inputs_num, ir_opdesc_inputs_num); return PARAM_INVALID; @@ -490,7 +509,7 @@ Status SingleOpParser::VerifyOpInputOutputSizeByIr(const OpDesc ¤t_op_desc string reason = "is smaller than the ir needed output size " + std::to_string(ir_opdesc_outputs_num); ErrorManager::GetInstance().ATCReportErrMessage("E19014", {"opname", "value", "reason"}, {current_op_desc.GetName(), "output size " + std::to_string(current_opdesc_outputs_num), reason}); - GELOGE(PARAM_INVALID, + GELOGE(PARAM_INVALID, "[Verify][OpInputOutputSize]This op:%s output size %zu is smaller than the ir needed output size %zu", current_op_desc.GetName().c_str(), current_opdesc_outputs_num, ir_opdesc_outputs_num); return PARAM_INVALID; @@ -511,7 +530,7 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, {op_name, "shape", "has unknown rank but dim size is not one"}); - GELOGE(PARAM_INVALID, "[Set][ShapeRange]Invalid tensor shape:%s.", + GELOGE(PARAM_INVALID, "[Set][ShapeRange]Invalid tensor shape:%s.", ge_tensor_desc.MutableShape().ToString().c_str()); return PARAM_INVALID; } @@ -553,7 +572,7 @@ Status SingleOpParser::SetShapeRange(const std::string &op_name, {op_name, "shape range " + std::to_string(range_index), reason}); - GELOGE(PARAM_INVALID, "[Set][ShapeRange]Invalid shape range entry. index = %zu, size = %zu", + GELOGE(PARAM_INVALID, "[Set][ShapeRange]Invalid shape range entry. index = %zu, size = %zu", range_index, range.size()); return PARAM_INVALID; } @@ -609,7 +628,7 @@ Status SingleOpParser::ParseSingleOpList(const std::string &file, std::vector(model.model_data); @@ -967,7 +967,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js ModelPartition ir_part; status = omFileLoadHelper.GetModelPartition(MODEL_DEF, ir_part); if (status != ge::GRAPH_SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"Get model part failed"}); + REPORT_CALL_ERROR("E19999", "Get model part of om file:%s failed", model_file); GELOGE(ge::FAILED, "[Get][ModelPartition] failed."); if (model.model_data != nullptr) { delete[] reinterpret_cast(model.model_data); @@ -993,12 +993,12 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js } } else { ret = INTERNAL_ERROR; - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"ReadProtoFromArray failed"}); + REPORT_CALL_ERROR("E19999", "ReadProtoFromArray failed for om file:%s", model_file); GELOGE(ret, "[Read][Proto]From Array failed."); } } else { 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, "[Parse][ModelContent] failed because of invalid om file. Please check --om param."); } @@ -1009,8 +1009,8 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertOm(const char *model_file, const char *js } return ret; } catch (const std::exception &e) { - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, - {"Convert om model to json failed, exception message[" + std::string(e.what()) + "]"}); + REPORT_INNER_ERROR("E19999", "Convert om model to json failed, exception message:%s, model_file:%s", + std::string(e.what()).c_str(), model_file); GELOGE(FAILED, "[Save][Model]Convert om model to json failed, exception message : %s.", e.what()); return FAILED; } @@ -1021,7 +1021,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const // Mode 2 does not need to verify the priority, and a default value of 0 is passed int32_t priority = 0; // Load model from file - Status ret = ModelParserBase::LoadFromFile(model_file, "", priority, model); + Status ret = ModelParserBase::LoadFromFile(model_file, priority, model); auto free_model_data = [](void **ptr) -> void { if (ptr != nullptr && *ptr != nullptr) { delete[] reinterpret_cast(*ptr); @@ -1042,7 +1042,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const if (!flag) { free_model_data(&model.model_data); - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"ParseFromString failed"}); + REPORT_CALL_ERROR("E19999", "ParseFromString failed for model_file:%s", model_file); GELOGE(FAILED, "[Invoke][ParseFromString] failed."); return FAILED; } @@ -1060,13 +1060,13 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertPbtxtToJson(const char *model_file, const return SUCCESS; } catch (google::protobuf::FatalException &e) { free_model_data(&model.model_data); - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {"ParseFromString failed, exception message[" - + std::string(e.what()) + "]"}); + REPORT_INNER_ERROR("E19999", "ParseFromString failed, exception message:%s, model_file:%s", + std::string(e.what()).c_str(), model_file); GELOGE(FAILED, "[Invoke][ParseFromString] failed. exception message : %s", e.what()); return FAILED; } catch (const std::exception &e) { - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, - {"Convert pbtxt to json failed, exception message[" + std::string(e.what()) + "]"}); + REPORT_INNER_ERROR("E19999", "ParseFromString failed, exception message:%s, model_file:%s", + std::string(e.what()).c_str(), model_file); GELOGE(FAILED, "[Save][pbtxt]Convert pbtxt to json failed, exception message : %s.", e.what()); return FAILED; } @@ -1086,7 +1086,7 @@ FMK_FUNC_HOST_VISIBILITY Status ConvertFwkModelToJson(const domi::FrameworkType ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, - {"--framework", std::to_string(framework), "only support 0(Caffe) 3(TensorFlow) 5(Onnx)"}); + {"--framework", std::to_string(framework), "only support 0(Caffe) 3(TensorFlow) 5(Onnx) when model set 1"}); GELOGE(PARAM_INVALID, "[Check][Param]Input parameter[--framework] is mandatory " "and it's value must be: 0(Caffe) 3(TensorFlow) or 5(Onnx)."); return PARAM_INVALID; diff --git a/ge/single_op/single_op_manager.cc b/ge/single_op/single_op_manager.cc index d09dd802..5edd4bf9 100644 --- a/ge/single_op/single_op_manager.cc +++ b/ge/single_op/single_op_manager.cc @@ -37,7 +37,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status SingleOpManager::GetOpFr GELOGI("GetOpFromModel in. model name = %s, model id = %lu", model_name.c_str(), model_id); if (single_op == nullptr) { GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "[Check][Param:single_op] is null."); - REPORT_INPUT_ERROR("E10412", std::vector({"inputparam"}), std::vector({"single_op"})); + REPORT_INNER_ERROR("E10412", "input param single_op is nullptr, check invalid"); return ACL_ERROR_GE_INTERNAL_ERROR; } @@ -156,7 +156,7 @@ Status SingleOpManager::GetResourceId(rtStream_t stream, uintptr_t &resource_id) auto rt_err = rtCtxGetCurrent(&rt_cur_ctx); if (rt_err != RT_ERROR_NONE) { GELOGE(rt_err, "[Get][CurrentContext] failed, runtime result is %d", static_cast(rt_err)); - REPORT_CALL_ERROR("E19999", + REPORT_CALL_ERROR("E19999", "GetResourceId failed because rtCtxGetCurrent result is %d", static_cast(rt_err)); return RT_ERROR_TO_GE_STATUS(rt_err); } diff --git a/ge/single_op/single_op_model.cc b/ge/single_op/single_op_model.cc index 5b5f24a2..67642f2e 100755 --- a/ge/single_op/single_op_model.cc +++ b/ge/single_op/single_op_model.cc @@ -30,6 +30,7 @@ #include "runtime/rt.h" #include "task/aicpu_task_builder.h" #include "task/aicpu_kernel_task_builder.h" +#include "task/rts_kernel_task_builder.h" #include "task/tbe_task_builder.h" #include "hybrid/executor/hybrid_model_executor.h" #include "hybrid/node_executor/node_executor.h" @@ -266,7 +267,9 @@ Status SingleOpModel::ParseInputsAndOutputs() { for (auto &op_desc : data_ops_) { GE_CHK_STATUS_RET_NOLOG(ParseInputNode(op_desc)); } - ParseOutputNode(netoutput_op_); + if (netoutput_op_ != nullptr) { + ParseOutputNode(netoutput_op_); + } return SUCCESS; } @@ -323,10 +326,7 @@ Status SingleOpModel::BuildTaskList(StreamResource *stream_resource, SingleOp &s OpTask *task = nullptr; uint64_t singleop_kernel_id = aicpu_kernel_id++; GELOGI("Build singleOp CCTask, kernel_id = %lu", singleop_kernel_id); - auto ret = BuildCpuKernelTask(task_def.kernel(), &task, singleop_kernel_id); - if (ret != SUCCESS) { - return ret; - } + GE_CHK_STATUS_RET_NOLOG(BuildCpuKernelTask(task_def.kernel(), &task, singleop_kernel_id)); task->SetModelArgs(model_name_, model_id_); ParseArgTable(task, single_op); single_op.tasks_.emplace_back(task); @@ -345,13 +345,22 @@ Status SingleOpModel::BuildTaskList(StreamResource *stream_resource, SingleOp &s bool depend_compute_flag = false; uint64_t singleop_kernel_id = aicpu_kernel_id++; GELOGI("Build singleOp TfTask, kernel_id = %lu", singleop_kernel_id); - auto ret = BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, false, depend_compute_flag, singleop_kernel_id); - if (ret != SUCCESS) { - return ret; - } + GE_CHK_STATUS_RET_NOLOG( + BuildKernelExTask(task_def.kernel_ex(), &aicpu_task, false, depend_compute_flag, singleop_kernel_id)); aicpu_task->SetModelArgs(model_name_, model_id_); ParseArgTable(aicpu_task, single_op); single_op.tasks_.emplace_back(aicpu_task); + } else if ((task_type == RT_MODEL_TASK_MEMCPY_ASYNC) || (task_type == RT_MODEL_TASK_MEMCPY_ADDR_ASYNC)) { + auto kernel_def = task_def.memcpy_async(); + auto node = op_list_[kernel_def.op_index()]; + GE_CHECK_NOTNULL(node); + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + std::unique_ptr task; + GE_CHK_STATUS_RET_NOLOG(RtsKernelTaskBuilder::BuildMemcpyAsyncTask(op_desc, kernel_def, model_params_, task)); + task->SetModelArgs(model_name_, model_id_); + ParseArgTable(task.get(), single_op); + single_op.tasks_.emplace_back(task.release()); } else { // skip GELOGD("Skip task type: %d", static_cast(task_type)); diff --git a/ge/single_op/single_op_model.h b/ge/single_op/single_op_model.h index e7d07ee0..529a442d 100755 --- a/ge/single_op/single_op_model.h +++ b/ge/single_op/single_op_model.h @@ -26,6 +26,7 @@ #include "common/helper/model_helper.h" #include "single_op/single_op.h" #include "single_op/stream_resource.h" +#include "single_op/task/op_task.h" namespace ge { struct SingleOpModelParam { diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index fbc3d68b..e48677f8 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -34,6 +34,7 @@ namespace ge { namespace { constexpr int kLaunchRetryTimes = 1000; +constexpr size_t kMemcpyArgCount = 2; constexpr int kSleepTime = 10; constexpr uint64_t kReleaseFlag = 1; constexpr int kCopyNum = 2; @@ -963,4 +964,17 @@ void AiCpuCCTask::GetIoAddr(uintptr_t *&arg_base, size_t &arg_count) { arg_base = io_addr_; arg_count = io_addr_num_; } + +Status MemcpyAsyncTask::LaunchKernel(rtStream_t stream) { + auto src_addr = reinterpret_cast(addresses_[0]); + auto dst_addr = reinterpret_cast(addresses_[1]); + kind_ = (kind_ == RT_MEMCPY_ADDR_DEVICE_TO_DEVICE) ? RT_MEMCPY_DEVICE_TO_DEVICE : kind_; + GE_CHK_RT_RET(rtMemcpyAsync(dst_addr, dst_max_, src_addr, count_, kind_, stream)); + return SUCCESS; +} + +void MemcpyAsyncTask::GetIoAddr(uintptr_t *&arg_base, size_t &arg_count) { + arg_base = addresses_; + arg_count = kMemcpyArgCount; +} } // namespace ge diff --git a/ge/single_op/task/op_task.h b/ge/single_op/task/op_task.h index 0c64ecb4..ed6cf40f 100644 --- a/ge/single_op/task/op_task.h +++ b/ge/single_op/task/op_task.h @@ -44,6 +44,9 @@ class OpTask { virtual Status UpdateArgTable(const SingleOpModelParam ¶m); void SetModelArgs(std::string model_name, uint32_t model_id); Status GetProfilingArgs(TaskDescInfo &task_desc_info, uint32_t &model_id); + void SetOpDesc(const OpDescPtr &op_desc) { + op_desc_ = op_desc; + } const OpDescPtr &GetOpdesc() const {return op_desc_;} Status OpenDump(rtStream_t stream); virtual void GetIoAddr(uintptr_t *&arg_base, size_t &arg_count) = 0; @@ -244,6 +247,22 @@ private: std::string op_type_; uint64_t kernel_id_ = 0; }; + +class MemcpyAsyncTask : public OpTask { + public: + Status LaunchKernel(rtStream_t stream) override; + void GetIoAddr(uintptr_t *&arg_base, size_t &arg_count) override; + + private: + friend class SingleOpModel; + friend class RtsKernelTaskBuilder; + + uintptr_t addresses_[2]; + size_t dst_max_; + size_t count_; + rtMemcpyKind_t kind_; + NodePtr node_; +}; } // namespace ge #endif // GE_SINGLE_OP_TASK_OP_TASK_H_ diff --git a/ge/single_op/task/rts_kernel_task_builder.cc b/ge/single_op/task/rts_kernel_task_builder.cc new file mode 100644 index 00000000..aad78fd9 --- /dev/null +++ b/ge/single_op/task/rts_kernel_task_builder.cc @@ -0,0 +1,45 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "single_op/task/rts_kernel_task_builder.h" +#include "build_task_utils.h" + +namespace ge { +namespace { +const size_t kNumAddresses = 2; +} // namespace + +Status RtsKernelTaskBuilder::BuildMemcpyAsyncTask(const OpDescPtr &op_desc, + const domi::MemcpyAsyncDef &kernel_def, + const SingleOpModelParam ¶m, + std::unique_ptr &task) { + task.reset(new(std::nothrow)MemcpyAsyncTask()); + GE_CHECK_NOTNULL(task); + task->SetOpDesc(op_desc); + task->dst_max_ = kernel_def.dst_max(); + task->count_ = kernel_def.count(); + task->kind_ = static_cast(kernel_def.kind()); + auto addresses = BuildTaskUtils::JoinAddresses(BuildTaskUtils::GetAddresses(op_desc, param, false)); + if (addresses.size() != kNumAddresses) { + GELOGE(INTERNAL_ERROR, "[Build][MemcpyAsyncTask] Invalid address count: %zu", addresses.size()); + return INTERNAL_ERROR; + } + + task->addresses_[0] = reinterpret_cast(addresses[0]); + task->addresses_[1] = reinterpret_cast(addresses[1]); + return SUCCESS; +} +} // namespace ge \ No newline at end of file diff --git a/ge/single_op/task/rts_kernel_task_builder.h b/ge/single_op/task/rts_kernel_task_builder.h new file mode 100644 index 00000000..80bf92a3 --- /dev/null +++ b/ge/single_op/task/rts_kernel_task_builder.h @@ -0,0 +1,34 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GE_SINGLE_OP_TASK_RTS_KERNEL_TASK_BUILDER_H_ +#define GE_SINGLE_OP_TASK_RTS_KERNEL_TASK_BUILDER_H_ + +#include +#include "graph/op_desc.h" +#include "single_op/single_op.h" +#include "single_op/single_op_model.h" + +namespace ge { +class RtsKernelTaskBuilder { + public: + static Status BuildMemcpyAsyncTask(const OpDescPtr &op_desc, + const domi::MemcpyAsyncDef &kernel_def, + const SingleOpModelParam ¶m, + std::unique_ptr &task); +}; +} // namespace ge +#endif // GE_SINGLE_OP_TASK_RTS_KERNEL_TASK_BUILDER_H_ \ No newline at end of file diff --git a/inc/external/acl/acl.h b/inc/external/acl/acl.h index a53d029d..8b1fb78f 100644 --- a/inc/external/acl/acl.h +++ b/inc/external/acl/acl.h @@ -72,7 +72,7 @@ ACL_FUNC_VISIBILITY aclError aclrtGetVersion(int32_t *majorVersion, int32_t *min * * @retval null for failed * @retval OtherValues success -*/ + */ ACL_FUNC_VISIBILITY const char *aclGetRecentErrMsg(); #ifdef __cplusplus diff --git a/inc/framework/common/profiling/ge_profiling.h b/inc/framework/common/profiling/ge_profiling.h index 7017aca3..a8de56a8 100644 --- a/inc/framework/common/profiling/ge_profiling.h +++ b/inc/framework/common/profiling/ge_profiling.h @@ -19,6 +19,7 @@ #include "ge/ge_api_error_codes.h" #include "toolchain/prof_callback.h" +#include "runtime/base.h" const int MAX_DEV_NUM = 64; @@ -42,5 +43,6 @@ GE_FUNC_VISIBILITY ge::Status RegProfCtrlCallback(MsprofCtrlCallback func); GE_FUNC_VISIBILITY ge::Status RegProfSetDeviceCallback(MsprofSetDeviceCallback func); GE_FUNC_VISIBILITY ge::Status RegProfReporterCallback(MsprofReporterCallback func); GE_FUNC_VISIBILITY ge::Status ProfCommandHandle(ProfCommandHandleType type, void *data, uint32_t len); +GE_FUNC_VISIBILITY ge::Status ProfSetStepInfo(uint64_t index_id, uint16_t tag_id, rtStream_t stream); #endif // INC_FRAMEWORK_COMMON_GE_PROFILING_H_ diff --git a/inc/framework/common/taskdown_common.h b/inc/framework/common/taskdown_common.h index 090e7e26..f2f731be 100644 --- a/inc/framework/common/taskdown_common.h +++ b/inc/framework/common/taskdown_common.h @@ -45,7 +45,8 @@ typedef enum tagccKernelType { TE_AI_CPU = 5, /* te aicpu operator */ AI_CPU = 6, /* aicpu */ CUST_AI_CPU = 7, /* custom aicpu*/ - INVALID = 8, /* unknown kernel type */ + HOST_CPU = 8, /* host cpu */ + INVALID = 10000 /* unknown kernel type */ } ccKernelType; typedef struct tagOpContext { diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index 91759b8f..811d5eed 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -132,6 +132,7 @@ REGISTER_OPTYPE_DECLARE(DROPOUT, "Dropout"); REGISTER_OPTYPE_DECLARE(DROPOUTDOMASK, "DropOutDoMask"); REGISTER_OPTYPE_DECLARE(DROPOUTDOMASKV3, "DropOutDoMaskV3"); REGISTER_OPTYPE_DECLARE(DROPOUTDOMASKV3D, "DropOutDoMaskV3D"); +REGISTER_OPTYPE_DECLARE(SOFTMAXV2WITHDROPOUTDOMASKV3D, "SoftmaxV2WithDropOutDoMaskV3D"); REGISTER_OPTYPE_DECLARE(DROPOUTGENMASK, "DropOutGenMask"); REGISTER_OPTYPE_DECLARE(CONCAT, "Concat"); REGISTER_OPTYPE_DECLARE(ROIPOOLING, "ROIPooling"); @@ -440,6 +441,8 @@ REGISTER_OPTYPE_DECLARE(HCOMREMOTEREAD, "HcomRemoteRead"); REGISTER_OPTYPE_DECLARE(HCOMREMOTEREFREAD, "HcomRemoteRefRead"); REGISTER_OPTYPE_DECLARE(HCOMREMOTEWRITE, "HcomRemoteWrite"); REGISTER_OPTYPE_DECLARE(HCOMREMOTESCATTERWRITE, "HcomRemoteScatterWrite"); +REGISTER_OPTYPE_DECLARE(HCOMALLTOALLV, "HcomAllToAllV"); +REGISTER_OPTYPE_DECLARE(HCOMGATHERALLTOALLV, "HcomGatherAllToAllV"); REGISTER_OPTYPE_DECLARE(VARASSIGN, "VarAssign"); REGISTER_OPTYPE_DECLARE(VARISINITIALIZEDOP, "VarIsInitializedOp"); diff --git a/inc/framework/common/util.h b/inc/framework/common/util.h index bd84d0ac..a3989b9d 100644 --- a/inc/framework/common/util.h +++ b/inc/framework/common/util.h @@ -234,16 +234,6 @@ const int32_t DOMI_MAX_PATH_LEN = 256; /// /// @ingroup domi_common -/// @brief proto file in bianary format -/// @param [in] file path of proto file -/// @param [out] proto memory for storing the proto file -/// @return true success -/// @return false fail -/// -GE_FUNC_VISIBILITY bool ReadProtoFromBinaryFile(const char *file, Message *proto); - -/// -/// @ingroup domi_common /// @brief Reads the proto structure from an array. /// @param [in] data proto data to be read /// @param [in] size proto data size diff --git a/metadef b/metadef index 854a3313..00c0c12e 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 854a3313eb5ff68af7300b393d48fdbfb5bf466e +Subproject commit 00c0c12eede6c7bce93a1eda5f0bb437ae80a7ec diff --git a/parser b/parser index 39d868cb..e75eda62 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 39d868cb961181f421eb80775a978ca519ef65cd +Subproject commit e75eda62de2b51a0bded5481ca81eb8fc7bf376e diff --git a/scripts/env/ge_env.sh b/scripts/env/ge_env.sh index 9052830e..18c6aa5d 100755 --- a/scripts/env/ge_env.sh +++ b/scripts/env/ge_env.sh @@ -98,7 +98,7 @@ EOF } function parse_args(){ - parsed_args=$(getopt -a -o bperh --long build,pull,enter,resethelp -- "$@") || { + parsed_args=$(getopt -a -o bperh --long build,pull,enter,reset,help -- "$@") || { help exit 1 } diff --git a/scripts/readme.md b/scripts/readme.md index f055f941..64805225 100755 --- a/scripts/readme.md +++ b/scripts/readme.md @@ -41,20 +41,13 @@ $ cd ./scripts $ ./ge.sh env ``` -3.配置外部依赖服务器信息 -```sh -ge config -i=121.36.**.** -u=asc**, -p=Asc***\#@\!$ (Need add escape character \ before special charactor $、#、!) -``` - -4.下载和安装构建所依赖的外部库 - -```sh -$ ge update -``` - +3.下载和安装构建所依赖的外部库 + ```sh + $ ge update + ``` (注:进入容器后,`ge`命令已经自动注册进系统,因此容器内不需要写脚本全称) -5.执行测试,默认执行单元测试用例,`ge test`会自动触发构建 +4.执行测试,默认执行单元测试用例,`ge test`会自动触发构建 ```sh $ ge test @@ -140,7 +133,7 @@ Options: -p, --password Config password -h, --help -Example: ge config -i=121.36.**.** -u=asc**, -p=Asc***\#@\!$ (Need add escape character \ before special charactor $、#、!) +Example: ge config -i= -u= -p= (Need add escape character \ before special charactor $、#、!) ``` 参数详细解释: @@ -164,6 +157,7 @@ Usage: ge update [OPTIONS] update dependencies of build and test Options: + -p, --public Download dependencies from community -d, --download Download dependencies -i, --install Install dependencies -c, --clear Clear dependencies @@ -171,7 +165,7 @@ Options: ``` 参数详细解释: - +- `-p, --public` : 从社区下载安装依赖库; - `-d, --download` : 下载构建需要外部依赖库; - `-i, --install` : 安装外部依赖包到对应位置; - `-c, --clear` : 清除下载的外部依赖包; @@ -200,28 +194,6 @@ Options: 默认:格式化本次修改代码。 -### `ge lint` - -使用clang-format进行代码格式化检查,具体参数如下: - -```sh -$ ge lint -h - -Options: - -a Check code format of all files, default case - -c Check code format of the files changed compared to last commit - -l Check code format of the files changed in last commit - -h Print usage -``` - -参数详细解释: - -- `-a` : 检查所有代码格式; -- `-c` : 只检查修改的代码格式; -- `-l` : 检查上次提交的代码格式; - -默认:检查本次修改代码格式。 - ### `ge build` 执行构建 (注:调用原有build.sh脚本,改造中...); diff --git a/scripts/update/deps_config_community.sh b/scripts/update/deps_config_community.sh new file mode 100644 index 00000000..54b9dd78 --- /dev/null +++ b/scripts/update/deps_config_community.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ +set -e +#社区版 +CHIP_NAME_C=A800-9010 +DRIVER_VERSION_C=21.0.rc1 +DRIVER_RUN_NAME_C=${CHIP_NAME_C}-npu-driver_${DRIVER_VERSION_C}_ubuntu18.04-x86_64.run +DRIVER_SERVER_PATH_C=https://obs-9be7.obs.cn-east-2.myhuaweicloud.com +export DRIVER_URL_C=${DRIVER_SERVER_PATH_C}/turing/resourcecenter/Software/AtlasI/A800-9010%201.0.10/NPU/${DRIVER_RUN_NAME_C} + +PACKAGE_VERSION_C=5.0.2.alpha002 +PACKAGE_NAME_C=Ascend-cann-toolkit_${PACKAGE_VERSION_C}_linux-x86_64.run +PACKAGE_SERVER_PATH_C=https://mirrors.huaweicloud.com +export PACKAGE_URL_C=${PACKAGE_SERVER_PATH_C}/ascend/autoarchive/CANN/${PACKAGE_VERSION_C}/${PACKAGE_NAME_C} + +DEV_TOOLS_VERSION_C=1.78.t12.0.b120 +CPU_ARCH_C=linux.x86_64 +export ATC_RUN_NAME_C=Ascend-atc-${DEV_TOOLS_VERSION_C}-${CPU_ARCH_C}.run +export ACL_RUN_NAME_C=Ascend-acllib-${DEV_TOOLS_VERSION_C}-${CPU_ARCH_C}.run +export FWKACL_RUN_NAME_C=Ascend-fwkacllib-${DEV_TOOLS_VERSION_C}-${CPU_ARCH_C}.run +set +e \ No newline at end of file diff --git a/scripts/update/ge_update.sh b/scripts/update/ge_update.sh index f1a42057..d6bcd043 100755 --- a/scripts/update/ge_update.sh +++ b/scripts/update/ge_update.sh @@ -34,6 +34,19 @@ function extract_deps_so() ./${DEV_TOOLS_PACKAGE}/${FWKACL_RUN_NAME} --noexec --extract=${DEP_TMP_DIR}/fwkacllib } +function extract_deps_so_community() +{ + echo "begin to extract .run file ........." + chmod +x ./${DRIVER_RUN_NAME_C} + chmod +X ./${PACKAGE_NAME_C} + [ -n "${DEP_TMP_DIR}" ] && rm -rf "${DEP_TMP_DIR}" + ./${DRIVER_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/driver + ./${PACKAGE_NAME_C} --noexec --extract=${DEP_TMP_DIR}/Packages_tmp + ${DEP_TMP_DIR}/Packages_tmp/run_package/${ATC_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/atc + ${DEP_TMP_DIR}/Packages_tmp/run_package/${ACL_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/acllib + ${DEP_TMP_DIR}/Packages_tmp/run_package/${FWKACL_RUN_NAME_C} --noexec --extract=${DEP_TMP_DIR}/fwkacllib +} + function copy_so_to_target_dir() { mkdir -p $DEP_LIB_DIR @@ -59,7 +72,19 @@ function download_runs() wget --user=${DEP_USER} --password=${DEP_PASSWORD} ${DRIVER_URL} wget --user=${DEP_USER} --password=${DEP_PASSWORD} ${DEV_TOOLS_URL} popd >/dev/null +} +function download_runs_from_community +{ + source scripts/update/deps_config_community.sh + echo "begin to download .run file from community........." + clear_libs + mkdir -p ./ ${DOWNLOAD_PATH} + pushd "${DOWNLOAD_PATH}" >/dev/null + cd ${DOWNLOAD_PATH} + wget ${DRIVER_URL_C} + wget ${PACKAGE_URL_C} + popd >/dev/null } function install_deps() @@ -73,6 +98,17 @@ function install_deps() popd >/dev/null } +function install_deps_community() +{ + source scripts/update/deps_config_community.sh + mkdir -p ./ ${DOWNLOAD_PATH} + pushd "${DOWNLOAD_PATH}" >/dev/null + cd ${DOWNLOAD_PATH} + extract_deps_so_community + copy_so_to_target_dir + popd >/dev/null +} + function help(){ cat <<-EOF @@ -81,6 +117,7 @@ Usage: ge update [OPTIONS] update dependencies of build and test Options: + -p, --public Download dependencies from community -d, --download Download dependencies -i, --install Install dependencies -c, --clear Clear dependencies @@ -90,20 +127,24 @@ EOF } function parse_args(){ - parsed_args=$(getopt -a -o dich --long download,install,clear,help -- "$@") || { + parsed_args=$(getopt -a -o pdich --long public,download,install,clear,help -- "$@") || { help exit 1 } if [ $# -lt 1 ]; then - download_runs - install_deps + download_runs_from_community + install_deps_community exit 1 fi eval set -- "$parsed_args" while true; do case "$1" in + -p | --public) + download_runs_from_community + install_deps_community + ;; -d | --download) download_runs ;; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a56705e0..cfad36e1 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -28,5 +28,6 @@ if (ENABLE_GE_COV OR ENABLE_GE_UT) endif() if (ENABLE_GE_ST) + add_subdirectory(framework) add_subdirectory(st) endif() diff --git a/tests/depends/hccl/src/hccl_stub.cc b/tests/depends/hccl/src/hccl_stub.cc index b9b9d4f6..5f5e513c 100644 --- a/tests/depends/hccl/src/hccl_stub.cc +++ b/tests/depends/hccl/src/hccl_stub.cc @@ -42,3 +42,14 @@ HcclResult hcom_reduce_scatter(const char *tag, void *input_ptr, void *output_pt HcclDataType data_type, HcclReduceOp op, const char *group, rtStream_t stream) { return HCCL_SUCCESS; } + +HcclResult HcomExecEnqueueAllToAllV(HcomAllToAllVParams params, std::function callback) { + return HCCL_SUCCESS; +} + +HcclResult HcomExecEnqueueGatherAllToAllV(HcomGatherAllToAllVParams params, +std::function callback) { + return HCCL_SUCCESS; +} + + diff --git a/tests/framework/CMakeLists.txt b/tests/framework/CMakeLists.txt new file mode 100644 index 00000000..d7c806a6 --- /dev/null +++ b/tests/framework/CMakeLists.txt @@ -0,0 +1,32 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +include(cmake/graphengine.cmake) +add_subdirectory(easy_graph) +add_subdirectory(stub_engine) +add_subdirectory(ge_graph_dsl) + +file(GLOB_RECURSE UTILS_SRC CONFIGURE_DEPENDS + "utils/*.cc" + ) + +add_library(framework STATIC ${UTILS_SRC}) + +target_include_directories(framework + PUBLIC utils/ +) + +set_target_properties(framework PROPERTIES CXX_STANDARD 11) +target_link_libraries(framework PUBLIC ge_graph_dsl graphengine fe) diff --git a/tests/framework/cmake/graphengine.cmake b/tests/framework/cmake/graphengine.cmake new file mode 100644 index 00000000..81aa00cc --- /dev/null +++ b/tests/framework/cmake/graphengine.cmake @@ -0,0 +1,276 @@ +# ---- Test coverage ---- + +if (ENABLE_GE_COV) + set(COVERAGE_COMPILER_FLAGS "-g --coverage -fprofile-arcs -fPIC -O0 -ftest-coverage") + set(CMAKE_CXX_FLAGS "${COVERAGE_COMPILER_FLAGS}") +endif() + +# ----metadef Proto generate ---- +set(PROTO_LIST + "${GE_CODE_DIR}/metadef/proto/om.proto" + "${GE_CODE_DIR}/metadef/proto/ge_ir.proto" + "${GE_CODE_DIR}/metadef/proto/insert_op.proto" + "${GE_CODE_DIR}/metadef/proto/task.proto" + "${GE_CODE_DIR}/metadef/proto/dump_task.proto" + "${GE_CODE_DIR}/metadef/proto/fwk_adapter.proto" + "${GE_CODE_DIR}/metadef/proto/op_mapping.proto" + "${GE_CODE_DIR}/metadef/proto/ge_api.proto" + "${GE_CODE_DIR}/metadef/proto/optimizer_priority.proto" + "${GE_CODE_DIR}/metadef/proto/onnx/ge_onnx.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/attr_value.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/function.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/graph.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/node_def.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/op_def.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/resource_handle.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/tensor.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/tensor_shape.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/types.proto" + "${GE_CODE_DIR}/metadef/proto/tensorflow/versions.proto" + ) + +protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) + +# ---- File glob by group ---- + +file(GLOB_RECURSE METADEF_SRCS CONFIGURE_DEPENDS + "${GE_CODE_DIR}/metadef/graph/*.cc" + "${GE_CODE_DIR}/metadef/register/*.cc" + "${GE_CODE_DIR}/metadef/register/*.cpp" + "${GE_CODE_DIR}/metadef/ops/*.cc" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/*.cc" +) +file(GLOB_RECURSE METADEF_REGISTER_SRCS CONFIGURE_DEPENDS + "${GE_CODE_DIR}/metadef/register/*.cc" + "${GE_CODE_DIR}/metadef/register/*.cpp" +) + +file(GLOB_RECURSE PARSER_SRCS CONFIGURE_DEPENDS + "${GE_CODE_DIR}/parser/parser/common/*.cc" +) + +file(GLOB_RECURSE LOCAL_ENGINE_SRC CONFIGURE_DEPENDS + "${GE_CODE_DIR}/ge/ge_local_engine/*.cc" +) +list(REMOVE_ITEM LOCAL_ENGINE_SRC + "${GE_CODE_DIR}/ge/ge_local_engine/engine/host_cpu_engine.cc") + + +file(GLOB_RECURSE HOST_ENGINE_SRC CONFIGURE_DEPENDS + "${GE_CODE_DIR}/ge/host_cpu_engine/*.cc" +) + +file(GLOB_RECURSE NN_ENGINE_SRC CONFIGURE_DEPENDS + "${GE_CODE_DIR}/ge/plugin/*.cc" +) + +file(GLOB_RECURSE OFFLINE_SRC CONFIGURE_DEPENDS + "${GE_CODE_DIR}/ge/offline/*.cc" +) + +file(GLOB_RECURSE GE_SRCS CONFIGURE_DEPENDS + "${GE_CODE_DIR}/ge/*.cc" +) +file(GLOB_RECURSE GE_SUB_ENGINE_SRCS CONFIGURE_DEPENDS + "${GE_CODE_DIR}/ge/ge_local_engine/engine/host_cpu_engine.cc" + ) + +list(REMOVE_ITEM GE_SRCS ${LOCAL_ENGINE_SRC} ${HOST_ENGINE_SRC} ${NN_ENGINE_SRC} ${OFFLINE_SRC}) +list(APPEND GE_SRCS ${GE_SUB_ENGINE_SRCS}) + +list(APPEND INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_SOURCE_DIR}" + "${GE_CODE_DIR}" + "${GE_CODE_DIR}/inc" + "${GE_CODE_DIR}/metadef/inc" + "${GE_CODE_DIR}/ge" + "${GE_CODE_DIR}/ge/inc" + "${GE_CODE_DIR}/ge/ir_build" + "${GE_CODE_DIR}/metadef" + "${GE_CODE_DIR}/metadef/graph" + "${GE_CODE_DIR}/inc/external" + "${GE_CODE_DIR}/inc/framework/common" + "${GE_CODE_DIR}/metadef/inc/external" + "${GE_CODE_DIR}/metadef/inc/external/graph" + "${GE_CODE_DIR}/metadef/inc/graph" + "${GE_CODE_DIR}/inc/framework" + "${GE_CODE_DIR}/metadef/inc/common" + "${GE_CODE_DIR}/metadef/third_party" + "${GE_CODE_DIR}/metadef/third_party/transformer/inc" + "${GE_CODE_DIR}/parser" + "${GE_CODE_DIR}/parser/parser" + "${GE_CODE_DIR}/third_party/fwkacllib/inc" + "${GE_CODE_DIR}/third_party/fwkacllib/inc/cce" + "${GE_CODE_DIR}/third_party/fwkacllib/inc/ops" + "${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain" + "${GE_CODE_DIR}/tests/ut/ge" + "${GE_CODE_DIR}/tests/ut/common" + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/proto/ge" + "${CMAKE_BINARY_DIR}/proto/ge/proto" +) + +list(APPEND STUB_LIBS + c_sec + slog_stub + cce_ge_stub + runtime_stub + profiler_stub + hccl_stub + error_manager_stub + ascend_protobuf + json +) + +# ---- Target : metadef graph ---- + +add_library(metadef_graph SHARED ${METADEF_SRCS} ${PROTO_SRCS}) + +target_include_directories(metadef_graph + PUBLIC + "${INCLUDE_DIRECTORIES}" + ) + +target_compile_definitions(metadef_graph PRIVATE + google=ascend_private + FMK_SUPPORT_DUMP + ) + +target_compile_options(metadef_graph PRIVATE + -g --coverage -fprofile-arcs -ftest-coverage + -Werror=format + ) + +target_link_libraries(metadef_graph PUBLIC + $ ${STUB_LIBS} + mmpa -L${GE_CODE_DIR}/third_party/prebuild/x86_64 -lrt -ldl -lpthread -lgcov + ) + +set_target_properties(metadef_graph PROPERTIES CXX_STANDARD 11) + +# ---- Target : Local engine ---- + +add_library(ge_local_engine SHARED ${LOCAL_ENGINE_SRC} ${METADEF_REGISTER_SRCS}) + +target_include_directories(ge_local_engine + PUBLIC + "${INCLUDE_DIRECTORIES}" + "${GE_CODE_DIR}/ge/ge_local_engine" + ) + +target_compile_definitions(ge_local_engine PRIVATE + google=ascend_private + ) + +target_compile_options(ge_local_engine PRIVATE + -g --coverage -fprofile-arcs -ftest-coverage + -Werror=format + ) + +target_link_libraries(ge_local_engine PUBLIC + $ ${STUB_LIBS} + metadef_graph + -lrt -ldl -lpthread -lgcov + ) + +set_target_properties(ge_local_engine PROPERTIES CXX_STANDARD 11) + +# ---- Target : Host engine ---- + +add_library(host_cpu_engine SHARED ${HOST_ENGINE_SRC}) + +target_include_directories(host_cpu_engine + PUBLIC + "${INCLUDE_DIRECTORIES}" + "${GE_CODE_DIR}/ge/host_cpu_engine" +) + +target_compile_definitions(host_cpu_engine PRIVATE + google=ascend_private + FMK_SUPPORT_DUMP +) + +target_compile_options(host_cpu_engine PRIVATE + -g --coverage -fprofile-arcs -ftest-coverage + -Werror=format +) + +target_link_libraries(host_cpu_engine PUBLIC + $ ${STUB_LIBS} metadef_graph -lrt -ldl -lpthread -lgcov +) + +set_target_properties(host_cpu_engine PROPERTIES CXX_STANDARD 11) + +# ---- Target : engine plugin---- +# + +add_library(nnengine SHARED ${NN_ENGINE_SRC}) + +target_include_directories(nnengine + PUBLIC + "${INCLUDE_DIRECTORIES}" + "${GE_CODE_DIR}/ge/plugin/engine" +) + +target_compile_definitions(nnengine PRIVATE + google=ascend_private +) + +target_compile_options(nnengine PRIVATE + -g --coverage -fprofile-arcs -ftest-coverage + -Werror=format +) + +target_link_libraries(nnengine PUBLIC + $ ${STUB_LIBS} -lrt -ldl -lpthread -lgcov +) + +set_target_properties(nnengine PROPERTIES CXX_STANDARD 11) + +# Targe: engine_conf +add_custom_target( + engine_conf.json ALL + DEPENDS ${CMAKE_BINARY_DIR}/engine_conf.json +) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/engine_conf.json + COMMAND cp ${GE_CODE_DIR}/ge/engine_manager/engine_conf.json ${CMAKE_BINARY_DIR}/ +) +# Targe: optimizer priority +add_custom_target( + optimizer_priority.pbtxt ALL + DEPENDS ${CMAKE_BINARY_DIR}/optimizer_priority.pbtxt +) +add_custom_command( + OUTPUT ${CMAKE_BINARY_DIR}/optimizer_priority.pbtxt + COMMAND cp ${GE_CODE_DIR}/ge/opskernel_manager/optimizer_priority.pbtxt ${CMAKE_BINARY_DIR}/ +) + +# ---- Target : Graph engine ---- + +add_library(graphengine STATIC ${PARSER_SRCS} ${GE_SRCS}) + +target_include_directories(graphengine + PUBLIC + "${INCLUDE_DIRECTORIES}" + "${GE_CODE_DIR}/ge/host_cpu_engine" +) + +target_compile_definitions(graphengine PRIVATE + google=ascend_private + FMK_SUPPORT_DUMP +) + +target_compile_options(graphengine PRIVATE + -g --coverage -fprofile-arcs -ftest-coverage + -Werror=format +) + +target_link_libraries(graphengine PUBLIC + $ ${STUB_LIBS} + metadef_graph + -lrt -ldl -lpthread -lgcov +) + +set_target_properties(graphengine PROPERTIES CXX_STANDARD 11) +add_dependencies(graphengine host_cpu_engine ge_local_engine nnengine engine_conf.json optimizer_priority.pbtxt) diff --git a/tests/framework/easy_graph/CMakeLists.txt b/tests/framework/easy_graph/CMakeLists.txt new file mode 100644 index 00000000..124cd344 --- /dev/null +++ b/tests/framework/easy_graph/CMakeLists.txt @@ -0,0 +1,26 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +file(GLOB_RECURSE EASY_GRAPH_SRCS src/*.cc) + +add_library(easy_graph STATIC ${EASY_GRAPH_SRCS}) + +target_link_libraries(easy_graph PUBLIC + $ ) + +set_target_properties(easy_graph PROPERTIES CXX_STANDARD 17) + +target_include_directories(easy_graph PUBLIC include + PRIVATE src) \ No newline at end of file diff --git a/tests/framework/easy_graph/include/easy_graph/builder/box_builder.h b/tests/framework/easy_graph/include/easy_graph/builder/box_builder.h new file mode 100644 index 00000000..78da155b --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/builder/box_builder.h @@ -0,0 +1,40 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HE7D53295_59F0_46B0_A881_D6A33B1F9C14 +#define HE7D53295_59F0_46B0_A881_D6A33B1F9C14 + +#include +#include "easy_graph/graph/box.h" + +EG_NS_BEGIN + +namespace detail { +template +struct BoxWrapper : Anything, Box { + using Anything::Anything; +}; + +template +using BoxedAnything = std::conditional_t, Anything, BoxWrapper>; +} // namespace detail + +#define BOX_WRAPPER(Anything) ::EG_NS::detail::BoxedAnything +#define BOX_OF(Anything, ...) ::EG_NS::BoxPacking(__VA_ARGS__) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/builder/chain_builder.h b/tests/framework/easy_graph/include/easy_graph/builder/chain_builder.h new file mode 100644 index 00000000..7e4829d0 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/builder/chain_builder.h @@ -0,0 +1,81 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HDF50E564_F050_476A_A479_F82B20F35C84 +#define HDF50E564_F050_476A_A479_F82B20F35C84 + +#include "easy_graph/builder/link.h" +#include "easy_graph/graph/node_id.h" +#include "easy_graph/graph/node.h" + +EG_NS_BEGIN + +struct GraphBuilder; +struct Graph; +struct Edge; + +struct ChainBuilder { + ChainBuilder(GraphBuilder &graphBuilder, EdgeType defaultEdgeType); + + struct LinkBuilder { + using NodeObj = ::EG_NS::Node; + using EdgeObj = ::EG_NS::Edge; + + LinkBuilder(ChainBuilder &chain, EdgeType defaultEdgeType); + + ChainBuilder &Node(const NodeObj &node); + + template + ChainBuilder &Node(const NodeId &id, const PARAMS &... params) { + auto node = chain_.FindNode(id); + if (node) { + return this->Node(*node); + } + return this->Node(NodeObj(id, params...)); + } + + ChainBuilder &Ctrl(const std::string &label = ""); + ChainBuilder &Data(const std::string &label = ""); + + ChainBuilder &Data(PortId srcId = UNDEFINED_PORT_ID, PortId dstId = UNDEFINED_PORT_ID, + const std::string &label = ""); + + ChainBuilder &Edge(EdgeType type, PortId srcId = UNDEFINED_PORT_ID, PortId dstId = UNDEFINED_PORT_ID, + const std::string &label = ""); + + private: + ChainBuilder &startLink(const Link &); + + private: + ChainBuilder &chain_; + EdgeType default_edge_type_; + Link from_link_; + } linker; + + LinkBuilder *operator->(); + + private: + ChainBuilder &LinkTo(const Node &, const Link &); + const Node *FindNode(const NodeId &) const; + + private: + Node *prev_node_{nullptr}; + GraphBuilder &graph_builder_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/builder/graph_builder.h b/tests/framework/easy_graph/include/easy_graph/builder/graph_builder.h new file mode 100644 index 00000000..d55ed7ca --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/builder/graph_builder.h @@ -0,0 +1,64 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H5FED5F58_167D_4536_918A_D5FE8F28DD9C +#define H5FED5F58_167D_4536_918A_D5FE8F28DD9C + +#include "easy_graph/graph/graph.h" + +EG_NS_BEGIN + +struct Link; + +struct GraphBuilder { + GraphBuilder(const std::string &name); + + Node *BuildNode(const Node &); + Edge *BuildEdge(const Node &src, const Node &dst, const Link &); + + Graph &operator*() { + return graph_; + } + + const Graph &operator*() const { + return graph_; + } + + Graph *operator->() { + return &graph_; + } + + const Graph *operator->() const { + return &graph_; + } + + private: + struct NodeInfo { + PortId inPortMax{0}; + PortId outPortMax{0}; + }; + + NodeInfo *FindNode(const NodeId &); + const NodeInfo *FindNode(const NodeId &) const; + + private: + std::map nodes_; + Graph graph_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/builder/graph_dsl.h b/tests/framework/easy_graph/include/easy_graph/builder/graph_dsl.h new file mode 100644 index 00000000..4d430983 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/builder/graph_dsl.h @@ -0,0 +1,45 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H46D07001_D54E_497C_B1BA_878A47164DA5 +#define H46D07001_D54E_497C_B1BA_878A47164DA5 + +#include "easy_graph/builder/graph_builder.h" +#include "easy_graph/builder/chain_builder.h" +#include "easy_graph/builder/box_builder.h" +#include "easy_graph/infra/macro_traits.h" + +EG_NS_BEGIN + +//////////////////////////////////////////////////////////////// +namespace detail { +template +Graph BuildGraph(const char *name, GRAPH_BUILDER builderInDSL) { + GraphBuilder builder(name); + builderInDSL(builder); + return std::move(*builder); +} +} // namespace detail + +#define HAS_NAME(...) NOT_EMPTY_SELECT(__VA_ARGS__) +#define DEF_GRAPH(G, ...) ::EG_NS::Graph G = ::EG_NS::detail::BuildGraph(HAS_NAME(__VA_ARGS__)(__VA_ARGS__, #G), [&](::EG_NS::GraphBuilder& BUILDER) +#define DATA_CHAIN(...) ::EG_NS::ChainBuilder(BUILDER, ::EG_NS::EdgeType::DATA)->__VA_ARGS__ +#define CTRL_CHAIN(...) ::EG_NS::ChainBuilder(BUILDER, ::EG_NS::EdgeType::CTRL)->__VA_ARGS__ +#define CHAIN(...) DATA_CHAIN(__VA_ARGS__) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/builder/link.h b/tests/framework/easy_graph/include/easy_graph/builder/link.h new file mode 100644 index 00000000..83c6de69 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/builder/link.h @@ -0,0 +1,49 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H35695B82_E9E5_419D_A6B4_C13FB0842C9F +#define H35695B82_E9E5_419D_A6B4_C13FB0842C9F + +#include +#include "easy_graph/graph/edge_type.h" +#include "easy_graph/graph/port_id.h" + +EG_NS_BEGIN + +struct Link { + explicit Link(EdgeType type) : type_(type) { + Reset(type); + } + + Link(EdgeType type, const std::string &label, PortId srcPortId, PortId dstPortId) + : type_(type), label_(label), src_port_id_(srcPortId), dst_port_id_(dstPortId) {} + + void Reset(EdgeType type) { + this->type_ = type; + this->label_ = ""; + this->src_port_id_ = UNDEFINED_PORT_ID; + this->dst_port_id_ = UNDEFINED_PORT_ID; + } + + EdgeType type_; + std::string label_; + PortId src_port_id_; + PortId dst_port_id_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/eg.h b/tests/framework/easy_graph/include/easy_graph/eg.h new file mode 100644 index 00000000..ac96daf8 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/eg.h @@ -0,0 +1,29 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H04F67145_86B2_4529_BC2E_EBDB2115687E +#define H04F67145_86B2_4529_BC2E_EBDB2115687E + +#define EG_NS eg +#define EG_NS_BEGIN namespace EG_NS { +#define EG_NS_END } +#define USING_EG_NS using namespace EG_NS; +#define FWD_DECL_EG(type) \ + namespace EG_NS { \ + struct type; \ + } + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/box.h b/tests/framework/easy_graph/include/easy_graph/graph/box.h new file mode 100644 index 00000000..cdb55960 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/box.h @@ -0,0 +1,41 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H4AA49861_3311_4114_8687_1C7D04FA43B9 +#define H4AA49861_3311_4114_8687_1C7D04FA43B9 + +#include +#include "easy_graph/infra/keywords.h" + +EG_NS_BEGIN + +INTERFACE(Box){}; + +using BoxPtr = std::shared_ptr; + +template +BoxPtr BoxPacking(Args &&... args) { + return std::make_shared(std::forward(args)...); +} + +template +Anything *BoxUnpacking(const BoxPtr &box) { + return dynamic_cast(box.get()); +} + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/edge.h b/tests/framework/easy_graph/include/easy_graph/graph/edge.h new file mode 100644 index 00000000..f4066b8b --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/edge.h @@ -0,0 +1,46 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HE62943BF_1F7C_4EF9_B306_D9C94634EA74 +#define HE62943BF_1F7C_4EF9_B306_D9C94634EA74 + +#include +#include "easy_graph/graph/edge_type.h" +#include "easy_graph/graph/endpoint.h" + +EG_NS_BEGIN + +struct Edge { + Edge(const EdgeType type, const std::string &label, const Endpoint &src, const Endpoint &dst); + + __DECL_COMP(Edge); + + EdgeType GetType() const; + std::string GetLabel() const; + + Endpoint GetSrc() const; + Endpoint GetDst() const; + + private: + std::string label_; + EdgeType type_; + Endpoint src_; + Endpoint dst_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/edge_type.h b/tests/framework/easy_graph/include/easy_graph/graph/edge_type.h new file mode 100644 index 00000000..f7c482c0 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/edge_type.h @@ -0,0 +1,31 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H19D3F004_119F_4E6A_ACFA_A635FD6FEA98 +#define H19D3F004_119F_4E6A_ACFA_A635FD6FEA98 + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +enum class EdgeType { + CTRL = 0, + DATA, +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/endpoint.h b/tests/framework/easy_graph/include/easy_graph/graph/endpoint.h new file mode 100644 index 00000000..a595b039 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/endpoint.h @@ -0,0 +1,41 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H8DB48A37_3257_4E15_8869_09E58221ADE8 +#define H8DB48A37_3257_4E15_8869_09E58221ADE8 + +#include "easy_graph/graph/node_id.h" +#include "easy_graph/graph/port_id.h" +#include "easy_graph/infra/operator.h" + +EG_NS_BEGIN + +struct Endpoint { + Endpoint(const NodeId &, const PortId &); + + __DECL_COMP(Endpoint); + + NodeId getNodeId() const; + PortId getPortId() const; + + private: + NodeId node_id_; + PortId port_id_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/graph.h b/tests/framework/easy_graph/include/easy_graph/graph/graph.h new file mode 100644 index 00000000..f967b649 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/graph.h @@ -0,0 +1,58 @@ +#ifndef H813EC8C1_3850_4320_8AC0_CE071C89B871 +#define H813EC8C1_3850_4320_8AC0_CE071C89B871 + +#include "easy_graph/graph/node.h" +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/graph/edge.h" +#include "easy_graph/infra/status.h" +#include +#include +#include + +EG_NS_BEGIN + +struct GraphVisitor; +struct LayoutOption; + +struct Graph { + explicit Graph(const std::string &name); + + std::string GetName() const; + + Node *AddNode(const Node &); + Edge *AddEdge(const Edge &); + + Node *FindNode(const NodeId &); + const Node *FindNode(const NodeId &) const; + + std::pair FindNodePair(const Edge &) const; + std::pair FindNodePair(const Edge &); + + void Accept(GraphVisitor &) const; + + Status Layout(const LayoutOption *option = nullptr) const; + + private: + std::string name_; + std::map nodes_; + std::set edges_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/graph_visitor.h b/tests/framework/easy_graph/include/easy_graph/graph/graph_visitor.h new file mode 100644 index 00000000..4d4ad408 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/graph_visitor.h @@ -0,0 +1,37 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H13960AED_B5B1_45F9_A664_6CB6C15CA3C1 +#define H13960AED_B5B1_45F9_A664_6CB6C15CA3C1 + +#include "easy_graph/infra/keywords.h" +#include "easy_graph/infra/status.h" + +EG_NS_BEGIN + +struct Graph; +struct Node; +struct Edge; + +INTERFACE(GraphVisitor) { + DEFAULT(Status, Visit(const Graph &)); + DEFAULT(Status, Visit(const Node &)); + DEFAULT(Status, Visit(const Edge &)); +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/node.h b/tests/framework/easy_graph/include/easy_graph/graph/node.h new file mode 100644 index 00000000..5f7f46e1 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/node.h @@ -0,0 +1,62 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HF37ACE88_F726_4AA3_8599_ED7A888AA623 +#define HF37ACE88_F726_4AA3_8599_ED7A888AA623 + +#include +#include "easy_graph/graph/node_id.h" +#include "easy_graph/infra/operator.h" +#include "easy_graph/infra/ext_traits.h" +#include "easy_graph/graph/box.h" + +EG_NS_BEGIN + +struct GraphVisitor; +struct Graph; + +struct Node { + template + Node(const NodeId &id, const GRAPHS &... graphs) : id_(id), subgraphs_{&graphs...} {} + + template + Node(const NodeId &id, const BoxPtr &box, const GRAPHS &... graphs) : id_(id), box_(box), subgraphs_{&graphs...} {} + + __DECL_COMP(Node); + + NodeId GetId() const; + + Node &Packing(const BoxPtr &); + + template + Anything *Unpacking() const { + if (!box_) + return nullptr; + return BoxUnpacking(box_); + } + + Node &AddSubgraph(const Graph &); + void Accept(GraphVisitor &) const; + + private: + NodeId id_; + BoxPtr box_; + std::vector subgraphs_; +}; + +EG_NS_END + +#endif diff --git a/ge/host_cpu_engine/common/constant/constant.h b/tests/framework/easy_graph/include/easy_graph/graph/node_id.h similarity index 57% rename from ge/host_cpu_engine/common/constant/constant.h rename to tests/framework/easy_graph/include/easy_graph/graph/node_id.h index b9603b6a..8c98e8da 100644 --- a/ge/host_cpu_engine/common/constant/constant.h +++ b/tests/framework/easy_graph/include/easy_graph/graph/node_id.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,17 +14,16 @@ * limitations under the License. */ -#ifndef GE_HOST_CPU_ENGINE_COMMON_CONSTANT_CONSTANT_H_ -#define GE_HOST_CPU_ENGINE_COMMON_CONSTANT_CONSTANT_H_ +#ifndef HB53D0830_615F_4E4A_8531_77E2A177717D +#define HB53D0830_615F_4E4A_8531_77E2A177717D #include +#include "easy_graph/eg.h" -namespace ge { -namespace host_cpu { -// engine name -const char kHostCpuEngineName[] = "DNN_VM_HOST_CPU"; -const char kHostCpuOpKernelLibName[] = "DNN_VM_HOST_CPU_OP_STORE"; -} // namespace host_cpu -} // namespace ge +EG_NS_BEGIN -#endif // GE_HOST_CPU_ENGINE_COMMON_CONSTANT_CONSTANT_H_ +typedef std::string NodeId; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/graph/port_id.h b/tests/framework/easy_graph/include/easy_graph/graph/port_id.h new file mode 100644 index 00000000..4c82cfae --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/graph/port_id.h @@ -0,0 +1,30 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HC8732748_F658_4759_9284_CC13C0BFE6D4 +#define HC8732748_F658_4759_9284_CC13C0BFE6D4 + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +typedef unsigned int PortId; + +static const PortId UNDEFINED_PORT_ID = 0xFFFFFFFF; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/default.h b/tests/framework/easy_graph/include/easy_graph/infra/default.h new file mode 100644 index 00000000..124cb89b --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/default.h @@ -0,0 +1,59 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H05B2224D_B926_4FC0_A936_77B52B8A98DB +#define H05B2224D_B926_4FC0_A936_77B52B8A98DB + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +namespace details { +template +struct DefaultValue { + static T value() { + return T(); + } +}; + +template +struct DefaultValue { + static T *value() { + return 0; + } +}; + +template +struct DefaultValue { + static T *value() { + return 0; + } +}; + +template<> +struct DefaultValue { + static void value() {} +}; +} // namespace details + +#define DEFAULT(type, method) \ + virtual type method { \ + return ::EG_NS::details::DefaultValue::value(); \ + } + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/ext_traits.h b/tests/framework/easy_graph/include/easy_graph/infra/ext_traits.h new file mode 100644 index 00000000..6f637658 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/ext_traits.h @@ -0,0 +1,39 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HF25A2E8D_A775_44BF_88D1_166DFF56186A +#define HF25A2E8D_A775_44BF_88D1_166DFF56186A + +#include +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +template +using all_same_traits = typename std::enable_if...>::value>::type; + +template +using all_same_but_none_traits = typename std::enable_if< + std::disjunction, std::conjunction...>>::value>::type; + +#define ALL_SAME_CONCEPT(TS, T) all_same_traits * = nullptr +#define ALL_SAME_BUT_NONE_CONCEPT(TS, T) ::EG_NS::all_same_but_none_traits * = nullptr + +#define SUBGRAPH_CONCEPT(GS, G) ALL_SAME_BUT_NONE_CONCEPT(GS, G) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/keywords.h b/tests/framework/easy_graph/include/easy_graph/infra/keywords.h new file mode 100644 index 00000000..6adf9a14 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/keywords.h @@ -0,0 +1,42 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H05B2224D_B926_4FC0_A936_97B52B8A98DB +#define H05B2224D_B926_4FC0_A936_97B52B8A98DB + +#include "easy_graph/infra/default.h" + +EG_NS_BEGIN + +namespace details { +template +struct Interface { + virtual ~Interface() {} +}; +} // namespace details + +#define INTERFACE(Intf) struct Intf : ::EG_NS::details::Interface + +#define ABSTRACT(...) virtual __VA_ARGS__ = 0 + +#define OVERRIDE(...) virtual __VA_ARGS__ override + +#define EXTENDS(...) , ##__VA_ARGS__ +#define IMPLEMENTS(...) EXTENDS(__VA_ARGS__) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/log.h b/tests/framework/easy_graph/include/easy_graph/infra/log.h new file mode 100644 index 00000000..0ff269d9 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/log.h @@ -0,0 +1,64 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H38247538_297F_4A80_94D3_8A289788461B +#define H38247538_297F_4A80_94D3_8A289788461B + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +enum EgLogLevel { + EG_NONE_LEVEL = 0x0, + EG_DEBUG_LEVEL = 0x01, + EG_INFO_LEVEL = 0x02, + EG_SUCC_LEVEL = 0x04, + EG_WARN_LEVEL = 0x08, + EG_ERR_LEVEL = 0x10, + EG_FATAL_LEVEL = 0x20, + EG_TOTAL_LEVEL = 0xFF +}; + +#define EG_LOG_LEVELS (EG_FATAL_LEVEL | EG_ERR_LEVEL | EG_WARN_LEVEL | EG_INFO_LEVEL) + +///////////////////////////////////////////////////////////////// + +void eg_log(int level, const char *levelstr, const char *file, unsigned int line, const char *fmt, ...); + +#define EG_LOG_OUTPUT eg_log + +#define __EG_LOG_TITLE(level, levelstr, fmt, ...) \ + do { \ + if (level & EG_LOG_LEVELS) { \ + EG_LOG_OUTPUT(level, levelstr, __FILE__, __LINE__, fmt, ##__VA_ARGS__); \ + } \ + } while (0) + +#define EG_FATAL(fmt, ...) __EG_LOG_TITLE(EG_FATAL_LEVEL, "FATAL", fmt, ##__VA_ARGS__) + +#define EG_ERR(fmt, ...) __EG_LOG_TITLE(EG_ERR_LEVEL, "ERROR", fmt, ##__VA_ARGS__) + +#define EG_WARN(fmt, ...) __EG_LOG_TITLE(EG_WARN_LEVEL, "WARN", fmt, ##__VA_ARGS__) + +#define EG_SUCC(fmt, ...) __EG_LOG_TITLE(EG_SUCC_LEVEL, "SUCC", fmt, ##__VA_ARGS__) + +#define EG_INFO(fmt, ...) __EG_LOG_TITLE(EG_INFO_LEVEL, "INFO", fmt, ##__VA_ARGS__) + +#define EG_DBG(fmt, ...) __EG_LOG_TITLE(EG_DEBUG_LEVEL, "DEBUG", fmt, ##__VA_ARGS__) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/macro_traits.h b/tests/framework/easy_graph/include/easy_graph/infra/macro_traits.h new file mode 100644 index 00000000..f8ef2495 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/macro_traits.h @@ -0,0 +1,58 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H7DA4A075_246A_4DD6_B1BB_ECA3806C9483 +#define H7DA4A075_246A_4DD6_B1BB_ECA3806C9483 + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +//////////////////////////////////////////////////////////////////////// + +#define VA_ARGS_NUM(...) \ + VA_ARGS_NUM_PRIVATE(0, ##__VA_ARGS__, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, \ + 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, \ + 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0) + +#define VA_ARGS_NUM_PRIVATE(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, \ + _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34, _35, _36, _37, \ + _38, _39, _40, _41, _42, _43, _44, _45, _46, _47, _48, _49, _50, _51, _52, _53, _54, _55, \ + _56, _57, _58, _59, _60, _61, _62, _63, _64, N, ...) \ + N + +//////////////////////////////////////////////////////////////////////// + +#define __MACRO_CONCAT(x, y) x##y +#define MACRO_CONCAT(x, y) __MACRO_CONCAT(x, y) + +#define __MACRO_SECOND(FIRST, SECOND, ...) SECOND +#define MACRO_SECOND(...) __MACRO_SECOND(__VA_ARGS__) + +#define MACRO_VERIFY_FIRST(...) MACRO_SECOND(__VA_ARGS__, 1) + +#define MACRO_BOOL_0 MACRO_DUMMY, 0 +#define MACRO_BOOL(N) MACRO_VERIFY_FIRST(__MACRO_CONCAT(MACRO_BOOL_, N)) + +#define MACRO_CONDITION_0(TRUE_BRANCH, FALSE_BRANCH) FALSE_BRANCH +#define MACRO_CONDITION_1(TRUE_BRANCH, FALSE_BRANCH) TRUE_BRANCH +#define MACRO_CONDITION(N) MACRO_CONCAT(MACRO_CONDITION_, MACRO_BOOL(N)) + +#define NOT_EMPTY_SELECT(...) MACRO_CONDITION(VA_ARGS_NUM(__VA_ARGS__)) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/operator.h b/tests/framework/easy_graph/include/easy_graph/infra/operator.h new file mode 100644 index 00000000..41d794ff --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/operator.h @@ -0,0 +1,68 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H05B2224D_B927_4FC0_A936_97B52B8A99DB +#define H05B2224D_B927_4FC0_A936_97B52B8A99DB + +////////////////////////////////////////////////////////////// +#define __DECL_EQUALS(cls) \ + bool operator!=(const cls &rhs) const; \ + bool operator==(const cls &rhs) const + +////////////////////////////////////////////////////////////// +#define __FIELD_EQ(name) this->name == rhs.name +#define __FIELD_LT(name) this->name < rhs.name + +////////////////////////////////////////////////////////////// +#define __SUPER_EQ(super) static_cast(*this) == rhs +#define __SUPER_LT(super) static_cast(*this) < rhs + +////////////////////////////////////////////////////////////// +#define __DEF_EQUALS(cls) \ + bool cls::operator!=(const cls &rhs) const { \ + return !(*this == rhs); \ + } \ + bool cls::operator==(const cls &rhs) const + +///////////////////////////////////////////////////////////// +#define __INLINE_EQUALS(cls) \ + bool operator!=(const cls &rhs) const { \ + return !(*this == rhs); \ + } \ + bool operator==(const cls &rhs) const + +///////////////////////////////////////////////////////////// +#define __DECL_COMP(cls) \ + __DECL_EQUALS(cls); \ + bool operator<(const cls &) const; \ + bool operator>(const cls &) const; \ + bool operator<=(const cls &) const; \ + bool operator>=(const cls &) const + +///////////////////////////////////////////////////////////// +#define __DEF_COMP(cls) \ + bool cls::operator>(const cls &rhs) const { \ + return !(*this <= rhs); \ + } \ + bool cls::operator>=(const cls &rhs) const { \ + return !(*this < rhs); \ + } \ + bool cls::operator<=(const cls &rhs) const { \ + return (*this < rhs) || (*this == rhs); \ + } \ + bool cls::operator<(const cls &rhs) const + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/scope_guard.h b/tests/framework/easy_graph/include/easy_graph/infra/scope_guard.h new file mode 100644 index 00000000..4d4068fc --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/scope_guard.h @@ -0,0 +1,41 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H187A4A00_BD91_4B9D_8DD9_3D6C9EA15854 +#define H187A4A00_BD91_4B9D_8DD9_3D6C9EA15854 + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +template +struct ScopeGuard { + ScopeGuard(BEGIN begin, END end) : begin(begin), end(end) { + begin(); + } + + ~ScopeGuard() { + end(); + } + + private: + BEGIN begin; + END end; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/singleton.h b/tests/framework/easy_graph/include/easy_graph/infra/singleton.h new file mode 100644 index 00000000..72fa3b66 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/singleton.h @@ -0,0 +1,42 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HD18A3E42_2801_4BEB_B365_03633D1D81C4 +#define HD18A3E42_2801_4BEB_B365_03633D1D81C4 + +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +template +struct Singleton { + static T &GetInstance() { + static T instance; + return instance; + } + + Singleton(const Singleton &) = delete; + Singleton &operator=(const Singleton &) = delete; + + protected: + Singleton() {} +}; + +#define SINGLETON(object) struct object : ::EG_NS::Singleton + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/infra/status.h b/tests/framework/easy_graph/include/easy_graph/infra/status.h new file mode 100644 index 00000000..3cef8c8a --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/infra/status.h @@ -0,0 +1,55 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HA25033D6_1564_4748_B2C8_4DE2C5A286DE +#define HA25033D6_1564_4748_B2C8_4DE2C5A286DE + +#include +#include +#include "easy_graph/eg.h" + +EG_NS_BEGIN + +typedef uint32_t Status; + +#define EG_SUCC_STATUS(status) (EG_NS::Status) status +#define EG_FAIL_STATUS(status) (EG_NS::Status)(status | EG_RESERVED_FAIL) + +/* OK */ +#define EG_SUCCESS EG_SUCC_STATUS(0) + +/* Error Status */ +#define EG_RESERVED_FAIL (EG_NS::Status) 0x80000000 +#define EG_FAILURE EG_FAIL_STATUS(1) +#define EG_FATAL_BUG EG_FAIL_STATUS(2) +#define EG_TIMEDOUT EG_FAIL_STATUS(3) +#define EG_OUT_OF_RANGE EG_FAIL_STATUS(4) +#define EG_UNIMPLEMENTED EG_FAIL_STATUS(5) + +static inline bool eg_status_is_ok(Status status) { + return (status & EG_RESERVED_FAIL) == 0; +} + +static inline bool eg_status_is_fail(Status status) { + return !eg_status_is_ok(status); +} + +#define __EG_FAILED(result) eg_status_is_fail(result) +#define __EG_OK(result) eg_status_is_ok(result) + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_executor.h b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_executor.h new file mode 100644 index 00000000..43836f66 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_executor.h @@ -0,0 +1,31 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HAC96EB3A_2169_4BB0_A8EB_7B966C262B2F +#define HAC96EB3A_2169_4BB0_A8EB_7B966C262B2F + +#include "easy_graph/layout/layout_executor.h" + +EG_NS_BEGIN + +struct GraphEasyExecutor : LayoutExecutor { + private: + Status Layout(const Graph &, const LayoutOption *) override; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_layout_context.h b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_layout_context.h new file mode 100644 index 00000000..b9fc8e46 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_layout_context.h @@ -0,0 +1,53 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HB8CC77BE_6A2E_4EB4_BE59_CA85DE56C027 +#define HB8CC77BE_6A2E_4EB4_BE59_CA85DE56C027 + +#include "easy_graph/eg.h" +#include +#include + +EG_NS_BEGIN + +struct GraphEasyOption; +struct Graph; + +struct GraphEasyLayoutContext { + GraphEasyLayoutContext(const GraphEasyOption &); + + const Graph *GetCurrentGraph() const; + + void EnterGraph(const Graph &); + void ExitGraph(); + + void LinkBegin(); + void LinkEnd(); + + bool InLinking() const; + + std::string GetGroupPath() const; + const GraphEasyOption &GetOptions() const; + + private: + std::deque graphs_; + const GraphEasyOption &options_; + bool is_linking_{false}; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_option.h b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_option.h new file mode 100644 index 00000000..33690ae8 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_option.h @@ -0,0 +1,63 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H37156CC2_92BD_44DA_8DA7_A11629E762BE +#define H37156CC2_92BD_44DA_8DA7_A11629E762BE + +#include "easy_graph/layout/layout_option.h" +#include + +EG_NS_BEGIN + +enum class FlowDir { + LR = 0, + TB, +}; + +enum class LayoutType { + FREE = 0, + REGULAR, +}; + +enum class LayoutFormat { + ASCII = 0, + BOXART, + SVG, + DOT, + HTML, +}; + +enum class LayoutOutput { + CONSOLE = 0, + FILE, +}; + +struct GraphEasyOption : LayoutOption { + static const GraphEasyOption &GetDefault(); + + std::string GetLayoutCmdArgs(const std::string &graphName) const; + + LayoutFormat format_{LayoutFormat::BOXART}; + LayoutOutput output_{LayoutOutput::CONSOLE}; + FlowDir dir_{FlowDir::LR}; + LayoutType type_{LayoutType::FREE}; + size_t scale_{1}; + std::string output_path_{"./"}; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_visitor.h b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_visitor.h new file mode 100644 index 00000000..56a6211f --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/engines/graph_easy/graph_easy_visitor.h @@ -0,0 +1,45 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HB6783151_C24E_4DA3_B969_46C2298FF43F +#define HB6783151_C24E_4DA3_B969_46C2298FF43F + +#include +#include "easy_graph/graph/graph_visitor.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_layout_context.h" + +EG_NS_BEGIN + +struct GraphEasyOption; + +struct GraphEasyVisitor : GraphVisitor { + GraphEasyVisitor(const GraphEasyOption &); + + std::string GetLayout() const; + + private: + Status Visit(const Graph &) override; + Status Visit(const Node &) override; + Status Visit(const Edge &) override; + + private: + std::string layout_; + GraphEasyLayoutContext ctxt_; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/graph_layout.h b/tests/framework/easy_graph/include/easy_graph/layout/graph_layout.h new file mode 100644 index 00000000..bd0c71af --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/graph_layout.h @@ -0,0 +1,40 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H550E4ACB_BEC7_4E71_8C6F_CD7FA53662A9 +#define H550E4ACB_BEC7_4E71_8C6F_CD7FA53662A9 + +#include "easy_graph/infra/status.h" +#include "easy_graph/infra/singleton.h" + +EG_NS_BEGIN + +struct LayoutExecutor; +struct LayoutOption; +struct Graph; + +SINGLETON(GraphLayout) { + void Config(LayoutExecutor &, const LayoutOption * = nullptr); + Status Layout(const Graph &, const LayoutOption * = nullptr); + + private: + LayoutExecutor *executor_{nullptr}; + const LayoutOption *options_{nullptr}; +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/layout_executor.h b/tests/framework/easy_graph/include/easy_graph/layout/layout_executor.h new file mode 100644 index 00000000..089b5463 --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/layout_executor.h @@ -0,0 +1,34 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HE4984335_C586_4533_A056_27F9F996DF50 +#define HE4984335_C586_4533_A056_27F9F996DF50 + +#include "easy_graph/infra/status.h" +#include "easy_graph/infra/keywords.h" + +EG_NS_BEGIN + +struct Graph; +struct LayoutOption; + +INTERFACE(LayoutExecutor) { + ABSTRACT(Status Layout(const Graph &, const LayoutOption *)); +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/include/easy_graph/layout/layout_option.h b/tests/framework/easy_graph/include/easy_graph/layout/layout_option.h new file mode 100644 index 00000000..fd732a7e --- /dev/null +++ b/tests/framework/easy_graph/include/easy_graph/layout/layout_option.h @@ -0,0 +1,28 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H9491820D_4371_4C88_804E_4C77613F80C1 +#define H9491820D_4371_4C88_804E_4C77613F80C1 + +#include "easy_graph/infra/keywords.h" + +EG_NS_BEGIN + +INTERFACE(LayoutOption){}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/src/builder/chain_builder.cc b/tests/framework/easy_graph/src/builder/chain_builder.cc new file mode 100644 index 00000000..0e48f2b3 --- /dev/null +++ b/tests/framework/easy_graph/src/builder/chain_builder.cc @@ -0,0 +1,72 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/builder/chain_builder.h" +#include "easy_graph/builder/graph_builder.h" + +EG_NS_BEGIN + +ChainBuilder::ChainBuilder(GraphBuilder &graphBuilder, EdgeType defaultEdgeType) + : linker(*this, defaultEdgeType), graph_builder_(graphBuilder) {} + +ChainBuilder::LinkBuilder *ChainBuilder::operator->() { + return &linker; +} + +ChainBuilder &ChainBuilder::LinkTo(const Node &node, const Link &link) { + Node *currentNode = graph_builder_.BuildNode(node); + if (prev_node_) { + graph_builder_.BuildEdge(*prev_node_, *currentNode, link); + } + prev_node_ = currentNode; + return *this; +} + +const Node *ChainBuilder::FindNode(const NodeId &id) const { + return graph_builder_->FindNode(id); +} + +ChainBuilder::LinkBuilder::LinkBuilder(ChainBuilder &chain, EdgeType defaultEdgeType) + : chain_(chain), default_edge_type_(defaultEdgeType), from_link_(defaultEdgeType) {} + +ChainBuilder &ChainBuilder::LinkBuilder::Node(const NodeObj &node) { + chain_.LinkTo(node, from_link_); + from_link_.Reset(default_edge_type_); + return chain_; +} + +ChainBuilder &ChainBuilder::LinkBuilder::startLink(const Link &link) { + this->from_link_ = link; + return chain_; +} + +ChainBuilder &ChainBuilder::LinkBuilder::Ctrl(const std::string &label) { + return this->Edge(EdgeType::CTRL, UNDEFINED_PORT_ID, UNDEFINED_PORT_ID, label); +} + +ChainBuilder &ChainBuilder::LinkBuilder::Data(const std::string &label) { + return this->Edge(EdgeType::DATA, UNDEFINED_PORT_ID, UNDEFINED_PORT_ID, label); +} + +ChainBuilder &ChainBuilder::LinkBuilder::Data(PortId srcId, PortId dstId, const std::string &label) { + return this->Edge(EdgeType::DATA, srcId, dstId, label); +} + +ChainBuilder &ChainBuilder::LinkBuilder::Edge(EdgeType type, PortId srcPort, PortId dstPort, const std::string &label) { + return this->startLink(Link(type, label, srcPort, dstPort)); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/builder/graph_builder.cc b/tests/framework/easy_graph/src/builder/graph_builder.cc new file mode 100644 index 00000000..7b8e27ee --- /dev/null +++ b/tests/framework/easy_graph/src/builder/graph_builder.cc @@ -0,0 +1,78 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/builder/graph_builder.h" +#include "easy_graph/graph/endpoint.h" +#include "easy_graph/builder/link.h" +#include "easy_graph/infra/log.h" + +EG_NS_BEGIN + +namespace { +PortId getPortIdBy(const EdgeType &type, const PortId &specifiedPortId, PortId &reservedPortId) { + if (type == EdgeType::CTRL) + return 0; + if (specifiedPortId == UNDEFINED_PORT_ID) + return reservedPortId++; + if (specifiedPortId < reservedPortId) + return specifiedPortId; + reservedPortId = specifiedPortId; + return reservedPortId++; +} +} // namespace + +GraphBuilder::GraphBuilder(const std::string &name) : graph_(name) {} + +GraphBuilder::NodeInfo *GraphBuilder::FindNode(const NodeId &id) { + auto it = nodes_.find(id); + if (it == nodes_.end()) { + return nullptr; + } + return &(it->second); +} + +const GraphBuilder::NodeInfo *GraphBuilder::FindNode(const NodeId &id) const { + return const_cast(*this).FindNode(id); +} + +Node *GraphBuilder::BuildNode(const Node &node) { + auto it = nodes_.find(node.GetId()); + if (it == nodes_.end()) { + nodes_.emplace(std::make_pair(node.GetId(), NodeInfo())); + } + return graph_.AddNode(node); +} + +Edge *GraphBuilder::BuildEdge(const Node &src, const Node &dst, const Link &link) { + NodeInfo *srcInfo = FindNode(src.GetId()); + NodeInfo *dstInfo = FindNode(dst.GetId()); + + if (!srcInfo || !dstInfo) { + EG_ERR("link edge{%d : %s} error!", link.type_, link.label_.c_str()); + return nullptr; + } + + PortId srcPortId = getPortIdBy(link.type_, link.src_port_id_, srcInfo->outPortMax); + PortId dstPortId = getPortIdBy(link.type_, link.dst_port_id_, dstInfo->inPortMax); + + EG_DBG("link edge(%d) from (%s:%d) to (%s:%d)", link.type_, src.GetId().c_str(), srcPortId, dst.GetId().c_str(), + dstPortId); + + return graph_.AddEdge( + Edge(link.type_, link.label_, Endpoint(src.GetId(), srcPortId), Endpoint(dst.GetId(), dstPortId))); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/graph/edge.cc b/tests/framework/easy_graph/src/graph/edge.cc new file mode 100644 index 00000000..65a97017 --- /dev/null +++ b/tests/framework/easy_graph/src/graph/edge.cc @@ -0,0 +1,53 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/graph/edge.h" + +EG_NS_BEGIN + +Edge::Edge(const EdgeType type, const std::string &label, const Endpoint &src, const Endpoint &dst) + : type_(type), label_(label), src_(src), dst_(dst) {} + +__DEF_EQUALS(Edge) { + return (type_ == rhs.type_) && (src_ == rhs.src_) && (dst_ == rhs.dst_); +} + +__DEF_COMP(Edge) { + if (src_ < rhs.src_) + return true; + if ((src_ == rhs.src_) && (dst_ < rhs.dst_)) + return true; + if ((src_ == rhs.src_) && (dst_ < rhs.dst_) && (type_ < rhs.type_)) + return true; + return false; +} + +EdgeType Edge::GetType() const { + return type_; +} + +std::string Edge::GetLabel() const { + return label_; +} + +Endpoint Edge::GetSrc() const { + return src_; +} +Endpoint Edge::GetDst() const { + return dst_; +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/graph/endpoint.cc b/tests/framework/easy_graph/src/graph/endpoint.cc new file mode 100644 index 00000000..995f7eac --- /dev/null +++ b/tests/framework/easy_graph/src/graph/endpoint.cc @@ -0,0 +1,43 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/graph/endpoint.h" + +EG_NS_BEGIN + +Endpoint::Endpoint(const NodeId &nodeId, const PortId &portId) : node_id_(nodeId), port_id_(portId) {} + +__DEF_EQUALS(Endpoint) { + return (node_id_ == rhs.node_id_) && (port_id_ == rhs.port_id_); +} + +__DEF_COMP(Endpoint) { + if (node_id_ < rhs.node_id_) + return true; + if ((node_id_ == rhs.node_id_) && (port_id_ < rhs.port_id_)) + return true; + return false; +} + +NodeId Endpoint::getNodeId() const { + return node_id_; +} + +PortId Endpoint::getPortId() const { + return port_id_; +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/graph/graph.cc b/tests/framework/easy_graph/src/graph/graph.cc new file mode 100644 index 00000000..a17935be --- /dev/null +++ b/tests/framework/easy_graph/src/graph/graph.cc @@ -0,0 +1,70 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/graph/graph.h" +#include "easy_graph/graph/graph_visitor.h" +#include "easy_graph/layout/graph_layout.h" +#include + +EG_NS_BEGIN + +Graph::Graph(const std::string &name) : name_(name) {} + +std::string Graph::GetName() const { + return name_; +} + +Node *Graph::AddNode(const Node &node) { + auto result = nodes_.emplace(node.GetId(), node); + return &(result.first->second); +} + +Edge *Graph::AddEdge(const Edge &edge) { + auto result = edges_.emplace(edge); + return &(const_cast(*(result.first))); +} + +Node *Graph::FindNode(const NodeId &id) { + auto it = nodes_.find(id); + if (it == nodes_.end()) { + return nullptr; + } + return &(it->second); +} + +const Node *Graph::FindNode(const NodeId &id) const { + return const_cast(*this).FindNode(id); +} + +std::pair Graph::FindNodePair(const Edge &edge) const { + return std::make_pair(FindNode(edge.GetSrc().getNodeId()), FindNode(edge.GetDst().getNodeId())); +} + +std::pair Graph::FindNodePair(const Edge &edge) { + return std::make_pair(FindNode(edge.GetSrc().getNodeId()), FindNode(edge.GetDst().getNodeId())); +} + +void Graph::Accept(GraphVisitor &visitor) const { + visitor.Visit(*this); + std::for_each(nodes_.begin(), nodes_.end(), [&visitor](const auto &node) { visitor.Visit(node.second); }); + std::for_each(edges_.begin(), edges_.end(), [&visitor](const auto &edge) { visitor.Visit(edge); }); +} + +Status Graph::Layout(const LayoutOption *option) const { + return GraphLayout::GetInstance().Layout(*this, option); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/graph/node.cc b/tests/framework/easy_graph/src/graph/node.cc new file mode 100644 index 00000000..bf03b9d2 --- /dev/null +++ b/tests/framework/easy_graph/src/graph/node.cc @@ -0,0 +1,49 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/graph/node.h" +#include "easy_graph/graph/graph_visitor.h" +#include + +EG_NS_BEGIN + +__DEF_EQUALS(Node) { + return id_ == rhs.id_; +} + +__DEF_COMP(Node) { + return id_ < rhs.id_; +} + +NodeId Node::GetId() const { + return id_; +} + +Node &Node::Packing(const BoxPtr &box) { + this->box_ = box; + return *this; +} + +Node &Node::AddSubgraph(const Graph &graph) { + subgraphs_.push_back(&graph); + return *this; +} + +void Node::Accept(GraphVisitor &visitor) const { + std::for_each(subgraphs_.begin(), subgraphs_.end(), [&visitor](const auto &graph) { visitor.Visit(*graph); }); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/infra/log.cc b/tests/framework/easy_graph/src/infra/log.cc new file mode 100644 index 00000000..381dfa3d --- /dev/null +++ b/tests/framework/easy_graph/src/infra/log.cc @@ -0,0 +1,138 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include "easy_graph/infra/log.h" + +EG_NS_BEGIN + +namespace { +struct ConsoleState { + bool isColorful() const { + return colorful; + } + + protected: + ConsoleState(bool c) : colorful(c) {} + + private: + bool colorful; +}; + +//////////////////////////////////////////////////////// +#define DEF_COLOR_STATE(STATE, COLOR) \ + struct STATE : ConsoleState { \ + STATE(bool colorful) : ConsoleState(colorful) {} \ + }; \ + std::ostream &operator<<(std::ostream &os, const STATE &state) { \ + if (state.isColorful()) \ + os << COLOR; \ + return os; \ + } + +//////////////////////////////////////////////////////// +#define __RED "\033[1;31m" +#define __GREEN "\033[1;32m" +#define __YELLOW "\033[1;33m" +#define __BLUE "\033[1;34m" +#define __MAGENTA "\033[1;35m" +#define __CYAN "\033[1;36m" +#define __WHITE "\033[0m" + +DEF_COLOR_STATE(DebugState, __BLUE) +DEF_COLOR_STATE(InfoState, __CYAN) +DEF_COLOR_STATE(NormalState, __WHITE) +DEF_COLOR_STATE(SuccState, __GREEN) +DEF_COLOR_STATE(WarnState, __YELLOW) +DEF_COLOR_STATE(FailState, __RED) + +/////////////////////////////////////////////////////// +struct StdoutListener; +StdoutListener *inst = nullptr; + +struct StdoutListener { + static StdoutListener &getInstance() { + if (inst == 0) { + inst = new StdoutListener(true); + } + + return *inst; + } + + void println(const uint8_t level, const char *msg) { +#define ON_LEVEL(level, state) \ + case level: \ + doPrint(state, msg); \ + break; + + switch (level) { + ON_LEVEL(EG_FATAL_LEVEL, fail) + ON_LEVEL(EG_ERR_LEVEL, fail) + ON_LEVEL(EG_WARN_LEVEL, warn) + ON_LEVEL(EG_SUCC_LEVEL, succ) + ON_LEVEL(EG_INFO_LEVEL, info) + ON_LEVEL(EG_DEBUG_LEVEL, debug) + default: + doPrint(normal, msg); + } + } + + private: + StdoutListener(bool colorful) + : succ(colorful), fail(colorful), normal(colorful), info(colorful), warn(colorful), debug(colorful) {} + + template + void doPrint(const STATE &state, const char *msg) { + std::cout << state << msg << normal << std::endl; + } + + private: + SuccState succ; + FailState fail; + NormalState normal; + InfoState info; + WarnState warn; + DebugState debug; +}; + +const char *getBaseName(const char *absPath) { + if (absPath == 0) + return ""; + const char *p = absPath + strlen(absPath); + while ((p != absPath) && (*(p - 1) != '/')) { + p--; + } + return p; +} + +} // namespace + +void eg_log(int level, const char *levelstr, const char *file, unsigned int line, const char *fmt, ...) { + const int FMT_BUFF_SIZE = 1024; + char fmt_buff[FMT_BUFF_SIZE] = {0}; + va_list valist; + va_start(valist, fmt); + vsnprintf(fmt_buff, FMT_BUFF_SIZE, fmt, valist); + va_end(valist); + + char buff[1280] = {0}; + sprintf(buff, "[%s]: %s:%u: %s", levelstr, getBaseName(file), line, fmt_buff); + StdoutListener::getInstance().println(level, buff); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_executor.cc b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_executor.cc new file mode 100644 index 00000000..0558e332 --- /dev/null +++ b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_executor.cc @@ -0,0 +1,47 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/layout/engines/graph_easy/graph_easy_executor.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_visitor.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_option.h" +#include "layout/engines/graph_easy/utils/shell_executor.h" +#include "easy_graph/layout/layout_option.h" +#include "easy_graph/graph/graph.h" + +EG_NS_BEGIN + +namespace { +const GraphEasyOption *GraphEasyOptionCast(const LayoutOption *opts) { + if (!opts) + return &(GraphEasyOption::GetDefault()); + auto options = dynamic_cast(opts); + if (options) + return options; + return &(GraphEasyOption::GetDefault()); +} +} // namespace + +Status GraphEasyExecutor::Layout(const Graph &graph, const LayoutOption *opts) { + auto options = GraphEasyOptionCast(opts); + GraphEasyVisitor visitor(*options); + graph.Accept(visitor); + + std::string script = + std::string("echo \"") + visitor.GetLayout() + "\" | graph-easy " + options->GetLayoutCmdArgs(graph.GetName()); + return ShellExecutor::execute(script); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_layout_context.cc b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_layout_context.cc new file mode 100644 index 00000000..87c16c5a --- /dev/null +++ b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_layout_context.cc @@ -0,0 +1,65 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "easy_graph/layout/engines/graph_easy/graph_easy_layout_context.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_option.h" +#include "easy_graph/graph/graph.h" + +EG_NS_BEGIN + +GraphEasyLayoutContext::GraphEasyLayoutContext(const GraphEasyOption &options) : options_(options) {} + +const Graph *GraphEasyLayoutContext::GetCurrentGraph() const { + if (graphs_.empty()) + return nullptr; + return graphs_.back(); +} + +void GraphEasyLayoutContext::EnterGraph(const Graph &graph) { + graphs_.push_back(&graph); +} + +void GraphEasyLayoutContext::ExitGraph() { + graphs_.pop_back(); +} + +void GraphEasyLayoutContext::LinkBegin() { + is_linking_ = true; +} + +void GraphEasyLayoutContext::LinkEnd() { + is_linking_ = false; +} + +bool GraphEasyLayoutContext::InLinking() const { + return is_linking_; +} + +std::string GraphEasyLayoutContext::GetGroupPath() const { + if (graphs_.empty()) + return ""; + std::string result(""); + std::for_each(graphs_.begin(), graphs_.end(), + [&result](const auto &graph) { result += (std::string("/") + graph->GetName()); }); + return (result + "/"); +} + +const GraphEasyOption &GraphEasyLayoutContext::GetOptions() const { + return options_; +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_option.cc b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_option.cc new file mode 100644 index 00000000..d5817dfa --- /dev/null +++ b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_option.cc @@ -0,0 +1,54 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include "easy_graph/layout/engines/graph_easy/graph_easy_option.h" + +EG_NS_BEGIN + +namespace { +struct Format { + const char *format; + const char *postfix; +}; + +std::map formats = {{LayoutFormat::ASCII, {"ascii", "txt"}}, + {LayoutFormat::BOXART, {"boxart", "txt"}}, + {LayoutFormat::SVG, {"svg", "svg"}}, + {LayoutFormat::DOT, {"dot", "dot"}}, + {LayoutFormat::HTML, {"html", "html"}}}; + +std::string GetLayoutOutputArg(const GraphEasyOption &options, const std::string &graphName) { + if (options.output_ == LayoutOutput::CONSOLE) + return ""; + return std::string(" --output ") + options.output_path_ + graphName + "." + formats[options.format_].postfix; +} + +std::string GetLayoutFomartArg(const GraphEasyOption &options) { + return std::string(" --as=") + formats[options.format_].format; +} +} // namespace + +const GraphEasyOption &GraphEasyOption::GetDefault() { + static GraphEasyOption option; + return option; +} + +std::string GraphEasyOption::GetLayoutCmdArgs(const std::string &graphName) const { + return GetLayoutFomartArg(*this) + GetLayoutOutputArg(*this, graphName); +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_visitor.cc b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_visitor.cc new file mode 100644 index 00000000..7dcdfc2d --- /dev/null +++ b/tests/framework/easy_graph/src/layout/engines/graph_easy/graph_easy_visitor.cc @@ -0,0 +1,188 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/layout/engines/graph_easy/graph_easy_visitor.h" +#include "layout/engines/graph_easy/utils/shell_executor.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_option.h" +#include "easy_graph/infra/scope_guard.h" +#include "easy_graph/graph/graph.h" +#include "easy_graph/graph/edge.h" +#include "easy_graph/graph/node.h" +#include "easy_graph/infra/log.h" + +EG_NS_BEGIN + +namespace { +struct SubgraphLayoutVisitor : GraphVisitor { + SubgraphLayoutVisitor(const NodeId &id, GraphEasyLayoutContext &ctxt) : id_(id), ctxt_(ctxt) {} + std::string layout; + bool hasSubgraph{false}; + + private: + Status Visit(const Graph &graph) override { + ScopeGuard guard([this, &graph]() { ctxt_.EnterGraph(graph); }, [this]() { ctxt_.ExitGraph(); }); + layout += (std::string(" -- [") + id_ + "/" + graph.GetName() + "]" + + "{class : subgraph; label : " + graph.GetName() + ";}"); + hasSubgraph = true; + return EG_SUCCESS; + } + + private: + NodeId id_; + GraphEasyLayoutContext &ctxt_; +}; + +///////////////////////////////////////////////////////////////////////// +std::string GetGraphLayoutTitle(const Graph &graph, const GraphEasyLayoutContext &ctxt) { + std::string flowDirection = (ctxt.GetOptions().dir_ == FlowDir::LR) ? "east" : "down"; + std::string graphTitle = std::string("graph { label : ") + graph.GetName() + "; flow : " + flowDirection + + " ; } node.subgraph { border : double-dash; }"; + return graphTitle; +} +///////////////////////////////////////////////////////////////////////// +std::string GetNodeLayout(const Node &node, GraphEasyLayoutContext &ctxt) { + const auto &id = node.GetId(); + std::string nodeBox = std::string("[") + id + "]"; + + SubgraphLayoutVisitor subgraphVisitor(id, ctxt); + node.Accept(subgraphVisitor); + + if (!subgraphVisitor.hasSubgraph || ctxt.InLinking()) + return nodeBox; + + return (std::string("( ") + id + ": " + nodeBox + subgraphVisitor.layout + ")"); +} + +///////////////////////////////////////////////////////////////////////// +INTERFACE(EdgeLayout) { + EdgeLayout(GraphEasyLayoutContext & ctxt, const Edge &edge) : ctxt_(ctxt), options_(ctxt.GetOptions()), edge_(edge) {} + + std::string GetLayout() const { + auto graph = ctxt_.GetCurrentGraph(); + if (!graph) { + EG_FATAL("Layout context has no graph!"); + return ""; + } + + auto node_pair = graph->FindNodePair(edge_); + + if ((!node_pair.first) || (!node_pair.second)) { + EG_FATAL("Layout context graph(%s) has not found node(%s, %s)!", graph->GetName().c_str(), + edge_.GetSrc().getNodeId().c_str(), edge_.GetDst().getNodeId().c_str()); + return ""; + } + + std::string src_node_layout = GetNodeLayout(*node_pair.first, ctxt_); + std::string dst_node_layout = GetNodeLayout(*node_pair.second, ctxt_); + return src_node_layout + GetArrowLayout() + GetAttrLayout() + dst_node_layout; + } + + private: + ABSTRACT(std::string GetAttrLayout() const); + ABSTRACT(std::string GetArrowLayout() const); + + protected: + GraphEasyLayoutContext &ctxt_; + const GraphEasyOption &options_; + const Edge &edge_; +}; + +///////////////////////////////////////////////////////////////////////// +struct CtrlEdgeLayout : EdgeLayout { + using EdgeLayout::EdgeLayout; + + private: + std::string GetAttrLayout() const override { + if (edge_.GetLabel() == "") + return ""; + return std::string("{label : ") + edge_.GetLabel() + "}"; + } + + std::string GetArrowLayout() const override { + return " ..> "; + } +}; + +///////////////////////////////////////////////////////////////////////// +struct DataEdgeLayout : EdgeLayout { + using EdgeLayout::EdgeLayout; + + private: + std::string GetAttrLayout() const override { + return std::string("{ ") + GetLabelAttr() + GetPortAttr() + " }"; + } + + std::string GetArrowLayout() const override { + return " --> "; + } + + private: + std::string GetPortPair() const { + return std::string("(") + std::to_string(edge_.GetSrc().getPortId()) + "," + + std::to_string(edge_.GetDst().getPortId()) + ")"; + } + + std::string GetLabelAttr() const { + return std::string("label :") + edge_.GetLabel() + GetPortPair() + "; "; + } + + std::string GetPortAttr() const { + return (options_.type_ == LayoutType::FREE) ? "" : GetOutPortAttr() + GetInPortAttr(); + } + + std::string GetOutPortAttr() const { + return std::string(" start : ") + "front" + ", " + std::to_string(edge_.GetSrc().getPortId() * options_.scale_) + + "; "; + } + + std::string GetInPortAttr() const { + return std::string(" end : ") + "back" + ", " + std::to_string(edge_.GetDst().getPortId() * options_.scale_) + "; "; + } +}; +} // namespace + +GraphEasyVisitor::GraphEasyVisitor(const GraphEasyOption &options) : ctxt_(options) {} + +Status GraphEasyVisitor::Visit(const Graph &graph) { + ctxt_.EnterGraph(graph); + layout_ += GetGraphLayoutTitle(graph, ctxt_); + return EG_SUCCESS; +} + +Status GraphEasyVisitor::Visit(const Node &node) { + layout_ += GetNodeLayout(node, ctxt_); + return EG_SUCCESS; +} + +Status GraphEasyVisitor::Visit(const Edge &edge) { + ScopeGuard guard([this]() { ctxt_.LinkBegin(); }, [this]() { ctxt_.LinkEnd(); }); + + auto makeEdgeLayout = [this, &edge]() -> const EdgeLayout * { + if (edge.GetType() == EdgeType::CTRL) + return new CtrlEdgeLayout(ctxt_, edge); + return new DataEdgeLayout(ctxt_, edge); + }; + + std::unique_ptr edgeLayout(makeEdgeLayout()); + layout_ += edgeLayout->GetLayout(); + return EG_SUCCESS; +} + +std::string GraphEasyVisitor::GetLayout() const { + return layout_; +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/layout/engines/graph_easy/utils/shell_executor.cc b/tests/framework/easy_graph/src/layout/engines/graph_easy/utils/shell_executor.cc new file mode 100644 index 00000000..d608c703 --- /dev/null +++ b/tests/framework/easy_graph/src/layout/engines/graph_easy/utils/shell_executor.cc @@ -0,0 +1,43 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include +#include "easy_graph/infra/log.h" +#include "layout/engines/graph_easy/utils/shell_executor.h" + +EG_NS_BEGIN + +Status ShellExecutor::execute(const std::string &script) { + EG_DBG("%s", script.c_str()); + + pid_t status = system(script.c_str()); + if (-1 == status) { + EG_ERR("system execute return error!"); + return EG_FAILURE; + } + + if (WIFEXITED(status) && (0 == WEXITSTATUS(status))) + return EG_SUCCESS; + + EG_ERR("system execute {%s} exit status value = [0x%x], exit code: %d\n", script.c_str(), status, + WEXITSTATUS(status)); + return EG_FAILURE; +} + +EG_NS_END diff --git a/tests/framework/easy_graph/src/layout/engines/graph_easy/utils/shell_executor.h b/tests/framework/easy_graph/src/layout/engines/graph_easy/utils/shell_executor.h new file mode 100644 index 00000000..72477056 --- /dev/null +++ b/tests/framework/easy_graph/src/layout/engines/graph_easy/utils/shell_executor.h @@ -0,0 +1,32 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HB141A993_B14A_4A1D_A1DD_353D33AE77A2 +#define HB141A993_B14A_4A1D_A1DD_353D33AE77A2 + +#include +#include "easy_graph/eg.h" +#include "easy_graph/infra/status.h" + +EG_NS_BEGIN + +struct ShellExecutor { + static Status execute(const std::string &script); +}; + +EG_NS_END + +#endif diff --git a/tests/framework/easy_graph/src/layout/graph_layout.cc b/tests/framework/easy_graph/src/layout/graph_layout.cc new file mode 100644 index 00000000..340acf67 --- /dev/null +++ b/tests/framework/easy_graph/src/layout/graph_layout.cc @@ -0,0 +1,35 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/layout/graph_layout.h" +#include "easy_graph/layout/layout_executor.h" +#include "easy_graph/graph/graph.h" + +EG_NS_BEGIN + +void GraphLayout::Config(LayoutExecutor &executor, const LayoutOption *opts) { + this->executor_ = &executor; + options_ = opts; +} + +Status GraphLayout::Layout(const Graph &graph, const LayoutOption *opts) { + const LayoutOption *options = opts ? opts : this->options_; + if (!executor_) + return EG_UNIMPLEMENTED; + return executor_->Layout(graph, options); +} + +EG_NS_END diff --git a/tests/framework/ge_graph_dsl/CMakeLists.txt b/tests/framework/ge_graph_dsl/CMakeLists.txt new file mode 100644 index 00000000..deac4e03 --- /dev/null +++ b/tests/framework/ge_graph_dsl/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +add_subdirectory(include) +add_subdirectory(src) +add_subdirectory(tests) \ No newline at end of file diff --git a/tests/framework/ge_graph_dsl/include/CMakeLists.txt b/tests/framework/ge_graph_dsl/include/CMakeLists.txt new file mode 100644 index 00000000..3ae40204 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +add_library(ge_graph_dsl_inc INTERFACE) +target_include_directories(ge_graph_dsl_inc INTERFACE ./) diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/ge.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/ge.h new file mode 100644 index 00000000..c022bf1d --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/ge.h @@ -0,0 +1,29 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H382C2083_01CC_43DF_8BBD_EF6714FF62B2 +#define H382C2083_01CC_43DF_8BBD_EF6714FF62B2 + +#define GE_NS ge +#define GE_NS_BEGIN namespace GE_NS { +#define GE_NS_END } +#define USING_GE_NS using namespace GE_NS; +#define FWD_DECL_GE(type) \ + namespace GE_NS { \ + struct type; \ + } + +#endif /* H382C2083_01CC_43DF_8BBD_EF6714FF62B2 */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/graph_dsl.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/graph_dsl.h new file mode 100644 index 00000000..4e1903ae --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/graph_dsl.h @@ -0,0 +1,38 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H7C82E219_BDEF_4480_A2D9_30F0590C8AC5 +#define H7C82E219_BDEF_4480_A2D9_30F0590C8AC5 + +#include "easy_graph/graph/graph.h" +#include "easy_graph/builder/graph_dsl.h" +#include "ge_graph_dsl/ge.h" +#include "ge_graph_dsl/op_desc/op_desc_node_builder.h" +#include "external/graph/graph.h" + +GE_NS_BEGIN + +Graph ToGeGraph(const ::EG_NS::Graph &graph); +ComputeGraphPtr ToComputeGraph(const ::EG_NS::Graph &graph); + +#define DATA_EDGE(...) Data(__VA_ARGS__) +#define CTRL_EDGE(...) Ctrl(__VA_ARGS__) +#define NODE(...) Node(::GE_NS::OpDescNodeBuild(__VA_ARGS__)) +#define EDGE(...) DATA_EDGE(__VA_ARGS__) + +GE_NS_END + +#endif diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_box.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_box.h new file mode 100644 index 00000000..25e0f976 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_box.h @@ -0,0 +1,33 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H6DCF6C61_7C9B_4048_BB5D_E748142FF7F8 +#define H6DCF6C61_7C9B_4048_BB5D_E748142FF7F8 + +#include "ge_graph_dsl/ge.h" +#include "easy_graph/graph/node_id.h" +#include "easy_graph/graph/box.h" +#include "external/graph/gnode.h" + +GE_NS_BEGIN + +struct OpBox : ::EG_NS::Box { + ABSTRACT(OpDescPtr Build(const ::EG_NS::NodeId &) const); +}; + +GE_NS_END + +#endif /* H6DCF6C61_7C9B_4048_BB5D_E748142FF7F8 */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg.h new file mode 100644 index 00000000..bb2326ec --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg.h @@ -0,0 +1,52 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H77F0BD09_6C00_4E45_8DED_38A676D6B20A +#define H77F0BD09_6C00_4E45_8DED_38A676D6B20A + +#include +#include "ge_graph_dsl/ge.h" +#include "graph/types.h" +#include "ge_graph_dsl/op_desc/op_type.h" + +GE_NS_BEGIN + +struct OpDescCfg { + struct TensorCfg { + TensorCfg(Format format = FORMAT_NCHW, DataType data_type = DT_FLOAT, std::vector shape = {1, 1, 224, 224}) + : format_(format), data_type_(data_type), shape_(shape) {} + Format format_; + DataType data_type_; + std::vector shape_; + }; + + OpDescCfg(const OpType &type, int in_cnt = 0, int out_cnt = 0, Format format = FORMAT_NCHW, + DataType data_type = DT_FLOAT, std::vector shape = {1, 1, 224, 224}) + : type_(type), in_cnt_(in_cnt), out_cnt_(out_cnt), default_tensor_(format, data_type, shape) {} + + protected: + OpType GetType() const { + return type_; + } + OpType type_; + int in_cnt_; + int out_cnt_; + TensorCfg default_tensor_; +}; + +GE_NS_END + +#endif /* H77F0BD09_6C00_4E45_8DED_38A676D6B20A */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_box.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_box.h new file mode 100644 index 00000000..af3a1971 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_box.h @@ -0,0 +1,51 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HF55B1FFE_C64C_4671_8A25_A57DDD5D1280 +#define HF55B1FFE_C64C_4671_8A25_A57DDD5D1280 + +#include "easy_graph/graph/node_id.h" +#include "ge_graph_dsl/ge.h" +#include "ge_graph_dsl/op_desc/op_box.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg.h" +#include "graph/op_desc.h" + +GE_NS_BEGIN + +struct OpDescCfgBox : OpBox, private OpDescCfg { + OpDescCfgBox(const OpType &opType); + OpDescCfgBox &InCnt(int in_cnt); + OpDescCfgBox &OutCnt(int out_cnt); + OpDescCfgBox &TensorDesc(Format format = FORMAT_NCHW, DataType data_type = DT_FLOAT, + std::vector shape = {1, 1, 224, 224}); + template + OpDescCfgBox& Attr(const std::string &name, Type value) { + auto attrvalue = ge::GeAttrValue::CreateFrom(value); + attrs_.emplace(std::make_pair(name, attrvalue)); + return *this; + } + + private: + OpDescPtr Build(const ::EG_NS::NodeId &id) const override; + void UpdateAttrs(OpDescPtr&) const; + std::map attrs_; +}; + +#define OP_CFG(optype) ::GE_NS::OpDescCfgBox(optype) + +GE_NS_END + +#endif /* HF55B1FFE_C64C_4671_8A25_A57DDD5D1280 */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_repo.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_repo.h new file mode 100644 index 00000000..275f7597 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_cfg_repo.h @@ -0,0 +1,34 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H600DEDD4_D5B9_4803_AF48_262B2C4FBA94d +#define H600DEDD4_D5B9_4803_AF48_262B2C4FBA94c + +#include "easy_graph/infra/singleton.h" +#include "ge_graph_dsl/ge.h" +#include "ge_graph_dsl/op_desc/op_type.h" + +GE_NS_BEGIN + +struct OpDescCfg; + +SINGLETON(OpDescCfgRepo) { + const OpDescCfg *FindBy(const OpType &); +}; + +GE_NS_END + +#endif /* H600DEDD4_D5B9_4803_AF48_262B2C4FBA94 */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_node_builder.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_node_builder.h new file mode 100644 index 00000000..f3c0603d --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_node_builder.h @@ -0,0 +1,57 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef H53F1A984_1D06_4458_9595_0A6DC60EA9CE +#define H53F1A984_1D06_4458_9595_0A6DC60EA9CE + +#include "easy_graph/graph/node.h" +#include "ge_graph_dsl/ge.h" +#include "ge_graph_dsl/op_desc/op_desc_ptr_box.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg_box.h" +#include "graph/op_desc.h" + +using ::EG_NS::Node; +using ::EG_NS::NodeId; + +GE_NS_BEGIN + +inline const ::EG_NS::NodeId OpDescNodeBuild(const ::EG_NS::NodeId &id) { + return id; +} + +template +inline ::EG_NS::Node OpDescNodeBuild(const ::EG_NS::NodeId &id, const GRAPHS &... graphs) { + return ::EG_NS::Node(id, graphs...); +} + +template +inline ::EG_NS::Node OpDescNodeBuild(const OpDescPtr &op, const GRAPHS &... graphs) { + return ::EG_NS::Node(op->GetName(), BOX_OF(::GE_NS::OpDescPtrBox, op), graphs...); +} + +template +inline ::EG_NS::Node OpDescNodeBuild(const ::EG_NS::NodeId &id, const OpType &opType, const GRAPHS &... graphs) { + return ::EG_NS::Node(id, BOX_OF(OpDescCfgBox, opType), graphs...); +} + +template +inline ::EG_NS::Node OpDescNodeBuild(const ::EG_NS::NodeId &id, const OpDescCfgBox &opBox, const GRAPHS &... graphs) { + return ::EG_NS::Node(id, BOX_OF(OpDescCfgBox, opBox), graphs...); +} + +GE_NS_END + +#endif /* H53F1A984_1D06_4458_9595_0A6DC60EA9CE */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_ptr_box.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_ptr_box.h new file mode 100644 index 00000000..8a45e732 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_desc_ptr_box.h @@ -0,0 +1,38 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HCFDD0816_CC46_4264_9363_9E8C6934F43E +#define HCFDD0816_CC46_4264_9363_9E8C6934F43E + +#include "easy_graph/eg.h" +#include "easy_graph/graph/node_id.h" +#include "graph/op_desc.h" +#include "ge_graph_dsl/ge.h" +#include "ge_graph_dsl/op_desc/op_box.h" + +GE_NS_BEGIN + +struct OpDescPtrBox : OpBox { + OpDescPtrBox(const OpDescPtr &op) : op_(op) {} + + private: + OpDescPtr Build(const ::EG_NS::NodeId &id) const override; + const OpDescPtr op_; +}; + +GE_NS_END + +#endif /* HCFDD0816_CC46_4264_9363_9E8C6934F43E */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_type.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_type.h new file mode 100644 index 00000000..182bde3c --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/op_desc/op_type.h @@ -0,0 +1,28 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef HAA2D4486_DB43_4ED2_BCF8_F41AD8267A85 +#define HAA2D4486_DB43_4ED2_BCF8_F41AD8267A85 + +#include +#include "ge_graph_dsl/ge.h" + +GE_NS_BEGIN + +using OpType = std::string; + +GE_NS_END + +#endif /* HAA2D4486_DB43_4ED2_BCF8_F41AD8267A85 */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/vistor/ge_graph_vistor.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/vistor/ge_graph_vistor.h new file mode 100644 index 00000000..fbb4e4c4 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/vistor/ge_graph_vistor.h @@ -0,0 +1,44 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HD31125D4_0EB8_494C_B83D_3B8B923A914D +#define HD31125D4_0EB8_494C_B83D_3B8B923A914D + +#include "easy_graph/graph/graph_visitor.h" +#include "graph/compute_graph.h" +#include "external/graph/graph.h" +#include "ge_graph_dsl/ge.h" + +GE_NS_BEGIN + +struct GeGraphVisitor : ::EG_NS::GraphVisitor { + GeGraphVisitor(); + void reset(const ComputeGraphPtr &graph); + Graph BuildGeGraph() const; + ComputeGraphPtr BuildComputeGraph() const; + + private: + ::EG_NS::Status Visit(const ::EG_NS::Graph &) override; + ::EG_NS::Status Visit(const ::EG_NS::Node &) override; + ::EG_NS::Status Visit(const ::EG_NS::Edge &) override; + + private: + ComputeGraphPtr build_graph_; +}; + +GE_NS_END + +#endif /* TESTS_ST_EASY_GRAPH_GELAYOUT_GRAPH_GE_VISTOR_H_ */ diff --git a/tests/framework/ge_graph_dsl/include/ge_graph_dsl/vistor/ge_subgraph_vistor.h b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/vistor/ge_subgraph_vistor.h new file mode 100644 index 00000000..97418296 --- /dev/null +++ b/tests/framework/ge_graph_dsl/include/ge_graph_dsl/vistor/ge_subgraph_vistor.h @@ -0,0 +1,47 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef HF900DC04_D202_42ED_992A_35DD7C940CE6 +#define HF900DC04_D202_42ED_992A_35DD7C940CE6 + +#include "easy_graph/infra/status.h" +#include "external/graph/gnode.h" +#include "ge_graph_dsl/ge.h" +#include "ge_graph_dsl/vistor/ge_graph_vistor.h" + +GE_NS_BEGIN + +struct GeSubgraphVisitor : ::EG_NS::GraphVisitor { + GeSubgraphVisitor(ComputeGraphPtr &, const ::EG_NS::Node &); + ::EG_NS::Status BuildGraphRelations(); + + private: + ::EG_NS::Status Visit(const ::EG_NS::Graph &) override; + ::EG_NS::Status Visit(const ::EG_NS::Node &) override; + ::EG_NS::Status Visit(const ::EG_NS::Edge &) override; + + private: + ::EG_NS::Status BuildGraphRelations(OpDescPtr &); + + private: + ComputeGraphPtr &root_graph_; + const ::EG_NS::Node &node_; + GeGraphVisitor cur_graph_vistor_; + std::vector subgraphs_; +}; + +GE_NS_END + +#endif /* HF900DC04_D202_42ED_992A_35DD7C940CE6 */ diff --git a/tests/framework/ge_graph_dsl/src/CMakeLists.txt b/tests/framework/ge_graph_dsl/src/CMakeLists.txt new file mode 100644 index 00000000..c92c6b5c --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/CMakeLists.txt @@ -0,0 +1,28 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cc" "*.CC" "*.cpp" "*.CPP") + +add_library(ge_graph_dsl STATIC ${SOURCES}) + +target_include_directories(ge_graph_dsl + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries(ge_graph_dsl PUBLIC + $) + +set_target_properties(ge_graph_dsl PROPERTIES CXX_STANDARD 17) +target_link_libraries(ge_graph_dsl PUBLIC ge_graph_dsl_inc easy_graph metadef_graph) diff --git a/tests/framework/ge_graph_dsl/src/ge_graph_vistor.cc b/tests/framework/ge_graph_dsl/src/ge_graph_vistor.cc new file mode 100644 index 00000000..d8bc2aab --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/ge_graph_vistor.cc @@ -0,0 +1,79 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include "easy_graph/graph/edge.h" +#include "easy_graph/graph/graph.h" +#include "easy_graph/graph/node.h" +#include "easy_graph/graph/edge_type.h" +#include "easy_graph/builder/box_builder.h" + +#include "external/graph/types.h" +#include "graph/utils/graph_utils.h" +#include "graph/compute_graph.h" +#include "graph/ge_tensor.h" + +#include "framework/common/types.h" +#include "ge_graph_dsl/op_desc/op_box.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg_box.h" +#include "ge_graph_dsl/vistor/ge_graph_vistor.h" +#include "ge_graph_dsl/vistor/ge_subgraph_vistor.h" + +using ::EG_NS::Status; + +GE_NS_BEGIN + +GeGraphVisitor::GeGraphVisitor() : build_graph_(std::make_shared("")) {} + +void GeGraphVisitor::reset(const ComputeGraphPtr &graph) { + build_graph_ = graph; +} + +Graph GeGraphVisitor::BuildGeGraph() const { + return GraphUtils::CreateGraphFromComputeGraph(build_graph_); +} + +ComputeGraphPtr GeGraphVisitor::BuildComputeGraph() const { + return build_graph_; +} + +Status GeGraphVisitor::Visit(const ::EG_NS::Graph &graph) { + build_graph_->SetName(graph.GetName()); + return EG_SUCCESS; +} + +Status GeGraphVisitor::Visit(const ::EG_NS::Node &node) { + GeSubgraphVisitor vistor(build_graph_, node); + return vistor.BuildGraphRelations(); +} + +Status GeGraphVisitor::Visit(const ::EG_NS::Edge &edge) { + auto src_node = build_graph_->FindNode(edge.GetSrc().getNodeId()); + auto dst_node = build_graph_->FindNode(edge.GetDst().getNodeId()); + + if (edge.GetType() == ::EG_NS::EdgeType::CTRL) { + GraphUtils::AddEdge(src_node->GetOutControlAnchor(), dst_node->GetInControlAnchor()); + return EG_SUCCESS; + } + + if (src_node->GetAllOutDataAnchorsSize() <= edge.GetSrc().getPortId() || + dst_node->GetAllInDataAnchorsSize() <= edge.GetDst().getPortId()) { + return EG_FAILURE; + } + GraphUtils::AddEdge(src_node->GetOutDataAnchor(edge.GetSrc().getPortId()), + dst_node->GetInDataAnchor(edge.GetDst().getPortId())); + return EG_SUCCESS; +} + +GE_NS_END diff --git a/tests/framework/ge_graph_dsl/src/ge_subgraph_vistor.cc b/tests/framework/ge_graph_dsl/src/ge_subgraph_vistor.cc new file mode 100644 index 00000000..d16ca3b7 --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/ge_subgraph_vistor.cc @@ -0,0 +1,70 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/graph/node.h" +#include "easy_graph/graph/graph.h" +#include "easy_graph/graph/edge.h" +#include "ge_graph_dsl/op_desc/op_box.h" +#include "ge_graph_dsl/vistor/ge_subgraph_vistor.h" + +GE_NS_BEGIN + +GeSubgraphVisitor::GeSubgraphVisitor(ComputeGraphPtr &rootGraph, const ::EG_NS::Node &node) + : root_graph_(rootGraph), node_(node) {} + +::EG_NS::Status GeSubgraphVisitor::BuildGraphRelations() { + node_.Accept(*this); + auto nod_builder = node_.Unpacking(); + if (nod_builder == nullptr) { + return EG_FAILURE; + } else { + auto opPtr = nod_builder->Build(node_.GetId()); + return BuildGraphRelations(opPtr); + } +} + +::EG_NS::Status GeSubgraphVisitor::BuildGraphRelations(OpDescPtr &opPtr) { + auto node = root_graph_->AddNode(opPtr); + int graph_index = 0; + for (auto subGraph : subgraphs_) { + opPtr->AddSubgraphName(subGraph->GetName()); + opPtr->SetSubgraphInstanceName(graph_index++, subGraph->GetName()); + subGraph->SetParentNode(node); + subGraph->SetParentGraph(root_graph_); + root_graph_->AddSubgraph(subGraph); + } + return EG_SUCCESS; +} + +::EG_NS::Status GeSubgraphVisitor::Visit(const ::EG_NS::Graph &graph) { + auto subgraph = std::make_shared(graph.GetName()); + cur_graph_vistor_.reset(subgraph); + graph.Accept(cur_graph_vistor_); + subgraphs_.push_back(subgraph); + return EG_SUCCESS; +} + +::EG_NS::Status GeSubgraphVisitor::Visit(const ::EG_NS::Node &node) { + ::EG_NS::GraphVisitor &vistor = cur_graph_vistor_; + return vistor.Visit(node); +} + +::EG_NS::Status GeSubgraphVisitor::Visit(const ::EG_NS::Edge &edge) { + ::EG_NS::GraphVisitor &vistor = cur_graph_vistor_; + return vistor.Visit(edge); +} + +GE_NS_END diff --git a/tests/framework/ge_graph_dsl/src/graph_dsl.cc b/tests/framework/ge_graph_dsl/src/graph_dsl.cc new file mode 100644 index 00000000..d2d297f9 --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/graph_dsl.cc @@ -0,0 +1,39 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "easy_graph/builder/graph_dsl.h" +#include "easy_graph/graph/graph.h" +#include "external/graph/graph.h" +#include "ge_graph_dsl/graph_dsl.h" +#include "ge_graph_dsl/vistor/ge_graph_vistor.h" + +GE_NS_BEGIN + +Graph ToGeGraph(const ::EG_NS::Graph &graph) { + graph.Layout(); + GeGraphVisitor geVistor; + graph.Accept(geVistor); + return geVistor.BuildGeGraph(); +} + +ComputeGraphPtr ToComputeGraph(const ::EG_NS::Graph &graph) { + graph.Layout(); + GeGraphVisitor geVistor; + graph.Accept(geVistor); + return geVistor.BuildComputeGraph(); +} + +GE_NS_END diff --git a/tests/framework/ge_graph_dsl/src/op_desc_cfg_box.cc b/tests/framework/ge_graph_dsl/src/op_desc_cfg_box.cc new file mode 100644 index 00000000..fc2a6c1c --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/op_desc_cfg_box.cc @@ -0,0 +1,75 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge_graph_dsl/op_desc/op_desc_cfg_box.h" +#include "easy_graph/infra/status.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg_repo.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg.h" +#include "external/graph/gnode.h" +#include "graph/ge_tensor.h" + +using ::EG_NS::Status; +using ::GE_NS::OpDescCfg; + +GE_NS_BEGIN + +OpDescCfgBox::OpDescCfgBox(const OpType &opType) : OpDescCfg(opType) { + auto opCfg = OpDescCfgRepo::GetInstance().FindBy(opType); + if (opCfg != nullptr) { + ::OpDescCfg &base = *this; + base = (*opCfg); + } +} + +OpDescCfgBox &OpDescCfgBox::InCnt(int in_cnt) { + this->in_cnt_ = in_cnt; + return *this; +} + +OpDescCfgBox &OpDescCfgBox::OutCnt(int out_cnt) { + this->out_cnt_ = out_cnt; + return *this; +} + +OpDescCfgBox &OpDescCfgBox::TensorDesc(Format format, DataType data_type, std::vector shape) { + default_tensor_.format_ = format; + default_tensor_.data_type_ = data_type; + default_tensor_.shape_ = shape; + return *this; +} + +void OpDescCfgBox::UpdateAttrs(OpDescPtr& op_desc) const { + std::for_each(attrs_.begin(), attrs_.end(), [&op_desc](const auto &attr){ + op_desc->SetAttr(attr.first, attr.second); + }); +} + +OpDescPtr OpDescCfgBox::Build(const ::EG_NS::NodeId &id) const { + auto opPtr = std::make_shared(id, GetType()); + GeTensorDesc tensor_desc(ge::GeShape(default_tensor_.shape_), default_tensor_.format_, default_tensor_.data_type_); + for (int i = 0; i < in_cnt_; i++) { + opPtr->AddInputDesc(tensor_desc); + } + + for (int i = 0; i < out_cnt_; i++) { + opPtr->AddOutputDesc(tensor_desc); + } + + UpdateAttrs(opPtr); + return opPtr; +} + +GE_NS_END diff --git a/tests/framework/ge_graph_dsl/src/op_desc_cfg_repo.cc b/tests/framework/ge_graph_dsl/src/op_desc_cfg_repo.cc new file mode 100644 index 00000000..e7fa018f --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/op_desc_cfg_repo.cc @@ -0,0 +1,46 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge_graph_dsl/op_desc/op_desc_cfg_repo.h" +#include "framework/common/types.h" +#include "graph/debug/ge_attr_define.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg.h" + +GE_NS_BEGIN + +namespace { + +#define OP_CFG(optype, ...) \ + { \ + optype, OpDescCfg { \ + optype, __VA_ARGS__ \ + } \ + } + +static std::map cfg_repo{OP_CFG(DATA, 1, 1, FORMAT_NCHW, DT_FLOAT, {1, 1, 224, 224}), + OP_CFG(ADD, 2, 1, FORMAT_NCHW, DT_FLOAT, {1, 1, 224, 224}), + OP_CFG(VARIABLE, 1, 1)}; +} // namespace + +const OpDescCfg *OpDescCfgRepo::FindBy(const OpType &id) { + auto it = cfg_repo.find(id); + if (it == cfg_repo.end()) { + return nullptr; + } + return &(it->second); +} + +GE_NS_END diff --git a/tests/framework/ge_graph_dsl/src/op_desc_ptr_box.cc b/tests/framework/ge_graph_dsl/src/op_desc_ptr_box.cc new file mode 100644 index 00000000..23d4773c --- /dev/null +++ b/tests/framework/ge_graph_dsl/src/op_desc_ptr_box.cc @@ -0,0 +1,24 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ge_graph_dsl/op_desc/op_desc_ptr_box.h" +#include "external/graph/gnode.h" + +USING_GE_NS + +OpDescPtr OpDescPtrBox::Build(const ::EG_NS::NodeId &id) const { + return op_; +} diff --git a/tests/framework/ge_graph_dsl/tests/CMakeLists.txt b/tests/framework/ge_graph_dsl/tests/CMakeLists.txt new file mode 100644 index 00000000..40097d8b --- /dev/null +++ b/tests/framework/ge_graph_dsl/tests/CMakeLists.txt @@ -0,0 +1,33 @@ +# Copyright 2021 Huawei Technologies Co., Ltd +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# ============================================================================ + +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cc" "*.CC" "*.cpp" "*.CPP") + +add_executable(ge_graph_dsl_test ${SOURCES}) + +target_include_directories(ge_graph_dsl_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_compile_options(ge_graph_dsl_test PRIVATE + -g +) +set_target_properties(ge_graph_dsl_test PROPERTIES CXX_STANDARD 17) + +target_link_libraries(ge_graph_dsl_test PUBLIC gtest gtest_main ge_graph_dsl) + +include(CTest) +enable_testing() +add_test(NAME test COMMAND ge_graph_dsl_test) \ No newline at end of file diff --git a/tests/framework/ge_graph_dsl/tests/graph_dsl_test.cc b/tests/framework/ge_graph_dsl/tests/graph_dsl_test.cc new file mode 100644 index 00000000..f7e55e3d --- /dev/null +++ b/tests/framework/ge_graph_dsl/tests/graph_dsl_test.cc @@ -0,0 +1,218 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "gtest/gtest.h" +#include +#include "easy_graph/graph/box.h" +#include "easy_graph/graph/node.h" +#include "easy_graph/builder/graph_dsl.h" +#include "easy_graph/builder/box_builder.h" +#include "easy_graph/layout/graph_layout.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_option.h" +#include "easy_graph/layout/engines/graph_easy/graph_easy_executor.h" +#include "graph/graph.h" +#include "graph/compute_graph.h" +#include "framework/common/types.h" +#include "graph/debug/ge_attr_define.h" +#include "ge_graph_dsl/graph_dsl.h" +#include "ge_graph_dsl/op_desc/op_desc_cfg_box.h" + +USING_GE_NS + +class GraphDslTest : public testing::Test { + private: + EG_NS::GraphEasyExecutor executor; + + protected: + void SetUp() { + EG_NS::GraphLayout::GetInstance().Config(executor, nullptr); + } + + void TearDown() {} +}; + +TEST_F(GraphDslTest, test_build_graph_from_optype_with_name) { + DEF_GRAPH(g1) { + CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + }); + + auto geGraph = ToGeGraph(g1); + auto computeGraph = ToComputeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); + ASSERT_EQ(computeGraph->GetAllNodesSize(), 2); +} + +TEST_F(GraphDslTest, test_build_graph_with_name) { + DEF_GRAPH(g1, "sample_graph") { + CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); + ASSERT_EQ(geGraph.GetName(), "sample_graph"); +} + +TEST_F(GraphDslTest, test_build_from_from_op_desc_ptr) { + DEF_GRAPH(g1) { + auto data = std::make_shared("data1", DATA); + auto add = std::make_shared("Add", ADD); + CHAIN(NODE(data)->NODE(add)); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_from_op_desc_cfg) { + DEF_GRAPH(g1) { + auto datCfg = OP_CFG(DATA).InCnt(1).OutCnt(1); + auto addCfg = OP_CFG(DATA).InCnt(1).OutCnt(1); + CHAIN(NODE("data1", datCfg)->NODE("add", addCfg)); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_from_op_desc_cfg_inline) { + DEF_GRAPH(g1) { + CHAIN(NODE("data1", OP_CFG(DATA).InCnt(1).OutCnt(1))->NODE("add", OP_CFG(ADD).InCnt(2).OutCnt(1))); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_from_control_chain) { + DEF_GRAPH(g1) { + CTRL_CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_from_data_chain) { + DEF_GRAPH(g1) { + DATA_CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_from_data_chain_with_edge) { + DEF_GRAPH(g1) { + CTRL_CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + CHAIN(NODE("data1", DATA)->EDGE(2, 2)->NODE("add")); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_graph_reused_before_node) { + DEF_GRAPH(g1) { + CTRL_CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + CHAIN(NODE("data1")->EDGE(2, 2)->NODE("add")); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 2); +} + +TEST_F(GraphDslTest, test_build_graph_with_constant_folding) { + DEF_GRAPH(g1) { + CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + CHAIN(NODE("data2", DATA)->NODE("add")); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 3); +} + +TEST_F(GraphDslTest, test_build_complex_normal_graph_build_suggested) { + DEF_GRAPH(g1) { + CHAIN(NODE("w1", VARIABLE)->NODE("prefetch1", HCOMALLGATHER)->NODE("Add1", ADD)); + CHAIN(NODE("w2", VARIABLE)->NODE("prefetch2", HCOMALLGATHER)->NODE("Add2", ADD)); + CHAIN(NODE("w3", VARIABLE)->NODE("prefetch3", HCOMALLGATHER)->NODE("Add3", ADD)); + CHAIN(NODE("w4", VARIABLE)->NODE("prefetch4", HCOMALLGATHER)->NODE("Add4", ADD)); + CHAIN(NODE("w5", VARIABLE)->NODE("prefetch5", HCOMALLGATHER)->NODE("Add5", ADD)); + CHAIN(NODE("const1", CONSTANTOP) + ->NODE("Add1") + ->NODE("Add2") + ->NODE("Add3") + ->NODE("Add4") + ->NODE("Add5") + ->NODE("net_output", NETOUTPUT)); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 17); +} + +TEST_F(GraphDslTest, test_build_complex_mult_normal_graph_build) { + DEF_GRAPH(g1) { + CHAIN(NODE("w1", VARIABLE)->NODE("prefetch1", HCOMALLGATHER)->NODE("add1", ADD)); + CHAIN(NODE("w2", VARIABLE)->NODE("prefetch2", HCOMALLGATHER)->NODE("add1")); + CHAIN(NODE("w3", VARIABLE)->NODE("prefetch3", HCOMALLGATHER)->NODE("add2", ADD)); + CHAIN(NODE("w4", VARIABLE)->NODE("prefetch4", HCOMALLGATHER)->NODE("add2")); + CHAIN(NODE("w5", VARIABLE)->NODE("prefetch5", HCOMALLGATHER)->NODE("add3", ADD)); + CHAIN(NODE("const1", CONSTANTOP)->NODE("add3")); + CHAIN(NODE("add1")->NODE("net_output", NETOUTPUT)); + CHAIN(NODE("add2")->NODE("net_output")); + CHAIN(NODE("add3")->NODE("net_output")); + CTRL_CHAIN(NODE("add1")->NODE("add2")->NODE("add3")); + }); + + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 15); +} + +TEST_F(GraphDslTest, test_build_graph_with_sub_graph) { + DEF_GRAPH(sub_1) { + CHAIN(NODE("data_i", DATA)->NODE("less", LESS)->NODE("netoutput", NETOUTPUT)); + CHAIN(NODE("const_5", CONSTANTOP)->NODE("less")); + }); + + DEF_GRAPH(sub_2) { + CHAIN(NODE("data_a", DATA)->NODE("mul", MUL)->NODE("netoutput", NETOUTPUT)); + CHAIN(NODE("const_2", CONSTANTOP)->NODE("mul")); + }); + + DEF_GRAPH(g1) { + CHAIN(NODE("data_a", DATA)->NODE("while", WHILE, sub_1, sub_2)->NODE("netoutput", NETOUTPUT)); + CHAIN(NODE("data_i", DATA)->NODE("while")); + }); + + sub_1.Layout(); + sub_2.Layout(); + auto geGraph = ToGeGraph(g1); + + ASSERT_EQ(geGraph.GetAllNodes().size(), 12); +} diff --git a/tests/framework/ge_graph_dsl/tests/stub/optype_stub.cc b/tests/framework/ge_graph_dsl/tests/stub/optype_stub.cc new file mode 100644 index 00000000..b83d68fc --- /dev/null +++ b/tests/framework/ge_graph_dsl/tests/stub/optype_stub.cc @@ -0,0 +1,33 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "framework/common/types.h" +#include "graph/debug/ge_attr_define.h" +#include "ge_graph_dsl/ge.h" + +GE_NS_BEGIN + +REGISTER_OPTYPE_DEFINE(DATA, "Data"); +REGISTER_OPTYPE_DEFINE(HCOMALLGATHER, "HcomAllGather"); +REGISTER_OPTYPE_DEFINE(VARIABLE, "Variable"); +REGISTER_OPTYPE_DEFINE(CONSTANTOP, "Constant"); +REGISTER_OPTYPE_DEFINE(LESS, "Less"); +REGISTER_OPTYPE_DEFINE(MUL, "Mul"); +REGISTER_OPTYPE_DEFINE(NETOUTPUT, "NetOutput"); +REGISTER_OPTYPE_DEFINE(ADD, "Add"); +REGISTER_OPTYPE_DEFINE(WHILE, "While"); + +GE_NS_END diff --git a/tests/framework/stub_engine/CMakeLists.txt b/tests/framework/stub_engine/CMakeLists.txt new file mode 100644 index 00000000..c86313c7 --- /dev/null +++ b/tests/framework/stub_engine/CMakeLists.txt @@ -0,0 +1,58 @@ +list(APPEND INCLUDE_DIRECTORIES + "${CMAKE_CURRENT_SOURCE_DIR}" + "${GE_CODE_DIR}" + "${GE_CODE_DIR}/inc" + "${GE_CODE_DIR}/metadef/inc" + "${GE_CODE_DIR}/ge" + "${GE_CODE_DIR}/ge/inc" + "${GE_CODE_DIR}/ge/ir_build" + "${GE_CODE_DIR}/metadef" + "${GE_CODE_DIR}/metadef/graph" + "${GE_CODE_DIR}/inc/external" + "${GE_CODE_DIR}/inc/framework/common" + "${GE_CODE_DIR}/metadef/inc/external" + "${GE_CODE_DIR}/metadef/inc/external/graph" + "${GE_CODE_DIR}/metadef/inc/graph" + "${GE_CODE_DIR}/inc/framework" + "${GE_CODE_DIR}/metadef/inc/common" + "${GE_CODE_DIR}/metadef/third_party" + "${GE_CODE_DIR}/metadef/third_party/transformer/inc" + "${GE_CODE_DIR}/parser" + "${GE_CODE_DIR}/parser/parser" + "${GE_CODE_DIR}/third_party/fwkacllib/inc" + "${GE_CODE_DIR}/third_party/fwkacllib/inc/cce" + "${GE_CODE_DIR}/third_party/fwkacllib/inc/ops" + "${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain" + "${GE_CODE_DIR}/tests/ut/ge" + "${GE_CODE_DIR}/tests/ut/common" + "${CMAKE_BINARY_DIR}" + "${CMAKE_BINARY_DIR}/proto/ge" + "${CMAKE_BINARY_DIR}/proto/ge/proto" + ) + +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cc" "*.CC" "*.cpp" "*.CPP" "*.c++") + +# ---- Target : stub Host engine ---- +add_library(fe SHARED ${SOURCES}) + +target_include_directories(fe + PUBLIC + ${INCLUDE_DIRECTORIES} + ${CMAKE_CURRENT_SOURCE_DIR} + ) + +target_compile_definitions(fe PRIVATE + google=ascend_private + FMK_SUPPORT_DUMP + ) + +target_compile_options(fe PRIVATE + -g --coverage -fprofile-arcs -ftest-coverage + -Werror=format + ) + +target_link_libraries(fe PUBLIC + $ ${STUB_LIBS} metadef_graph -lmmpa -L${GE_CODE_DIR}/third_party/prebuild/x86_64 -lrt -ldl -lpthread -lgcov + ) + +set_target_properties(fe PROPERTIES CXX_STANDARD 11) diff --git a/tests/framework/stub_engine/engine/stub_engine.cc b/tests/framework/stub_engine/engine/stub_engine.cc new file mode 100644 index 00000000..622e8c4e --- /dev/null +++ b/tests/framework/stub_engine/engine/stub_engine.cc @@ -0,0 +1,74 @@ +/** + * Copyright 2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "stub_engine.h" +#include +#include +#include +#include +#include "framework/common/debug/ge_log.h" +#include "common/ge/ge_util.h" +#include "inc/st_types.h" + +namespace ge { +namespace st { +StubEngine &StubEngine::Instance() { + static StubEngine instance; + return instance; +} + +Status StubEngine::Initialize(const std::map &options) { + for (const auto engine_2_lib : kStubEngine2KernelLib) { + auto ops_kernel_store = MakeShared(engine_2_lib.second); + if (ops_kernel_store == nullptr) { + return FAILED; + } + ops_kernel_store_map_.insert(make_pair(engine_2_lib.second, ops_kernel_store)); + } + return SUCCESS; +} + +void StubEngine::GetOpsKernelInfoStores(std::map &ops_kernel_map) { + for (const auto name_2_ops_kernel_store : ops_kernel_store_map_) { + ops_kernel_map[name_2_ops_kernel_store.first] = name_2_ops_kernel_store.second; + } +} + +void StubEngine::GetGraphOptimizerObjs(std::map &) { + // no optimizer for host cpu engine +} + +Status StubEngine::Finalize() { + return SUCCESS; +} +} // namespace st +} // namespace ge + +ge::Status Initialize(const std::map &options) { + return ge::st::StubEngine::Instance().Initialize(options); +} + +void GetOpsKernelInfoStores(std::map &ops_kernel_map) { + ge::st::StubEngine::Instance().GetOpsKernelInfoStores(ops_kernel_map); +} + +void GetGraphOptimizerObjs(std::map &graph_optimizers) { + ge::st::StubEngine::Instance().GetGraphOptimizerObjs(graph_optimizers); +} + +ge::Status Finalize() { + return ge::st::StubEngine::Instance().Finalize(); +} diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.h b/tests/framework/stub_engine/engine/stub_engine.h similarity index 78% rename from ge/host_cpu_engine/engine/host_cpu_engine.h rename to tests/framework/stub_engine/engine/stub_engine.h index c29df00c..d3909115 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.h +++ b/tests/framework/stub_engine/engine/stub_engine.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef GE_HOST_CPU_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ -#define GE_HOST_CPU_ENGINE_ENGINE_HOST_CPU_ENGINE_H_ +#ifndef GRAPH_ENGINE_LLT_STUB_ENGINE_H_ +#define GRAPH_ENGINE_LLT_STUB_ENGINE_H_ #if defined(_MSC_VER) #ifdef FUNC_VISIBILITY @@ -34,27 +34,30 @@ #include #include #include +#include "inc/st_types.h" #include "common/opskernel/ops_kernel_info_store.h" #include "common/optimizer/graph_optimizer.h" +#include "stub_engine/ops_kernel_store/stub_ops_kernel_store.h" using OpsKernelInfoStorePtr = std::shared_ptr; +using StubOpsKernelInfoStorePtr = std::shared_ptr; using GraphOptimizerPtr = std::shared_ptr; namespace ge { -namespace host_cpu { +namespace st { /** * host cpu engine. * Used for the ops which executes on host. */ -class GE_FUNC_VISIBILITY HostCpuEngine { +class GE_FUNC_VISIBILITY StubEngine { public: /** - * get HostCpuEngine instance. - * @return HostCpuEngine instance. + * get StubEngine instance. + * @return StubEngine instance. */ - static HostCpuEngine &Instance(); + static StubEngine &Instance(); - virtual ~HostCpuEngine() = default; + virtual ~StubEngine() = default; /** * When Ge start, GE will invoke this interface @@ -82,17 +85,16 @@ class GE_FUNC_VISIBILITY HostCpuEngine { */ Status Finalize(); - HostCpuEngine(const HostCpuEngine &HostCpuEngine) = delete; - HostCpuEngine(const HostCpuEngine &&HostCpuEngine) = delete; - HostCpuEngine &operator=(const HostCpuEngine &HostCpuEngine) = delete; - HostCpuEngine &operator=(HostCpuEngine &&HostCpuEngine) = delete; + StubEngine(const StubEngine &StubEngine) = delete; + StubEngine(const StubEngine &&StubEngine) = delete; + StubEngine &operator=(const StubEngine &StubEngine) = delete; + StubEngine &operator=(StubEngine &&StubEngine) = delete; private: - HostCpuEngine() = default; - - OpsKernelInfoStorePtr ops_kernel_store_ = nullptr; + StubEngine() = default; + map ops_kernel_store_map_; }; -} // namespace host_cpu +} // namespace st } // namespace ge extern "C" { @@ -122,4 +124,4 @@ GE_FUNC_VISIBILITY void GetGraphOptimizerObjs(std::map +namespace ge { +namespace st { +const std::string kAicoreLibName = "AiCoreLib"; +const std::string kVectorLibName = "VectorLib"; +const std::string kAicpuLibName = "AicpuLib"; +const std::string kAicpuAscendLibName = "AicpuAscendLib"; +const std::string kHcclLibName = "HcclLib"; +const std::string kRTSLibName = "RTSLib"; +const std::map kStubEngine2KernelLib = { + {"AIcoreEngine", "AiCoreLib"}, {"VectorEngine", "VectorLib"}, + {"DNN_VM_AICPU", "AicpuLib"}, {"DNN_VM_AICPU_ASCEND", "AicpuAscendLib"}, + {"DNN_HCCL", "HcclLib"}, {"DNN_VM_RTS", "RTSLib"}}; +} // namespace st +} // namespace ge +#endif // GRAPHENGINE_ST_TYPES_H diff --git a/tests/framework/stub_engine/ops_kernel_store/op/host_op.cc b/tests/framework/stub_engine/ops_kernel_store/op/host_op.cc new file mode 100644 index 00000000..42678148 --- /dev/null +++ b/tests/framework/stub_engine/ops_kernel_store/op/host_op.cc @@ -0,0 +1,41 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "inc/st_types.h" +#include "stub_engine/ops_kernel_store/op/host_op.h" +#include "framework/common/util.h" +#include "stub_engine/ops_kernel_store/op/stub_op_factory.h" + +namespace ge { +namespace st { +Status HostOp::Run() { + // no need to generate device task + return SUCCESS; +} +REGISTER_OP_CREATOR(Enter, RTSLib, HostOp); +REGISTER_OP_CREATOR(Merge, RTSLib, HostOp); +REGISTER_OP_CREATOR(Switch, RTSLib, HostOp); +REGISTER_OP_CREATOR(Less, AiCoreLib, HostOp); +REGISTER_OP_CREATOR(NextIteration, AiCoreLib, HostOp); +REGISTER_OP_CREATOR(LoopCond, RTSLib, HostOp); +REGISTER_OP_CREATOR(Exit, RTSLib, HostOp); +REGISTER_OP_CREATOR(StreamMerge, RTSLib, HostOp); +REGISTER_OP_CREATOR(StreamSwitch, RTSLib, HostOp); +REGISTER_OP_CREATOR(StreamActive, RTSLib, HostOp); +REGISTER_OP_CREATOR(Cast, AiCoreLib, HostOp); +REGISTER_OP_CREATOR(Transdata, AiCoreLib, HostOp); +} // namespace st +} // namespace ge diff --git a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h b/tests/framework/stub_engine/ops_kernel_store/op/host_op.h similarity index 87% rename from ge/host_cpu_engine/ops_kernel_store/op/host_op.h rename to tests/framework/stub_engine/ops_kernel_store/op/host_op.h index 023eb957..464df47a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/host_op.h +++ b/tests/framework/stub_engine/ops_kernel_store/op/host_op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,10 +17,10 @@ #ifndef GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_OP_HOST_OP_H_ #define GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_OP_HOST_OP_H_ -#include "host_cpu_engine/ops_kernel_store/op/op.h" +#include "stub_engine/ops_kernel_store/op/op.h" namespace ge { -namespace host_cpu { +namespace st { class GE_FUNC_VISIBILITY HostOp : public Op { public: HostOp(const Node &node, RunContext &run_context) : Op(node, run_context) {} @@ -30,7 +30,7 @@ class GE_FUNC_VISIBILITY HostOp : public Op { Status Run() override; }; -} // namespace host_cpu +} // namespace st } // namespace ge #endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_OP_HOST_OP_H_ diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op.h b/tests/framework/stub_engine/ops_kernel_store/op/op.h similarity index 92% rename from ge/host_cpu_engine/ops_kernel_store/op/op.h rename to tests/framework/stub_engine/ops_kernel_store/op/op.h index b4c8b33e..3741567a 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op.h +++ b/tests/framework/stub_engine/ops_kernel_store/op/op.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,7 +25,7 @@ #include "graph/node.h" namespace ge { -namespace host_cpu { +namespace st { /** * The base class for all op. */ @@ -39,7 +39,7 @@ class GE_FUNC_VISIBILITY Op { const RunContext &run_context_; const Node &node_; }; -} // namespace host_cpu +} // namespace st } // namespace ge #endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_OP_OP_H_ diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc b/tests/framework/stub_engine/ops_kernel_store/op/stub_op_factory.cc similarity index 73% rename from ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc rename to tests/framework/stub_engine/ops_kernel_store/op/stub_op_factory.cc index 176ae579..601bca4d 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.cc +++ b/tests/framework/stub_engine/ops_kernel_store/op/stub_op_factory.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,13 +14,13 @@ * limitations under the License. */ -#include "host_cpu_engine/ops_kernel_store/op/op_factory.h" +#include "stub_op_factory.h" #include "framework/common/debug/ge_log.h" #include "common/ge_inner_error_codes.h" #include "graph/op_desc.h" namespace ge { -namespace host_cpu { +namespace st { OpFactory &OpFactory::Instance() { static OpFactory instance; return instance; @@ -31,25 +31,21 @@ std::shared_ptr OpFactory::CreateOp(const Node &node, RunContext &run_contex if (iter != op_creator_map_.end()) { return iter->second(node, run_context); } - GELOGE(FAILED, "Not supported OP, type = %s, name = %s", node.GetType().c_str(), node.GetName().c_str()); return nullptr; } -void OpFactory::RegisterCreator(const std::string &type, const OP_CREATOR_FUNC &func) { +void OpFactory::RegisterCreator(const std::string &type, const std::string &kernel_lib, const OP_CREATOR_FUNC &func) { if (func == nullptr) { GELOGW("Func is NULL."); return; } - auto iter = op_creator_map_.find(type); - if (iter != op_creator_map_.end()) { - GELOGW("%s creator already exist", type.c_str()); - return; + if (all_store_ops_.find(kernel_lib) != all_store_ops_.end()) { + all_store_ops_[kernel_lib].emplace_back(type); + } else { + all_store_ops_[kernel_lib] = {type}; } - - op_creator_map_[type] = func; - all_ops_.emplace_back(type); } -} // namespace host_cpu +} // namespace st } // namespace ge diff --git a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h b/tests/framework/stub_engine/ops_kernel_store/op/stub_op_factory.h similarity index 63% rename from ge/host_cpu_engine/ops_kernel_store/op/op_factory.h rename to tests/framework/stub_engine/ops_kernel_store/op/stub_op_factory.h index 73174860..f41fd07e 100644 --- a/ge/host_cpu_engine/ops_kernel_store/op/op_factory.h +++ b/tests/framework/stub_engine/ops_kernel_store/op/stub_op_factory.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,10 +23,11 @@ #include #include #include "common/ge/ge_util.h" -#include "host_cpu_engine/ops_kernel_store/op/op.h" +#include "stub_engine/ops_kernel_store/op/op.h" +#include "inc/st_types.h" namespace ge { -namespace host_cpu { +namespace st { using OP_CREATOR_FUNC = std::function(const Node &, RunContext &)>; /** @@ -50,11 +51,23 @@ class GE_FUNC_VISIBILITY OpFactory { * @param [in] type Op type * @param [in] func Op create func */ - void RegisterCreator(const std::string &type, const OP_CREATOR_FUNC &func); + void RegisterCreator(const std::string &type, const std::string &lib_name, const OP_CREATOR_FUNC &func); - const std::vector &GetAllOps() const { return all_ops_; } + const std::vector &GetAllOps() const { + return all_ops_; + } + + const std::vector &GetAllOps(std::string lib_name) const { + auto iter = all_store_ops_.find(lib_name); + if (iter == all_store_ops_.end()) { + return all_ops_; + } + return iter->second; + } - bool CheckSupported(const std::string &type) { return op_creator_map_.find(type) != op_creator_map_.end(); } + bool CheckSupported(const std::string &type) { + return op_creator_map_.find(type) != op_creator_map_.end(); + } OpFactory(const OpFactory &) = delete; OpFactory &operator=(const OpFactory &) = delete; @@ -67,13 +80,15 @@ class GE_FUNC_VISIBILITY OpFactory { // the op creator function map std::map op_creator_map_; + std::map> lib_op_creator_map_; std::vector all_ops_; + std::map> all_store_ops_; }; class GE_FUNC_VISIBILITY OpRegistrar { public: - OpRegistrar(const std::string &type, const OP_CREATOR_FUNC &func) { - OpFactory::Instance().RegisterCreator(type, func); + OpRegistrar(const std::string &type, const std::string &kernel_lib, const OP_CREATOR_FUNC &func) { + OpFactory::Instance().RegisterCreator(type, kernel_lib, func); } ~OpRegistrar() = default; @@ -83,12 +98,12 @@ class GE_FUNC_VISIBILITY OpRegistrar { OpRegistrar &operator=(OpRegistrar &&) = delete; }; -#define REGISTER_OP_CREATOR(type, clazz) \ - std::shared_ptr Creator_##type##Op(const Node &node, RunContext &run_context) { \ - return MakeShared(node, run_context); \ - } \ - OpRegistrar g_##type##Op_creator(#type, Creator_##type##Op) -} // namespace host_cpu +#define REGISTER_OP_CREATOR(type, lib_name, clazz) \ + std::shared_ptr Creator_##type##Op(const Node &node, RunContext &run_context) { \ + return MakeShared(node, run_context); \ + } \ + OpRegistrar g_##type##Op_creator(#type, #lib_name, Creator_##type##Op) +} // namespace st } // namespace ge #endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_OP_OP_FACTORY_H_ diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_builder.cc similarity index 64% rename from ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc rename to tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_builder.cc index 47809ae1..2de8691f 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc +++ b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_builder.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,7 +14,7 @@ * limitations under the License. */ -#include "host_cpu_ops_kernel_builder.h" +#include "stub_ops_kernel_builder.h" #include #include "common/ge_inner_error_codes.h" #include "ge/ge_api_types.h" @@ -25,19 +25,25 @@ #include "framework/common/debug/ge_log.h" #include "host_cpu_engine/common/constant/constant.h" #include "register/ops_kernel_builder_registry.h" +#include "inc/st_types.h" namespace ge { -namespace host_cpu { -REGISTER_OPS_KERNEL_BUILDER(kHostCpuOpKernelLibName, HostCpuOpsKernelBuilder); +namespace st { +REGISTER_OPS_KERNEL_BUILDER(kAicoreLibName, StubOpsKernelBuilder); +REGISTER_OPS_KERNEL_BUILDER(kVectorLibName, StubOpsKernelBuilder); +REGISTER_OPS_KERNEL_BUILDER(kAicpuLibName, StubOpsKernelBuilder); +REGISTER_OPS_KERNEL_BUILDER(kAicpuAscendLibName, StubOpsKernelBuilder); +REGISTER_OPS_KERNEL_BUILDER(kHcclLibName, StubOpsKernelBuilder); +REGISTER_OPS_KERNEL_BUILDER(kRTSLibName, StubOpsKernelBuilder); -Status HostCpuOpsKernelBuilder::Finalize() { +Status StubOpsKernelBuilder::Finalize() { return SUCCESS; } -Status HostCpuOpsKernelBuilder::Initialize(const map &options) { +Status StubOpsKernelBuilder::Initialize(const map &options) { return SUCCESS; } -Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { +Status StubOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { OpDescPtr op_desc = ge_node.GetOpDesc(); if (op_desc == nullptr) { GELOGE(FAILED, "[Get][OpDesc]CalcOpRunningParam failed, as op desc is null"); @@ -75,29 +81,28 @@ Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { GeShape output_shape = output_tensor.GetShape(); if ((TensorUtils::CalcTensorMemSize(output_shape, format, data_type, output_mem_size) != GRAPH_SUCCESS) || (output_mem_size < 0)) { - GELOGE(FAILED, - "[Calc][TensorMemSize] fail for op[%s:%s] out[%zu] mem size, mem_size=%ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), - TypeUtils::DataTypeToSerialString(data_type).c_str()); - REPORT_CALL_ERROR("E19999", - "CalcTensorMemSize failed for op[%s:%s] out[%zu] mem size, mem_size=%ld, format=%s, data_type=%s.", + GELOGE(FAILED, + "[Calc][TensorMemSize] fail for op[%s:%s] out[%zu] mem size, mem_size=%ld, format=%s, data_type=%s.", + name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + REPORT_CALL_ERROR( + "E19999", "CalcTensorMemSize failed for op[%s:%s] out[%zu] mem size, mem_size=%ld, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; } - GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), + GELOGI("Calc op[%s:%s] out[%zu] mem size is %ld, format=%s, data_type=%s.", name.c_str(), type.c_str(), i, + output_mem_size, TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); TensorUtils::SetSize(output_tensor, output_mem_size); if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { - GELOGE(FAILED, - "[Update][OutputDesc] fail for op[%s:%s] out[%zu] desc , format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, - TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGE(FAILED, "[Update][OutputDesc] fail for op[%s:%s] out[%zu] desc , format=%s, data_type=%s.", name.c_str(), + type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); REPORT_CALL_ERROR("E19999", "UpdateOutputDesc failed for op[%s:%s] out[%zu] desc , format=%s, data_type=%s.", - name.c_str(), type.c_str(), i, - TypeUtils::FormatToSerialString(format).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); + name.c_str(), type.c_str(), i, TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; } } @@ -106,9 +111,9 @@ Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { return SUCCESS; } -Status HostCpuOpsKernelBuilder::GenerateTask(const Node &node, RunContext &context, vector &tasks) { +Status StubOpsKernelBuilder::GenerateTask(const Node &node, RunContext &context, vector &tasks) { // no need to generate device task return SUCCESS; } -} // namespace host_cpu +} // namespace st } // namespace ge \ No newline at end of file diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_builder.h similarity index 89% rename from ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h rename to tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_builder.h index 066d943c..62dab542 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.h +++ b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_builder.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,8 +34,8 @@ #include "common/opskernel/ops_kernel_builder.h" namespace ge { -namespace host_cpu { -class GE_FUNC_VISIBILITY HostCpuOpsKernelBuilder : public OpsKernelBuilder { +namespace st { +class GE_FUNC_VISIBILITY StubOpsKernelBuilder : public OpsKernelBuilder { public: Status Initialize(const map &options) override; @@ -45,7 +45,7 @@ class GE_FUNC_VISIBILITY HostCpuOpsKernelBuilder : public OpsKernelBuilder { Status GenerateTask(const Node &node, RunContext &context, std::vector &tasks) override; }; -} // namespace host_cpu +} // namespace st } // namespace ge #endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_BUILDER_H_ diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_store.cc similarity index 55% rename from ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc rename to tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_store.cc index de20492c..d43fee88 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.cc +++ b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_store.cc @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,54 +14,64 @@ * limitations under the License. */ -#include "host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h" +#include "stub_ops_kernel_store.h" #include -#include "common/constant/constant.h" #include "ge/ge_api_types.h" #include "framework/common/debug/ge_log.h" #include "graph/utils/node_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" -#include "op/op_factory.h" +#include "op/stub_op_factory.h" namespace ge { -namespace host_cpu { +namespace st { using domi::TaskDef; using std::map; using std::string; using std::vector; -Status HostCpuOpsKernelInfoStore::Initialize(const map &options) { - GELOGI("HostCpuOpsKernelInfoStore init start."); - OpInfo default_op_info = {.engine = kHostCpuEngineName, - .opKernelLib = kHostCpuOpKernelLibName, +Status StubOpsKernelInfoStore::Initialize(const map &options) { + GELOGI("StubOpsKernelInfoStore init start."); + string engine_name; + for (const auto &engine_2_lib : kStubEngine2KernelLib) { + if (engine_2_lib.second == store_name_) { + engine_name = engine_2_lib.first; + } + } + if (engine_name.empty()) { + return FAILED; + } + + OpInfo default_op_info = {.engine = engine_name, + .opKernelLib = store_name_, .computeCost = 0, .flagPartial = false, .flagAsync = false, .isAtomic = false}; // Init op_info_map_ - auto all_ops = OpFactory::Instance().GetAllOps(); - for (auto &op : all_ops) { + auto all_ops_in_store = OpFactory::Instance().GetAllOps(store_name_); + for (auto &op : all_ops_in_store) { op_info_map_[op] = default_op_info; } - GELOGI("HostCpuOpsKernelInfoStore inited success. op num=%zu", op_info_map_.size()); - + GELOGI("StubOpsKernelInfoStore inited success. op num=%zu", op_info_map_.size()); return SUCCESS; } -Status HostCpuOpsKernelInfoStore::Finalize() { +Status StubOpsKernelInfoStore::Finalize() { op_info_map_.clear(); return SUCCESS; } -void HostCpuOpsKernelInfoStore::GetAllOpsKernelInfo(map &infos) const { infos = op_info_map_; } +void StubOpsKernelInfoStore::GetAllOpsKernelInfo(map &infos) const { + infos = op_info_map_; +} -bool HostCpuOpsKernelInfoStore::CheckSupported(const OpDescPtr &op_desc, std::string &) const { +bool StubOpsKernelInfoStore::CheckSupported(const OpDescPtr &op_desc, std::string &) const { if (op_desc == nullptr) { return false; } return op_info_map_.count(op_desc->GetType()) > 0; } -} // namespace host_cpu +} // namespace st } // namespace ge diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_store.h similarity index 56% rename from ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h rename to tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_store.h index e3667d61..ea7f712b 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_info.h +++ b/tests/framework/stub_engine/ops_kernel_store/stub_ops_kernel_store.h @@ -1,5 +1,5 @@ /** - * Copyright 2020 Huawei Technologies Co., Ltd + * Copyright 2021 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,49 +38,36 @@ #include "common/opskernel/ops_kernel_info_store.h" namespace ge { -namespace host_cpu { -class GE_FUNC_VISIBILITY HostCpuOpsKernelInfoStore : public OpsKernelInfoStore { +namespace st { +/*const vector kStubOpKernelLibNameVec = { + "AiCoreLib", + "AicpuLib", + "HcclLib", + "RTSLib" +};*/ +class GE_FUNC_VISIBILITY StubOpsKernelInfoStore : public OpsKernelInfoStore { public: - HostCpuOpsKernelInfoStore() {} - ~HostCpuOpsKernelInfoStore() override = default; - - /** - * Initialize related resources of the host cpu kernelinfo store - * @return status whether this operation success - */ + StubOpsKernelInfoStore(std::string store_name) : store_name_(store_name) {} + ~StubOpsKernelInfoStore() override = default; Status Initialize(const std::map &options) override; - - /** - * Release related resources of the host cpu kernel info store - * @return status whether this operation success - */ Status Finalize() override; - - /** - * Check to see if an operator is fully supported or partially supported. - * @param op_desc OpDesc information - * @param reason unsupported reason - * @return bool value indicate whether the operator is fully supported - */ bool CheckSupported(const OpDescPtr &op_desc, std::string &reason) const override; - - /** - * Returns the full operator information. - * @param infos reference of a map, - * contain operator's name and detailed information - */ void GetAllOpsKernelInfo(std::map &infos) const override; + std::string GetOpsKernelStoreName() const { + return store_name_; + } - HostCpuOpsKernelInfoStore(const HostCpuOpsKernelInfoStore &ops_kernel_store) = delete; - HostCpuOpsKernelInfoStore(const HostCpuOpsKernelInfoStore &&ops_kernel_store) = delete; - HostCpuOpsKernelInfoStore &operator=(const HostCpuOpsKernelInfoStore &ops_kernel_store) = delete; - HostCpuOpsKernelInfoStore &operator=(HostCpuOpsKernelInfoStore &&ops_kernel_store) = delete; + StubOpsKernelInfoStore(const StubOpsKernelInfoStore &ops_kernel_store) = delete; + StubOpsKernelInfoStore(const StubOpsKernelInfoStore &&ops_kernel_store) = delete; + StubOpsKernelInfoStore &operator=(const StubOpsKernelInfoStore &ops_kernel_store) = delete; + StubOpsKernelInfoStore &operator=(StubOpsKernelInfoStore &&ops_kernel_store) = delete; private: // store op name and OpInfo key-value pair std::map op_info_map_; + std::string store_name_; }; -} // namespace host_cpu +} // namespace st } // namespace ge #endif // GE_HOST_CPU_ENGINE_OPS_KERNEL_STORE_HOST_CPU_OPS_KERNEL_INFO_H_ diff --git a/tests/framework/utils/builder/graph_builder_utils.cc b/tests/framework/utils/builder/graph_builder_utils.cc new file mode 100644 index 00000000..c5555235 --- /dev/null +++ b/tests/framework/utils/builder/graph_builder_utils.cc @@ -0,0 +1,48 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "graph_builder_utils.h" +#include "inc/external/graph/operator.h" +#include "inc/external/graph/operator_factory.h" +#include "graph/utils/graph_utils.h" + +namespace ge { +namespace st { +NodePtr ComputeGraphBuilder::AddNode(const std::string &name, const std::string &type, int in_cnt, int out_cnt, + Format format, DataType data_type, std::vector shape) { + auto tensor_desc = std::make_shared(); + tensor_desc->SetShape(GeShape(std::move(shape))); + tensor_desc->SetFormat(format); + tensor_desc->SetDataType(data_type); + + auto op_desc = std::make_shared(name, type); + for (int i = 0; i < in_cnt; ++i) { + op_desc->AddInputDesc(tensor_desc->Clone()); + } + for (int i = 0; i < out_cnt; ++i) { + op_desc->AddOutputDesc(tensor_desc->Clone()); + } + + return graph_->AddNode(op_desc); +} +void ComputeGraphBuilder::AddDataEdge(NodePtr &src_node, int src_idx, NodePtr &dst_node, int dst_idx) { + GraphUtils::AddEdge(src_node->GetOutDataAnchor(src_idx), dst_node->GetInDataAnchor(dst_idx)); +} +void ComputeGraphBuilder::AddControlEdge(NodePtr &src_node, NodePtr &dst_node) { + GraphUtils::AddEdge(src_node->GetOutControlAnchor(), dst_node->GetInControlAnchor()); +} +} // namespace st +} // namespace ge diff --git a/tests/framework/utils/builder/graph_builder_utils.h b/tests/framework/utils/builder/graph_builder_utils.h new file mode 100644 index 00000000..4627f082 --- /dev/null +++ b/tests/framework/utils/builder/graph_builder_utils.h @@ -0,0 +1,55 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRAPHENGINE_LLT_ST_GRAPH_BUILDER_H +#define GRAPHENGINE_LLT_ST_GRAPH_BUILDER_H + +#include +#include + +#include "graph/compute_graph.h" +#include "graph/utils/graph_utils.h" +#include "graph/graph.h" +#include "graph/node.h" + +namespace ge { +namespace st { +class ComputeGraphBuilder { + public: + explicit ComputeGraphBuilder(const std::string &name) { + graph_ = std::make_shared(name); + } + NodePtr AddNode(const std::string &name, const std::string &type, int in_cnt, int out_cnt, + Format format = FORMAT_NCHW, DataType data_type = DT_FLOAT, + std::vector shape = {1, 1, 224, 224}); + void AddDataEdge(NodePtr &src_node, int src_idx, NodePtr &dst_node, int dst_idx); + void AddControlEdge(NodePtr &src_node, NodePtr &dst_node); + ComputeGraphPtr GetComputeGraph() { + graph_->TopologicalSorting(); + return graph_; + } + Graph GetGraph() { + graph_->TopologicalSorting(); + return GraphUtils::CreateGraphFromComputeGraph(graph_); + } + + private: + ComputeGraphPtr graph_; +}; +} // namespace st +} // namespace ge + +#endif // GRAPHENGINE_LLT_ST_GRAPH_BUILDER_H diff --git a/tests/framework/utils/builder/tensor_builder_utils.cc b/tests/framework/utils/builder/tensor_builder_utils.cc new file mode 100644 index 00000000..f99b9107 --- /dev/null +++ b/tests/framework/utils/builder/tensor_builder_utils.cc @@ -0,0 +1,17 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "tensor_builder_utils.h" diff --git a/tests/framework/utils/builder/tensor_builder_utils.h b/tests/framework/utils/builder/tensor_builder_utils.h new file mode 100644 index 00000000..73656e4a --- /dev/null +++ b/tests/framework/utils/builder/tensor_builder_utils.h @@ -0,0 +1,22 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GRAPHENGINE_LLT_ST_TENSOR_BUILDER_UTILS_H +#define GRAPHENGINE_LLT_ST_TENSOR_BUILDER_UTILS_H + +class tensor_builder_utils {}; + +#endif // GRAPHENGINE_LLT_ST_TENSOR_BUILDER_UTILS_H diff --git a/tests/st/CMakeLists.txt b/tests/st/CMakeLists.txt new file mode 100644 index 00000000..9e05b03b --- /dev/null +++ b/tests/st/CMakeLists.txt @@ -0,0 +1,2 @@ +project(graphengine_st) +add_subdirectory(testcase) \ No newline at end of file diff --git a/tests/st/testcase/CMakeLists.txt b/tests/st/testcase/CMakeLists.txt new file mode 100644 index 00000000..9d1d5a0e --- /dev/null +++ b/tests/st/testcase/CMakeLists.txt @@ -0,0 +1,15 @@ +file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS "*.cc" "*.CC" "*.cpp" "*.CPP" "*.c++") + +add_executable(graph_engine_test ${SOURCES}) + +target_include_directories(graph_engine_test + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} +) + +set_target_properties(graph_engine_test PROPERTIES CXX_STANDARD 17) + +target_link_libraries(graph_engine_test PRIVATE gtest gtest_main framework) + +include(CTest) +enable_testing() +add_test(NAME test COMMAND graph_engine_test) \ No newline at end of file diff --git a/tests/st/testcase/test_framework_dummy.cc b/tests/st/testcase/test_framework_dummy.cc new file mode 100644 index 00000000..951e6b2b --- /dev/null +++ b/tests/st/testcase/test_framework_dummy.cc @@ -0,0 +1,188 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include "external/ge/ge_api.h" +#include "graph/debug/ge_attr_define.h" +#include "framework/common/types.h" +#include "builder/graph_builder_utils.h" +#include "graph/operator_reg.h" +#include "graph/operator.h" +#define protected public +#define private public +#include "graph/utils/op_desc_utils.h" +#include "ge_graph_dsl/graph_dsl.h" +#undef protected +#undef private + +using namespace std; +using namespace ge; +namespace { +/** data a = 2; + * for(int i =0; i<5; ++i){ + * a=a * 2; + * } + * return a; + * ----------------------------------------------| + * | const(5) exit const(1) | + * | \ / \ | + * data(i)--Enter--merge--less--loopcond--switch-----add-----nextiteration + * \________________\___/ + * ------\------------------------| + * | \ const(2) | + * | \ \ | + * data(a)--Enter--merge--switch------mul-----nextiteration + * \ + * exit + * \ + * netoutput + * + **/ +Graph BuildV1ControlFlowGraph() { + // build graph + st::ComputeGraphBuilder graphBuilder("g1"); + auto data_i = graphBuilder.AddNode("data_i", DATA, 1, 1); + auto enter_i = graphBuilder.AddNode("enter_i", ENTER, 1, 1); + ge::AttrUtils::SetStr(enter_i->GetOpDesc(), ENTER_ATTR_FRAME_NAME, "1"); + auto merge_i = graphBuilder.AddNode("merge_i", MERGE, 2, 1); + auto const_5 = graphBuilder.AddNode("const_5", CONSTANT, 0, 1); + auto less = graphBuilder.AddNode("less", LESS, 2, 1); + auto loopcond = graphBuilder.AddNode("loopcond", LOOPCOND, 1, 1, FORMAT_NCHW, DT_BOOL); + auto switch_i = graphBuilder.AddNode("switch_i", SWITCH, 2, 2); + auto exit_i = graphBuilder.AddNode("switch_i", EXIT, 1, 1); + auto const_1 = graphBuilder.AddNode("const_1", CONSTANT, 0, 1); + auto add = graphBuilder.AddNode("add", ADD, 2, 1); + auto next_iteration_i = graphBuilder.AddNode("next_iteration_i", NEXTITERATION, 1, 1); + + auto data_a = graphBuilder.AddNode("data_a", DATA, 1, 1); + auto enter_a = graphBuilder.AddNode("enter_a", ENTER, 1, 1); + ge::AttrUtils::SetStr(enter_a->GetOpDesc(), ENTER_ATTR_FRAME_NAME, "1"); + auto merge_a = graphBuilder.AddNode("merge_a", MERGE, 2, 1); + auto switch_a = graphBuilder.AddNode("switch_a", SWITCH, 2, 2); + auto exit_a = graphBuilder.AddNode("exit_a", EXIT, 1, 1); + auto mul = graphBuilder.AddNode("mul", MUL, 2, 1); + auto const_2 = graphBuilder.AddNode("const_2", CONSTANT, 0, 1); + auto next_iteration_a = graphBuilder.AddNode("next_iteration_a", NEXTITERATION, 1, 1); + auto netoutput = graphBuilder.AddNode("netoutput", NETOUTPUT, 2, 2); + // i = i+1 + graphBuilder.AddDataEdge(data_i, 0, enter_i, 0); + graphBuilder.AddDataEdge(enter_i, 0, merge_i, 0); + graphBuilder.AddDataEdge(next_iteration_i, 0, merge_i, 1); + graphBuilder.AddDataEdge(merge_i, 0, less, 0); + graphBuilder.AddDataEdge(const_5, 0, less, 1); + graphBuilder.AddDataEdge(less, 0, loopcond, 0); + graphBuilder.AddDataEdge(loopcond, 0, switch_i, 1); + graphBuilder.AddDataEdge(merge_i, 0, switch_i, 0); + graphBuilder.AddDataEdge(switch_i, 0, exit_i, 0); + graphBuilder.AddDataEdge(switch_i, 1, add, 0); + graphBuilder.AddDataEdge(const_1, 0, add, 1); + graphBuilder.AddDataEdge(add, 0, next_iteration_i, 0); + graphBuilder.AddDataEdge(exit_i, 0, netoutput, 1); + // a=a*2 + graphBuilder.AddDataEdge(data_a, 0, enter_a, 0); + graphBuilder.AddDataEdge(enter_a, 0, merge_a, 0); + graphBuilder.AddDataEdge(next_iteration_a, 0, merge_a, 1); + graphBuilder.AddDataEdge(loopcond, 0, switch_a, 1); + graphBuilder.AddDataEdge(merge_a, 0, switch_a, 0); + graphBuilder.AddDataEdge(switch_a, 0, exit_a, 0); + graphBuilder.AddDataEdge(switch_a, 1, mul, 0); + graphBuilder.AddDataEdge(const_2, 0, mul, 1); + graphBuilder.AddDataEdge(mul, 0, next_iteration_a, 0); + graphBuilder.AddDataEdge(exit_a, 0, netoutput, 0); + // set const weight + int64_t dims_size = 1; + vector data_vec = {5}; + for_each(data_vec.begin(), data_vec.end(), [&](int64_t &data) { dims_size *= data; }); + vector data_value_vec(dims_size, 1); + GeTensorDesc data_tensor_desc(GeShape(data_vec), FORMAT_NCHW, DT_INT32); + GeTensorPtr data_tensor = make_shared(data_tensor_desc, (uint8_t *) data_value_vec.data(), + data_value_vec.size() * sizeof(int32_t)); + OpDescUtils::SetWeights(const_5->GetOpDesc(), data_tensor); + OpDescUtils::SetWeights(const_2->GetOpDesc(), data_tensor); + OpDescUtils::SetWeights(const_1->GetOpDesc(), data_tensor); + + return graphBuilder.GetGraph(); +} +} // namespace +class FrameworkTest : public testing::Test { + protected: + void SetUp() { + // ge initialize + map options; + auto ret = ge::GEInitialize(options); + EXPECT_EQ(ret, SUCCESS); + } + void TearDown() {} +}; + +/// data data +/// \ / +/// add +TEST_F(FrameworkTest, test_framework_add) { + DEF_GRAPH(g1) { + CHAIN(NODE("data1", DATA)->NODE("add", ADD)); + CHAIN(NODE("data2", DATA)->NODE("add")); + }); + + auto graph = ToGeGraph(g1); + // new session & add graph + map options; + Session session(options); + auto ret = session.AddGraph(1, graph, options); + EXPECT_EQ(ret, SUCCESS); + // build input tensor + std::vector inputs; + // build_graph through session + ret = session.BuildGraph(1, inputs); + EXPECT_EQ(ret, SUCCESS); +} + +/** data a = 2; + * for(int i =0; i<5; ++i){ + * a=a * 2; + * } + * return a; + * ----------------------------------------------| + * | const(5) exit const(1) | + * | \ / \ | + * data(i)--Enter--merge--less--loopcond--switch-----add-----nextiteration + * \________________\___/ + * ------\------------------------| + * | \ const(2) | + * | \ \ | + * data(a)--Enter--merge--switch------mul-----nextiteration + * \ + * exit + * \ + * netoutput + * + **/ +TEST_F(FrameworkTest, test_framework_v1_control_flow) { + // build graph + Graph graph = BuildV1ControlFlowGraph(); + // new session & add graph + map options; + Session session(options); + auto ret = session.AddGraph(2, graph, options); + EXPECT_EQ(ret, SUCCESS); + // build input tensor + std::vector inputs; + // build_graph through session + ret = session.BuildGraph(2, inputs); + EXPECT_EQ(ret, SUCCESS); + // check result +} diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index ec0b146c..63579109 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -157,6 +157,7 @@ set(COMMON_SRC_FILES "${GE_CODE_DIR}/ge/graph/load/model_manager/model_manager.cc" "${GE_CODE_DIR}/ge/common/profiling/profiling_manager.cc" "${GE_CODE_DIR}/ge/graph/manager/host_mem_manager.cc" + "${GE_CODE_DIR}/ge/graph/manager/memory_api.cc" "${GE_CODE_DIR}/ge/session/inner_session.cc" "${GE_CODE_DIR}/ge/graph/manager/util/rt_context_util.cc" "${GE_CODE_DIR}/ge/graph/execute/graph_execute.cc" @@ -585,6 +586,7 @@ set(SINGLE_OP_SRC_FILES "${GE_CODE_DIR}/ge/single_op/single_op_manager.cc" "${GE_CODE_DIR}/ge/single_op/task/aicpu_task_builder.cc" "${GE_CODE_DIR}/ge/single_op/task/aicpu_kernel_task_builder.cc" + "${GE_CODE_DIR}/ge/single_op/task/rts_kernel_task_builder.cc" "${GE_CODE_DIR}/ge/hybrid/common/tensor_value.cc" "${GE_CODE_DIR}/ge/hybrid/common/npu_memory_allocator.cc" "${GE_CODE_DIR}/ge/hybrid/executor/rt_callback_manager.cc" @@ -613,12 +615,6 @@ set(SINGLE_OP_SRC_FILES "${GE_CODE_DIR}/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc" "${GE_CODE_DIR}/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc" "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/host_cpu_node_executor.cc" - "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/kernel_factory.cc" - "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/kernel/no_op_kernel.cc" - "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/kernel/variable_kernel.cc" - "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/kernel/assign_kernel.cc" - "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/kernel/random_uniform_kernel.cc" - "${GE_CODE_DIR}/ge/hybrid/node_executor/host_cpu/kernel/data_kernel.cc" "${GE_CODE_DIR}/ge/hybrid/node_executor/controlop/control_op_executor.cc" "${GE_CODE_DIR}/ge/hybrid/node_executor/partitioned_call/partitioned_call_node_executor.cc" "${GE_CODE_DIR}/ge/hybrid/node_executor/hccl/hccl_node_executor.cc" @@ -708,6 +704,7 @@ set(PASS_TEST_FILES "graph/passes/infershape_pass_unittest.cc" "graph/passes/mark_force_unknown_for_cond_pass_unittest.cc" "graph/passes/multi_batch_clone_pass_unittest.cc" + "graph/passes/subgraph_const_migration_pass_unittest.cc" "graph/passes/replace_with_empty_const_pass_unittest.cc" "graph/passes/link_gen_mask_nodes_pass_unittest.cc" "graph/passes/transpose_transdata_pass_unittest.cc" @@ -716,7 +713,7 @@ set(PASS_TEST_FILES "graph/passes/mark_node_unknown_shape_pass_unittest.cc" "graph/passes/reshape_recovery_pass_unittest.cc" "graph/passes/cast_remove_pass_unittest.cc" - "graph/passes/memcpy_addr_async_unittest.cc" + "graph/passes/memcpy_addr_async_unittest.cc" "graph/passes/hccl_continuous_pass_unittest.cc" "graph/passes/hccl_memcpy_pass_unittest.cc" @@ -798,6 +795,7 @@ set(MULTI_PARTS_TEST_FILES "graph/manager/hcom_util_unittest.cc" "graph/manager/graph_caching_allocator_unittest.cc" "graph/manager/host_mem_allocator_unittest.cc" + "graph/manager/memory_api_unittest.cc" "graph/manager/session_scope_mem_allocator_unittest.cc" "graph/manager/run_graph_unittest.cc" "graph/partition/dynamic_shape_partition_unittest.cc" @@ -839,7 +837,9 @@ set(HYBRID_TEST_FILES "hybrid/executor/worker/execution_engine_unittest.cc" "hybrid/model/hybrid_model_builder_unittest.cc" "hybrid/node_executor/rts/rts_node_task_unittest.cc" + "hybrid/node_executor/host_cpu/host_cpu_node_task_unittest.cc" "hybrid/node_executor/ge_local/ge_local_node_executor_unittest.cc" + "hybrid/node_executor/hccl/hccl_node_executor_unittest.cc" "hybrid/executor/hybrid_model_async_executor_unittest.cc" "hybrid/executor/hybrid_model_pipeline_executor_unittest.cc" "hybrid/node_executor/aicore/aicore_task_compiler_unittest.cc" diff --git a/tests/ut/ge/graph/build/task_generator_unittest.cc b/tests/ut/ge/graph/build/task_generator_unittest.cc index 84c6e3fc..f869f1e0 100644 --- a/tests/ut/ge/graph/build/task_generator_unittest.cc +++ b/tests/ut/ge/graph/build/task_generator_unittest.cc @@ -60,10 +60,12 @@ class UtestTaskGeneratorTest : public testing::Test { ge::ut::GraphBuilder builder("graph"); auto data = builder.AddNode("data", "phony", 1, 1); auto addn1 = builder.AddNode("addn1", "AddN", 1, 1); - auto netoutput = builder.AddNode("netoutput", "NetOutput", 2, 0); - auto op_desc = data->GetOpDesc(); - (void)AttrUtils::SetStr(op_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, "IteratorV2"); - op_desc->SetOpKernelLibName("GE"); + auto netoutput = builder.AddNode("Node_Output", "NetOutput", 2, 0); + auto data_desc = data->GetOpDesc(); + (void)AttrUtils::SetStr(data_desc, ATTR_NAME_FRAMEWORK_ORIGINAL_TYPE, "IteratorV2"); + data_desc->SetOpKernelLibName("GE"); + auto output_desc = netoutput->GetOpDesc(); + output_desc->SetOpKernelLibName("output"); builder.AddDataEdge(data, 0, addn1, 0); builder.AddControlEdge(addn1, netoutput); return builder.GetGraph(); @@ -112,7 +114,7 @@ TEST_F(UtestTaskGeneratorTest, AutoFindFpOpIndex) { TEST_F(UtestTaskGeneratorTest, FindLastBpFromBpNode) { auto graph = BuildGraphBpProfiling(); TaskGenerator task_generator(nullptr, 0); - auto net_output = graph->FindNode("netoutput"); + auto net_output = graph->FindNode("Node_Output"); // netoutput has no data input, return default value 0 EXPECT_EQ(task_generator.FindLastBpFromBpNode(graph, net_output), 0); } @@ -138,3 +140,17 @@ TEST_F(UtestTaskGeneratorTest, UpdateOpIsVarAttr) { MemManager::Instance().Finalize(); } + +TEST_F(UtestTaskGeneratorTest, AutoFindBpOpIndex) { + auto graph = BuildGraphBpProfiling(); + TaskGenerator task_generator(nullptr, 0); + auto net_output = graph->FindNode("Node_Output"); + ProfilingPoint profiling_point; + vector all_reduce_nodes; + EXPECT_EQ(task_generator.AutoFindBpOpIndex(graph, profiling_point, all_reduce_nodes), SUCCESS); + + auto output_desc = net_output->GetOpDesc(); + output_desc->SetType("HcomAllReduce"); + output_desc->SetName("hcom"); + EXPECT_EQ(task_generator.AutoFindBpOpIndex(graph, profiling_point, all_reduce_nodes), SUCCESS); +} diff --git a/tests/ut/ge/graph/manager/graph_manager_unittest.cc b/tests/ut/ge/graph/manager/graph_manager_unittest.cc index f68b5080..9bae10eb 100644 --- a/tests/ut/ge/graph/manager/graph_manager_unittest.cc +++ b/tests/ut/ge/graph/manager/graph_manager_unittest.cc @@ -114,6 +114,7 @@ #include "graph/common/local_context.h" #include "graph/common/omg_util.h" #include "common/formats/utils/formats_trans_utils.h" +#include "../passes/graph_builder_utils.h" #include "register/custom_pass_helper.h" #include "graph/ops_stub.h" #include "ge_attr_value.h" @@ -151,6 +152,24 @@ void CreateGraph(Graph &graph) { // Graph graph("test_graph"); graph.SetInputs(inputs).SetOutputs(outputs).SetTargets(targets); } +/* Data + * | + * Relu Const + * | + * Netoutput + */ + +ge::ComputeGraphPtr CreateGraphWithIsolatedConst() { + ge::ut::GraphBuilder builder("graph"); + auto data = builder.AddNode("data", "Data", 1, 1); + auto relu = builder.AddNode("addn1", "Relu", 1, 1); + auto netoutput = builder.AddNode("Node_Output", "NetOutput", 1, 0); + auto const1 = builder.AddNode("const1", "Const", 0, 1); + + builder.AddDataEdge(data, 0, relu, 0); + builder.AddDataEdge(relu, 0, netoutput, 0); + return builder.GetGraph(); +} TEST_F(UtestGraphManagerTest, set_and_get_add_graph_flag) { GraphId graph_id = 1; @@ -558,3 +577,19 @@ TEST_F(UtestGraphManagerTest, test_prerunthread_failed_2) { // auto ret = graph_manager.ParseInputsDimsForGetNexNosinkAndData(nodes, input_tensors); // EXPECT_EQ(ret, ge::SUCCESS); // } + +TEST_F(UtestGraphManagerTest, ChangeAndDeleteConst_success) { + GraphId graph_id = 1; + GraphManager graph_manager; + graph_manager.options_.train_graph_flag = true; + + auto graph = CreateGraphWithIsolatedConst(); + graph_manager.ChangeConstTypeWhenTraining(graph); + auto const1 = graph->FindFirstNodeMatchType("Const"); + EXPECT_EQ(const1, nullptr); + + Status status = graph_manager.RemoveIsolatedConstInThisGraph(graph); + EXPECT_EQ(status, ge::SUCCESS); + auto all_nodes = graph->GetDirectNode(); + EXPECT_EQ(all_nodes.size(), 3); +} diff --git a/tests/ut/ge/graph/manager/memory_api_unittest.cc b/tests/ut/ge/graph/manager/memory_api_unittest.cc new file mode 100644 index 00000000..0799adb9 --- /dev/null +++ b/tests/ut/ge/graph/manager/memory_api_unittest.cc @@ -0,0 +1,68 @@ +/** + * Copyright 2019-2020 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + + + +#define protected public +#define private public +#include "graph/manager/host_mem_manager.h" +#include "inc/framework/memory/memory_api.h" +#undef protected +#undef private +#include "metadef/inc/graph/aligned_ptr.h" + +using namespace std; +using namespace testing; +using namespace ge; + +class UtestMemoryApiTest : public testing::Test { + protected: + void SetUp() {} + + void TearDown() {} +}; + +TEST_F(UtestMemoryApiTest, query_mem_info_success) { +string var_name = "host_params"; +SharedMemInfo info; +uint8_t tmp(0); +info.device_address = &tmp; + +std::shared_ptr aligned_ptr = std::make_shared(100, 16); + +info.host_aligned_ptr = aligned_ptr; +info.fd=0; +info.mem_size = 100; +info.op_name = var_name; +HostMemManager::Instance().var_memory_base_map_[var_name] = info; +uint64_t base_addr; +uint64_t var_size; +Status ret = GetVarBaseAddrAndSize(var_name, base_addr, var_size); +EXPECT_EQ(ret, SUCCESS); +EXPECT_EQ(var_size, 100); +HostMemManager::Instance().var_memory_base_map_.clear(); +} + +TEST_F(UtestMemoryApiTest, query_mem_info_failed) { +string var_name = "host_params"; +uint64_t base_addr; +uint64_t var_size; +Status ret = GetVarBaseAddrAndSize(var_name, base_addr, var_size); +EXPECT_NE(ret, SUCCESS); +} diff --git a/tests/ut/ge/graph/passes/subgraph_const_migration_pass_unittest.cc b/tests/ut/ge/graph/passes/subgraph_const_migration_pass_unittest.cc new file mode 100644 index 00000000..00157395 --- /dev/null +++ b/tests/ut/ge/graph/passes/subgraph_const_migration_pass_unittest.cc @@ -0,0 +1,125 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include +#include + +#include "framework/omg/omg_inner_types.h" +#include "graph/common/local_context.h" +#include "graph/passes/subgraph_const_migration_pass.h" +#include "inc/pass_manager.h" +#include "register/op_registry.h" + +namespace ge { +class UtestSubgraphConstMigrationPass : public testing::Test { + protected: + void SetUp() {} + void TearDown() {} + + public: + NodePtr MakeNode(const ComputeGraphPtr &graph, uint32_t in_num, uint32_t out_num, string name, string type) { + GeTensorDesc test_desc(GeShape(), FORMAT_NCHW, DT_FLOAT); + auto op_desc = std::make_shared(name, type); + for (auto i = 0; i < in_num; ++i) { + op_desc->AddInputDesc(test_desc); + } + for (auto i = 0; i < out_num; ++i) { + op_desc->AddOutputDesc(test_desc); + } + if (type == "Const") { + uint64_t const_value = 101; + auto weight = make_shared(op_desc->GetOutputDesc(0), (uint8_t *)&const_value, sizeof(uint64_t)); + AttrUtils::SetTensor(op_desc, ge::ATTR_NAME_WEIGHTS, weight); + } + return graph->AddNode(op_desc); + } + + void make_original_graph(const ComputeGraphPtr &graph) { + auto data = MakeNode(graph, 1, 1, "data", "Data"); + { + AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_INDEX, 0); + AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, 1); + } + auto const1 = MakeNode(graph, 0, 1, "const1", "Const"); + { + auto data1 = MakeNode(graph, 1, 1, "data1", "Data"); + AttrUtils::SetInt(data1->GetOpDesc(), ATTR_NAME_INDEX, 1); + AttrUtils::SetInt(data1->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, 2); + GraphUtils::AddEdge(data1->GetOutControlAnchor(), const1->GetInControlAnchor()); + } + + auto const2 = MakeNode(graph, 0, 1, "const2", "Const"); + { + auto data2 = MakeNode(graph, 1, 1, "data2", "Data"); + AttrUtils::SetInt(data2->GetOpDesc(), ATTR_NAME_INDEX, 2); + AttrUtils::SetInt(data2->GetOpDesc(), ATTR_NAME_PARENT_NODE_INDEX, 3); + GraphUtils::AddEdge(data2->GetOutControlAnchor(), const2->GetInControlAnchor()); + } + + auto conv2d_node = MakeNode(graph, 3, 1, "conv1", "Conv2D"); + GraphUtils::AddEdge(data->GetOutDataAnchor(0), conv2d_node->GetInDataAnchor(0)); + GraphUtils::AddEdge(const1->GetOutDataAnchor(0), conv2d_node->GetInDataAnchor(1)); + GraphUtils::AddEdge(const2->GetOutDataAnchor(0), conv2d_node->GetInDataAnchor(2)); + } + + void make_multibatch_graph(const ComputeGraphPtr &graph) { + auto index = MakeNode(graph, 1, 1, "index", "Data"); + auto data = MakeNode(graph, 1, 1, "data", "Data"); + auto data1 = MakeNode(graph, 1, 1, "data1", "Data"); + auto data2 = MakeNode(graph, 1, 1, "data2", "Data"); + AttrUtils::SetInt(data->GetOpDesc(), ATTR_NAME_INDEX, 0); + AttrUtils::SetInt(data1->GetOpDesc(), ATTR_NAME_INDEX, 1); + AttrUtils::SetInt(data2->GetOpDesc(), ATTR_NAME_INDEX, 2); + + auto case1 = MakeNode(graph, 4, 1, "case", "Case"); + GraphUtils::AddEdge(index->GetOutDataAnchor(0), case1->GetInDataAnchor(0)); + GraphUtils::AddEdge(data->GetOutDataAnchor(0), case1->GetInDataAnchor(1)); + GraphUtils::AddEdge(data1->GetOutDataAnchor(0), case1->GetInDataAnchor(2)); + GraphUtils::AddEdge(data2->GetOutDataAnchor(0), case1->GetInDataAnchor(3)); + auto output_node = MakeNode(graph, 1, 0, "output", "NetOutput"); + GraphUtils::AddEdge(case1->GetOutDataAnchor(0), output_node->GetInDataAnchor(0)); + + AttrUtils::SetInt(case1->GetOpDesc(), ATTR_NAME_BATCH_NUM, 2); + case1->GetOpDesc()->RegisterSubgraphIrName("branches", kDynamic); + ComputeGraphPtr branch = std::make_shared("test_branch"); + make_original_graph(branch); + for (int i = 0; i < 2; ++i) { + std::string name("_ascend_mbatch_batch_" + std::to_string(i)); + std::vector input_nodes; + std::vector output_nodes; + ComputeGraphPtr subgraph = GraphUtils::CloneGraph(branch, name, input_nodes, output_nodes); + + subgraph->SetName(name); + subgraph->SetParentNode(case1); + subgraph->SetParentGraph(graph); + graph->AddSubgraph(subgraph->GetName(), subgraph); + + case1->GetOpDesc()->AddSubgraphName(name); + case1->GetOpDesc()->SetSubgraphInstanceName(i, subgraph->GetName()); + } + } +}; + +TEST_F(UtestSubgraphConstMigrationPass, subgraph_const_migration) { + PassManager pass_manager; + pass_manager.AddPass("SubgraphConstMigrationPass", new (std::nothrow) SubgraphConstMigrationPass); + ComputeGraphPtr graph = std::make_shared("test_graph"); + make_multibatch_graph(graph); + EXPECT_EQ(pass_manager.Run(graph), SUCCESS); +} +} // namespace ge \ No newline at end of file diff --git a/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc b/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc index 8ece7564..ebd0ab25 100644 --- a/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc +++ b/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc @@ -120,29 +120,63 @@ ComputeGraphPtr BuildGraph4_Subgraph(string graph_name) { return builder.GetGraph(); } +ComputeGraphPtr BuildGraph6() { + auto builder = ut::GraphBuilder("g6"); + auto data1 = builder.AddNode("input1", DATA, 1, 1, FORMAT_NCHW, DT_FLOAT, {3, -1, -1, 5}); + auto data2 = builder.AddNode("input2", DATA, 1, 1, FORMAT_NCHW, DT_FLOAT, {}); + AttrUtils::SetInt(data1->GetOpDesc(), ATTR_NAME_INDEX, 0); + AttrUtils::SetInt(data2->GetOpDesc(), ATTR_NAME_INDEX, 1); + auto add = builder.AddNode("add", ADD, 2, 1); + auto netoutput = builder.AddNode("netoutput", NETOUTPUT, 1, 0); + + builder.AddDataEdge(data1, 0, add, 0); + builder.AddDataEdge(data2, 0, add, 1); + builder.AddDataEdge(add, 0,netoutput, 0); + return builder.GetGraph(); +} + TEST_F(UtestGraphPreproces, test_dynamic_input_shape_parse) { ge::GraphPrepare graph_prepare; - graph_prepare.compute_graph_ = BuildGraph1(); + graph_prepare.compute_graph_ = BuildGraph6(); // prepare user_input & graph option ge::GeTensorDesc tensor1; tensor1.SetFormat(ge::FORMAT_NCHW); tensor1.SetShape(ge::GeShape({3, 12, 5, 5})); tensor1.SetDataType(ge::DT_FLOAT); GeTensor input1(tensor1); - std::vector user_input = {input1}; + ge::GeTensorDesc tensor2; + tensor2.SetFormat(ge::FORMAT_NCHW); + tensor2.SetShape(ge::GeShape()); + tensor2.SetDataType(ge::DT_FLOAT); + GeTensor input2(tensor2); + std::vector user_input = {input1, input2}; std::map graph_option = {{"ge.exec.dynamicGraphExecuteMode","dynamic_execute"}, - {"ge.exec.dataInputsShapeRange","[3,1~20,2~10,5]"}}; + {"ge.exec.dataInputsShapeRange","[3,1~20,2~10,5],[]"}}; auto ret = graph_prepare.UpdateInput(user_input, graph_option); EXPECT_EQ(ret, ge::SUCCESS); - // check data node output shape_range and shape - auto data_node = graph_prepare.compute_graph_->FindNode("data1"); + // check data1 node output shape_range and shape + auto data_node = graph_prepare.compute_graph_->FindNode("input1"); auto data_output_desc = data_node->GetOpDesc()->GetOutputDescPtr(0); - vector expect_shape = {3,-1,-1,5}; - auto result_shape = data_output_desc->GetShape(); - EXPECT_EQ(result_shape.GetDimNum(), expect_shape.size()); - for(size_t i =0; i< expect_shape.size(); ++i){ - EXPECT_EQ(result_shape.GetDim(i), expect_shape.at(i)); + vector input1_expect_shape = {3,-1,-1,5}; + vector> intpu1_expect_shape_range = {{3,3},{1,20},{2,10},{5,5}}; + auto input1_result_shape = data_output_desc->GetShape(); + vector> input1_result_shape_range; + data_output_desc->GetShapeRange(input1_result_shape_range); + EXPECT_EQ(input1_result_shape.GetDimNum(), input1_expect_shape.size()); + EXPECT_EQ(input1_result_shape_range.size(), input1_expect_shape.size()); + for(size_t i =0; i< input1_expect_shape.size(); ++i){ + EXPECT_EQ(input1_result_shape.GetDim(i), input1_expect_shape.at(i)); + } + for(size_t i =0; i< intpu1_expect_shape_range.size(); ++i){ + EXPECT_EQ(input1_result_shape_range.at(i).first, intpu1_expect_shape_range.at(i).first); + EXPECT_EQ(input1_result_shape_range.at(i).second, intpu1_expect_shape_range.at(i).second); } + // check data2 node output shape_range and shape + auto data_node_2 = graph_prepare.compute_graph_->FindNode("input2"); + auto data_output_desc_2 = data_node_2->GetOpDesc()->GetOutputDescPtr(0); + vector> intput2_result_shape_range; + data_output_desc_2->GetShapeRange(intput2_result_shape_range); + EXPECT_EQ(intput2_result_shape_range.size(), 0); } TEST_F(UtestGraphPreproces, test_check_user_input) { diff --git a/tests/ut/ge/hybrid/executor/subgraph_executor_unittest.cc b/tests/ut/ge/hybrid/executor/subgraph_executor_unittest.cc index d97629cf..2dc3b639 100644 --- a/tests/ut/ge/hybrid/executor/subgraph_executor_unittest.cc +++ b/tests/ut/ge/hybrid/executor/subgraph_executor_unittest.cc @@ -127,7 +127,7 @@ static void CreateSimpleCondGraph(ComputeGraph &graph, NodePtr &switch_t, NodePt AttrUtils::SetTensor(op_desc, ATTR_NAME_WEIGHTS, weight); } - const auto less1 = CreateNode(graph, "less", EXIT, 2, 1); // Mock for less, just pass input0. + const auto less1 = CreateNode(graph, "less", IDENTITY, 2, 1); // Mock for less, just pass input0. const auto active1 = CreateNode(graph, "active1", STREAMACTIVE, 0, 0); switch_t = CreateNode(graph, "switch_t", STREAMSWITCH, 2, 0); @@ -135,8 +135,8 @@ static void CreateSimpleCondGraph(ComputeGraph &graph, NodePtr &switch_t, NodePt AttrUtils::SetInt(switch_t->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND, RT_EQUAL); // 101 for true. AttrUtils::SetInt(switch_f->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_COND, RT_NOT_EQUAL); - const auto add1 = CreateNode(graph, "add", EXIT, 2, 1); // Mock for add, just pass input0. - const auto sub1 = CreateNode(graph, "sub", EXIT, 2, 1); // Mock for sub, just pass input0. + const auto add1 = CreateNode(graph, "add", IDENTITY, 2, 1); // Mock for add, just pass input0. + const auto sub1 = CreateNode(graph, "sub", IDENTITY, 2, 1); // Mock for sub, just pass input0. const auto merge1 = CreateNode(graph, "merge", STREAMMERGE, 2, 2); const auto active2 = CreateNode(graph, "active2", STREAMACTIVE, 0, 0); diff --git a/tests/ut/ge/hybrid/model/hybrid_model_builder_unittest.cc b/tests/ut/ge/hybrid/model/hybrid_model_builder_unittest.cc index 1037c764..2ab82350 100644 --- a/tests/ut/ge/hybrid/model/hybrid_model_builder_unittest.cc +++ b/tests/ut/ge/hybrid/model/hybrid_model_builder_unittest.cc @@ -23,6 +23,7 @@ #define protected public #include "hybrid/model/hybrid_model_builder.h" #include "hybrid/node_executor/node_executor.h" +#include "graph/manager/host_mem_manager.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/graph_utils.h" @@ -88,7 +89,7 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { * \ / \. * Switch Add * / | | - * / | | + * Active / | | * / | | * LoopCond | | * \ | | @@ -97,9 +98,10 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { * Less | | * \ | NextIteration * \ | | - * \ | | + * \ | | Active * Merge <---------| * | + * | Active * | * Enter ******************************************************************************/ @@ -109,6 +111,7 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { GeModelPtr ge_sub_model = make_shared(); ge_root_model->SetSubgraphInstanceNameToModel("sub", ge_sub_model); + auto data1 = CreateNode(*graph, "data", DATA, 1, 1); auto enter1 = CreateNode(*graph, "enter", ENTER, 1, 1); auto merge1 = CreateNode(*graph, "merge", STREAMMERGE, 2, 2); auto less1 = CreateNode(*graph, "less", LESS, 2, 1); @@ -128,6 +131,7 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { auto active3 = CreateNode(*graph, "active3", STREAMACTIVE, 0, 0); auto output1 = CreateNode(*graph, "net_output", NETOUTPUT, 1, 1); + GraphUtils::AddEdge(data1->GetOutDataAnchor(0), enter1->GetInDataAnchor(0)); GraphUtils::AddEdge(enter1->GetOutDataAnchor(0), merge1->GetInDataAnchor(0)); GraphUtils::AddEdge(merge1->GetOutDataAnchor(0), less1->GetInDataAnchor(0)); GraphUtils::AddEdge(value1->GetOutDataAnchor(0), less1->GetInDataAnchor(1)); @@ -152,8 +156,7 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { GraphUtils::AddEdge(active1->GetOutControlAnchor(), merge1->GetInControlAnchor()); GraphUtils::AddEdge(next1->GetOutControlAnchor(), active3->GetInControlAnchor()); - //GraphUtils::AddEdge(active3->GetOutControlAnchor(), merge1->GetInControlAnchor()); - SetNextIteration(merge1, next1); + SetNextIteration(merge1, next1); // for relink NextIteration --> StreamMerge GraphUtils::AddEdge(active1->GetOutControlAnchor(), switch_t->GetInControlAnchor()); // Test for not merge. @@ -168,6 +171,17 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { AttrUtils::SetBool(add1->GetOpDesc(), ATTR_NAME_INSERT_FP_PROFILILNG_TASK, true); AttrUtils::SetBool(add1->GetOpDesc(), ATTR_NAME_INSERT_BP_PROFILILNG_TASK, true); + SetControlFlowGroup(enter1, loop1->GetOpDesc()->GetId()); + SetControlFlowGroup(active1, loop1->GetOpDesc()->GetId()); + SetControlFlowGroup(merge1, loop1->GetOpDesc()->GetId()); + SetControlFlowGroup(loop1, loop1->GetOpDesc()->GetId()); + SetControlFlowGroup(active2, switch_t->GetOpDesc()->GetId()); + SetControlFlowGroup(switch_t, switch_t->GetOpDesc()->GetId()); + SetControlFlowGroup(switch_f, switch_t->GetOpDesc()->GetId()); + SetControlFlowGroup(next1, loop1->GetOpDesc()->GetId()); + SetControlFlowGroup(active3, loop1->GetOpDesc()->GetId()); + SetControlFlowGroup(exit1, loop1->GetOpDesc()->GetId()); + // Build -> IndexSpecialNodes --> stream_merge_op_nodes_ // Build -> LoadGraph -> RelinkNextIteration // Build -> LoadGraph -> LoadDynamicSubgraph --> BuildNodeItem --> NodeItem::SetDataSend @@ -189,9 +203,23 @@ TEST_F(UtestHybridModelBuilder, normal_hybrid_model_build) { task_executor.emplace(NodeExecutorManager::ExecutorType::RTS, std::unique_ptr(new NodeExecutor())); task_executor.emplace(NodeExecutorManager::ExecutorType::HOST_CPU, std::unique_ptr(new NodeExecutor())); + const auto control_group_index = loop1->GetOpDesc()->GetId(); HybridModel hybrid_model(ge_root_model); HybridModelBuilder hybrid_model_builder(hybrid_model); ASSERT_EQ(hybrid_model_builder.Build(), SUCCESS); + + const auto TestFrameGroup = [&hybrid_model](const NodePtr &n, int64_t index) { + const auto it = hybrid_model.node_items_.find(n); + ASSERT_NE(hybrid_model.node_items_.end(), it); + ASSERT_EQ(it->second->frame_index_, index); + ASSERT_EQ(it->second->parent_frame_, -1); + }; + TestFrameGroup(enter1, control_group_index); + TestFrameGroup(active1, control_group_index); + TestFrameGroup(active2, control_group_index); + TestFrameGroup(active3, control_group_index); + TestFrameGroup(output1, -1); + engine_mapping.clear(); task_executor.clear(); } @@ -263,4 +291,59 @@ TEST_F(UtestHybridModelBuilder, init_constant_op_host_) { EXPECT_EQ(hybrid_model_builder.InitConstantOps(), SUCCESS); EXPECT_EQ(hybrid_model_builder.hybrid_model_.variable_tensors_.size(), 2); } + +TEST_F(UtestHybridModelBuilder, init_host_var_with_host_mem) { +ComputeGraphPtr graph = std::make_shared("test"); +GeRootModelPtr ge_root_model = make_shared(graph); +HybridModel hybrid_model(ge_root_model); +HybridModelBuilder hybrid_model_builder(hybrid_model); + +OpDescPtr op_desc = std::make_shared("host_params", VARIABLE); +GeTensorDesc tensor_desc(GeShape(),FORMAT_NHWC,DT_FLOAT); +TensorUtils::SetSize(tensor_desc, 512); +op_desc->AddOutputDesc(tensor_desc); +auto host_var = graph->AddNode(op_desc); + +hybrid_model.host_variable_nodes_.emplace("host_params", host_var); +std::map options; +options["ge.exec.placement"] = "HOST"; +GetThreadLocalContext().SetGraphOption(options); + +EXPECT_EQ(hybrid_model_builder.InitVariableTensors(), SUCCESS); +EXPECT_EQ(hybrid_model_builder.hybrid_model_.variable_tensors_.size(), 1); +} + +TEST_F(UtestHybridModelBuilder, init_host_var_with_host_shared_mem) { +ComputeGraphPtr graph = std::make_shared("test"); +GeRootModelPtr ge_root_model = make_shared(graph); +HybridModel hybrid_model(ge_root_model); +HybridModelBuilder hybrid_model_builder(hybrid_model); + +OpDescPtr op_desc = std::make_shared("host_params", VARIABLE); +GeTensorDesc tensor_desc(GeShape(),FORMAT_NHWC,DT_FLOAT); +TensorUtils::SetSize(tensor_desc, 512); +op_desc->AddOutputDesc(tensor_desc); +auto host_var = graph->AddNode(op_desc); + +hybrid_model.host_variable_nodes_.emplace("host_params", host_var); +std::map options; +options["ge.exec.placement"] = "HOST"; +GetThreadLocalContext().SetGraphOption(options); + +SharedMemInfo info; +uint8_t tmp(0); +info.device_address = &tmp; +std::shared_ptr aligned_ptr = std::make_shared(512, 16); +info.host_aligned_ptr = aligned_ptr; +info.fd=0; +info.mem_size = 100; +info.op_name = "host_params"; +HostMemManager::Instance().var_memory_base_map_["host_params"] = info; + + + +EXPECT_EQ(hybrid_model_builder.InitVariableTensors(), SUCCESS); +EXPECT_EQ(hybrid_model_builder.hybrid_model_.variable_tensors_.size(), 1); +HostMemManager::Instance().var_memory_base_map_.clear(); +} } // namespace ge diff --git a/tests/ut/ge/hybrid/node_executor/hccl/hccl_node_executor_unittest.cc b/tests/ut/ge/hybrid/node_executor/hccl/hccl_node_executor_unittest.cc new file mode 100644 index 00000000..afaf067e --- /dev/null +++ b/tests/ut/ge/hybrid/node_executor/hccl/hccl_node_executor_unittest.cc @@ -0,0 +1,240 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +#include + +#define private public +#define protected public +#include "graph/runtime_inference_context.h" +#include "hybrid/executor/subgraph_context.h" +#include "hybrid/node_executor/hccl/hccl_node_executor.h" +#undef protected +#undef private + +using namespace std; +using namespace testing; +namespace { +const string kHcclSoPath = "../build/tests/depends/hccl/libhccl_stub.so"; +} +namespace ge { +using namespace hybrid; + +class UtestHcclNodeExecutor : public testing::Test { + protected: + void SetUp() {} + void TearDown() {} +}; + +static NodePtr CreateNode(ComputeGraph &graph, const string &name, const string &type, int in_num, int out_num) { + OpDescPtr op_desc = std::make_shared(name, type); + op_desc->SetStreamId(0); + static int32_t index = 0; + op_desc->SetId(index++); + + GeTensorDesc tensor(GeShape(), FORMAT_ND, DT_INT64); + TensorUtils::SetSize(tensor, 64); + vector input_offset; + for (int i = 0; i < in_num; i++) { + op_desc->AddInputDesc(tensor); + input_offset.emplace_back(i * 64); + } + op_desc->SetInputOffset(input_offset); + + vector output_offset; + for (int i = 0; i < out_num; i++) { + op_desc->AddOutputDesc(tensor); + output_offset.emplace_back(in_num * 64 + i * 64); + } + op_desc->SetOutputOffset(output_offset); + + return graph.AddNode(op_desc); +} + +TEST_F(UtestHcclNodeExecutor, test_rdmatask_extract_tensor) { + ComputeGraphPtr graph = std::make_shared("test"); + NodePtr node = CreateNode(*graph, "hcom", HCOMREMOTEREAD, 0, 0); + std::unique_ptr new_node; + ASSERT_EQ(NodeItem::Create(node, new_node), SUCCESS); + NodeItem *node_item = new_node.get(); + node_item->input_start = 0; + node_item->output_start = 0; + + GraphItem graph_item; + GraphExecutionContext graph_context; + SubgraphContext subgraph_context(&graph_item, &graph_context); + ASSERT_EQ(subgraph_context.Init(), SUCCESS); + + auto node_state = subgraph_context.GetOrCreateNodeState(node_item); + ASSERT_NE(node_state, nullptr); + + RuntimeInferenceContext::CreateContext(std::to_string(graph_context.context_id)); + RuntimeInferenceContext *ctx = nullptr; + RuntimeInferenceContext::GetContext(std::to_string(graph_context.context_id), &ctx); + + Shape s({1, 3}); + TensorDesc tensor_desc(s); + Tensor tensor(tensor_desc); + std::vector data = {1, 2, 3, 4}; + tensor.SetData(data); + ctx->SetTensor(1, 0, tensor.Clone()); + + auto unique_task_context = TaskContext::Create(node_state.get(), &graph_context, &subgraph_context); + vector addr_infos; + shared_ptr task = MakeShared(); + task->remote_index_ = {1, 0}; + ASSERT_EQ(task->ExtractTensor(*unique_task_context, addr_infos), PARAM_INVALID); + + Shape s2({1}); + TensorDesc tensor_desc2(s2); + Tensor tensor2(tensor_desc2); + ctx->SetTensor(1, 0, tensor2.Clone()); + task->ExtractTensor(*unique_task_context, addr_infos); + ASSERT_EQ(task->ExtractTensor(*unique_task_context, addr_infos), PARAM_INVALID); + RuntimeInferenceContext::DestroyContext(std::to_string(graph_context.context_id)); +} + +TEST_F(UtestHcclNodeExecutor, gatheralltoallv_execute) { + ComputeGraphPtr graph = std::make_shared("test"); + GeModelPtr ge_sub_model = std::make_shared(); + GeRootModelPtr ge_root_model = std::make_shared(graph); + ge_root_model->SetModelName("test_name"); + ge_root_model->SetSubgraphInstanceNameToModel("sub", ge_sub_model); + HybridModel hybrid_model(ge_root_model); + + + NodePtr node = CreateNode(*graph, "gatheralltoallv", HCOMGATHERALLTOALLV, 4, 2); + + std::unique_ptr new_node; + ASSERT_EQ(NodeItem::Create(node, new_node), SUCCESS); + NodeItem *node_item = new_node.get(); + hybrid_model.node_items_[node] = std::move(new_node); + node_item->input_start = 0; + node_item->output_start = 0; + + GraphItem graph_item; + graph_item.node_items_.emplace_back(node_item); + graph_item.total_inputs_ = 4; + graph_item.total_outputs_ = 2; + + GraphExecutionContext graph_context; + SubgraphContext subgraph_context(&graph_item, &graph_context); + ASSERT_EQ(subgraph_context.Init(), SUCCESS); + graph_context.callback_manager = std::unique_ptr(new CallbackManager()); + + auto node_state = subgraph_context.GetOrCreateNodeState(node_item); + ASSERT_NE(node_state, nullptr); + + auto unique_task_context = TaskContext::Create(node_state.get(), &graph_context, &subgraph_context); + ASSERT_NE(unique_task_context, nullptr); + auto shared_task_context = std::shared_ptr(unique_task_context.release()); + node_state->SetTaskContext(shared_task_context); + + for (int i=0; i<4; ++i) { + uint64_t value_0 = 512; + TensorValue in_tensor0(&value_0, sizeof(value_0)); + subgraph_context.SetInput(*node_item, 0, in_tensor0); + } + + uint64_t value_0 = 512; + TensorValue out_tensor0(&value_0, sizeof(value_0)); + subgraph_context.SetOutput(*node_item, 0, out_tensor0); + + uint64_t value_1 = 512; + TensorValue out_tensor1(&value_1, sizeof(value_1)); + subgraph_context.SetOutput(*node_item, 1, out_tensor1); + + NodeTaskPtr task = nullptr; + HcclNodeExecutor node_executor; + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), SUCCESS); + ASSERT_NE(task, nullptr); + + auto handle = dlopen(kHcclSoPath.c_str(), RTLD_NOW | RTLD_GLOBAL); + ASSERT_NE(handle, nullptr); + node_state->GetTaskContext()->handle_ = handle; + std::function done = []() {}; + ASSERT_EQ(task->ExecuteAsync(*node_state->GetTaskContext(), done), SUCCESS); + + if (handle = nullptr) { + dlclose(handle); + } +} + +TEST_F(UtestHcclNodeExecutor, alltoallv_execute) { + ComputeGraphPtr graph = std::make_shared("test"); + GeModelPtr ge_sub_model = std::make_shared(); + GeRootModelPtr ge_root_model = std::make_shared(graph); + ge_root_model->SetModelName("test_name"); + ge_root_model->SetSubgraphInstanceNameToModel("sub", ge_sub_model); + HybridModel hybrid_model(ge_root_model); + + + NodePtr node = CreateNode(*graph, "alltoallv", HCOMALLTOALLV, 5, 1); + + std::unique_ptr new_node; + ASSERT_EQ(NodeItem::Create(node, new_node), SUCCESS); + NodeItem *node_item = new_node.get(); + hybrid_model.node_items_[node] = std::move(new_node); + node_item->input_start = 0; + node_item->output_start = 0; + + GraphItem graph_item; + graph_item.node_items_.emplace_back(node_item); + graph_item.total_inputs_ = 5; + graph_item.total_outputs_ = 1; + + GraphExecutionContext graph_context; + SubgraphContext subgraph_context(&graph_item, &graph_context); + ASSERT_EQ(subgraph_context.Init(), SUCCESS); + graph_context.callback_manager = std::unique_ptr(new CallbackManager()); + + auto node_state = subgraph_context.GetOrCreateNodeState(node_item); + ASSERT_NE(node_state, nullptr); + + auto unique_task_context = TaskContext::Create(node_state.get(), &graph_context, &subgraph_context); + ASSERT_NE(unique_task_context, nullptr); + auto shared_task_context = std::shared_ptr(unique_task_context.release()); + node_state->SetTaskContext(shared_task_context); + + for (int i=0; i<5; ++i) { + uint64_t value_0 = 512; + TensorValue in_tensor0(&value_0, sizeof(value_0)); + subgraph_context.SetInput(*node_item, 0, in_tensor0); + } + + uint64_t value_1 = 512; + TensorValue out_tensor0(&value_1, sizeof(value_1)); + subgraph_context.SetOutput(*node_item, 0, out_tensor0); + NodeTaskPtr task = nullptr; + HcclNodeExecutor node_executor; + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), SUCCESS); + ASSERT_NE(task, nullptr); + + auto handle = dlopen(kHcclSoPath.c_str(), RTLD_NOW | RTLD_GLOBAL); + ASSERT_NE(handle, nullptr); + node_state->GetTaskContext()->handle_ = handle; + + std::function done = []() {}; + ASSERT_EQ(task->ExecuteAsync(*node_state->GetTaskContext(), done), SUCCESS); + + if (handle = nullptr) { + dlclose(handle); + } +} +} // namespace ge + diff --git a/tests/ut/ge/hybrid/node_executor/host_cpu/host_cpu_node_task_unittest.cc b/tests/ut/ge/hybrid/node_executor/host_cpu/host_cpu_node_task_unittest.cc new file mode 100644 index 00000000..b113fa9b --- /dev/null +++ b/tests/ut/ge/hybrid/node_executor/host_cpu/host_cpu_node_task_unittest.cc @@ -0,0 +1,137 @@ +/** + * Copyright 2021 Huawei Technologies Co., Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#define private public +#define protected public +#include "hybrid/executor/subgraph_context.h" +#include "hybrid/node_executor/host_cpu/host_cpu_node_executor.h" +#include "model/ge_root_model.h" +#include "graph/passes/graph_builder_utils.h" +#include "aicpu/common/aicpu_task_struct.h" +#include "graph/manager/graph_mem_manager.h" +#include "ge_local_engine/engine/host_cpu_engine.h" +#undef private +#undef protected + +using namespace std; +using namespace testing; + +namespace ge { +using namespace hybrid; + +namespace { +struct AicpuTaskStruct { + aicpu::AicpuParamHead head; + uint64_t io_addrp[2]; +}__attribute__((packed)); +} // namespace + +class UtestHostCpuNodeTask : public testing::Test { + protected: + void SetUp() {} + void TearDown() {} +}; + +TEST_F(UtestHostCpuNodeTask, test_load) { + ut::GraphBuilder builder = ut::GraphBuilder("graph"); + auto node = builder.AddNode("Data", "Data", 1, 1); + auto graph = builder.GetGraph(); + + GeRootModelPtr ge_root_model = std::make_shared(graph); + HybridModel hybrid_model(ge_root_model); + std::unique_ptr node_item; + ASSERT_EQ(NodeItem::Create(node, node_item), SUCCESS); + hybrid_model.node_items_[node] = std::move(node_item); + hybrid_model.task_defs_[node] = {}; + + NodeTaskPtr task = nullptr; + HostCpuNodeExecutor node_executor; + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), PARAM_INVALID); + + AicpuTaskStruct args; + args.head.length = sizeof(args); + args.head.ioAddrNum = 2; + + domi::TaskDef task_def; + task_def.set_type(RT_MODEL_TASK_ALL_KERNEL); + task_def.mutable_kernel()->set_args(reinterpret_cast(&args), args.head.length); + task_def.mutable_kernel()->set_args_size(args.head.length); + hybrid_model.task_defs_[node] = {task_def}; + hybrid_model.node_items_[node]->num_inputs = 1; + hybrid_model.node_items_[node]->num_outputs = 1; + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), INTERNAL_ERROR); + + domi::TaskDef &host_task_def = hybrid_model.task_defs_[node][0]; + host_task_def.set_type(RT_MODEL_TASK_KERNEL); + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), INTERNAL_ERROR); + domi::KernelContext *context = host_task_def.mutable_kernel()->mutable_context(); + context->set_kernel_type(8); // ccKernelType::HOST_CPU + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), INTERNAL_ERROR); + HostCpuEngine::GetInstance().constant_folding_handle_ = (void *)0x01; + ASSERT_EQ(node_executor.LoadTask(hybrid_model, node, task), INTERNAL_ERROR); +} + +TEST_F(UtestHostCpuNodeTask, test_execute) { + ut::GraphBuilder builder = ut::GraphBuilder("graph"); + auto node = builder.AddNode("Data", "Data", 1, 1); + std::unique_ptr node_item; + ASSERT_EQ(NodeItem::Create(node, node_item), SUCCESS); + domi::TaskDef task_def; + + HostAicpuNodeTask task(node_item.get(), task_def); + std::function call_back = []{}; + NodeState node_state(*node_item, nullptr); + TaskContext context(nullptr, &node_state, nullptr); + ASSERT_EQ(task.ExecuteAsync(context, call_back), INTERNAL_ERROR); + + std::function run_cpu_kernel = [](void *){ return 0; }; + task.SetRunKernel(run_cpu_kernel); + ASSERT_EQ(task.ExecuteAsync(context, call_back), SUCCESS); +} + +TEST_F(UtestHostCpuNodeTask, test_update_args) { + ut::GraphBuilder builder = ut::GraphBuilder("graph"); + auto node = builder.AddNode("Data", "Data", 1, 1); + std::unique_ptr node_item; + ASSERT_EQ(NodeItem::Create(node, node_item), SUCCESS); + NodeState node_state(*node_item, nullptr); + TaskContext context(nullptr, &node_state, nullptr); + + auto *in_addr = MemManager::Instance().HostMemInstance(RT_MEMORY_HBM).Malloc(1); + auto tmp = TensorBuffer::Create(in_addr, 1); + std::shared_ptr input_buffer(tmp.release()); + TensorValue input_start[1] = {TensorValue(input_buffer)}; + context.inputs_start_ = input_start; + + auto *out_addr = MemManager::Instance().HostMemInstance(RT_MEMORY_HBM).Malloc(1); + tmp = TensorBuffer::Create(out_addr, 1); + std::shared_ptr output_buffer(tmp.release()); + TensorValue output_start[1] = {TensorValue(output_buffer)}; + context.outputs_start_ = output_start; + + domi::TaskDef task_def; + HostAicpuNodeTask task(node_item.get(), task_def); + ASSERT_EQ(task.UpdateArgs(context), INTERNAL_ERROR); + + task.args_size_ = sizeof(AicpuTaskStruct); + task.args_.reset(new(std::nothrow) uint8_t[task.args_size_]()); + ASSERT_EQ(task.UpdateArgs(context), SUCCESS); +} +} // namespace ge diff --git a/tests/ut/ge/hybrid/node_executor/rts/rts_node_task_unittest.cc b/tests/ut/ge/hybrid/node_executor/rts/rts_node_task_unittest.cc index c4c2c65b..44b2f37f 100644 --- a/tests/ut/ge/hybrid/node_executor/rts/rts_node_task_unittest.cc +++ b/tests/ut/ge/hybrid/node_executor/rts/rts_node_task_unittest.cc @@ -166,6 +166,10 @@ TEST_F(UtestRtsNodeTask, test_stream_active_task) { std::function done = []() {}; ASSERT_EQ(node_state->GetSwitchIndex(), -1); ASSERT_EQ(task->ExecuteAsync(*node_state->GetTaskContext(), done), SUCCESS); + ASSERT_EQ(node_state->GetSwitchIndex(), -1); + + node_item->ctrl_send_.emplace(nullptr); + ASSERT_EQ(task->ExecuteAsync(*node_state->GetTaskContext(), done), SUCCESS); ASSERT_EQ(node_state->GetSwitchIndex(), 0); } diff --git a/tests/ut/ge/single_op/single_op_model_unittest.cc b/tests/ut/ge/single_op/single_op_model_unittest.cc index f5d1a83c..a2c1cb02 100644 --- a/tests/ut/ge/single_op/single_op_model_unittest.cc +++ b/tests/ut/ge/single_op/single_op_model_unittest.cc @@ -25,6 +25,11 @@ #define private public #include "single_op/single_op_model.h" #include "single_op/task/tbe_task_builder.h" +#include "single_op/task/rts_kernel_task_builder.h" +#include "single_op/task/op_task.h" +#include "framework/common/helper/model_helper.h" +#include "single_op/single_op.h" +#include "single_op/stream_resource.h" #undef private #undef protected #include "graph/passes/graph_builder_utils.h" @@ -240,3 +245,45 @@ TEST_F(UtestSingleOpModel, test_host_mem) { DynamicSingleOp single_op(0, &stream_mu_, nullptr); ASSERT_EQ(model.SetHostMemTensor(single_op), SUCCESS); } + +TEST_F(UtestSingleOpModel, BuildTaskList) { + ComputeGraphPtr graph = make_shared("single_op"); + GeModelPtr ge_model = make_shared(); + ge_model->SetGraph(GraphUtils::CreateGraphFromComputeGraph(graph)); + shared_ptr model_task_def = make_shared(); + ge_model->SetModelTaskDef(model_task_def); + NodePtr node = nullptr; + { + auto op_desc = std::make_shared("memcpy", MEMCPYASYNC); + GeTensorDesc tensor(GeShape(), FORMAT_NCHW, DT_FLOAT); + op_desc->AddInputDesc(tensor); + op_desc->AddOutputDesc(tensor); + op_desc->SetInputOffset({0}); + op_desc->SetOutputOffset({0}); + node = graph->AddNode(op_desc); + + domi::TaskDef *task_def = model_task_def->add_task(); + task_def->set_stream_id(0); + task_def->set_type(RT_MODEL_TASK_MEMCPY_ASYNC); + domi::MemcpyAsyncDef *memcpy_async = task_def->mutable_memcpy_async(); + memcpy_async->set_src(0); + memcpy_async->set_dst(0); + memcpy_async->set_dst_max(512); + memcpy_async->set_count(1); + memcpy_async->set_kind(RT_MEMCPY_DEVICE_TO_DEVICE); + memcpy_async->set_op_index(0); + } + + string model_data_str = "123456789"; + SingleOpModel model("model", model_data_str.c_str(), model_data_str.size()); + StreamResource *res = new (std::nothrow) StreamResource(1); + std::mutex stream_mu; + rtStream_t stream = nullptr; + rtStreamCreate(&stream, 0); + SingleOp single_op(res, &stream_mu, stream); + model.model_helper_.model_ = ge_model; + model.op_list_.emplace(0, node); + ASSERT_EQ(model.BuildTaskList(res, single_op), SUCCESS); + MemcpyAsyncTask mem_task; + ASSERT_EQ(mem_task.LaunchKernel(0), SUCCESS); +} diff --git a/third_party/fwkacllib/inc/hccl/base.h b/third_party/fwkacllib/inc/hccl/base.h index 9facd20c..e57563b3 100644 --- a/third_party/fwkacllib/inc/hccl/base.h +++ b/third_party/fwkacllib/inc/hccl/base.h @@ -123,6 +123,30 @@ struct HcomRemoteAccessAddrInfo { u64 length; // Memory Length in Bytes }; +struct HcomAllToAllVParams { + void *sendbuf; + void *sendcounts; + void *sdispls; + HcclDataType sendtype; + void *recvbuf; + void *recvcounts; + void *rdispls; + HcclDataType recvtype; + const char *group; +}; + +struct HcomGatherAllToAllVParams { + void *addrInfo; + void *addrInfoCountPerRank; + void *recvbuf; + void *recvcounts; + void *rdispls; + void *gatheredbuf; + s32 addrLength; + HcclDataType recvtype; + const char *group; +}; + #ifdef __cplusplus } #endif // __cplusplus diff --git a/third_party/fwkacllib/inc/hccl/hcom.h b/third_party/fwkacllib/inc/hccl/hcom.h index 972f470c..955764d6 100644 --- a/third_party/fwkacllib/inc/hccl/hcom.h +++ b/third_party/fwkacllib/inc/hccl/hcom.h @@ -164,6 +164,11 @@ HcclResult HcomExecEnqueueRemoteAccess(const std::string& remoteAccessType, const std::vector& addrInfos, std::function callback); +HcclResult HcomExecEnqueueAllToAllV(HcomAllToAllVParams params, std::function callback); + +HcclResult HcomExecEnqueueGatherAllToAllV(HcomGatherAllToAllVParams params, + std::function callback); + /** * @brief Register memories and init resources for remote access. *