diff --git a/build.sh b/build.sh index 3e2dcdec..7b1c0792 100644 --- a/build.sh +++ b/build.sh @@ -229,7 +229,7 @@ if [[ "X$ENABLE_GE_UT" = "Xon" || "X$ENABLE_GE_COV" = "Xon" ]]; then rm -rf ${BASEPATH}/cov mkdir ${BASEPATH}/cov lcov -c -d build/tests/ut/ge -d build/tests/ut/common/graph/ -o cov/tmp.info - lcov -r cov/tmp.info '*/output/*' '*/build/opensrc/*' '*/build/proto/*' '*/third_party/*' '*/tests/*' '/usr/local/*' -o cov/coverage.info + lcov -r cov/tmp.info '*/output/*' '*/build/opensrc/*' '*/build/proto/*' '*/third_party/*' '*/tests/*' '/usr/local/*' '/usr/include/*' '*/metadef/*' '*/parser/*' -o cov/coverage.info cd ${BASEPATH}/cov genhtml coverage.info fi diff --git a/cmake/external_libs/gtest.cmake b/cmake/external_libs/gtest.cmake index f2f50e7d..39888110 100755 --- a/cmake/external_libs/gtest.cmake +++ b/cmake/external_libs/gtest.cmake @@ -27,7 +27,7 @@ ExternalProject_Add(gtest_build URL ${REQ_URL} TLS_VERIFY OFF CONFIGURE_COMMAND ${CMAKE_COMMAND} -DCMAKE_CXX_FLAGS=${gtest_CXXFLAGS} -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}/gtest - -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_MACOSX_RPATH=TRUE -Dgtest_disable_pthreads=ON + -DBUILD_TESTING=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_MACOSX_RPATH=TRUE BUILD_COMMAND $(MAKE) INSTALL_COMMAND $(MAKE) install EXCLUDE_FROM_ALL TRUE @@ -52,10 +52,27 @@ set_target_properties(gtest_main PROPERTIES target_include_directories(gtest INTERFACE ${GTEST_PKG_DIR}/include) target_include_directories(gtest_main INTERFACE ${GTEST_PKG_DIR}/include) + +add_library(gmock SHARED IMPORTED) + +set_target_properties(gmock PROPERTIES + IMPORTED_LOCATION ${GTEST_PKG_DIR}/lib/libgmock.so +) + +add_library(gmock_main SHARED IMPORTED) + +set_target_properties(gmock_main PROPERTIES + IMPORTED_LOCATION ${GTEST_PKG_DIR}/lib/libgmock_main.so +) + +target_include_directories(gmock INTERFACE ${GTEST_PKG_DIR}/include) +target_include_directories(gmock_main INTERFACE ${GTEST_PKG_DIR}/include) + + set(INSTALL_BASE_DIR "") set(INSTALL_LIBRARY_DIR lib) -install(FILES ${GTEST_PKG_DIR}/lib/libgtest.so ${GTEST_PKG_DIR}/lib/libgtest_main.so OPTIONAL +install(FILES ${GTEST_PKG_DIR}/lib/libgtest.so ${GTEST_PKG_DIR}/lib/libgtest_main.so ${GTEST_PKG_DIR}/lib/libgmock.so ${GTEST_PKG_DIR}/lib/libgmock_main.so OPTIONAL DESTINATION ${INSTALL_LIBRARY_DIR}) add_dependencies(gtest gtest_build) diff --git a/ge/CMakeLists.txt b/ge/CMakeLists.txt index 93c88cbf..bd9edd86 100755 --- a/ge/CMakeLists.txt +++ b/ge/CMakeLists.txt @@ -31,6 +31,7 @@ set(PROTO_HEADER_LIST protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) protobuf_generate(ge PROTO_CLIENT_SRCS PROTO_CLIENT_HDRS ${PROTO_CLIENT_LIST}) protobuf_generate(ge PROTO_HEADER_SRCS PROTO_HEADER_HDRS ${PROTO_HEADER_LIST}) +protobuf_generate(ge_client PROTO_CLIENT_HEADER_SRCS PROTO_CLIENT_HEADER_HDRS ${PROTO_HEADER_LIST}) if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) ############ libge_proto_common.a ############ @@ -56,7 +57,7 @@ target_link_libraries(ge_proto_common PRIVATE ############ libge_proto_client.a ############ add_library(ge_proto_client STATIC - ${PROTO_HEADER_HDRS} + ${PROTO_CLIENT_HEADER_HDRS} ${PROTO_CLIENT_SRCS} ) @@ -65,6 +66,11 @@ target_compile_definitions(ge_proto_client PRIVATE google=ascend_private ) +target_include_directories(ge_proto_client PRIVATE + ${CMAKE_BINARY_DIR}/proto/ge_client + ${CMAKE_BINARY_DIR}/proto/ge_client/proto +) + target_compile_options(ge_proto_client PRIVATE -O2 -fno-common @@ -103,6 +109,7 @@ set(TRAIN_SRC_LIST "common/profiling/profiling_manager.cc" "common/dump/dump_manager.cc" "common/dump/dump_properties.cc" + "common/dump/opdebug_register.cc" "common/dump/dump_op.cc" "common/profiling/ge_profiling.cc" "common/profiling/ge_runner_profiling.cc" @@ -319,6 +326,7 @@ set(TRAIN_SRC_LIST "graph/passes/variable_ref_useless_control_out_delete_pass.cc" "graph/passes/end_of_sequence_add_control_pass.cc" "graph/passes/memcpy_addr_async_pass.cc" + "graph/passes/parallel_group_pass.cc" "graph/passes/set_input_output_offset_pass.cc" "graph/preprocess/graph_preprocess.cc" "graph/preprocess/insert_op/ge_aipp_op.cc" @@ -427,6 +435,7 @@ set(INFER_SRC_LIST "common/dump/dump_properties.cc" "common/dump/dump_manager.cc" "common/dump/dump_op.cc" + "common/dump/opdebug_register.cc" "common/dump/dump_server.cc" "common/helper/model_cache_helper.cc" "ge_local_engine/engine/host_cpu_engine.cc" @@ -605,6 +614,7 @@ set(INFER_SRC_LIST "graph/passes/hccl_group_pass.cc" "graph/passes/memcpy_addr_async_pass.cc" "graph/passes/set_input_output_offset_pass.cc" + "graph/passes/parallel_group_pass.cc" "graph/manager/model_manager/event_manager.cc" "graph/manager/util/rt_context_util.cc" "graph/manager/util/variable_accelerate_ctrl.cc" @@ -935,6 +945,10 @@ add_library(atc_stub_ge_compiler SHARED add_dependencies(atc_stub_ge_compiler ge_stub) +target_compile_options(atc_stub_ge_compiler PRIVATE + -fno-common +) + target_link_libraries(atc_stub_ge_compiler PRIVATE $ ) @@ -971,6 +985,10 @@ add_library(fwk_stub_ge_runner SHARED add_dependencies(fwk_stub_ge_runner ge_stub) +target_compile_options(fwk_stub_ge_runner PRIVATE + -fno-common +) + target_link_libraries(fwk_stub_ge_runner PRIVATE $ ) diff --git a/ge/analyzer/analyzer.cc b/ge/analyzer/analyzer.cc index c63a6008..528a0265 100755 --- a/ge/analyzer/analyzer.cc +++ b/ge/analyzer/analyzer.cc @@ -103,7 +103,7 @@ ge::Status Analyzer::Initialize() { // Initialize file string real_path = RealPath(kFilePath.c_str()); if (real_path.empty()) { - GELOGE(FAILED, "File path is invalid."); + GELOGE(FAILED, "[Check][AnalyzeFilePath]File path is empty, Path invalid."); return FAILED; } json_file_name_ = real_path + "/" + kAnalyzeFile; @@ -155,12 +155,12 @@ std::shared_ptr Analyzer::GetJsonObject(uint64_t session_id, uint64_t std::lock_guard lg(mutex_); auto iter = graph_infos_.find(session_id); if (iter == graph_infos_.end()) { - GELOGE(PARAM_INVALID, "session_id:%lu does not exist!", session_id); + GELOGE(PARAM_INVALID, "[Check][SessionId]session_id:%lu does not exist! graph_id:%lu", session_id, graph_id); return nullptr; } else { auto iter1 = (iter->second).find(graph_id); if (iter1 == (iter->second).end()) { - GELOGE(PARAM_INVALID, "graph_id:%lu does not exist!", graph_id); + GELOGE(PARAM_INVALID, "[Check][GraphId]graph_id:%lu does not exist! session_id:%lu.", graph_id, session_id); return nullptr; } GELOGI("GetJsonObject Success!session_id:%lu graph_id:%lu", session_id, graph_id); @@ -186,11 +186,11 @@ ge::Status Analyzer::CreateAnalyzerFile() { std::lock_guard lg(file_mutex_); int fd = open(json_file_name_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, kFileAuthority); if (fd < 0) { - GELOGE(INTERNAL_ERROR, "Fail to open the file: %s.", json_file_name_.c_str()); + GELOGE(INTERNAL_ERROR, "[FileOpen][AnalyzeFile]Fail to open the analyze file: %s.", json_file_name_.c_str()); return INTERNAL_ERROR; } if (close(fd) != 0) { - GELOGE(INTERNAL_ERROR, "Fail to close the file: %s.", json_file_name_.c_str()); + GELOGE(INTERNAL_ERROR, "[FileClose][AnalyzeFile]Fail to close the analyze file: %s.", json_file_name_.c_str()); return INTERNAL_ERROR; } is_json_file_create_ = true; @@ -200,7 +200,7 @@ ge::Status Analyzer::CreateAnalyzerFile() { } ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_id) { - GELOGD("start to save analyze file!"); + GELOGD("start to save analyze file"); auto graph_info = GetJsonObject(session_id, graph_id); GE_CHECK_NOTNULL(graph_info); @@ -211,7 +211,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ std::lock_guard lg(file_mutex_); json_file_.open(json_file_name_, std::ios::app); if (!json_file_.is_open()) { - GELOGE(FAILED, "analyzer file does not exist[%s]", json_file_name_.c_str()); + GELOGE(FAILED, "[Check][AnalyzeFile]analyze file does not exist[%s]", json_file_name_.c_str()); return PARAM_INVALID; } @@ -221,7 +221,10 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ try { json_file_ << jsn.dump(kJsonDumpLevel) << std::endl; } catch (nlohmann::detail::type_error &e) { - GELOGE(FAILED, "analyzer file [%s] failed because [%s]", json_file_name_.c_str(), e.what()); + GELOGE(FAILED, + "[Json.dump][GraphInfo]json.dump to analyze file [%s] failed because [%s]," + "session_id:%lu, graph_id:%lu", + json_file_name_.c_str(), e.what(), session_id, graph_id); ret_failed = true; } json_file_.close(); @@ -229,7 +232,7 @@ ge::Status Analyzer::SaveAnalyzerDataToFile(uint64_t session_id, uint64_t graph_ } ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { - GELOGD("start to do analyzer!"); + GELOGD("start to do analyzer process"); auto pnode = data_info.node_ptr; GE_CHECK_NOTNULL(pnode); @@ -241,7 +244,9 @@ ge::Status Analyzer::DoAnalyze(DataInfo &data_info) { GE_CHECK_NOTNULL(graph_info); auto status = SaveOpInfo(desc, data_info, graph_info); if (status != SUCCESS) { - GELOGE(status, "save op info failed!"); + GELOGE(status, + "[Check][SaveOpInfo]save op info: desc_name [%s] desc_type [%s] failed!", + desc->GetName().c_str(), desc->GetType().c_str()); return FAILED; } // create json file diff --git a/ge/client/ge_api.cc b/ge/client/ge_api.cc index b6381710..a0c199e0 100644 --- a/ge/client/ge_api.cc +++ b/ge/client/ge_api.cc @@ -69,7 +69,10 @@ Status CheckOptionsValid(const std::map &options) { auto job_id_iter = options.find(OPTION_EXEC_JOB_ID); if (job_id_iter != options.end()) { if (job_id_iter->second.length() > kMaxStrLen) { - GELOGE(PARAM_INVALID, "CheckOptionsValid job_id failed, string len > %d", kMaxStrLen); + GELOGE(PARAM_INVALID,"[Check][JobId]Failed," + "the job_id [%s] string length > max string length: %d", + job_id_iter->second.c_str(), kMaxStrLen); + REPORT_INPUT_ERROR("E10051", std::vector({"id","length"}), std::vector({job_id_iter->second, std::to_string(kMaxStrLen)})); return FAILED; } } @@ -84,7 +87,8 @@ Status GEInitializeImpl(const std::map &options) { std::string path_base = ge::GELib::GetPath(); auto ret = ErrorManager::GetInstance().Init(path_base); if (ret != SUCCESS) { - GELOGE(GE_CLI_INIT_FAILED, "ErrorManager init fail"); + GELOGE(GE_CLI_INIT_FAILED, + "[Init][PathBase]Init failed when pass param path_base:%s", path_base.c_str()); return ret; } @@ -104,7 +108,9 @@ Status GEInitializeImpl(const std::map &options) { bool is_proto_init = manager->Initialize(option_tmp); GE_TIMESTAMP_END(GEInitialize, "GEInitialize::ManagerInitialize"); if (!is_proto_init) { - GELOGE(GE_CLI_INIT_FAILED, "geInitialize failed, ops proto path is invalid."); + GELOGE(GE_CLI_INIT_FAILED, + "[Init][OpsProtoPath]Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid.", + opsproto_path.c_str()); return FAILED; } @@ -127,7 +133,7 @@ Status GEInitializeImpl(const std::map &options) { ret = ge::GELib::Initialize(options); GE_TIMESTAMP_END(GELibInitialize, "GEInitialize::GELibInitialize"); if (ret != SUCCESS) { - GELOGE(GE_CLI_INIT_FAILED, "geInitialize failed, error code = %u", ret); + GELOGE(GE_CLI_INIT_FAILED, "[Init][GELib]Failed, error code = %u", ret); return FAILED; } @@ -155,7 +161,9 @@ Status GEInitialize(const std::map &options) { std::map str_options; for (auto &option : options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(FAILED, "GEInitialize options is nullptr."); + GELOGE(FAILED, "[Check][Param]Options invalid, first or second option is nullptr."); + REPORT_INNER_ERROR("E19999", "Check parameter's options invalid," + "the first or second option is nullptr."); return FAILED; } std::string key = option.first.GetString(); @@ -171,17 +179,17 @@ Status GEInitialize(const std::map &options) { // GE finalize, releasing all resources Status GEFinalize() { - ErrorManager::GetInstance().SetStage(ErrorMessage::kFinalize, ErrorMessage::kFinalize); - GELOGT(TRACE_INIT, "GEFinalize start"); - - ErrorManager::GetInstance().GenWorkStreamIdDefault(); + std::lock_guard lock(g_ge_release_mutex); // check init status if (!g_ge_initialized) { - GELOGW("GEFinalize is called before GEInitialize"); + GELOGW("[FINAL][FINAL]GEFinalize is called before GEInitialize"); return SUCCESS; } - std::lock_guard lock(g_ge_release_mutex); + ErrorManager::GetInstance().SetStage(ErrorMessage::kFinalize, ErrorMessage::kFinalize); + ErrorManager::GetInstance().GenWorkStreamIdDefault(); + GELOGT(TRACE_INIT, "GEFinalize start"); + // call Finalize Status ret = SUCCESS; Status middle_ret; @@ -237,13 +245,17 @@ Session::Session(const std::map &options) { // check init status sessionId_ = 0; if (!g_ge_initialized) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Construct][Session]Failed because lack GEInitialize call before."); + REPORT_INNER_ERROR("E19999", + "Creating session failed because lack GEInitialize call before."); return; } // call Initialize std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Construct][Session]Failed, GELib instance is nullptr or it is not InitFlag"); return; } @@ -256,7 +268,7 @@ Session::Session(const std::map &options) { if (ret == SUCCESS) { sessionId_ = session_id; } else { - GELOGE(ret, "Session constructor failed, session Id not initialized"); + GELOGE(ret, "[Construct][Session]Failed, error code:%u.", ret); return; } GELOGT(TRACE_STOP, "Session Constructor finished"); @@ -270,13 +282,17 @@ Session::Session(const std::map &options) { // check init status sessionId_ = 0; if (!g_ge_initialized) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Construct][Session]Failed because lack GEInitialize call before."); + REPORT_INNER_ERROR("E19999", + "Creating session failed because lack GEInitialize call before."); return; } // call Initialize std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Construct][Session]Failed, the GELib instance is nullptr or is not InitFlag"); return; } @@ -284,7 +300,9 @@ Session::Session(const std::map &options) { std::map str_options; for (auto &option : options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(FAILED, "Session options is nullptr."); + GELOGE(FAILED, "[Construct][Session]Failed, the first or second option is nullptr."); + REPORT_INNER_ERROR("E19999", "Creating session's options invalid," + "the first or second option is nullptr."); return; } std::string key = option.first.GetString(); @@ -299,7 +317,7 @@ Session::Session(const std::map &options) { if (ret == SUCCESS) { sessionId_ = session_id; } else { - GELOGE(ret, "Session constructor failed, session Id not initialized"); + GELOGE(ret, "[Construct][Session]Failed, error code:%u.", ret); return; } GELOGT(TRACE_STOP, "Session Constructor finished"); @@ -331,17 +349,18 @@ Session::~Session() { ret = instance_ptr->SessionManagerObj().DestroySession(session_id); } catch (google::protobuf::FatalException &e) { - GELOGE(GE_CLI_SESS_DESTROY_FAILED, "SessionDestructor throws FatalException"); + GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destruct][Session]Failed because get fatalException."); } // check return status, return, update session id if success if (ret != SUCCESS) { - GELOGE(ret, "Session Destructor failed"); + GELOGE(ret, "[Destruct][Session]Failed, error code:%u.", ret); } GELOGT(TRACE_STOP, "Session Destructor finished"); } +// Add Graph Status Session::AddGraph(uint32_t graph_id, const Graph &graph) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); std::map options; @@ -349,25 +368,32 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph) { return AddGraph(graph_id, graph, options); } +// Add Graph Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map &options) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Add][Graph]Failed because GELib instance is nullptr or it is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "AddGraph Failed, GELib instance is nullptr or it is not InitFlag."); return FAILED; } GELOGD("Adding graph to session"); Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, options); if (ret != SUCCESS) { - GELOGE(ret, "AddGraph failed in Session."); + GELOGE(ret, + "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } GELOGD("AddGraph finished in Session."); return ret; } +//Add Graph Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map &options) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); @@ -375,14 +401,19 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Add][Graph]Failed, the GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "AddGraph Failed, GELib instance is nullptr or it is not InitFlag."); return FAILED; } GELOGD("Adding graph to session"); std::map str_options; for (auto &option : options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(FAILED, "AddGraph options is nullptr."); + GELOGE(FAILED, "[Add][Graph]Failed, the first or second option is nullptr."); + REPORT_INNER_ERROR("E19999", + "Add Graph Failed, the first or second option is nullptr."); return FAILED; } std::string key = option.first.GetString(); @@ -391,7 +422,9 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, } Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); if (ret != SUCCESS) { - GELOGE(ret, "AddGraph failed in Session."); + GELOGE(ret, + "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } GELOGD("AddGraph finished in Session."); @@ -405,6 +438,7 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { return AddGraphWithCopy(graph_id, graph, options); } +// Add Graph With Copy Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, const std::map &options) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); @@ -412,7 +446,10 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Add][Graph]Failed, the GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "AddGraph Failed, GELib instance is nullptr or is not InitFlag."); return FAILED; } std::map str_options; @@ -422,13 +459,16 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, GELOGD("Adding graph to session"); Status ret = instance_ptr->SessionManagerObj().AddGraphWithCopy(sessionId_, graph_id, graph, str_options); if (ret != SUCCESS) { - GELOGE(ret, "AddGraph failed in Session."); + GELOGE(ret, + "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } GELOGD("AddGraph finished in Session."); return ret; } +// Remove Graph Status Session::RemoveGraph(uint32_t graph_id) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGT(TRACE_INIT, "Session RemoveGraph start"); @@ -437,7 +477,10 @@ Status Session::RemoveGraph(uint32_t graph_id) { // call RemoveGraph std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (!instance_ptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session RemoveGraph failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Remove][Graph]Failed, GELib instance is nullptr or is not InitFlag "); + REPORT_INNER_ERROR("E19999", + "RemoveGraph Failed, GELib instance is nullptr or is not InitFlag."); return FAILED; } @@ -445,13 +488,16 @@ Status Session::RemoveGraph(uint32_t graph_id) { Status ret = instance_ptr->SessionManagerObj().RemoveGraph(sessionId_, graph_id); // check return status, return if (ret != SUCCESS) { - GELOGE(ret, "session RemoveGraph failed"); + GELOGE(ret, + "[Remove][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } GELOGT(TRACE_STOP, "Session RemoveGraph finished"); return ret; } +// Print Output Result void PrintOutputResult(std::vector &outputs) { if (outputs.empty() || outputs[0].GetData() == nullptr) { GELOGW("outputs is empty or data is nullptr."); @@ -499,6 +545,7 @@ void PrintOutputResult(std::vector &outputs) { } } +// Run Graph Status Session::RunGraph(uint32_t graph_id, const std::vector &inputs, std::vector &outputs) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGT(TRACE_INIT, "Session RunGraph start"); @@ -508,14 +555,19 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector &inputs, s // call RunGraph std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session RunGraph failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Run][Graph]Failed, GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "RunGraph Failed, GELib instance is nullptr or is not InitFlag."); return FAILED; } GELOGT(TRACE_RUNNING, "Running Graph"); Status ret = instance_ptr->SessionManagerObj().RunGraph(sessionId_, graph_id, graph_inputs, outputs); // check return status if (ret != SUCCESS) { - GELOGE(ret, "Session RunGraph failed"); + GELOGE(ret, + "[Run][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } @@ -537,7 +589,7 @@ Status Session::RunGraphWithStreamAsync(uint32_t graph_id, const std::vector graph_inputs = inputs; std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session RunGraph failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Ge instace init failed"); return FAILED; } GELOGT(TRACE_RUNNING, "Running Graph"); @@ -573,30 +625,40 @@ Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFu return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); } +// Build Graph Status Session::BuildGraph(uint32_t graph_id, const std::vector &inputs) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Build][Graph]Failed, the GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "Build graph failed, the GELib instance is nullptr or is not InitFlag."); return FAILED; } GELOGT(TRACE_RUNNING, "Building Graph"); Status ret = instance_ptr->SessionManagerObj().BuildGraph(sessionId_, graph_id, inputs); if (ret != SUCCESS) { - GELOGE(ret, "Session BuildGraph failed"); + GELOGE(ret, + "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } return SUCCESS; } +// Run Graph Asynchronously Status Session::RunGraphAsync(uint32_t graph_id, const std::vector &inputs, RunAsyncCallback callback) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Run][Graph]RunGraphAsyncFailed, the GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "RunGraphAsync Failed, the GELib instance is nullptr or is not InitFlag."); return FAILED; } GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); @@ -605,49 +667,59 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vectorSessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); if (ret != SUCCESS) { - GELOGE(ret, "SessionManager RunGraphAsync failed"); + GELOGE(ret, "[Run][Graph]RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u.", + ret, sessionId_, graph_id); return FAILED; } return SUCCESS; } +// Get Variables Status Session::GetVariables(const std::vector &var_names, std::vector &var_values) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); ErrorManager::GetInstance().GenWorkStreamIdDefault(); auto instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Get][Variables]Failed, the GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "GetVariables failed, the GELib instance is nullptr or is not InitFlag."); return FAILED; } GELOGT(TRACE_RUNNING, "Get Variables"); Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, var_names, var_values); if (ret != SUCCESS) { - GELOGE(ret, "SessionManager RunGraphAsync failed"); + GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); return FAILED; } return SUCCESS; } +// Get Variables Status Session::GetVariables(const std::vector &var_names, std::vector &var_values) { ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); ErrorManager::GetInstance().GenWorkStreamIdDefault(); auto instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, + "[Get][Variables]Failed, the GELib instance is nullptr or is not InitFlag."); + REPORT_INNER_ERROR("E19999", + "GetVariables failed, the GELib instance is nullptr or is not InitFlag."); return FAILED; } GELOGT(TRACE_RUNNING, "Get Variables"); std::vector str_var_names; for (auto &var_name : var_names) { if (var_name.GetString() == nullptr) { - GELOGE(FAILED, "GetVariables name is nullptr."); + GELOGE(FAILED, "[Get][Variable]Failed, variables' names are nullptr."); + REPORT_INNER_ERROR("E19999", "GetVariables failed, variables' names are nullptr."); return FAILED; } str_var_names.emplace_back(var_name.GetString()); } Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); if (ret != SUCCESS) { - GELOGE(ret, "SessionManager RunGraphAsync failed"); + GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); return FAILED; } return SUCCESS; diff --git a/ge/common/CMakeLists.txt b/ge/common/CMakeLists.txt index a6f8e57c..75cb8ad1 100755 --- a/ge/common/CMakeLists.txt +++ b/ge/common/CMakeLists.txt @@ -16,6 +16,7 @@ set(PROTO_LIST ) protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +protobuf_generate(ge_static PROTO_STATIC_SRCS PROTO_STATIC_HDRS ${PROTO_LIST}) set(SRC_LIST "context/ctx.cc" @@ -127,7 +128,7 @@ target_link_libraries(ge_common PRIVATE ) ############ libge_common.a ############ -add_library(ge_common_static STATIC ${SRC_LIST} ${PROTO_HDRS}) +add_library(ge_common_static STATIC ${SRC_LIST} ${PROTO_STATIC_HDRS}) target_compile_definitions(ge_common_static PRIVATE PROTOBUF_INLINE_NOT_IN_HEADERS=0 HOST_VISIBILITY @@ -158,7 +159,7 @@ target_include_directories(ge_common_static PRIVATE ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/ge + ${CMAKE_BINARY_DIR}/proto/ge_static #### yellow zone #### ${GE_DEPEND_DIR}/inc ${GE_DEPEND_DIR}/inc/cce diff --git a/ge/common/cust_aicpu_kernel_store.cc b/ge/common/cust_aicpu_kernel_store.cc index 0bf4d819..1055989b 100755 --- a/ge/common/cust_aicpu_kernel_store.cc +++ b/ge/common/cust_aicpu_kernel_store.cc @@ -25,7 +25,7 @@ void CustAICPUKernelStore::AddCustAICPUKernel(const CustAICPUKernelPtr &kernel) } void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr &op_desc) const { - GELOGD("LoadCustAICPUKernelBinToOpDesc in"); + GELOGD("LoadCustAICPUKernelBinToOpDesc in."); if (op_desc != nullptr) { auto kernel_bin = FindKernel(op_desc->GetName()); if (kernel_bin != nullptr) { @@ -34,6 +34,6 @@ void CustAICPUKernelStore::LoadCustAICPUKernelBinToOpDesc(const std::shared_ptr< GELOGI("Load cust aicpu kernel:%s, %zu", kernel_bin->GetName().c_str(), kernel_bin->GetBinDataSize()); } } - GELOGD("LoadCustAICPUKernelBinToOpDesc success"); + GELOGD("LoadCustAICPUKernelBinToOpDesc success."); } } // namespace ge diff --git a/ge/common/dump/dump_manager.cc b/ge/common/dump/dump_manager.cc index 74324059..a659d9c6 100644 --- a/ge/common/dump/dump_manager.cc +++ b/ge/common/dump/dump_manager.cc @@ -104,8 +104,12 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status DumpManager::SetDumpConf FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY const DumpProperties &DumpManager::GetDumpProperties( uint64_t session_id) { std::lock_guard lock(mutex_); - // If session_id is not found in dump_properties_map_, operator[] will insert one. - return dump_properties_map_[session_id]; + auto iter = dump_properties_map_.find(session_id); + if (iter != dump_properties_map_.end()) { + return iter->second; + } + static DumpProperties default_properties; + return default_properties; } FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY void DumpManager::AddDumpProperties( diff --git a/ge/common/dump/dump_op.cc b/ge/common/dump/dump_op.cc index 5c768e22..0becbdc8 100755 --- a/ge/common/dump/dump_op.cc +++ b/ge/common/dump/dump_op.cc @@ -219,9 +219,9 @@ Status DumpOp::LaunchDumpOp() { op_mapping_info.set_dump_path(dump_path); op_mapping_info.set_flag(kAicpuLoadFlag); op_mapping_info.set_dump_step(dump_properties_.GetDumpStep()); - if (!dynamic_model_name_.empty()) { + op_mapping_info.set_model_id(dynamic_model_id_); + if (!dynamic_model_name_.empty() && dump_properties_.IsDumpOpen()) { op_mapping_info.set_model_name(dynamic_model_name_); - op_mapping_info.set_model_id(dynamic_model_id_); } SetOpMappingLoopAddr(global_step_, loop_per_iter_, loop_cond_, op_mapping_info); GELOGI("Dump step is %s ,dump path is %s ,in Launch dump op", dump_properties_.GetDumpStep().c_str(), @@ -253,7 +253,7 @@ Status DumpOp::LaunchDumpOp() { } op_mapping_info.mutable_task()->Add(std::move(task)); } - if (dump_properties_.GetDumpMode() == kDumpAll) { + if (dump_properties_.GetDumpMode() == kDumpAll || dump_properties_.IsOpDebugOpen()) { auto ret = DumpOutput(task); if (ret != SUCCESS) { GELOGE(ret, "Dump output failed when in dumping all"); diff --git a/ge/common/dump/dump_properties.h b/ge/common/dump/dump_properties.h index 67f8c00e..8c064d58 100644 --- a/ge/common/dump/dump_properties.h +++ b/ge/common/dump/dump_properties.h @@ -81,11 +81,11 @@ class DumpProperties { const std::string &GetEnableDumpDebug() const {return enable_dump_debug_;} + private: void CopyFrom(const DumpProperties &other); void SetDumpDebugOptions(); - std::string enable_dump_; std::string enable_dump_debug_; diff --git a/ge/common/dump/opdebug_register.cc b/ge/common/dump/opdebug_register.cc new file mode 100644 index 00000000..340b89e5 --- /dev/null +++ b/ge/common/dump/opdebug_register.cc @@ -0,0 +1,148 @@ +/** + * 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 "opdebug_register.h" + +namespace { +const size_t kOpDebugMemorySize = 2048UL; +const size_t kDebugP2pSize = 8UL; +} // namespace +namespace ge { +OpdebugRegister::~OpdebugRegister() {} + +Status OpdebugRegister::RegisterDebugForModel(rtModel_t model_handle, uint32_t op_debug_mode, DataDumper &data_dumper) { + GELOGD("Start to register debug for model in overflow"); + auto ret = MallocMemForOpdebug(); + if (ret != SUCCESS) { + GELOGE(ret, "Malloc memory for opdebug in model overflow failed ,ret:0x%X", ret); + return ret; + } + uint32_t debug_stream_id = 0; + uint32_t debug_task_id = 0; + auto rt_ret = rtDebugRegister(model_handle, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtDebugRegister error, ret: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + GELOGD("debug_task_id:%u, debug_stream_id:%u in model overflow", debug_task_id, debug_stream_id); + data_dumper.SaveOpDebugId(debug_task_id, debug_stream_id, p2p_debug_addr_, true); + return SUCCESS; +} + +void OpdebugRegister::UnregisterDebugForModel(rtModel_t model_handle) { + rtError_t rt_ret = RT_ERROR_NONE; + if (model_handle != nullptr) { + GELOGD("start to call rtDebugUnRegister in model overflow."); + rt_ret = rtDebugUnRegister(model_handle); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("rtDebugUnRegister failed, ret: 0x%X", rt_ret); + } + } + + if (op_debug_addr_ != nullptr) { + rt_ret = rtFree(op_debug_addr_); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("rtFree failed, ret: 0x%X", rt_ret); + } + op_debug_addr_ = nullptr; + } + + if (p2p_debug_addr_ != nullptr) { + rt_ret = rtFree(p2p_debug_addr_); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("rtFree failed, ret: 0x%X", rt_ret); + } + p2p_debug_addr_ = nullptr; + } + return; +} + +Status OpdebugRegister::RegisterDebugForStream(rtStream_t stream, uint32_t op_debug_mode, DataDumper &data_dumper) { + GELOGD("Start to register debug for stream in stream overflow"); + auto ret = MallocMemForOpdebug(); + if (ret != SUCCESS) { + GELOGE(ret, "Malloc memory for opdebug in stream overflow ,ret:0x%X", ret); + return ret; + } + + uint32_t debug_stream_id = 0; + uint32_t debug_task_id = 0; +#ifdef ONLY_COMPILE_OPEN_SRC + auto rt_ret = rtDebugRegisterForStream(stream, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtDebugRegisterForStream error, ret: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } +#endif + GELOGD("debug_task_id:%u, debug_stream_id:%u in stream overflow.", debug_task_id, debug_stream_id); + data_dumper.SaveOpDebugId(debug_task_id, debug_stream_id, p2p_debug_addr_, true); + return SUCCESS; +} + +void OpdebugRegister::UnregisterDebugForStream(rtStream_t stream) { + rtError_t rt_ret = RT_ERROR_NONE; +#ifdef ONLY_COMPILE_OPEN_SRC + if (stream != nullptr) { + GELOGD("start call rtDebugUnRegisterForStream in unknown shape over flow."); + rt_ret = rtDebugUnRegisterForStream(stream); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("rtDebugUnRegisterForStream failed, ret: 0x%X", rt_ret); + } + } +#endif + + if (op_debug_addr_ != nullptr) { + rt_ret = rtFree(op_debug_addr_); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("rtFree failed, ret: 0x%X", rt_ret); + } + op_debug_addr_ = nullptr; + } + + if (p2p_debug_addr_ != nullptr) { + rt_ret = rtFree(p2p_debug_addr_); + if (rt_ret != RT_ERROR_NONE) { + GELOGW("rtFree failed, ret: 0x%X", rt_ret); + } + p2p_debug_addr_ = nullptr; + } + return; +} + +Status OpdebugRegister::MallocMemForOpdebug() { + rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + + uint64_t debug_addrs_tmp = static_cast(reinterpret_cast(op_debug_addr_)); + // For data dump, aicpu needs the pointer to pointer that save the real debug address. + rt_ret = rtMalloc(&p2p_debug_addr_, kDebugP2pSize, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + rt_ret = rtMemcpy(p2p_debug_addr_, sizeof(uint64_t), &debug_addrs_tmp, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "rtMemcpy to p2p_addr error: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + + return SUCCESS; +} + +} // namespace ge \ No newline at end of file diff --git a/ge/common/dump/opdebug_register.h b/ge/common/dump/opdebug_register.h new file mode 100644 index 00000000..1826287d --- /dev/null +++ b/ge/common/dump/opdebug_register.h @@ -0,0 +1,44 @@ +/** + * 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_COMMON_DUMP_OPDEBUG_REGISTER_H_ +#define GE_COMMON_DUMP_OPDEBUG_REGISTER_H_ + +#include +#include "common/debug/ge_log.h" +#include "common/debug/log.h" +#include "graph/load/model_manager/data_dumper.h" + +namespace ge { +class OpdebugRegister { + public: + OpdebugRegister() = default; + ~OpdebugRegister(); + + Status RegisterDebugForModel(rtModel_t model_handle, uint32_t op_debug_mode, DataDumper &data_dumper); + void UnregisterDebugForModel(rtModel_t model_handle); + + Status RegisterDebugForStream(rtStream_t stream, uint32_t op_debug_mode, DataDumper &data_dumper); + void UnregisterDebugForStream(rtStream_t stream); + + private: + Status MallocMemForOpdebug(); + + void *op_debug_addr_ = nullptr; + void *p2p_debug_addr_ = nullptr; +}; +} // namespace ge +#endif // GE_COMMON_DUMP_OPDEBUG_REGISTER_H_ diff --git a/ge/common/formats/format_transfers/datatype_transfer.cc b/ge/common/formats/format_transfers/datatype_transfer.cc index ba3fcdf3..b1df4f53 100644 --- a/ge/common/formats/format_transfers/datatype_transfer.cc +++ b/ge/common/formats/format_transfers/datatype_transfer.cc @@ -111,7 +111,7 @@ Status CastKernel(const CastArgs &args, uint8_t *dst, const size_t data_size, co }; auto it = transfer_handle.find(trans_mode); if (it == transfer_handle.end()) { - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } else { return (it->second)(args, dst, data_size); } @@ -127,8 +127,8 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result std::string error = "Failed to trans data from datatype " + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)) + " to " + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)) + " , it is not supported."; - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_DATATYPE_INVALID, error.c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; } auto trans_mode = iter->second; @@ -136,14 +136,14 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result if (size <= 0) { std::string error = "Failed to calc size from data type" + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)) + ", it is not supported."; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); - return PARAM_INVALID; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_DATATYPE_INVALID, error.c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; } if (args.src_data_size > static_cast(SIZE_MAX / size)) { std::string error = "args.src_data_size" + FmtToStr(args.src_data_size) + " or data type size" + FmtToStr(size) + " is too big"; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); - return PARAM_INVALID; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_PARAM_INVALID, error.c_str()); + return ACL_ERROR_GE_PARAM_INVALID; } size_t total_size = static_cast(args.src_data_size * size); result.length = total_size; @@ -154,8 +154,9 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to alloc the memory for dst buf %zu, data size %zu", total_size, args.src_data_size); - return OUT_OF_MEMORY; + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to alloc the memory for dst buf %zu, data size %zu", total_size, args.src_data_size); + return ACL_ERROR_GE_MEMORY_ALLOCATION; } if (CastKernel(args, dst.get(), args.src_data_size, trans_mode) != SUCCESS) { @@ -163,8 +164,8 @@ Status DataTypeTransfer::TransDataType(const CastArgs &args, TransResult &result FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)) + " to " + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)) + ", data size is " + FmtToStr(std::to_string(args.src_data_size)); - GE_ERRORLOG_AND_ERRORMSG(INTERNAL_ERROR, error.c_str()); - return INTERNAL_ERROR; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_INTERNAL_ERROR, error.c_str()); + return ACL_ERROR_GE_INTERNAL_ERROR; } result.data = dst; return SUCCESS; diff --git a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc index 0cb581d7..20f493d7 100644 --- a/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_c1hwncoc0_hwcn.cc @@ -39,22 +39,22 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { std::string error = "Failed to trans shape from NC1HWNCoC0 to HWCN, invalid data type" + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_DATATYPE_INVALID, error.c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(src_shape, kC1hwncoc0DimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(dst_shape, kHwcnDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s.", ShapeToString(dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } auto cube_size = GetCubeSizeByDataType(args.src_data_type); if (src_shape.at(kC1hwncoc0C1) != (dst_shape.at(kHwcnC) - 1) / cube_size + 1 || @@ -63,8 +63,8 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { src_shape.at(kC1hwncoc0C0) != cube_size) { std::string error = "Failed to check relationship between src and dst shape, src shape" + FmtToStr(ShapeToString(src_shape)) + ", dst shape" + FmtToStr(ShapeToString(dst_shape)); - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); - return PARAM_INVALID; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -73,10 +73,11 @@ Status CheckArgsForC1hwncoc0ToHwcn(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto h = args.src_shape.at(kC1hwncoc0H); @@ -114,12 +115,12 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld to " "HWCN[%ld, %ld, %ld, %ld] offset %ld, err-code %d", c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, src_offset, h_idx, w_idx, c_idx, n_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -132,8 +133,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size } // namespace Status FormatTransferC1hwncoc0Hwcn::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForC1hwncoc0ToHwcn(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForC1hwncoc0ToHwcn(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); int64_t total_size = GetItemNumByShape(args.dst_shape) * size; @@ -143,26 +145,27 @@ Status FormatTransferC1hwncoc0Hwcn::TransFormat(const TransArgs &args, TransResu result.length = static_cast(total_size); return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s.", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } - GELOGD("Begin to trans format from C1HWNCoC0 to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", + GELOGD("Begin to trans format from C1HWNCoC0 to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld.", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } Status FormatTransferC1hwncoc0Hwcn::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { - GELOGD("The shape derivation from C1HWNCoC0 to HWCN is not unique. Trans shape in this direction is not supported"); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + GELOGD("The shape derivation from C1HWNCoC0 to HWCN is not unique. Trans shape in this direction is not supported."); + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferC1hwncoc0Hwcn, FORMAT_C1HWNCoC0, FORMAT_HWCN) diff --git a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc index eaa19d7d..0508a1a5 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwcn_fracz3D.cc @@ -32,7 +32,7 @@ Status TransShapeToFz(int64_t d, int64_t n, int64_t c, int64_t h, int64_t w, Dat std::vector &dst_shape) { auto c0 = GetCubeSizeByDataType(data_type); if (c0 < 0) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } auto c1 = Ceil(c, c0); @@ -50,7 +50,7 @@ Status TransShapeToFz(int64_t d, int64_t n, int64_t c, int64_t h, int64_t w, Dat Status TransShapeDhwckToFz3D(const std::vector &src_shape, DataType data_type, std::vector &dst_shape) { if (!CheckShapeValid(src_shape, kDhwcnDimsNum)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } auto d = src_shape.at(kDhwcnD); auto h = src_shape.at(kDhwcnH); @@ -62,7 +62,7 @@ Status TransShapeDhwckToFz3D(const std::vector &src_shape, DataType dat } Status TransFormatDhwckToFz3D(const TransArgs &args, TransResult &result) { if (!CheckShapeValid(args.src_shape, kDhwcnDimsNum)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t d = args.src_shape[kDhwcnD]; int64_t h = args.src_shape[kDhwcnH]; @@ -94,10 +94,11 @@ Status TransFormatDhwckToFz3D(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } for (int64_t di = 0; di < d; di++) { @@ -122,9 +123,10 @@ Status TransFormatDhwckToFz3D(const TransArgs &args, TransResult &result) { args.data + src_idx * data_size, static_cast(data_size)); } if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -149,28 +151,28 @@ Status FormatTransferDhwcnFractalZ3D::TransFormat(const TransArgs &args, TransRe return ret; } if (!IsTransShapeDstCorrect(args, expect_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } if (args.src_format == FORMAT_DHWCN && args.dst_format == FORMAT_FRACTAL_Z_3D) { return TransFormatDhwckToFz3D(args, result); } - return UNSUPPORTED; + return ACL_ERROR_GE_FORMAT_INVALID; } Status FormatTransferDhwcnFractalZ3D::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { if (CheckDataTypeSupport(data_type) != SUCCESS) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (src_format == FORMAT_DHWCN && dst_format == FORMAT_FRACTAL_Z_3D) { return TransShapeDhwckToFz3D(src_shape, data_type, dst_shape); } - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferDhwcnFractalZ3D, FORMAT_DHWCN, FORMAT_FRACTAL_Z_3D) diff --git a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc index 3a18312a..8dd1757b 100644 --- a/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_dhwnc_fracz3D_transpose.cc @@ -32,7 +32,7 @@ Status TransShapeToFz(int64_t d, int64_t n, int64_t c, int64_t h, int64_t w, Dat std::vector &dst_shape) { auto c0 = GetCubeSizeByDataType(data_type); if (c0 < 0) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } auto c1 = Ceil(c, c0); @@ -50,7 +50,7 @@ Status TransShapeToFz(int64_t d, int64_t n, int64_t c, int64_t h, int64_t w, Dat Status TransShapeDhwncToFz3DTranspose(const std::vector &src_shape, DataType data_type, std::vector &dst_shape) { if (!CheckShapeValid(src_shape, kDhwncDimsNum)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } auto d = src_shape.at(kDhwncD); auto h = src_shape.at(kDhwncH); @@ -62,7 +62,7 @@ Status TransShapeDhwncToFz3DTranspose(const std::vector &src_shape, Dat } Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &result) { if (!CheckShapeValid(args.src_shape, kDhwncDimsNum)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t d = args.src_shape[kDhwncD]; int64_t h = args.src_shape[kDhwncH]; @@ -95,10 +95,11 @@ Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &resul std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } for (int64_t di = 0; di < d; di++) { @@ -123,9 +124,10 @@ Status TransFormatDhwncToFz3DTranspose(const TransArgs &args, TransResult &resul args.data + src_idx * data_size, static_cast(data_size)); } if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -150,28 +152,28 @@ Status FormatTransferDhwncFractalZ3DTranspose::TransFormat(const TransArgs &args return ret; } if (!IsTransShapeDstCorrect(args, expect_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } if (args.src_format == ge::FORMAT_DHWNC && args.dst_format == ge::FORMAT_FRACTAL_Z_3D_TRANSPOSE) { return TransFormatDhwncToFz3DTranspose(args, result); } - return UNSUPPORTED; + return ACL_ERROR_GE_FORMAT_INVALID; } Status FormatTransferDhwncFractalZ3DTranspose::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { if (CheckDataTypeSupport(data_type) != SUCCESS) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (src_format == FORMAT_DHWNC && dst_format == FORMAT_FRACTAL_Z_3D_TRANSPOSE) { return TransShapeDhwncToFz3DTranspose(src_shape, data_type, dst_shape); } - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferDhwncFractalZ3DTranspose, FORMAT_DHWNC, FORMAT_FRACTAL_Z_3D_TRANSPOSE) diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc index c3b288c1..fccdb57b 100755 --- a/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_nz.cc @@ -87,8 +87,8 @@ Status TransShapeToFracNz(const ShapeVector &src_shape, DataType data_type, Shap hw_shape.push_back(DIM_DEFAULT_VALUE); hw_shape.push_back(src_shape[kNdDimIndexN]); if (!IsShapeValid(dst_shape)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; default: @@ -106,8 +106,8 @@ Status TransShapeToFracNz(const ShapeVector &src_shape, DataType data_type, Shap hw_shape.push_back(src_shape[size - kNdDimCountBackwardsWH]); hw_shape.push_back(src_shape[size - kNdDimCountBackwardsW]); if (!IsShapeValid(dst_shape)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; } @@ -117,14 +117,14 @@ Status CheckShapeRelation(const TransArgs &args, ShapeVector &hw_shape) { ShapeVector expect_src_shape; auto ret = TransShapeToFracNz(args.dst_shape, args.src_data_type, expect_src_shape, hw_shape); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Trans shape from %s to %s, shape %s to %s, data type %s failed", + GELOGE(ret, "Trans shape from %s to %s, shape %s to %s, data type %s failed", TypeUtils::FormatToSerialString(args.dst_format).c_str(), TypeUtils::FormatToSerialString(args.src_format).c_str(), ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return INTERNAL_ERROR; + return ret; } if (!IsTransShapeSrcCorrect(args, expect_src_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; } @@ -139,10 +139,11 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } // src&dst_shape can be written as times*H*W & times*W1*H1*H0*W0, respectively. dst_shape_size >= kDimNum4D @@ -175,8 +176,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } auto w1_head = num_w1 * w0; @@ -189,8 +191,9 @@ Status TransFormatFromNdToFracNz(const TransArgs &args, TransResult &result, con auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -210,10 +213,11 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto times = dst_hw_shape.at(kNdDimIndexN); @@ -246,8 +250,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } auto w1_head = num_w1 * w0; @@ -260,8 +265,9 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -273,13 +279,21 @@ Status TransFormatFromFracNzToNd(const TransArgs &args, TransResult &result, con } // namespace Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult &result) { - if (!IsDataTypeSupport(args.src_data_type) || !CheckShape(args.src_format, args.src_shape) || - !IsShapeValid(args.dst_shape)) { - GELOGE(PARAM_INVALID, "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", + if (!IsDataTypeSupport(args.src_data_type)) { + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, + "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", + TypeUtils::FormatToSerialString(args.src_format).c_str(), + TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), + ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; + } + if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) { + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from %s to %s, src shape %s, dst shape %s, data type %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), @@ -292,7 +306,7 @@ Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult & return ret; } if (!IsTransShapeDstCorrect(args, expect_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return TransFormatFromNdToFracNz(args, result, hw_shape); } @@ -300,31 +314,40 @@ Status FormatTransferFractalNz::TransFormat(const TransArgs &args, TransResult & Status FormatTransferFractalNz::TransShape(Format src_format, const ShapeVector &src_shape, DataType data_type, Format dst_format, ShapeVector &dst_shape) { if (!IsDataTypeSupport(data_type)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID, + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Trans format from %s to %s, src shape %s, data type %s is not supported", TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(), ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShape(src_format, src_shape)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Trans format from %s to %s, src shape %s, data type %s is not supported", TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(), ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } ShapeVector hw_shape; return TransShapeToFracNz(src_shape, data_type, dst_shape, hw_shape); } Status FormatTransferFractalNzND::TransFormat(const TransArgs &args, TransResult &result) { - if (!IsDataTypeSupport(args.src_data_type) || !IsShapeValid(args.src_shape) || - !CheckShape(args.dst_format, args.dst_shape)) { - GELOGE(PARAM_INVALID, "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", + if (!IsDataTypeSupport(args.src_data_type)) { + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, + "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", + TypeUtils::FormatToSerialString(args.src_format).c_str(), + TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), + ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; + } + + if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) { + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Trans format from %s to %s, src shape %s, dst shape %s, data type %s is not supported", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from %s to %s, src shape %s, dst shape %s, data type %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), @@ -332,8 +355,9 @@ Status FormatTransferFractalNzND::TransFormat(const TransArgs &args, TransResult ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeVector hw_shape; - if (CheckShapeRelation(args, hw_shape) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckShapeRelation(args, hw_shape); + if (ret != SUCCESS) { + return ret; } return TransFormatFromFracNzToNd(args, result, hw_shape); } @@ -342,7 +366,7 @@ Status FormatTransferFractalNzND::TransShape(Format src_format, const ShapeVecto Format dst_format, ShapeVector &dst_shape) { GELOGD("The shape derivation from %s to %s is not unique. Trans shape is not supported", TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferFractalNz, FORMAT_ND, FORMAT_FRACTAL_NZ) diff --git a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc index 45c6d157..39f33927 100644 --- a/ge/common/formats/format_transfers/format_transfer_fractal_z.cc +++ b/ge/common/formats/format_transfers/format_transfer_fractal_z.cc @@ -42,7 +42,7 @@ Status CheckDataTypeSupport(DataType data_type) { return GetSizeByDataType(data_ Status TransShapeToFz(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_type, std::vector &dst_shape) { auto c0 = GetCubeSizeByDataType(data_type); if (c0 < 0) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } auto c1 = Ceil(c, c0); @@ -54,16 +54,16 @@ Status TransShapeToFz(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_ dst_shape.push_back(kNiSize); dst_shape.push_back(c0); if (!IsShapeValid(dst_shape)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check dst shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; } Status TransShapeNchwToFz(const std::vector &src_shape, DataType data_type, std::vector &dst_shape) { if (!CheckShapeValid(src_shape, kNchwDimsNum)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } auto n = src_shape.at(kNchwN); @@ -75,7 +75,7 @@ Status TransShapeNchwToFz(const std::vector &src_shape, DataType data_t Status TransShapeHwcnToFz(const std::vector &src_shape, DataType data_type, std::vector &dst_shape) { if (!CheckShapeValid(src_shape, kHwcnDimsNum)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } auto h = src_shape.at(kHwcnH); @@ -88,7 +88,7 @@ Status TransShapeHwcnToFz(const std::vector &src_shape, DataType data_t Status TransShapeNhwcToFz(const std::vector &src_shape, DataType data_type, std::vector &dst_shape) { if (!CheckShapeValid(src_shape, kNhwcDimsNum)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } auto n = src_shape.at(kNhwcN); @@ -127,10 +127,11 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( dst == nullptr, - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY;); + return ACL_ERROR_GE_MEMORY_ALLOCATION;); for (int64_t vfi = 0; vfi < vf_cnt; vfi++) { // vertical fractal matrix base index @@ -163,8 +164,8 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { if (protected_size < size) { std::string error = "Failed to operate the dst memory, protected_size is " + FmtToStr(protected_size) + " and size is " + FmtToStr(size); - GE_ERRORLOG_AND_ERRORMSG(INTERNAL_ERROR, error.c_str()); - return INTERNAL_ERROR; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_PARAM_INVALID, error.c_str()); + return ACL_ERROR_GE_PARAM_INVALID; } char *dst_data = reinterpret_cast(dst.get() + offset); const char *src_data = reinterpret_cast(args.data + src_offset * size); @@ -173,9 +174,10 @@ Status TransFormatFromNchwToFz(const TransArgs &args, TransResult &result) { } } if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d pad mode %d", offset, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d pad mode %d", offset, ret, need_pad_zero); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -213,10 +215,11 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( dst == nullptr, - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY;); + return ACL_ERROR_GE_MEMORY_ALLOCATION;); for (int64_t c1i = 0; c1i < c1; c1i++) { for (int64_t hi = 0; hi < h; hi++) { @@ -235,9 +238,10 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { static_cast(data_size)); } else { if (protected_size < data_size) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory, protected_size is %ld and size is %ld", + GELOGE(ACL_ERROR_GE_PARAM_INVALID, + "Failed to operate the dst memory, protected_size is %ld and size is %ld", protected_size, data_size); - return INTERNAL_ERROR; + return ACL_ERROR_GE_PARAM_INVALID; } int64_t src_idx = hi * wcn + wi * cn + (c1i * c0 + c0i) * n + n1n0i; char *dst_data = reinterpret_cast(dst.get() + dst_offset); @@ -247,9 +251,10 @@ Status TransFormatHwcnToFz(const TransArgs &args, TransResult &result) { } } if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -288,10 +293,11 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( dst == nullptr, - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY;); + return ACL_ERROR_GE_MEMORY_ALLOCATION;); for (int64_t c1i = 0; c1i < c1; c1i++) { for (int64_t hi = 0; hi < h; hi++) { @@ -310,9 +316,10 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { static_cast(data_size)); } else { if (protected_size < data_size) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory, protected_size is %ld and size is %ld", + GELOGE(ACL_ERROR_GE_PARAM_INVALID, + "Failed to operate the dst memory, protected_size is %ld and size is %ld", protected_size, data_size); - return INTERNAL_ERROR; + return ACL_ERROR_GE_PARAM_INVALID; } int64_t src_idx = n1n0i * hwc + hi * wc + wi * c + (c1i * c0 + c0i); char *dst_data = reinterpret_cast(dst.get() + dst_offset); @@ -322,9 +329,10 @@ Status TransFormatNhwcToFz(const TransArgs &args, TransResult &result) { } } if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d, pad mode %d", dst_offset, ret, pad_zero); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -349,7 +357,7 @@ Status FormatTransferFractalZ::TransFormat(const TransArgs &args, TransResult &r return ret; } if (!IsTransShapeDstCorrect(args, expect_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } if (args.src_format == FORMAT_NHWC && args.dst_format == FORMAT_FRACTAL_Z) { @@ -364,13 +372,13 @@ Status FormatTransferFractalZ::TransFormat(const TransArgs &args, TransResult &r return TransFormatFromNchwToFz(args, result); } - return UNSUPPORTED; + return ACL_ERROR_GE_FORMAT_INVALID; } Status FormatTransferFractalZ::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { if (CheckDataTypeSupport(data_type) != SUCCESS) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (src_format == FORMAT_NHWC && dst_format == FORMAT_FRACTAL_Z) { @@ -383,7 +391,7 @@ Status FormatTransferFractalZ::TransShape(Format src_format, const std::vector dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } // The src&dst_shape can be written as times*H*W & times*H1*W1*H0*W0, respectively. dst_shape_size >= kDimNum4D auto times = hw_shape.at(kNdDimIndexN); @@ -179,8 +180,9 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } auto w1_head = num_w1 * w0; @@ -195,8 +197,9 @@ Status TransFormatFromNdToFracZz(const TransArgs &args, TransResult &result, con auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -217,10 +220,11 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size](), std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } // The src&dst_shape can be written as times*H*W & times*H1*W1*H0*W0, respectively. dst_shape_size >= kDimNum4D @@ -257,8 +261,9 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size * w0)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } auto w1_head = num_w1 * w0; @@ -273,8 +278,9 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, + "Failed to operate the dst memory at offset %ld, error-code %d", dst_offset, ret); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -287,13 +293,21 @@ Status TransFormatFromFracZzToNd(const TransArgs &args, TransResult &result, con } // namespace Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult &result) { - if (!IsDataTypeSupport(args.src_data_type) || !CheckShape(args.src_format, args.src_shape) || - !IsShapeValid(args.dst_shape)) { - GELOGE(PARAM_INVALID, "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", + if (!IsDataTypeSupport(args.src_data_type)) { + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, + "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", + TypeUtils::FormatToSerialString(args.src_format).c_str(), + TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), + ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; + } + if (!CheckShape(args.src_format, args.src_shape) || !IsShapeValid(args.dst_shape)) { + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from %s to %s, src shape %s, dst shape %s, data type %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), @@ -306,7 +320,7 @@ Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult & return ret; } if (!IsTransShapeDstCorrect(args, expect_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return TransFormatFromNdToFracZz(args, result, hw_shape); } @@ -314,31 +328,40 @@ Status FormatTransferFractalZz::TransFormat(const TransArgs &args, TransResult & Status FormatTransferFractalZz::TransShape(Format src_format, const ShapeVector &src_shape, DataType data_type, Format dst_format, ShapeVector &dst_shape) { if (!IsDataTypeSupport(data_type)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID, + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Not support trans format from %s to %s, src shape %s, data type %s", TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(), ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShape(src_format, src_shape)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Not support trans format from %s to %s, src shape %s, data type %s", TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str(), ShapeToString(src_shape).c_str(), TypeUtils::DataTypeToSerialString(data_type).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } ShapeVector hw_shape; return TransShapeToFracZz(src_shape, data_type, dst_shape, hw_shape); } Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult &result) { - if (!IsDataTypeSupport(args.src_data_type) || !IsShapeValid(args.src_shape) || - !CheckShape(args.dst_format, args.dst_shape)) { - GELOGE(PARAM_INVALID, "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", + if (!IsDataTypeSupport(args.src_data_type)) { + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, + "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", + TypeUtils::FormatToSerialString(args.src_format).c_str(), + TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), + ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; + } + + if (!IsShapeValid(args.src_shape) || !CheckShape(args.dst_format, args.dst_shape)) { + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Not support trans format from %s to %s, src shape %s, dst shape %s, data type %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from %s to %s, src shape %s, dst shape %s, data type %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), @@ -346,8 +369,9 @@ Status FormatTransferFractalZzND::TransFormat(const TransArgs &args, TransResult ShapeToString(args.dst_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); ShapeVector hw_shape; - if (CheckShapeRelation(args, hw_shape) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckShapeRelation(args, hw_shape); + if (ret != SUCCESS) { + return ret; } return TransFormatFromFracZzToNd(args, result, hw_shape); } @@ -356,7 +380,7 @@ Status FormatTransferFractalZzND::TransShape(Format src_format, const ShapeVecto Format dst_format, ShapeVector &dst_shape) { GELOGD("The shape derivation from %s to %s is not unique. Trans shape is not supported", TypeUtils::FormatToSerialString(src_format).c_str(), TypeUtils::FormatToSerialString(dst_format).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferFractalZz, FORMAT_ND, FORMAT_FRACTAL_ZZ) diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc index 80164941..3f071593 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_hwcn.cc @@ -37,25 +37,25 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from FORMAT_FRACTAL_Z to HWCN, invalid data type %s", + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to HWCN, invalid data type %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(src_shape, kFracZDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(dst_shape, kHwcnDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t c0 = GetCubeSizeByDataType(args.src_data_type); if (c0 < 0) { - return PARAM_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } int64_t c1 = Ceil(dst_shape.at(kHwcnC), c0); int64_t n0 = Ceil(dst_shape.at(kHwcnN), static_cast(kNiSize)); @@ -64,8 +64,8 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { std::string error = "Failed to check relationship between src shape" + FmtToStr(ShapeToString(src_shape)) + " and dst shape" + FmtToStr(ShapeToString(dst_shape)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return PARAM_INVALID; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -74,10 +74,11 @@ Status CheckArgsForFracZToHwcn(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto n0 = args.src_shape.at(kFracZN0); @@ -113,11 +114,11 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from FracZ offset %ld to HWCN[%ld, %ld, %ld, %ld] " "offset %ld, err-code %d", src_offset, h_idx, w_idx, c_idx, n_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -130,8 +131,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForFracZToHwcn(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForFracZToHwcn(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -142,18 +144,19 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from FracZ to HWCN, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -161,7 +164,7 @@ Status FormatTransferFracZHwcn::TransFormat(const TransArgs &args, TransResult & Status FormatTransferFracZHwcn::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { GELOGD("The shape derivation from FracZ to HWCN is not unique. Trans shape in this direction is not supported"); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferFracZHwcn, FORMAT_FRACTAL_Z, FORMAT_HWCN) diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc index 90bf8fcb..5233a72e 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nchw.cc @@ -37,33 +37,34 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s", + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to NCHW, invalid data type %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(src_shape, kFracZDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(dst_shape, kNchwDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t c0 = GetCubeSizeByDataType(args.src_data_type); if (c0 < 0) { - return PARAM_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } int64_t c1 = Ceil(dst_shape.at(kNchwC), c0); int64_t n0 = Ceil(dst_shape.at(kNchwN), static_cast(kNiSize)); - if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 || src_shape.at(kFracZC0) != c0 || - src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { - GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", + if (src_shape.at(kFracZHWC1) != dst_shape.at(kNchwH) * dst_shape.at(kNchwW) * c1 || + src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -72,10 +73,11 @@ Status CheckArgsForFracZToNchw(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto n0 = args.src_shape.at(kFracZN0); @@ -111,11 +113,11 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from FracZ offset %ld to NCHW[%ld, %ld, %ld, %ld] offset %ld, " "err-code %d", src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -128,8 +130,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForFracZToNchw(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForFracZToNchw(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -140,19 +143,20 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from FracZ to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -160,7 +164,7 @@ Status FormatTransferFracZNchw::TransFormat(const TransArgs &args, TransResult & Status FormatTransferFracZNchw::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { GELOGD("The shape derivation from FracZ to NCHW is not unique. Trans shape in this direction is not supported"); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferFracZNchw, FORMAT_FRACTAL_Z, FORMAT_NCHW) diff --git a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc index a2c86300..1aed4a74 100755 --- a/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_fracz_nhwc.cc @@ -37,33 +37,34 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from FORMAT_FRACTAL_Z to NHWC, invalid data type %s", + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from FORMAT_FRACTAL_Z to NHWC, invalid data type %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(src_shape, kFracZDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(dst_shape, kNhwcDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t c0 = GetCubeSizeByDataType(args.src_data_type); if (c0 < 0) { - return PARAM_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } int64_t c1 = Ceil(dst_shape.at(kNhwcC), c0); int64_t n0 = Ceil(dst_shape.at(kNhwcN), static_cast(kNiSize)); - if (src_shape.at(kFracZHWC1) != dst_shape.at(kNhwcH) * dst_shape.at(kNhwcW) * c1 || src_shape.at(kFracZC0) != c0 || - src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { - GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", + if (src_shape.at(kFracZHWC1) != dst_shape.at(kNhwcH) * dst_shape.at(kNhwcW) * c1 || + src_shape.at(kFracZC0) != c0 || src_shape.at(kFracZNi) != kNiSize || src_shape.at(kFracZN0) != n0) { + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -72,10 +73,11 @@ Status CheckArgsForFracZToNhwc(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size, int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto n0 = args.src_shape.at(kFracZN0); @@ -111,10 +113,10 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from FracZ offset %ld to HHWC[%ld, %ld, %ld, %ld] offset %ld, err-code %d", src_offset, n_idx, h_idx, w_idx, c_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -127,8 +129,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, int size } // namespace Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForFracZToNhwc(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForFracZToNhwc(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -139,18 +142,19 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_PARAM_INVALID; } GELOGD("Begin to trans format from FracZ to NHWC, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -158,7 +162,7 @@ Status FormatTransferFracZNhwc::TransFormat(const TransArgs &args, TransResult & Status FormatTransferFracZNhwc::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { GELOGD("The shape derivation from FracZ to NHWC is not unique. Trans shape in this direction is not supported"); - return UNSUPPORTED; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferFracZNhwc, FORMAT_FRACTAL_Z, FORMAT_NHWC) diff --git a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc index 1e29baf2..1f2477fd 100755 --- a/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_hwcn_c1hwncoc0.cc @@ -43,9 +43,9 @@ Status TransShapeHwcnToC1hwncoc0(const DataType &data_type, const std::vector expect_dst_shape; auto ret = TransShapeHwcnToC1hwncoc0(args.src_data_type, args.src_shape, expect_dst_shape); @@ -77,12 +77,12 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) { return ret; } if (args.dst_shape != expect_dst_shape) { - GELOGE(PARAM_INVALID, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to trans format, src and dst shape are not compatible. src shape %s, dst shape %s, " "expect dst shape %s", ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), ShapeToString(expect_dst_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -91,10 +91,11 @@ Status CheckArgsForHwcnToC1hwncoc0(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto h = args.src_shape.at(kHwcnH); @@ -135,22 +136,22 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from HWCN[%ld, %ld, %ld, %ld] offset %ld to " "C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", h_idx, w_idx, c_idx, n_idx, src_offset, c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } else { auto ret = memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to set to 0 to C1HWNCoC0[%ld, %ld, %ld, %ld, %ld, %ld] offset %ld, " "err-code %d", c1_idx, h_idx, w_idx, n_idx, co_idx, c0_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -166,8 +167,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferHwcnC1hwncoc0::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForHwcnToC1hwncoc0(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForHwcnToC1hwncoc0(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -178,18 +180,20 @@ Status FormatTransferHwcnC1hwncoc0::TransFormat(const TransArgs &args, TransResu return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from HWCN to C1HWNCoC0, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -198,15 +202,15 @@ Status FormatTransferHwcnC1hwncoc0::TransShape(Format src_format, const std::vec DataType data_type, Format dst_format, std::vector &dst_shape) { if (src_format == FORMAT_HWCN && CheckDataTypeSupported(data_type)) { if (!CheckShapeValid(src_shape, kHwcnDimsNum)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check src shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return TransShapeHwcnToC1hwncoc0(data_type, src_shape, dst_shape); } else if (src_format != FORMAT_HWCN) { - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } else { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } } diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc index df8e5a29..54959eb8 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nchw.cc @@ -37,33 +37,34 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from NC1HWC0 to NCHW, invalid data type %s", + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NC1HWC0 to NCHW, invalid data type %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(args.dst_shape, kNchwDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t c0 = GetCubeSizeByDataType(args.src_data_type); if (c0 <= 0) { - GELOGE(PARAM_INVALID, "Failed to get cube size, the data type is invalid"); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); + return ACL_ERROR_GE_DATATYPE_INVALID; } if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNchwH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNchwW) || src_shape.at(kNc1hwc0N) != dst_shape.at(kNchwN) || src_shape.at(kNc1hwc0C0) != c0 || src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNchwC), c0))) { - GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -72,10 +73,11 @@ Status CheckArgsForNc1hwc0ToNchw(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto h = args.src_shape.at(kNc1hwc0H); @@ -109,11 +111,11 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld to NCHW[%ld, %ld, %ld, %ld]" " offset %ld, err-code %d", n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -126,8 +128,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForNc1hwc0ToNchw(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForNc1hwc0ToNchw(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -138,18 +141,19 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_PARAM_INVALID; } GELOGD("Begin to trans format from NC1HWC0 to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -157,7 +161,7 @@ Status FormatTransferNc1hwc0Nchw::TransFormat(const TransArgs &args, TransResult Status FormatTransferNc1hwc0Nchw::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { GELOGD("The shape derivation from NC1HWC0 to NCHW is not unique. Trans shape in this direction is not supported"); - return UNSUPPORTED; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferNc1hwc0Nchw, FORMAT_NC1HWC0, FORMAT_NCHW) diff --git a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc index fd09b34c..53b96fd3 100755 --- a/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc +++ b/ge/common/formats/format_transfers/format_transfer_nc1hwc0_nhwc.cc @@ -37,33 +37,34 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from NC1HWC0 to NHWC, invalid data type %s", + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NC1HWC0 to NHWC, invalid data type %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(args.src_shape, kNc1hwc0DimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(args.dst_shape, kNhwcDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } int64_t c0 = GetCubeSizeByDataType(args.src_data_type); if (c0 <= 0) { - GELOGE(PARAM_INVALID, "Failed to get cube size, the data type is invalid"); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); + return ACL_ERROR_GE_DATATYPE_INVALID; } if (src_shape.at(kNc1hwc0H) != dst_shape.at(kNhwcH) || src_shape.at(kNc1hwc0W) != dst_shape.at(kNhwcW) || src_shape.at(kNc1hwc0N) != dst_shape.at(kNhwcN) || src_shape.at(kNc1hwc0C0) != c0 || src_shape.at(kNc1hwc0C1) != (Ceil(dst_shape.at(kNhwcC), c0))) { - GELOGE(PARAM_INVALID, "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, + "Failed to check relationship between src and dst shape, src shape %s, dst shape %s", ShapeToString(src_shape).c_str(), ShapeToString(dst_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -72,10 +73,11 @@ Status CheckArgsForNc1hwc0ToNhwc(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto h = args.src_shape.at(kNc1hwc0H); @@ -109,11 +111,11 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld to NHWC[%ld, %ld, %ld, %ld]" " offset %ld, err-code %d", n_idx, c1_idx, h_idx, w_idx, c0_idx, src_offset, n_idx, c_idx, h_idx, w_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -126,8 +128,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferNc1hwc0Nhwc::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForNc1hwc0ToNhwc(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForNc1hwc0ToNhwc(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -138,18 +141,20 @@ Status FormatTransferNc1hwc0Nhwc::TransFormat(const TransArgs &args, TransResult return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD("Begin to trans format from NC1HWC0 to NCHW, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -157,7 +162,7 @@ Status FormatTransferNc1hwc0Nhwc::TransFormat(const TransArgs &args, TransResult Status FormatTransferNc1hwc0Nhwc::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { GELOGD("The shape derivation from NC1HWC0 to NHWC is not unique. Trans shape in this direction is not supported"); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferNc1hwc0Nhwc, FORMAT_NC1HWC0, FORMAT_NHWC) diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc index dd8721c0..3c54a00c 100644 --- a/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_fz_c04.cc @@ -45,7 +45,7 @@ Status CheckDataTypeSupport(DataType data_type) { return GetSizeByDataType(data_ Status TransShape(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_type, std::vector &dst_shape) { auto c0 = GetCubeSizeByDataType(data_type); if (c0 < 0) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } auto chw = c * h * w; @@ -59,9 +59,9 @@ Status TransShape(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_type dst_shape.push_back(c0); if (!IsShapeValid(dst_shape)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check dst shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; } @@ -69,7 +69,7 @@ Status TransShape(int64_t n, int64_t c, int64_t h, int64_t w, DataType data_type Status TransShapeNchwToFzC04(const std::vector &src_shape, DataType data_type, std::vector &dst_shape) { if (!CheckShapeValid(src_shape, kNchwDimsNum)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } auto n = src_shape.at(kNchwN); @@ -94,8 +94,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { std::vector expect_shape = {n, h, w, c}; auto ret = ge::formats::Transpose(data, args.src_shape, args.src_data_type, perm_arg_1, trans_result_1); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to Transpose from NCHW to HWCN"); - return NOT_CHANGED; + GELOGE(ret, "Failed to Transpose from NCHW to HWCN"); + return ret; } TransArgs args_tmp = args; @@ -104,8 +104,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { // check size it should be same with original size_t expect_size = n * c * h * w * size; // before has do check about mul if (trans_result_1.length != expect_size) { - GELOGE(INTERNAL_ERROR, "size is not match after transpose!"); - return NOT_CHANGED; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "size is not match after transpose!"); + return ACL_ERROR_GE_PARAM_INVALID; } // prepare for padding in chw @@ -118,20 +118,21 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { // data overflow check totally GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(h_o, w_o), - GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); - return INTERNAL_ERROR); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", h_o, w_o); + return ACL_ERROR_GE_INTERNAL_ERROR); GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(n_o, c_o), - GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); - return INTERNAL_ERROR); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", n_o, c_o); + return ACL_ERROR_GE_INTERNAL_ERROR); auto t1 = h_o * w_o; auto t2 = n_o * c_o; - GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); - return INTERNAL_ERROR); + GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(t1, t2), + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%ld]", t1, t2); + return ACL_ERROR_GE_INTERNAL_ERROR); int64_t total_ele_cnt = n_o * c_o * h_o * w_o; GE_IF_BOOL_EXEC(!CheckInt64MulOverflow(total_ele_cnt, size), - GELOGE(INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); - return INTERNAL_ERROR); + GELOGE(ACL_ERROR_GE_INTERNAL_ERROR, "int64 mul overflow.A[%ld], B[%d]", total_ele_cnt, size); + return ACL_ERROR_GE_INTERNAL_ERROR); int64_t dst_size = total_ele_cnt * size; if (dst_size == 0) { result.length = 0; @@ -140,15 +141,16 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { std::shared_ptr dst(new (std::nothrow) uint8_t[dst_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto retMem = memset_s(dst.get(), dst_size, 0, dst_size); if (retMem != EOK) { - GELOGE(INTERNAL_ERROR, "memst failed!"); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memst failed!"); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } // copy data auto block = c * h * w * size; @@ -159,8 +161,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { for (auto k = 0; k < n; k++) { ret = memcpy_s(p_d + k * stride, protectSize, p_s + k * block, block); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "memcpy_s failed!"); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memcpy_s failed!"); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } protectSize = protectSize - block; } @@ -169,8 +171,8 @@ Status TransFormatFromNchwToFzC04(const TransArgs &args, TransResult &result) { std::vector perm_arg_2 = {2, 0, 1, 3}; ret = ge::formats::Transpose(dst.get(), shape_o, args.src_data_type, perm_arg_2, result); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to Transpose from NCHW to HWCN"); - return NOT_CHANGED; + GELOGE(ret, "Failed to Transpose from NCHW to HWCN"); + return ret; } return SUCCESS; @@ -180,7 +182,7 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr kMaxDimsNumC) { - GELOGE(PARAM_INVALID, "Invalie dim c num[%lu].It should be in (0,4]", c); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Invalie dim c num[%lu].It should be in (0,4]", c); + return ACL_ERROR_GE_SHAPE_INVALID; } auto n_o = Ceil(n, c0) * c0; @@ -205,21 +207,22 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, + "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), dst_size); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto ret = memset_s(dst.get(), dst_size, 0, dst_size); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, "memst failed!"); - return INTERNAL_ERROR; + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "memst failed!"); + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } auto p_s = args.data; @@ -249,8 +253,8 @@ Status PaddingNC(const TransArgs &args, TransArgs &args_tmp, std::shared_ptr dst = nullptr; auto ret = PaddingNC(args, args_tmp, dst); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Padding in NC axis failed!"); + GELOGE(ret, "Padding in NC axis failed!"); return ret; } std::vector expect_shape; - ret = TransShape(args_tmp.src_format, args_tmp.src_shape, args_tmp.src_data_type, args_tmp.dst_format, expect_shape); + ret = TransShape(args_tmp.src_format, args_tmp.src_shape, args_tmp.src_data_type, + args_tmp.dst_format, expect_shape); if (ret != SUCCESS) { return ret; } if (!IsTransShapeDstCorrect(args_tmp, expect_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } if (args_tmp.src_format == FORMAT_NCHW && args_tmp.dst_format == FORMAT_FRACTAL_Z_C04) { return TransFormatFromNchwToFzC04(args_tmp, result); } - return UNSUPPORTED; + return ACL_ERROR_GE_FORMAT_INVALID; } Status FormatTransferNchwToFZC04::TransShape(Format src_format, const std::vector &src_shape, DataType data_type, Format dst_format, std::vector &dst_shape) { if (CheckDataTypeSupport(data_type) != SUCCESS) { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (src_format == FORMAT_NCHW && dst_format == FORMAT_FRACTAL_Z_C04) { return TransShapeNchwToFzC04(src_shape, data_type, dst_shape); } - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } REGISTER_FORMAT_TRANSFER(FormatTransferNchwToFZC04, FORMAT_NCHW, FORMAT_FRACTAL_Z_C04) diff --git a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc index 752a4d64..d0579353 100755 --- a/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nchw_nc1hwc0.cc @@ -32,13 +32,13 @@ Status TransShapeNchwToNc1hwc0(const std::vector &src_shape, DataType d std::vector &dst_shape) { int64_t c0 = GetCubeSizeByDataType(data_type); if (c0 <= 0) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(src_shape, kNchwDimsNum)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check src shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } dst_shape.clear(); dst_shape.push_back(src_shape.at(kNchwN)); @@ -47,9 +47,9 @@ Status TransShapeNchwToNc1hwc0(const std::vector &src_shape, DataType d dst_shape.push_back(src_shape.at(kNchwW)); dst_shape.push_back(c0); if (!CheckShapeValid(dst_shape, kNc1hwc0DimsNum)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check dst shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; } @@ -59,8 +59,8 @@ Status CheckArgsForNchwToNc1hwc0(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } std::vector expect_5d_shape; auto ret = TransShapeNchwToNc1hwc0(args.src_shape, args.src_data_type, expect_5d_shape); @@ -68,12 +68,12 @@ Status CheckArgsForNchwToNc1hwc0(const TransArgs &args) { return ret; } if (expect_5d_shape != args.dst_shape) { - GELOGE(PARAM_INVALID, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to trans format, the src and dst shape are not compatible. data" " type %s, src shape %s, dst shape %s, expect dst shape %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), ShapeToString(expect_5d_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -82,12 +82,12 @@ Status CheckArgsForNchwToNc1hwc0(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to trans format from %s to %s, can not alloc the memory for" " dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto n = args.src_shape.at(kNchwN); @@ -97,8 +97,8 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in int64_t c0 = GetCubeSizeByDataType(args.src_data_type); if (c0 <= 0) { - GELOGE(INTERNAL_ERROR, "The c0 is invalid %ld", c0); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "The c0 is invalid %ld", c0); + return ACL_ERROR_GE_DATATYPE_INVALID; } int64_t c1 = (c - 1) / c0 + 1; int64_t hw = h * w; @@ -129,21 +129,21 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in auto ret = memcpy_s(dst.get() + dst_offset, static_cast(protected_size), args.data + src_offset, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from NCHW[%ld] offset %ld to " "NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", srcIdx, src_offset, n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } else { auto ret = memset_s(dst.get() + dst_offset, static_cast(protected_size), 0, static_cast(size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to set to 0 to " "NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld, err-code %d", n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -159,8 +159,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForNchwToNc1hwc0(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForNchwToNc1hwc0(args); + if (ret != SUCCESS) { + return ret; } // Guarantee the validity of parameters in check function int size = GetSizeByDataType(args.src_data_type); @@ -172,20 +173,21 @@ Status FormatTransferNchwNc1hwc0::TransFormat(const TransArgs &args, TransResult return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } GELOGD( "Begin to trans format from NCHW to NC1HWC0, src shape %s, data type " "%s, dst shape %s memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -195,7 +197,7 @@ Status FormatTransferNchwNc1hwc0::TransShape(Format src_format, const std::vecto if (src_format == FORMAT_NCHW) { return TransShapeNchwToNc1hwc0(src_shape, data_type, dst_shape); } else { - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } } diff --git a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc index 2c6b392d..b09fd168 100755 --- a/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc +++ b/ge/common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.cc @@ -34,8 +34,8 @@ Status TransShapeNhwcToNc1hwc0(const std::vector &src_shape, DataType d std::vector &dst_shape) { int64_t c0 = GetCubeSizeByDataType(data_type); if (c0 <= 0) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to get cube size, the data type is invalid"); + return ACL_ERROR_GE_DATATYPE_INVALID; } dst_shape.clear(); dst_shape.push_back(src_shape.at(kNhwcN)); @@ -44,9 +44,9 @@ Status TransShapeNhwcToNc1hwc0(const std::vector &src_shape, DataType d dst_shape.push_back(src_shape.at(kNhwcW)); dst_shape.push_back(c0); if (!CheckShapeValid(dst_shape, kNc1hwc0DimsNum)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check dst shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(dst_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; } @@ -56,21 +56,21 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { std::string error = "Dose not support trans format from " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } if (!CheckDataTypeSupported(args.src_data_type)) { - GELOGE(UNSUPPORTED, "Failed to trans shape from NHWC to NC1HWC0, invalid data type %s", + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Failed to trans shape from NHWC to NC1HWC0, invalid data type %s", TypeUtils::DataTypeToSerialString(args.src_data_type).c_str()); - return UNSUPPORTED; + return ACL_ERROR_GE_DATATYPE_INVALID; } if (!CheckShapeValid(args.src_shape, kNhwcDimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(args.src_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } if (!CheckShapeValid(args.dst_shape, kNc1hwc0DimsNum)) { - GELOGE(PARAM_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check dst shape %s", ShapeToString(args.dst_shape).c_str()); + return ACL_ERROR_GE_SHAPE_INVALID; } std::vector expect_dst_shape; auto ret = TransShapeNhwcToNc1hwc0(args.src_shape, args.src_data_type, expect_dst_shape); @@ -78,12 +78,12 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { return ret; } if (args.dst_shape != expect_dst_shape) { - GELOGE(PARAM_INVALID, + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to trans format, the src and dst shape are not compatible. src shape %s, dst shape %s, " "expect dst shape %s", ShapeToString(args.src_shape).c_str(), ShapeToString(args.dst_shape).c_str(), ShapeToString(expect_dst_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return SUCCESS; @@ -92,10 +92,10 @@ Status CheckArgsForNhwcToNc1hwc0(const TransArgs &args) { Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const int size, const int64_t total_size) { std::shared_ptr dst(new (std::nothrow) uint8_t[total_size], std::default_delete()); if (dst == nullptr) { - GELOGE(OUT_OF_MEMORY, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", + GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Failed to trans format from %s to %s, can not alloc the memory for dst buf %ld, shape %s", TypeUtils::FormatToSerialString(args.src_format).c_str(), TypeUtils::FormatToSerialString(args.dst_format).c_str(), total_size, ShapeToString(args.dst_shape).c_str()); - return OUT_OF_MEMORY; + return ACL_ERROR_GE_MEMORY_ALLOCATION; } auto n = args.src_shape.at(kNhwcN); @@ -131,19 +131,19 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in if (c_idx < c) { auto ret = memcpy_s(dst.get() + dst_offset, protected_size, args.data + src_offset, size); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to copy data from NHWC[%ld, %ld, %ld, %ld] offset %ld to " "NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld err-code %d", n_idx, h_idx, w_idx, c_idx, src_offset, n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } else { auto ret = memset_s(dst.get() + dst_offset, protected_size, 0, size); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to set 0 to NC1HWC0[%ld, %ld, %ld, %ld, %ld] offset %ld base err-code %d", n_idx, c1_idx, h_idx, w_idx, c0_idx, dst_offset, ret); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } } } @@ -158,8 +158,9 @@ Status GetDstDataAfterTrans(const TransArgs &args, TransResult &result, const in } // namespace Status FormatTransferNhwcNc1hwc0::TransFormat(const TransArgs &args, TransResult &result) { - if (CheckArgsForNhwcToNc1hwc0(args) != SUCCESS) { - return PARAM_INVALID; + Status ret = CheckArgsForNhwcToNc1hwc0(args); + if (ret != SUCCESS) { + return ret; } int size = GetSizeByDataType(args.src_data_type); auto total_size = GetItemNumByShape(args.dst_shape) * size; @@ -170,18 +171,20 @@ Status FormatTransferNhwcNc1hwc0::TransFormat(const TransArgs &args, TransResult return SUCCESS; } - GELOGE(INTERNAL_ERROR, "Get %ld total size from dst shape %s, src shape %s", total_size, + GELOGE(ACL_ERROR_GE_DATATYPE_INVALID, "Get %ld total size from dst shape %s, src shape %s", total_size, ShapeToString(args.dst_shape).c_str(), ShapeToString(args.src_shape).c_str()); - return PARAM_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } GELOGD("Begin to trans format from NHWC to NC1HWC0, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - if (GetDstDataAfterTrans(args, result, size, total_size) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", + + ret = GetDstDataAfterTrans(args, result, size, total_size); + if (ret != SUCCESS) { + GELOGE(ret, "Failed to get data after trans, src shape %s, data type %s, dst shape %s, memory size %ld", ShapeToString(args.src_shape).c_str(), TypeUtils::DataTypeToSerialString(args.src_data_type).c_str(), ShapeToString(args.dst_shape).c_str(), total_size); - return INTERNAL_ERROR; + return ret; } return SUCCESS; } @@ -190,15 +193,15 @@ Status FormatTransferNhwcNc1hwc0::TransShape(Format src_format, const std::vecto DataType data_type, Format dst_format, std::vector &dst_shape) { if (src_format == FORMAT_NHWC && CheckDataTypeSupported(data_type)) { if (!CheckShapeValid(src_shape, kNhwcDimsNum)) { - GELOGE(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Failed to check src shape %s", + GELOGE(ACL_ERROR_GE_SHAPE_INVALID, "Failed to check src shape %s", ShapeToString(src_shape).c_str()); - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return TransShapeNhwcToNc1hwc0(src_shape, data_type, dst_shape); } else if (src_format != FORMAT_NHWC) { - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + return ACL_ERROR_GE_FORMAT_INVALID; } else { - return ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID; + return ACL_ERROR_GE_DATATYPE_INVALID; } } diff --git a/ge/common/formats/format_transfers/format_transfer_transpose.cc b/ge/common/formats/format_transfers/format_transfer_transpose.cc index de0b456c..694777f3 100755 --- a/ge/common/formats/format_transfers/format_transfer_transpose.cc +++ b/ge/common/formats/format_transfers/format_transfer_transpose.cc @@ -141,7 +141,7 @@ std::vector TransShapeByPerm(const std::vector &src_shape, con Status Transpose(const uint8_t *src, const std::vector &src_shape, DataType src_data_type, const std::vector &perm_arg, TransResult &result) { if (!IsTransposeArgValid(src, src_shape, src_data_type, perm_arg)) { - return PARAM_INVALID; + return ACL_ERROR_GE_PARAM_INVALID; } auto dst_shape = TransShapeByPerm(src_shape, perm_arg); @@ -172,12 +172,12 @@ Status Transpose(const uint8_t *src, const std::vector &src_shape, Data auto ret = memcpy_s(dst.get() + dst_offset_bytes, static_cast(protected_size), src + src_offset, static_cast(data_size)); if (ret != EOK) { - GELOGE(INTERNAL_ERROR, + GELOGE(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to transpose, src shape %s, perm arg %s, dst shape %s, " "failed to write to dst offset %ld, current dim offset %s", ShapeToString(src_shape).c_str(), ShapeToString(perm_arg).c_str(), ShapeToString(dst_shape).c_str(), dst_offset_bytes, ShapeToString(dst_indexes).c_str()); - return INTERNAL_ERROR; + return ACL_ERROR_GE_MEMORY_OPERATE_FAILED; } AddOne(dst_shape, dst_indexes); ++dst_index; @@ -192,14 +192,14 @@ Status TransposeWithShapeCheck(const uint8_t *data, const std::vector & const std::vector &dst_shape, DataType src_data_type, const std::vector &perm_arg, TransResult &result) { if (!IsTransposeArgValid(data, src_shape, src_data_type, perm_arg)) { - return PARAM_INVALID; + return ACL_ERROR_GE_PARAM_INVALID; } auto expected_shape = TransShapeByPerm(src_shape, perm_arg); if (dst_shape != expected_shape) { std::string error = "Failed to trans axis for perm_arg" + FmtToStr(ShapeToString(perm_arg)) + ", invalid dst shape" + FmtToStr(ShapeToString(dst_shape)) + ", expect" + FmtToStr(ShapeToString(expected_shape)); - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error.c_str()); + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_SHAPE_INVALID, error.c_str()); } return Transpose(data, src_shape, src_data_type, perm_arg, result); @@ -211,16 +211,16 @@ Status GetPermByForamt(Format src_format, Format dst_format, std::vectorsecond.find(dst_format); if (iter == dst_iter->second.end()) { std::string error = "Failed to trans shape, do not support transpose from format " + FmtToStr(TypeUtils::FormatToSerialString(src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(dst_format)); - GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID, error.c_str()); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } perm = iter->second; return SUCCESS; @@ -233,7 +233,7 @@ Status FormatTransferTranspose::TransFormat(const TransArgs &args, TransResult & return ret; } if (!IsTransShapeDstCorrect(args, expected_shape)) { - return PARAM_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } return Transpose(args.data, args.src_shape, args.src_data_type, perm_args[args.src_format][args.dst_format], result); @@ -244,7 +244,7 @@ Status FormatTransferTranspose::TransShape(Format src_format, const std::vector< std::vector perm_arg; GE_CHK_STATUS_RET_NOLOG(GetPermByForamt(src_format, dst_format, perm_arg)); if (!IsShapeArgValid(src_shape, perm_arg)) { - return ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID; + return ACL_ERROR_GE_SHAPE_INVALID; } dst_shape = TransShapeByPerm(src_shape, perm_arg); return SUCCESS; diff --git a/ge/common/formats/formats.cc b/ge/common/formats/formats.cc index 2b979e9a..353606d2 100755 --- a/ge/common/formats/formats.cc +++ b/ge/common/formats/formats.cc @@ -38,14 +38,14 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransFormat(const TransArg std::string error = "Failed to trans data from format " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } auto src_shape_size = GetItemNumByShape(args.src_shape); if (args.data == nullptr && src_shape_size != 0) { - GELOGE(PARAM_INVALID, "Invalid input null data"); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid input null data"); + return ACL_ERROR_GE_PARAM_INVALID; } return transfer->TransFormat(args, result); @@ -64,8 +64,8 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransShape(Format src_form std::string error = "Failed to trans data from format " + FmtToStr(TypeUtils::FormatToSerialString(args.src_format)) + " to " + FmtToStr(TypeUtils::FormatToSerialString(args.dst_format)); - GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID, error.c_str()); - return ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_FORMAT_INVALID, error.c_str()); + return ACL_ERROR_GE_FORMAT_INVALID; } return transfer->TransShape(src_format, src_shape, data_type, dst_format, dst_shape); @@ -77,13 +77,13 @@ GE_FUNC_DEV_VISIBILITY GE_FUNC_HOST_VISIBILITY Status TransDataType(const CastAr std::string error = "Failed to trans data from datatype " + FmtToStr(TypeUtils::DataTypeToSerialString(args.src_data_type)) + " to " + FmtToStr(TypeUtils::DataTypeToSerialString(args.dst_data_type)); - GE_ERRORLOG_AND_ERRORMSG(UNSUPPORTED, error.c_str()); - return UNSUPPORTED; + GE_ERRORLOG_AND_ERRORMSG(ACL_ERROR_GE_DATATYPE_INVALID, error.c_str()); + return ACL_ERROR_GE_DATATYPE_INVALID; } if (args.data == nullptr && args.src_data_size != 0) { - GELOGE(PARAM_INVALID, "Invalid input null data"); - return PARAM_INVALID; + GELOGE(ACL_ERROR_GE_PARAM_INVALID, "Invalid input null data"); + return ACL_ERROR_GE_PARAM_INVALID; } return transfer->TransDataType(args, result); diff --git a/ge/common/helper/model_helper.cc b/ge/common/helper/model_helper.cc index 02c0a8f0..74238bc1 100644 --- a/ge/common/helper/model_helper.cc +++ b/ge/common/helper/model_helper.cc @@ -87,12 +87,13 @@ Status ModelHelper::SaveSizeToModelDef(const GeModelPtr &ge_model) { std::shared_ptr model_task_def = ge_model->GetModelTaskDefPtr(); if (model_task_def == nullptr) { - GELOGE(ACL_ERROR_GE_MEMORY_ALLOCATION, "Create model task def ptr failed"); - return ACL_ERROR_GE_MEMORY_ALLOCATION; + GELOGD("SaveSizeToModelDef task_info_size is 0."); + om_info.push_back(0); + } else { + size_t partition_task_size = model_task_def->ByteSizeLong(); + GELOGD("SaveSizeToModelDef task_info_size is %zu", partition_task_size); + om_info.push_back(partition_task_size); } - size_t partition_task_size = model_task_def->ByteSizeLong(); - GELOGD("SaveSizeToModelDef task_info_size is %zu", partition_task_size); - om_info.push_back(partition_task_size); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(*(ge_model.get()), "om_info_list", om_info), GELOGE(FAILED, "SetListInt of om_info_list failed."); diff --git a/ge/common/types.cc b/ge/common/types.cc index 90ff9fe4..33b7f437 100644 --- a/ge/common/types.cc +++ b/ge/common/types.cc @@ -90,6 +90,8 @@ REGISTER_OPTYPE_DEFINE(DEPCONVOLUTION, "ConvolutionDepthwise"); REGISTER_OPTYPE_DEFINE(DROPOUT, "Dropout"); REGISTER_OPTYPE_DEFINE(DROPOUTGENMASK, "DropOutGenMask"); REGISTER_OPTYPE_DEFINE(DROPOUTDOMASK, "DropOutDoMask"); +REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3, "DropOutDoMaskV3"); +REGISTER_OPTYPE_DEFINE(DROPOUTDOMASKV3D, "DropOutDoMaskV3D"); REGISTER_OPTYPE_DEFINE(CONCAT, "Concat"); REGISTER_OPTYPE_DEFINE(ROIPOOLING, "ROIPooling"); REGISTER_OPTYPE_DEFINE(PROPOSAL, "Proposal"); diff --git a/ge/engine_manager/dnnengine_manager.cc b/ge/engine_manager/dnnengine_manager.cc index b23993b6..7ff5ed42 100644 --- a/ge/engine_manager/dnnengine_manager.cc +++ b/ge/engine_manager/dnnengine_manager.cc @@ -217,7 +217,7 @@ std::string DNNEngineManager::GetDNNEngineName(const ge::NodePtr &node_ptr) { std::string unsupported_reason; // It will be replaced by engine' checksupport uint64_t start_time = GetCurrentTimestamp(); - if (kernel_info_store->second->CheckSupported(op_desc, unsupported_reason)) { + if (kernel_info_store->second->CheckSupported(node_ptr, unsupported_reason)) { checksupport_cost_[kernel_name] += GetCurrentTimestamp() - start_time; op_desc->SetOpEngineName(it.engine); op_desc->SetOpKernelLibName(kernel_name); diff --git a/ge/executor/CMakeLists.txt b/ge/executor/CMakeLists.txt index 31cbad7a..363900d0 100644 --- a/ge/executor/CMakeLists.txt +++ b/ge/executor/CMakeLists.txt @@ -8,6 +8,7 @@ set(PROTO_LIST ) protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +protobuf_generate(ge_static PROTO_STATIC_SRCS PROTO_STATIC_HDRS ${PROTO_LIST}) set(SRC_LIST "ge_executor.cc" @@ -17,6 +18,7 @@ set(SRC_LIST "../common/dump/dump_properties.cc" "../common/dump/dump_manager.cc" "../common/dump/dump_op.cc" + "../common/dump/opdebug_register.cc" "../common/profiling/ge_profiling.cc" "../graph/load/graph_loader.cc" "../graph/execute/graph_execute.cc" @@ -161,7 +163,7 @@ set(SRC_LIST ) ######## libge_executor.a ######## -add_library(ge_executor STATIC ${SRC_LIST} ${PROTO_HDRS}) +add_library(ge_executor STATIC ${SRC_LIST} ${PROTO_STATIC_HDRS}) target_compile_options(ge_executor PRIVATE $<$,$>:-fvisibility=hidden -O2 -Werror -Wno-deprecated-declarations -fno-common> @@ -190,7 +192,7 @@ target_include_directories(ge_executor SYSTEM PRIVATE ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/ge + ${CMAKE_BINARY_DIR}/proto/ge_static #### yellow zone #### ${GE_CODE_DIR}/../inc ${GE_CODE_DIR}/../inc/cce @@ -211,6 +213,7 @@ target_link_libraries(ge_executor PRIVATE add_library(ge_executor_shared SHARED ${SRC_LIST} ${PROTO_HDRS}) target_compile_options(ge_executor_shared PRIVATE + -fno-common -Werror -O2 -Wno-deprecated-declarations diff --git a/ge/executor/ge_executor.cc b/ge/executor/ge_executor.cc index 44b2dbfa..4081bdf2 100755 --- a/ge/executor/ge_executor.cc +++ b/ge/executor/ge_executor.cc @@ -30,6 +30,8 @@ #include "single_op/single_op_manager.h" #include "graph/load/model_manager/davinci_model.h" #include "opskernel_manager/ops_kernel_builder_manager.h" +#include "graph/opsproto_manager.h" +#include "ge_local_engine/engine/host_cpu_engine.h" using std::string; using std::vector; @@ -199,6 +201,33 @@ bool IsDynmaicDimsSizeMatchModel(const vector cur_dynamic_dims, namespace ge { bool GeExecutor::isInit_ = false; +static void InitOpsProtoManager() { + string opsproto_path; + const char *path_env = std::getenv("ASCEND_OPP_PATH"); + if (path_env != nullptr) { + string path = path_env; + 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}); + return; + } + opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); + GELOGI("Get opsproto so path from env : %s", path.c_str()); + } else { + string path_base = PluginManager::GetPath(); + GELOGI("path_base is %s", path_base.c_str()); + path_base = path_base.substr(0, path_base.rfind('/')); + path_base = path_base.substr(0, path_base.rfind('/') + 1); + opsproto_path = (path_base + "ops/op_proto/custom/" + ":") + (path_base + "ops/op_proto/built-in/"); + } + GELOGI("Get opsproto path is %s", opsproto_path.c_str()); + OpsProtoManager *manager = OpsProtoManager::Instance(); + map option_tmp; + option_tmp.emplace(std::pair(string("ge.opsProtoLibPath"), opsproto_path)); + (void)manager->Initialize(option_tmp); +} + GeExecutor::GeExecutor() {} Status GeExecutor::Initialize() { @@ -208,6 +237,16 @@ Status GeExecutor::Initialize() { return ge::SUCCESS; } + OpTilingManager::GetInstance().LoadSo(); + + Status init_hostcpu_engine_status = HostCpuEngine::GetInstance().Initialize(); + if (init_hostcpu_engine_status != SUCCESS) { + GELOGE(init_hostcpu_engine_status, "Failed to initialize HostCpuEngine"); + return init_hostcpu_engine_status; + } + + InitOpsProtoManager(); + std::vector mem_type(1, RT_MEMORY_HBM); mem_type.push_back(RT_MEMORY_P2P_DDR); auto ret = MemManager::Instance().Initialize(mem_type); diff --git a/ge/ge_local_engine/CMakeLists.txt b/ge/ge_local_engine/CMakeLists.txt index 00142cfe..ab767ccb 100755 --- a/ge/ge_local_engine/CMakeLists.txt +++ b/ge/ge_local_engine/CMakeLists.txt @@ -20,6 +20,8 @@ set(OPS_KERNEL_SRC_LIST ) protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +protobuf_generate(ge_ops_shared PROTO_OPS_SHARED_SRCS PROTO_OPS_SHARED_HDRS ${PROTO_LIST}) +protobuf_generate(ge_ops_static PROTO_OPS_STATIC_SRCS PROTO_OPS_STATIC_HDRS ${PROTO_LIST}) ############ libge_local_engine.so ############ add_library(ge_local_engine SHARED ${SRC_LIST} ${PROTO_HDRS}) @@ -119,7 +121,7 @@ set_target_properties(atc_ge_local_engine PROPERTIES ) ############ libge_local_opskernel_builder.so ############ -add_library(ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_HDRS}) +add_library(ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_OPS_SHARED_HDRS}) target_compile_options(ge_local_opskernel_builder PRIVATE -Werror @@ -143,7 +145,7 @@ target_include_directories(ge_local_opskernel_builder PRIVATE ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/ge + ${CMAKE_BINARY_DIR}/proto/ge_ops_shared #### yellow zone #### ${GE_CODE_DIR}/../inc #### blue zone #### @@ -166,7 +168,7 @@ target_link_libraries(ge_local_opskernel_builder PRIVATE ) ############ atclib/libge_local_opskernel_builder.so ############ -add_library(atc_ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_HDRS}) +add_library(atc_ge_local_opskernel_builder SHARED ${OPS_KERNEL_SRC_LIST} ${PROTO_OPS_SHARED_HDRS}) target_compile_options(atc_ge_local_opskernel_builder PRIVATE -Werror @@ -190,7 +192,7 @@ target_include_directories(atc_ge_local_opskernel_builder PRIVATE ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/ge + ${CMAKE_BINARY_DIR}/proto/ge_ops_shared #### yellow zone #### ${GE_CODE_DIR}/../inc #### blue zone #### @@ -218,7 +220,7 @@ set_target_properties(atc_ge_local_opskernel_builder PROPERTIES ) ############ libge_local_opskernel_builder.a ############ -add_library(ge_local_opskernel_builder_static STATIC ${OPS_KERNEL_SRC_LIST} ${PROTO_HDRS}) +add_library(ge_local_opskernel_builder_static STATIC ${OPS_KERNEL_SRC_LIST} ${PROTO_OPS_STATIC_HDRS}) target_compile_options(ge_local_opskernel_builder_static PRIVATE -Werror @@ -243,7 +245,7 @@ target_include_directories(ge_local_opskernel_builder_static PRIVATE ${METADEF_DIR}/inc/external/graph ${METADEF_DIR}/inc/graph ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/ge + ${CMAKE_BINARY_DIR}/proto/ge_ops_static #### yellow zone #### ${GE_CODE_DIR}/../inc #### blue zone #### diff --git a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc index b2f3d095..90d95217 100755 --- a/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc +++ b/ge/ge_local_engine/ops_kernel_store/op/ge_deleted_op.cc @@ -38,6 +38,7 @@ REGISTER_OP_CREATOR(ExpandDims, GeDeletedOp); REGISTER_OP_CREATOR(Reshape, GeDeletedOp); REGISTER_OP_CREATOR(ReFormat, GeDeletedOp); REGISTER_OP_CREATOR(Squeeze, GeDeletedOp); +REGISTER_OP_CREATOR(Unsqueeze, GeDeletedOp); REGISTER_OP_CREATOR(Size, GeDeletedOp); REGISTER_OP_CREATOR(Shape, GeDeletedOp); REGISTER_OP_CREATOR(ShapeN, GeDeletedOp); diff --git a/ge/ge_runtime/task/label_goto_task.cc b/ge/ge_runtime/task/label_goto_task.cc index d357accb..ad93a98f 100644 --- a/ge/ge_runtime/task/label_goto_task.cc +++ b/ge/ge_runtime/task/label_goto_task.cc @@ -16,14 +16,12 @@ #include "ge_runtime/task/label_goto_task.h" #include "ge_runtime/task/task_factory.h" +#include "framework/common/util.h" namespace ge { namespace model_runner { LabelGotoTask::LabelGotoTask(const ModelContext &model_context, const std::shared_ptr &task_info) - : TaskRepeater(model_context, task_info), - task_info_(task_info), - stream_(nullptr), - label_(nullptr) { + : TaskRepeater(model_context, task_info), task_info_(task_info) { if (task_info_ == nullptr) { GELOGW("task_info_ is null!"); return; @@ -42,29 +40,78 @@ LabelGotoTask::LabelGotoTask(const ModelContext &model_context, const std::share label_ = label_list[label_id]; } -LabelGotoTask::~LabelGotoTask() {} +LabelGotoTask::~LabelGotoTask() { + GE_FREE_RT_LOG(label_info_); + GE_FREE_RT_LOG(index_value_); +} 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(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; } + if (label_ == nullptr) { GELOGE(PARAM_INVALID, "label is null!"); return false; } - rtError_t rt_ret = rtLabelGotoEx(label_, stream_); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); + + if (label_info_ != nullptr) { + GELOGE(PARAM_INVALID, "label_info_ has dirty data."); + return false; + } + + if (index_value_ != nullptr) { + GELOGE(PARAM_INVALID, "index_value_ has dirty data."); return false; } - GELOGI("DistributeTask end."); return true; } REGISTER_TASK(TaskInfoType::LABEL_GOTO, LabelGotoTask, LabelGotoTaskInfo); - } // namespace model_runner } // namespace ge diff --git a/ge/ge_runtime/task/label_goto_task.h b/ge/ge_runtime/task/label_goto_task.h index 4fd6d1bc..addbb700 100644 --- a/ge/ge_runtime/task/label_goto_task.h +++ b/ge/ge_runtime/task/label_goto_task.h @@ -31,9 +31,13 @@ class LabelGotoTask : public TaskRepeater { bool Distribute() override; private: + bool CheckParamValid(); + std::shared_ptr task_info_; - void *stream_; - void *label_; + void *stream_{nullptr}; + void *label_{nullptr}; + void *label_info_{nullptr}; + void *index_value_{nullptr}; }; } // namespace model_runner } // namespace ge diff --git a/ge/generator/ge_generator.cc b/ge/generator/ge_generator.cc index 354b22f7..c138ec0d 100644 --- a/ge/generator/ge_generator.cc +++ b/ge/generator/ge_generator.cc @@ -50,9 +50,13 @@ const char *const kFileNameSuffix = "online"; const char *const kAicpuAllshape = "_AllShape"; constexpr char const *kAttrSupportDynamicShape = "support_dynamicshape"; const int64_t kDynamicDimValue = -2; +const int kDefaultDeviceId = 0; +const int kDefaultJobId = 0; std::map engine_type_map{ - {ge::ENGINE_SYS, kEngineNameDefault}, {ge::ENGINE_AICORE, kAIcoreEngine}, {ge::ENGINE_VECTOR, kVectorEngine}}; + {ge::ENGINE_SYS, kEngineNameDefault}, + {ge::ENGINE_AICORE, kAIcoreEngine}, + {ge::ENGINE_VECTOR, kVectorEngine}}; bool ContainsDynamicInpus(const ge::OpDesc &op_desc) { for (auto &tensor_desc : op_desc.GetAllInputsDescPtr()) { @@ -66,7 +70,8 @@ bool ContainsDynamicInpus(const ge::OpDesc &op_desc) { } // namespace namespace ge { -static Status CheckEngineTypeSupport(const OpDescPtr &op_desc, OpEngineType engine_type) { +static Status CheckEngineTypeSupport(const NodePtr &node, OpEngineType engine_type) { + const OpDescPtr &op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL_EXEC(op_desc, return PARAM_INVALID); if (engine_type == ENGINE_SYS) { GELOGI("CheckEngineType: use default engine."); @@ -82,8 +87,9 @@ static Status CheckEngineTypeSupport(const OpDescPtr &op_desc, OpEngineType engi } else { ErrorManager::GetInstance().ATCReportErrMessage("E14001", {"opname", "optype", "value", "reason"}, {op_desc->GetName(), op_desc->GetType(), "engine type", - "it only support kEngineNameDefault/kAIcoreEngine/kVectorEngine"}); - GELOGE(FAILED, "CheckEngineType: engine type: %d not support", static_cast(engine_type)); + "it only support default/AIcoreEngine/VectorEngine"}); + GELOGE(FAILED, "[Check][EngineType]value:%d not support, " + "only support default/AIcoreEngine/VectorEngine now", static_cast(engine_type)); return FAILED; } @@ -123,7 +129,7 @@ static Status CheckEngineTypeSupport(const OpDescPtr &op_desc, OpEngineType engi auto kernel_info_store = kernel_map.find(kernel_name); if (kernel_info_store != kernel_map.end()) { std::string unsupported_reason; - if (kernel_info_store->second->CheckSupported(op_desc, unsupported_reason)) { + if (kernel_info_store->second->CheckSupported(node, unsupported_reason)) { op_desc->SetOpEngineName(op_engine_name); op_desc->SetOpKernelLibName(kernel_name); GELOGI("CheckEngineType:Set OpKernelLibName %s and engine name %s into op_desc %s", kernel_name.c_str(), @@ -187,17 +193,20 @@ static Status AddInputs(const ComputeGraphPtr &graph, const NodePtr &node, const (void)AttrUtils::SetBool(data_op, "_is_single_op", true); - GE_CHK_BOOL_EXEC(data_op->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add input desc fail."); - GE_CHK_BOOL_EXEC(data_op->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add output desc fail."); + GE_CHK_BOOL_EXEC(data_op->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, + "[Add][InputDesc]fail for node:%s", data_op->GetName().c_str()); + GE_CHK_BOOL_EXEC(data_op->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, + "[Add][OutputDesc]fail for node:%s", data_op->GetName().c_str()); if (attr) { - GE_CHK_BOOL_EXEC(AttrUtils::SetInt(data_op, ATTR_NAME_INDEX, index), return FAILED, "Set index fail."); + GE_CHK_BOOL_EXEC(AttrUtils::SetInt(data_op, ATTR_NAME_INDEX, index), return FAILED, + "[Set][Attr:%s]fail for node:%s", ATTR_NAME_INDEX.c_str(), data_op->GetName().c_str()); } ge::NodePtr arg_node = graph->AddNode(data_op); - GE_CHK_BOOL_EXEC(arg_node != nullptr, return FAILED, "Insert Data node fail."); + GE_CHK_BOOL_EXEC(arg_node != nullptr, return FAILED, "Insert Data node fail"); GE_CHK_STATUS(GraphUtils::AddEdge(arg_node->GetOutDataAnchor(0), node->GetInDataAnchor(index)), - "Add edge[%s->%s] fail.", data_op->GetName().c_str(), node->GetName().c_str()); + "[Add][Edge]fail from node:%s to node:%s", data_op->GetName().c_str(), node->GetName().c_str()); return SUCCESS; } @@ -212,20 +221,23 @@ static Status AddOutputs(const ComputeGraphPtr &graph, const NodePtr &node, cons for (const auto &out_desc : outputs) { GeTensorDesc tensor = out_desc.GetTensorDesc(); TensorUtils::SetInputTensor(tensor, true); - GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add input desc fail"); + GE_CHK_BOOL_EXEC(op_desc->AddInputDesc(tensor) == GRAPH_SUCCESS, return FAILED, + "[Add][InputDesc]fail for node:%s", op_desc->GetName().c_str()); TensorUtils::SetInputTensor(tensor, false); TensorUtils::SetOutputTensor(tensor, true); - GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, "Add output desc fail"); + GE_CHK_BOOL_EXEC(op_desc->AddOutputDesc(tensor) == GRAPH_SUCCESS, return FAILED, + "[Add][OutputDesc]fail for node:%s", op_desc->GetName().c_str()); count++; } GE_CHECK_NOTNULL_EXEC(graph, return PARAM_INVALID); ge::NodePtr out_node = graph->AddNode(op_desc); - GE_CHK_BOOL_EXEC(out_node != nullptr, return FAILED, "Insert Output node fail."); + GE_CHK_BOOL_EXEC(out_node != nullptr, return FAILED, + "[Add][Node:%s]fail in graph:%u", op_desc->GetName().c_str(), graph->GetGraphID()); GE_CHECK_NOTNULL_EXEC(node, return PARAM_INVALID); for (int32_t i = 0; i < count; ++i) { GE_CHK_STATUS(GraphUtils::AddEdge(node->GetOutDataAnchor(i), out_node->GetInDataAnchor(i)), - "Add edge[%s->%s] fail.", node->GetName().c_str(), out_node->GetName().c_str()); + "[Add][Edge]fail from node:%s to node:%s", node->GetName().c_str(), out_node->GetName().c_str()); } return SUCCESS; @@ -553,6 +565,44 @@ bool GeGenerator::Impl::SetOmSystemInfo(AttrHolder &obj) { return true; } +Status GeGenerator::SetModelNameForDump(const GeRootModelPtr &ge_root_model) { + bool is_unknown_shape = false; + Status ret = ge_root_model->CheckIsUnknownShape(is_unknown_shape); + if (ret != SUCCESS) { + GELOGE(FAILED, "[Check][IsUnknownShape]Check root model is unknown shape failed, model id:%u", + ge_root_model->GetModelId()); + REPORT_CALL_ERROR("E19999", "Check root model is unknown shape failed, model id:%zu", + ge_root_model->GetModelId()); + return FAILED; + } + GeModelPtr model_root = nullptr; + if (is_unknown_shape) { + model_root = MakeShared(); + GE_CHECK_NOTNULL(model_root); + model_root->SetGraph(GraphUtils::CreateGraphFromComputeGraph(ge_root_model->GetRootGraph())); + ge_root_model->SetSubgraphInstanceNameToModel(ge_root_model->GetRootGraph()->GetName(), model_root); + } + + ModelHelper model_helper; + string model_name; + GE_CHECK_NOTNULL(ge_root_model->GetRootGraph()); + Status name_ret = model_helper.GetModelNameFromMergedGraphName(ge_root_model->GetRootGraph()->GetName(), + model_name); + if (name_ret != SUCCESS) { + ErrorManager::GetInstance().ATCReportErrMessage("E10000", {"parameter"}, {"output"}); + GELOGE(FAILED, "[Check][GetModelNameStep]Get model_name failed. Param --output is invalid, root graph name: %s", + ge_root_model->GetRootGraph()->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "Get model_name failed. Param --output is invalid,", + "root graph name: %s", ge_root_model->GetRootGraph()->GetName().c_str()); + return PARAM_INVALID; + } + map name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); + GeModelPtr &ge_model = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; + GE_CHECK_NOTNULL(ge_model); + ge_model->SetName(model_name); + return SUCCESS; +} + Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_prefix, const vector &inputs, ModelBufferData &model, bool is_offline) { rtContext_t ctx = nullptr; @@ -587,20 +637,10 @@ Status GeGenerator::GenerateModel(const Graph &graph, const string &file_name_pr } GE_CHECK_NOTNULL(ge_root_model); - GE_CHECK_NOTNULL(ge_root_model->GetRootGraph()); - ModelHelper model_helper; - string model_name = ""; - Status name_ret = model_helper.GetModelNameFromMergedGraphName(ge_root_model->GetRootGraph()->GetName(), - model_name); - if (name_ret != SUCCESS) { - ErrorManager::GetInstance().ATCReportErrMessage("E10000", {"parameter"}, {"output"}); - GELOGE(FAILED, "Get model_name failed. Param --output is invalid."); - return PARAM_INVALID; + ret = SetModelNameForDump(ge_root_model); + if (ret != SUCCESS) { + return ret; } - map name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); - GeModelPtr &ge_model = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; - GE_RETURN_WITH_LOG_IF_FALSE(ge_model != nullptr, "ge_model cannot be null"); - ge_model->SetName(model_name); ret = impl_->SaveRootModel(file_name_prefix, ge_root_model, model); if (ret != SUCCESS) { GELOGE(ret, "Save model failed"); @@ -653,6 +693,22 @@ namespace { } } +bool GeGenerator::CheckNoAicore(const ComputeGraphPtr &graph) { + for (const auto &node : graph->GetDirectNode()) { + if (node == nullptr) { + continue; + } + auto op_desc = node->GetOpDesc(); + if (op_desc == nullptr) { + continue; + } + if (op_desc->GetOpEngineName() == kAIcoreEngine) { + return false; + } + } + return true; +} + Status GeGenerator::CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs) { GE_CHECK_NOTNULL_EXEC(op_desc, return PARAM_INVALID); @@ -697,22 +753,23 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in OpDescPtr op_desc_tmp = AttrUtils::CloneOpDesc(op_desc); GE_CHECK_NOTNULL(op_desc_tmp); - // 1. check engine type when compile online + // 1. Create ComputeGraph. + string name = ge::CurrentTimeInStr() + "_" + model_file_name; + Graph graph; + GE_CHK_STATUS(BuildSingleOpGraph(op_desc, inputs, outputs, name, graph), "make graph fail."); + + // 2. check engine type when compile online if (model_file_name == kFileNameSuffix) { - Status ret = CheckEngineTypeSupport(op_desc, engine_type); + auto comp_graph = GraphUtils::GetComputeGraph(graph); + GE_CHECK_NOTNULL(comp_graph); + auto node = comp_graph->FindNode(op_desc->GetName()); + Status ret = CheckEngineTypeSupport(node, engine_type); if (ret != SUCCESS) { - GELOGE(ret, "check engine type failed."); + GELOGE(ret, "[Check][EngineType]value:%d for node:%s not support", engine_type, node->GetName().c_str()); return ret; } } - // 2. Create ComputeGraph. - string name = ge::CurrentTimeInStr() + "_" + model_file_name; - Graph graph; - if (BuildSingleOpGraph(op_desc, inputs, outputs, name, graph) != ge::SUCCESS) { - GELOGE(GRAPH_FAILED, "make graph fail."); - return GRAPH_FAILED; - } GELOGI("ATC parser success in single op build."); GeRootModelPtr ge_root_model = nullptr; @@ -732,7 +789,7 @@ Status GeGenerator::BuildSingleOp(OpDescPtr &op_desc, const vector &in bool all_shape = false; (void)AttrUtils::GetBool(op_desc, kAicpuAllshape, all_shape); - if (all_shape) { + if (all_shape && CheckNoAicore(root_graph)) { GELOGD("Get aicpu all_shape kernel!"); vector inputs_dynamic; vector outputs_dynamic; @@ -869,13 +926,12 @@ Status GeGenerator::Impl::SaveRootModel(const string &file_name_prefix, GeRootMo "ge root model has no sub model") GeModelPtr model_root = nullptr; if (is_unknown_shape) { - model_root = make_shared(); - model_root->SetGraph(GraphUtils::CreateGraphFromComputeGraph(ge_root_model->GetRootGraph())); - ge_root_model->SetSubgraphInstanceNameToModel(ge_root_model->GetRootGraph()->GetName(), model_root); - model_root->SetName(ge_root_model->GetRootGraph()->GetName()); + auto name_to_ge_model = ge_root_model->GetSubgraphInstanceNameToModel(); + model_root = name_to_ge_model[ge_root_model->GetRootGraph()->GetName()]; } else { model_root = ge_root_model->GetSubgraphInstanceNameToModel().begin()->second; } + GE_CHECK_NOTNULL(model_root); // set atc version if (!SetAtcVersionInfo(*(model_root.get()))) { GELOGW("SetPackageVersionInfo of atc failed!"); @@ -913,6 +969,13 @@ Status GeGenerator::Impl::BuildModel(const Graph &graph, const vector static std::atomic atomic_session_id(0); auto session_id = atomic_session_id.fetch_add(1); + // This is a temporary add for graph with variable + auto version = static_cast(SessionVersion::ClOUD_VERSION); + ret = VarManager::Instance(session_id)->Init(version, session_id, kDefaultDeviceId, kDefaultJobId); + GELOGI("Start init var instance, session_id %lu", session_id); + if (ret != SUCCESS) { + GELOGW("Failed init var instance, session_id %lu", session_id); + } if (is_singleop_unregistered_) { ret = graph_manager_.BuildGraphForUnregisteredOp(graph_id, inputs, ge_root_model, session_id); } else { diff --git a/ge/graph/build/graph_builder.cc b/ge/graph/build/graph_builder.cc index 0883d895..74b884de 100644 --- a/ge/graph/build/graph_builder.cc +++ b/ge/graph/build/graph_builder.cc @@ -387,7 +387,7 @@ static Status InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDataAnchor GE_CHECK_NOTNULL(out_anchor); NodePtr in_node = out_anchor->GetOwnerNode(); GE_CHECK_NOTNULL(in_node); - OpDescBuilder op_desc_builder(name, MEMCPYADDRASYNC); + OpDescBuilder op_desc_builder(name, MEMCPYASYNC); OpDescPtr op_desc = op_desc_builder.AddInput("x", in_node->GetOpDesc()->GetOutputDesc(0)) .AddOutput("y", in_node->GetOpDesc()->GetOutputDesc(0)) .Build(); @@ -400,6 +400,10 @@ static Status InsertMemcpyNode(const ComputeGraphPtr &graph, const OutDataAnchor } static Status GenerateTaskForConstant(const std::shared_ptr &graph) { + if (graph->GetGraphUnknownFlag()) { + GELOGI("Graph %s is unknown graph, ignore gen_task for constant.", graph->GetName().c_str()); + return SUCCESS; + } for (auto &node : graph->GetDirectNode()) { // CONSTANT not generate task, so insert IDENTITY between CONSTANT and NETOUTPUT auto op_desc = node->GetOpDesc(); diff --git a/ge/graph/build/logical_stream_allocator.cc b/ge/graph/build/logical_stream_allocator.cc index 8ea7fe71..72fbdf33 100644 --- a/ge/graph/build/logical_stream_allocator.cc +++ b/ge/graph/build/logical_stream_allocator.cc @@ -33,13 +33,21 @@ using std::queue; namespace ge { LogicalStreamPass::LogicalStreamPass(const string &name) : name_(name) {} -const string &LogicalStreamPass::GetName() const { return name_; } +const string &LogicalStreamPass::GetName() const { + return name_; +} -bool LogicalStreamPass::IsEngineSkip(const Subgraph &subgraph) const { return subgraph.engine_conf.skip_assign_stream; } +bool LogicalStreamPass::IsEngineSkip(const Subgraph &subgraph) const { + return subgraph.engine_conf.skip_assign_stream; +} -bool LogicalStreamPass::IsEngineAttach(const Subgraph &subgraph) const { return subgraph.engine_conf.attach; } +bool LogicalStreamPass::IsEngineAttach(const Subgraph &subgraph) const { + return subgraph.engine_conf.attach; +} -bool LogicalStreamPass::IsEngineIndependent(const Subgraph &subgraph) const { return subgraph.engine_conf.independent; } +bool LogicalStreamPass::IsEngineIndependent(const Subgraph &subgraph) const { + return subgraph.engine_conf.independent; +} bool LogicalStreamPass::HasStreamLabel(const Subgraph &subgraph) const { return !subgraph.subgraph_info.GetStreamLabel().empty(); @@ -60,14 +68,14 @@ Status AssignByLabelPass::Run(ComputeGraphPtr graph, const vector & // Subgraphs of the same stream_label are assigned to the same stream, // and different stream_labels are assigned new streams. auto iter = label_streams.find(stream_label); - if (iter != label_streams.end()) { - subgraph->stream_id = iter->second; - } else { + if (iter == label_streams.end()) { subgraph->stream_id = next_stream; - GELOGI("Assign new stream %ld for label %s.", next_stream, stream_label.c_str()); + GELOGI("[Assign][NewStreamId] %ld for label %s.", next_stream, stream_label.c_str()); label_streams.emplace(stream_label, next_stream); - ++next_stream; + next_stream++; + } else { + subgraph->stream_id = iter->second; } changed = true; } @@ -92,15 +100,15 @@ Status IndependentStreamPass::Run(ComputeGraphPtr graph, const vectorsubgraph_info.GetStreamLabel(); auto &label_streams = engine_streams[engine]; auto iter = label_streams.find(stream_label); - if (iter != label_streams.end()) { - subgraph->stream_id = iter->second; - } else { + if (iter == label_streams.end()) { subgraph->stream_id = next_stream; - GELOGI("Assign new independent stream %ld for engine %s (label: %s).", next_stream, engine.c_str(), + GELOGI("[Assign][NewStreamId:independent] %ld for engine %s (label: %s).", next_stream, engine.c_str(), stream_label.c_str()); label_streams.emplace(stream_label, next_stream); - ++next_stream; + next_stream++; + } else { + subgraph->stream_id = iter->second; } changed = true; } @@ -121,14 +129,16 @@ Status AssignByDependencyPass::Run(ComputeGraphPtr graph, const vectorstream_id = reusable_subgraph->stream_id; } else { int64_t stream_id = AssignNewStream(reusable_subgraph); subgraph->stream_id = stream_id; - GELOGI("Reusable subgraph %s has not been assigned a stream, now assign new stream %ld.", - reusable_subgraph->name.c_str(), stream_id); + GELOGI("[Assign][NewStreamId] %ld for Reusable subgraph %s cause has not been assigned before.", + stream_id, reusable_subgraph->name.c_str()); } if (reusable_subgraph->reused_subgraph != nullptr) { @@ -137,11 +147,10 @@ Status AssignByDependencyPass::Run(ComputeGraphPtr graph, const vectorreused_subgraph = reusable_subgraph; reused_subgraphs_.emplace_back(subgraph, reusable_subgraph); - GELOGI("Subgraph %s of engine %s reuses stream of subgraph %s of engine %s.", subgraph->name.c_str(), + GELOGI("[Reuse][Stream]Subgraph %s of engine %s reuses stream of subgraph %s of engine %s.", + subgraph->name.c_str(), subgraph->engine_conf.id.c_str(), reusable_subgraph->name.c_str(), reusable_subgraph->engine_conf.id.c_str()); - } else { - (void)AssignNewStream(subgraph); } changed = true; } @@ -191,13 +200,15 @@ bool AssignByDependencyPass::CouldReuse(const SubgraphPtr &subgraph, const Subgr auto iter = pld_subgraph_map.find(end_pld_pair.second); if (iter != pld_subgraph_map.end()) { const SubgraphPtr &pred_subgraph_succ = iter->second; - if (pred_subgraph_succ != subgraph && pred_subgraph_succ->engine_conf.id == pred_subgraph->engine_conf.id) { + if ((pred_subgraph_succ != subgraph) && + (pred_subgraph_succ->engine_conf.id == pred_subgraph->engine_conf.id)) { return false; } } } - if ((subgraph->engine_conf.id == pred_subgraph->engine_conf.id) || IsEngineAttach(*subgraph)) { + if ((subgraph->engine_conf.id == pred_subgraph->engine_conf.id) || + IsEngineAttach(*subgraph)) { return true; } @@ -249,7 +260,7 @@ int64_t AssignByDependencyPass::AssignNewStream(SubgraphPtr subgraph) { engine_stream_num_[engine_name] = stream_id + 1; } - GELOGI("Subgraph %s assigns new temp stream %ld (engine: %s).", subgraph->name.c_str(), stream_id, + GELOGI("[Assign][NewStreamId:temp]id:%ld for Subgraph %s (engine: %s).", stream_id, subgraph->name.c_str(), engine_name.c_str()); return stream_id; @@ -282,7 +293,7 @@ void AssignByDependencyPass::UpdateAssignedSubgraphs(Context &context) { GELOGI("Subgraph %s of engine %s reuses default stream %ld.", subgraph->name.c_str(), subgraph->engine_conf.id.c_str(), context.default_stream); } else { - GELOGI("Stream of subgraph %s has been updated to %ld.", subgraph->name.c_str(), subgraph->stream_id); + GELOGI("[Update][StreamId]id:%ld for subgraph %s.", subgraph->stream_id, subgraph->name.c_str()); } } } @@ -293,7 +304,7 @@ void AssignByDependencyPass::UpdateReusedSubgraphs() { auto &cur_subgraph = item.first; auto &reused_graph = item.second; cur_subgraph->stream_id = reused_graph->stream_id; - GELOGI("Stream of subgraph %s has been updated to %ld.", cur_subgraph->name.c_str(), cur_subgraph->stream_id); + GELOGI("[Update][StreamId]id:%ld for subgraph %s.", cur_subgraph->stream_id, cur_subgraph->name.c_str()); } } @@ -330,7 +341,7 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vectorname.c_str(), subgraph->stream_id, + GELOGI("[Assign][StreamId] %ld for Subgraph %s (engine: %s).", subgraph->stream_id, subgraph->name.c_str(), engine_name.c_str()); } } @@ -353,12 +364,12 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vectorGetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), context.default_stream, engine_name.c_str()); } else if (IsEngineSkip(*subgraph) && node->GetInNodes().empty()) { - GELOGD("Node %s of type %s in subgraph %s doesn't need to assign a stream (engine: %s).", + GELOGD("[Skip][StreamIdAssign]Node %s of type %s in subgraph %s doesn't need (engine: %s).", node->GetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), engine_name.c_str()); } else { node->GetOpDesc()->SetStreamId(stream_id); - GELOGD("Node %s of type %s in subgraph %s is assigned stream %ld (engine: %s).", node->GetName().c_str(), - node->GetType().c_str(), subgraph->name.c_str(), stream_id, engine_name.c_str()); + GELOGD("[Assign][StreamId]id:%ld for Node %s of type %s in subgraph %s (engine: %s).", stream_id, + node->GetName().c_str(), node->GetType().c_str(), subgraph->name.c_str(), engine_name.c_str()); } } } @@ -366,6 +377,48 @@ Status NodeStreamUpdatePass::Run(ComputeGraphPtr graph, const vector &subgraphs, Context &context) { + std::map> stream_op_map; + for (const SubgraphPtr &subgraph : subgraphs) { + auto compute_graph = subgraph->subgraph_info.GetSubGraph(); + for (const NodePtr &node : compute_graph->GetDirectNode()) { + OpDescPtr op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + if (op_desc->HasAttr(ATTR_NAME_PARALLEL_GROUP)) { + int64_t op_desc_stream_id = op_desc->GetStreamId(); + stream_op_map[op_desc_stream_id].push_back(op_desc); + } + } + } + for (const auto &itr : stream_op_map) { + if (itr.first == kInvalidStream) { + continue; + } + std::map group_2_stream_id; + for (const auto &op_desc : itr.second) { + std::string group_name; + if (!AttrUtils::GetStr(op_desc, ATTR_NAME_PARALLEL_GROUP, group_name)) { + GELOGE(FAILED, "[GetAttr][OpDesc]Get node %s ATTR_NAME_PARALLEL_GROUP failed.", op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "Get node %s ATTR_NAME_PARALLEL_GROUP failed.", op_desc->GetName().c_str()); + return FAILED; + } + const auto &itr = group_2_stream_id.find(group_name); + int64_t new_stream_id = kInvalidStream; + int64_t old_stream_id = op_desc->GetStreamId(); + if (itr != group_2_stream_id.end()) { + new_stream_id = itr->second; + } else { + new_stream_id = context.next_stream++; + group_2_stream_id[group_name] = new_stream_id; + } + op_desc->SetStreamId(new_stream_id); + GELOGD("Node %s assigned stream %ld from stream %ld.", + op_desc->GetName().c_str(), new_stream_id, old_stream_id); + } + } + return SUCCESS; +} + int64_t UpdateForSkippedEnginePass::GetSingleInoutStream(const NodePtr &node) const { set stream_ids; @@ -387,8 +440,8 @@ int64_t UpdateForSkippedEnginePass::GetSingleInoutStream(const NodePtr &node) co if (stream_ids.size() == 1) { int64_t stream_id = *(stream_ids.begin()); - GELOGI("The stream of all input and output nodes of node %s (type: %s) is %ld.", node->GetName().c_str(), - node->GetType().c_str(), stream_id); + GELOGI("[Get][SingleStreamId]The stream of all input and output nodes of node %s (type: %s) is %ld.", + node->GetName().c_str(), node->GetType().c_str(), stream_id); return stream_id; } @@ -406,7 +459,7 @@ Status UpdateForSkippedEnginePass::Run(ComputeGraphPtr graph, const vectorGetOpDesc(); GE_CHECK_NOTNULL(op_desc); auto stream_id = op_desc->GetStreamId(); - if (stream_id != kInvalidStream && !HasStreamLabel(*subgraph)) { + if ((stream_id != kInvalidStream) && !HasStreamLabel(*subgraph)) { ops_without_label.emplace(op_desc); } } @@ -427,8 +480,8 @@ Status UpdateForSkippedEnginePass::Run(ComputeGraphPtr graph, const vectorSetStreamId(inout_stream); - GELOGI("Node %s of type %s reassign to stream %ld from stream %ld.", node->GetName().c_str(), - node->GetType().c_str(), inout_stream, stream_id); + GELOGI("[Reassign][StreamId]%ld for Node %s of type %s from stream %ld.", + inout_stream, node->GetName().c_str(), node->GetType().c_str(), stream_id); } } } @@ -455,7 +508,7 @@ Status AllReduceParallelPass::Run(ComputeGraphPtr graph, const vectorGetDirectNode()) { if (!IsHcomNode(node->GetType()) || - node->GetInDataNodes().size() <= 1) { + (node->GetInDataNodes().size() <= 1)) { continue; } @@ -565,7 +618,7 @@ Status LogicalStreamAllocator::Assign(const ComputeGraphPtr &root_graph, const G RefreshContinuousStreams(root_graph); stream_num = context_.next_stream; - GELOGI("Assigned logical stream num: %ld.", stream_num); + GELOGI("[Assign][LogicalStream] At last, stream num: %ld.", stream_num); return SUCCESS; } @@ -575,7 +628,7 @@ Status LogicalStreamAllocator::DoAssign(const ComputeGraphPtr &graph, const Grap GE_CHECK_NOTNULL(graph); NodePtr parent_node = graph->GetParentNode(); - if (parent_node == nullptr || parent_node->GetOpDesc() == nullptr) { + if ((parent_node == nullptr) || (parent_node->GetOpDesc() == nullptr)) { context_.default_stream = kInvalidStream; } else { context_.default_stream = parent_node->GetOpDesc()->GetStreamId(); @@ -597,7 +650,7 @@ Status LogicalStreamAllocator::DoAssign(const ComputeGraphPtr &graph, const Grap return status; } - GELOGD("Subgraphs of graph %s:", graph->GetName().c_str()); + GELOGD("[Show][Subgraphs] in graph %s", graph->GetName().c_str()); for (const auto &subgraph : subgraphs) { if (subgraph != nullptr) { GELOGD("subgraph: %s", subgraph->name.c_str()); @@ -655,6 +708,7 @@ Status LogicalStreamAllocator::RunPasses(const ComputeGraphPtr &graph, const vec passes.emplace_back(MakeShared()); passes.emplace_back(MakeShared()); passes.emplace_back(MakeShared()); + passes.emplace_back(MakeShared()); passes.emplace_back(MakeShared()); passes.emplace_back(MakeShared()); } @@ -664,9 +718,9 @@ Status LogicalStreamAllocator::RunPasses(const ComputeGraphPtr &graph, const vec Status status = pass->Run(graph, subgraphs, context_); if (status == SUCCESS) { - GELOGD("Stream pass %s return SUCCESS.", pass->GetName().c_str()); + GELOGD("[Show][Status]Stream pass %s return SUCCESS.", pass->GetName().c_str()); } else if (status == NOT_CHANGED) { - GELOGD("Stream pass %s return NOT_CHANGED.", pass->GetName().c_str()); + GELOGD("[Show][Status]Stream pass %s return NOT_CHANGED.", pass->GetName().c_str()); } else { GELOGE(status, "Stream pass %s failed.", pass->GetName().c_str()); return status; @@ -686,7 +740,7 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra auto op_desc = node->GetOpDesc(); if (op_desc != nullptr) { int64_t stream_id = op_desc->GetStreamId(); - if (stream_id != kInvalidStream && stream_id < stream_num) { + if ((stream_id != kInvalidStream) && (stream_id < stream_num)) { stream_has_node[stream_id] = true; } } @@ -695,10 +749,10 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra context_.next_stream = 0; vector old_to_new_streams(stream_num, kInvalidStream); - for (size_t old_stream = 0; old_stream < stream_has_node.size(); ++old_stream) { + for (size_t old_stream = 0; old_stream < stream_has_node.size(); old_stream++) { if (stream_has_node[old_stream]) { old_to_new_streams[old_stream] = context_.next_stream; - ++context_.next_stream; + context_.next_stream++; } } @@ -706,7 +760,7 @@ void LogicalStreamAllocator::RefreshContinuousStreams(const ComputeGraphPtr &gra auto op_desc = node->GetOpDesc(); if (op_desc != nullptr) { int64_t stream_id = op_desc->GetStreamId(); - if (stream_id != kInvalidStream && stream_id < stream_num) { + if ((stream_id != kInvalidStream) && (stream_id < stream_num)) { op_desc->SetStreamId(old_to_new_streams[stream_id]); } } diff --git a/ge/graph/build/logical_stream_allocator.h b/ge/graph/build/logical_stream_allocator.h index b9aec611..2a94c254 100644 --- a/ge/graph/build/logical_stream_allocator.h +++ b/ge/graph/build/logical_stream_allocator.h @@ -149,6 +149,13 @@ class NodeStreamUpdatePass : public LogicalStreamPass { Status Run(ComputeGraphPtr graph, const std::vector &subgraphs, Context &context) override; }; +// assign stream by parallel group +class UpdateForParallelGroupPass : public LogicalStreamPass { + public: + STREAM_PASS_DEFAULT_FUNC(UpdateForParallelGroupPass); + Status Run(ComputeGraphPtr graph, const std::vector &subgraphs, Context &context) override; +}; + // Update the stream of subgraphs to nodes. class UpdateForSkippedEnginePass : public LogicalStreamPass { public: diff --git a/ge/graph/build/memory/binary_block_mem_assigner.cc b/ge/graph/build/memory/binary_block_mem_assigner.cc index 97a0aed6..72cd5b9a 100644 --- a/ge/graph/build/memory/binary_block_mem_assigner.cc +++ b/ge/graph/build/memory/binary_block_mem_assigner.cc @@ -70,7 +70,10 @@ Status BinaryBlockMemAssigner::GetMemoryRanges(vector &range_ceils) { return SUCCESS; } if ((all_memory_size.front() <= 0) || (log(kLogBase) == 0)) { - GELOGE(FAILED, "Memory size:%ld is invalid.", all_memory_size.front()); + GELOGE(FAILED, "[Check][MemRangeStep]first mem_range_step:%ld less than 0,invalid," + "maybe has dynamic shape in graph", all_memory_size.front()); + REPORT_INNER_ERROR("E19999", "first mem_range_step:%ld less than 0,invalid," + "maybe has dynamic shape in graph", all_memory_size.front()); return FAILED; } // Memory size is 512 aligned, so it is not necessary to take less than 512 @@ -81,12 +84,18 @@ Status BinaryBlockMemAssigner::GetMemoryRanges(vector &range_ceils) { GELOGD("Range number: %zu", range_number); vector> ranges(range_number); - GE_CHK_BOOL_EXEC((range_number != 0), return PARAM_INVALID, "range_number can't be 0."); + GE_CHK_BOOL_EXEC((range_number != 0), + REPORT_INNER_ERROR("E19999", "inner data[range_number] is 0, judge invalid"); + return PARAM_INVALID, + "[Check][RangeNumber]inner data is 0, judge invalid."); size_t range_number_limit = all_memory_size.size() / range_number; int64_t range_ceil = min_memory_size; for (size_t i = 1; i <= range_number; i++) { GE_IF_BOOL_EXEC(TypeUtils::CheckUint64MulOverflow(static_cast(range_ceil), kRangeCeilInterval), - GELOGE(FAILED, "Multiply result is out of range."); + GELOGE(FAILED, "[Check][MemRangeCeil]Multiply result is out of range," + "range_ceil:%ld, interval:%u", range_ceil, kRangeCeilInterval); + REPORT_INNER_ERROR("E19999", "process mem_range_ceil,multiply result out of range," + "range_ceil:%ld, interval:%u", range_ceil, kRangeCeilInterval); return FAILED); range_ceil *= kRangeCeilInterval; // The block size of each interval is doubled every time. for (auto iter = all_memory_size.begin(); iter != all_memory_size.end();) { diff --git a/ge/graph/build/memory/block_mem_assigner.cc b/ge/graph/build/memory/block_mem_assigner.cc index 41f24b94..ae0c6e0d 100755 --- a/ge/graph/build/memory/block_mem_assigner.cc +++ b/ge/graph/build/memory/block_mem_assigner.cc @@ -30,6 +30,7 @@ #include "graph/utils/node_utils.h" #include "graph/utils/op_desc_utils.h" #include "graph/utils/tensor_utils.h" +#include "graph/utils/type_utils.h" #include "graph/debug/ge_attr_define.h" @@ -457,7 +458,16 @@ Status GetNoAlignSize(const ge::OpDesc &desc, uint32_t index, size_t &size) { DataType data_type = output_op_desc->GetDataType(); graphStatus graph_status = TensorUtils::CalcTensorMemSize(shape, format, data_type, tensor_size); if (graph_status != GRAPH_SUCCESS) { - GELOGE(graph_status, "CalcTensorMemSize failed!"); + GELOGE(graph_status, "[Calculate][TensorSize]shape:%s, format:%s, data_type:%s, op:%s, out_index:%u", + shape.ToString().c_str(), + TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), + desc.GetName().c_str(), index); + REPORT_CALL_ERROR("E19999", "CalcTensorMemSize fail, shape:%s, format:%s, data_type:%s, op:%s, out_index:%u", + shape.ToString().c_str(), + TypeUtils::FormatToSerialString(format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str(), + desc.GetName().c_str(), index); return FAILED; } size = static_cast(tensor_size); @@ -498,7 +508,7 @@ BlockMemAssigner::BlockMemAssigner(ComputeGraphPtr compute_graph, const map &all_memory_size) { GeTensorDesc output_desc = node_op_desc->GetOutputDesc(out_anchor->GetIdx()); int64_t size = 0; GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(output_desc, size) != SUCCESS, GELOGI("Get size failed")); - GE_IF_BOOL_EXEC(size < 0, GELOGE(FAILED, "Node:%s size:%ld is invalid, maybe it is unknown shape node.", - node_op_desc->GetName().c_str(), size); + GE_IF_BOOL_EXEC(size < 0, + GELOGE(FAILED, "[Check][TensorSize]tensor_size:%ld is invalid, " + "maybe it is unknown shape node, Node_name:%s", + size, node_op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "tensor_size:%ld is invalid, " + "maybe it is unknown shape node, Node_name:%s", + size, node_op_desc->GetName().c_str()); return;); batch_all_memory_size[batch_label].emplace_back(size); if (batch_total_size.find(batch_label) == batch_total_size.end()) { @@ -678,22 +693,34 @@ bool BlockMemAssigner::IsOutNodeSetContinuousInput(const NodePtr &n, uint32_t ou if (static_cast(out_index) < n->GetAllOutDataAnchors().size()) { auto out_anchor = n->GetOutDataAnchor(out_index); GE_IF_BOOL_EXEC(out_anchor == nullptr, - GELOGE(FAILED, "Node[%s] output[%u] anchor is null.", n->GetName().c_str(), out_index); + GELOGE(FAILED, "[Check][Anchor]Node[%s] output[%u] anchor is null.", + n->GetName().c_str(), out_index); + REPORT_INNER_ERROR("E19999", "output anchor is null, node_name: %s output_index: %u.", + n->GetName().c_str(), out_index); return false;); for (auto const &peer_in_anchor : out_anchor->GetPeerInDataAnchors()) { GE_IF_BOOL_EXEC(peer_in_anchor == nullptr, - GELOGE(FAILED, "Node[%s] output[%u] peer_in_anchor 0 is null.", n->GetName().c_str(), out_index); + GELOGE(FAILED, "[Check][Anchor]Node[%s] output[%u] peer_in_anchor 0 is null.", + n->GetName().c_str(), out_index); + REPORT_INNER_ERROR("E19999", "output anchor peer is null, node_name: %s output_index: %u.", + n->GetName().c_str(), out_index); return false;); auto peer_node = peer_in_anchor->GetOwnerNode(); GE_IF_BOOL_EXEC(peer_node == nullptr, - GELOGE(FAILED, "Node[%s] output[%u] node is null.", n->GetName().c_str(), out_index); + GELOGE(FAILED, "[Check][Node]Node[%s] output[%u] peer node is null.", + n->GetName().c_str(), out_index); + REPORT_INNER_ERROR("E19999", "output anchor peer node is null, node_name: %s output_index: %u.", + n->GetName().c_str(), out_index); return false;); // Get the continuous input type of the node, default is false bool is_input_continuous = false; auto peer_in_node_desc = peer_node->GetOpDesc(); GE_IF_BOOL_EXEC(peer_in_node_desc == nullptr, - GELOGE(FAILED, "Node[%s] output[%u] nodedesc is null.", n->GetName().c_str(), out_index); + GELOGE(FAILED, "[Check][OpDesc]Node[%s] output[%u] nodedesc is null.", + n->GetName().c_str(), out_index); + REPORT_INNER_ERROR("E19999", "output anchor peer op_desc is null, node_name:%s output_index:%u.", + n->GetName().c_str(), out_index); return false;); // If GetBool fail, is_input_continuous is false. @@ -793,7 +820,10 @@ bool BlockMemAssigner::IsContinuousMemoryReuse(const NodePtr &n, const NodePtr & if ((in_anchor == nullptr) || (in_anchor->GetPeerOutAnchor() == nullptr) || (in_anchor->GetPeerOutAnchor()->GetOwnerNode() == nullptr) || (in_anchor->GetPeerOutAnchor()->GetOwnerNode()->GetOpDesc() == nullptr)) { - GELOGE(FAILED, "Node[%s] output[%u] peer input node desc is null.", n->GetName().c_str(), out_index); + GELOGE(FAILED, "[Check][OpDesc]Node[%s] output[%u] peer input node desc is null.", + n->GetName().c_str(), out_index); + REPORT_INNER_ERROR("E19999", "get output anchor peer op_desc fail, node_name: %s output_index: %u.", + n->GetName().c_str(), out_index); return false; } auto peer_out_node_desc = in_anchor->GetPeerOutAnchor()->GetOwnerNode()->GetOpDesc(); @@ -1077,7 +1107,10 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, OpMemoryType mem_type, const NodePtr &n, uint32_t out_index, const vector &workspace_reuse_flag, const bool is_op_reuse_mem, const bool continuous, int64_t memory_type) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, return nullptr, "Input parameter n is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + n == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null, apply memory failed"); + return nullptr, "[Check][Param]Input parameter n(type:node_ptr) is null."); auto node_op_desc = n->GetOpDesc(); GE_IF_BOOL_EXEC(node_op_desc == nullptr, return nullptr); std::string batch_label; @@ -1129,7 +1162,12 @@ MemoryBlock *BlockMemAssigner::ApplyMemory(size_t block_size, size_t real_size, } auto block = new (std::nothrow) MemoryBlock(block_size, node_op_desc->GetStreamId(), is_reuse_memory, memory_type); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "new an object failed."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + block == nullptr, + REPORT_INNER_ERROR("E19999", "new a memoryblock object failed. node_name:%s out_index:%u", + n->GetName().c_str(), out_index); + return nullptr, + "[New][Object]new MemoryBlock failed, node_name:%s out_index:%u", n->GetName().c_str(), out_index); // Data and netoutput need zero copy block block->is_zero_copy_ = IsZeroCopyBlock(n, continuous); @@ -1188,9 +1226,15 @@ void BlockMemAssigner::ContinuousOutRefCheck(bool &isAllOutputRef, bool &isOutpu Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector &ranges, const bool is_op_reuse_mem) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, return INTERNAL_ERROR, "input node is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + n == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:node_ptr) is null"); + return INTERNAL_ERROR, "[check][param]Input parameter n(type:NodePtr) is null."); auto node_op_desc = n->GetOpDesc(); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, return INTERNAL_ERROR, "node_op_desc is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + node_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); + return INTERNAL_ERROR, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); // continuous output support ref only when all output ref input bool isAllOutputRef = true; @@ -1204,7 +1248,9 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorGetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][OutRefStatus]continuous output node ref part input, not support, node_name:%s", n->GetName().c_str()); return INTERNAL_ERROR; } @@ -1215,7 +1261,9 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector(node_op_desc->GetOutputsSize()); index++) { auto output_op_desc = node_op_desc->GetOutputDescPtr(index); if (output_op_desc == nullptr) { - GELOGE(INTERNAL_ERROR, "Get output desc failed, node_name:%s, output_index:%u", n->GetName().c_str(), index); + REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", + n->GetName().c_str(), index); + GELOGE(INTERNAL_ERROR, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); return INTERNAL_ERROR; } @@ -1226,7 +1274,9 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorGetName().c_str(), index); + REPORT_CALL_ERROR("E19999", "get tensor_size failed, node_name:%s, output_index:%u", + n->GetName().c_str(), index); + GELOGE(INTERNAL_ERROR, "[Get][TensorSize]node_name:%s, output_index:%u", n->GetName().c_str(), index); return INTERNAL_ERROR; } size_t align_size = static_cast(size); @@ -1266,7 +1316,9 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vectorlast_continuous_block_ = true; ++(block->ref_count_); } else { - GELOGE(INTERNAL_ERROR, "node apply continuous output memory failed. node_name:%s", n->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "apply continuousMemory failed, node_name:%s, total_size:%ld", + n->GetName().c_str(), total_size); + GELOGE(INTERNAL_ERROR, "[Apply][ContinuousMemory]node_name:%s, total_size:%ld", n->GetName().c_str(), total_size); return INTERNAL_ERROR; } return SUCCESS; @@ -1274,25 +1326,44 @@ Status BlockMemAssigner::ApplyContinuousMemory(const NodePtr &n, const vector &ranges, const bool is_op_reuse_mem, const bool continuous) { - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(n == nullptr, return nullptr, "input node is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + n == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:NodePtr) is null"); + return nullptr, "[Check][Param]Input parameter n(type:NodePtr) is null"); auto node_op_desc = n->GetOpDesc(); - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(node_op_desc == nullptr, return nullptr, "node_op_desc is null."); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + node_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "Input parameter n(type:OpDescPtr) is null"); + return nullptr, "[Check][Param]Input parameter n(type:OpDescPtr) is null"); MemoryBlock *block = nullptr; NodeIndexIO node_index_io(n, index, kOut); int64_t size = 0; auto output_op_desc = node_op_desc->GetOutputDescPtr(index); - GE_IF_BOOL_EXEC(output_op_desc == nullptr, return nullptr); + GE_IF_BOOL_EXEC( + output_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "get output_desc failed, node_name:%s, output_index:%u", + n->GetName().c_str(), index); + GELOGE(FAILED, "[Get][OutputDesc]node_name:%s, output_index:%u", n->GetName().c_str(), index); + return nullptr); GE_IF_BOOL_EXEC(ge::TensorUtils::GetSize(*output_op_desc, size) != SUCCESS, GELOGI("Get size failed")); size_t no_align_size = 0; - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, - return nullptr, "Get no align size failed"); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + GetNoAlignSize(*node_op_desc, index, no_align_size) != SUCCESS, + REPORT_CALL_ERROR("E19999", "Get no align size failed, node_name:%s, output_index:%u", + n->GetName().c_str(), index); + return nullptr, + "[Get][TensorSize]Get no align size, node_name:%s, output_index:%u", n->GetName().c_str(), index); std::string symbol; bool reuse_input = false; if (IsSymbolExist(node_index_io, symbol)) { block = symbol_blocks_[symbol]; - GE_IF_BOOL_EXEC(block == nullptr, GELOGE(FAILED, "Node %s ref block is nullptr.", node_op_desc->GetName().c_str()); - return nullptr); + GE_IF_BOOL_EXEC(block == nullptr, + REPORT_INNER_ERROR("E19999", "get ref block failed, node_name:%s, symbol:%s", + node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); + GELOGE(FAILED, "[Get][RefBlock]node_name:%s, symbol:%s", + node_op_desc->GetName().c_str(), node_index_io.ToString().c_str()); + return nullptr); // reduce old size size_t align_size = block->Size(); AlignMemOffset(align_size); @@ -1335,12 +1406,28 @@ MemoryBlock *BlockMemAssigner::ApplyOutMemory(const NodePtr &n, uint32_t index, vector workspace_reuse_flag; block = ApplyMemory(block_size, size, no_align_size, kOutput, n, index, workspace_reuse_flag, is_op_reuse_mem, continuous, memory_type); + GE_CHK_BOOL_TRUE_EXEC_WITH_LOG( + block == nullptr, + REPORT_CALL_ERROR("E19999", "apply out Memory failed, node_name:%s, block_size:%ld, out_index:%u", + n->GetName().c_str(), block_size, index); + return nullptr, + "[Apply][Memory]node_name:%s, block_size:%ld, out_index:%u", + n->GetName().c_str(), block_size, index); } - GE_CHK_BOOL_TRUE_EXEC_WITH_LOG(block == nullptr, return nullptr, "Block is nullptr."); int out_count = 0; - GE_IF_BOOL_EXEC(index >= n->GetAllOutDataAnchors().size(), GELOGE(FAILED, "index is out of range."); return nullptr); + GE_IF_BOOL_EXEC( + index >= n->GetAllOutDataAnchors().size(), + REPORT_INNER_ERROR("E19999", "out index:%u exceed out_size:%lu, node_name:%s", + index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); + GELOGE(FAILED, "[Check][OutIndex]index:%u exceed out_size:%lu, node_name:%s", + index, n->GetAllOutDataAnchors().size(), n->GetName().c_str()); + return nullptr); auto out_data_anchor = n->GetOutDataAnchor(index); - GE_IF_BOOL_EXEC(out_data_anchor == nullptr, GELOGE(FAILED, "Out data anchor is nullptr."); return nullptr); + GE_IF_BOOL_EXEC( + out_data_anchor == nullptr, + REPORT_INNER_ERROR("E19999", "out anchor is null, index:%u, node_name:%s", index, n->GetName().c_str()); + GELOGE(FAILED, "[Check][OutAnchor]is null, index:%u, node_name:%s", index, n->GetName().c_str()); + return nullptr); for (const auto &in_anchor : out_data_anchor->GetPeerInDataAnchors()) { auto owner_node = in_anchor->GetOwnerNode(); auto op_desc = owner_node->GetOpDesc(); @@ -1546,8 +1633,14 @@ Status BlockMemAssigner::AssignOutputMemoryWithReuse(const NodePtr &node, vector GELOGD("Assign memory node[%s], output size[%zu], output memory type size[%zu]", op_desc->GetName().c_str(), op_desc->GetOutputsSize(), memorys_type.size()); if (has_mem_type_attr && (memorys_type.size() != op_desc->GetOutputsSize())) { - GELOGE(INTERNAL_ERROR, "fusion: node[%s], output memory size err[outputsize:%zu, memorysize:%zu]", - op_desc->GetName().c_str(), op_desc->GetOutputsSize(), memorys_type.size()); + REPORT_INNER_ERROR("E19999", "Attr[%s] size:%zu not equal to node output size:%zu, node_name:%s", + ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), + op_desc->GetOutputsSize(), op_desc->GetName().c_str()); + GELOGE( + INTERNAL_ERROR, + "[Check][MemTypeAttr]Attr %s size:%zu not equal to node output size:%zu, node_name:%s", + ATTR_NAME_OUTPUT_MEM_TYPE_LIST.c_str(), memorys_type.size(), + op_desc->GetOutputsSize(), op_desc->GetName().c_str()); return INTERNAL_ERROR; } @@ -1673,8 +1766,12 @@ void BlockMemAssigner::AssignMemoryWithReuse(vector &ranges) { temp.size(), tvm_workspace_memory_type.size()); if (has_tvm_workspace_mem_type_attr && (temp.size() != tvm_workspace_memory_type.size())) { - GELOGE(INTERNAL_ERROR, "fusion: node[%s], tvm workspace memory size error![v_temp:%zu, workspace:%zu]", - n->GetName().c_str(), temp.size(), tvm_workspace_memory_type.size()); + REPORT_INNER_ERROR("E19999", "Attr[%s]size:%zu is not equal to workspace size:%zu, node_name:%s", + TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), + temp.size(), n->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Check][Attr]Attr %s size:%zu is not equal to workspace size:%zu, node_name:%s", + TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), tvm_workspace_memory_type.size(), + temp.size(), n->GetName().c_str()); return; } for (size_t i = 0; i < temp.size(); i++) { @@ -2059,7 +2156,7 @@ void BlockMemAssigner::SetOpMemOffset(bool is_zero_copy) { Status BlockMemAssigner::Assign() { vector ranges; if (GetMemoryRanges(ranges) != SUCCESS) { - GELOGE(FAILED, "GetMemoryRanges Fail!"); + GELOGE(FAILED, "[Get][MemoryRanges] Fail!"); return FAILED; } GE_IF_BOOL_EXEC(ranges.empty(), return SUCCESS); @@ -2083,8 +2180,12 @@ bool BlockMemAssigner::GetWorkSpaceMemoryType(const NodePtr &node, size_t index, bool has_workspace_mem_type_attr = ge::AttrUtils::GetListInt(op_desc, TVM_ATTR_NAME_WORKSPACE_TYPE, workspace_memory_type); if (has_workspace_mem_type_attr && (workspace_memory_type.size() <= index)) { - GELOGE(INTERNAL_ERROR, "node[%s], workspace_memory size error![index:%zu, workspace:%zu]", - node->GetName().c_str(), index, workspace_memory_type.size()); + REPORT_INNER_ERROR("E19999", "get workspace mem_type failed, " + "index %zu invalid, bigger than attr %s size:%zu, node_name:%s", + index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), + workspace_memory_type.size(), node->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Get][WorkspaceMemType]index %zu invalid, bigger than attr %s size:%zu, node_name:%s", + index, TVM_ATTR_NAME_WORKSPACE_TYPE.c_str(), workspace_memory_type.size(), node->GetName().c_str()); return false; } memory_type = has_workspace_mem_type_attr ? workspace_memory_type[index] : RT_MEMORY_HBM; diff --git a/ge/graph/build/memory/graph_mem_assigner.cc b/ge/graph/build/memory/graph_mem_assigner.cc index f62f6875..9d5b9d08 100755 --- a/ge/graph/build/memory/graph_mem_assigner.cc +++ b/ge/graph/build/memory/graph_mem_assigner.cc @@ -99,7 +99,8 @@ Status VariableMemoryAssigner::AssignMemory2HasRefAttrNode() { Status GraphMemoryAssigner::AssignMemory() { ge::HybridMemAssignerPtr mem_assigner(new(std::nothrow) HybridMemAssigner(compute_graph_)); if (mem_assigner->Assign() != ge::SUCCESS) { - GELOGE(ge::FAILED, "Memory assigner failed"); + GELOGE(ge::FAILED, "[Assign][GraphMem]graph_id:%u, graph_name:%s", + compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return ge::FAILED; } MemoryOffset memory_offset(RT_MEMORY_HBM, mem_assigner->GetMemOffset()); @@ -115,7 +116,10 @@ Status GraphMemoryAssigner::AssignMemory() { auto variable_assigner = std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { - GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); + GELOGE(ge::FAILED, "[New][Object:VariableMemoryAssigner]graph_id:%u, graph_name:%s", + compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return ge::FAILED; } @@ -134,7 +138,10 @@ ge::Status GraphMemoryAssigner::AssignVarAttr2Nodes() { auto variable_assigner = std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { - GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); + GELOGE(ge::FAILED, "[New][Object:VariableMemoryAssigner]graph_id:%u, graph_name:%s", + compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return ge::FAILED; } if (variable_assigner->AssignVarAttr2Nodes() != ge::SUCCESS) { @@ -147,8 +154,10 @@ ge::Status GraphMemoryAssigner::AssignMemory2HasRefAttrNode() { auto variable_assigner = std::unique_ptr(new(std::nothrow) ge::VariableMemoryAssigner(compute_graph_)); if (variable_assigner == nullptr) { - GELOGE(ge::FAILED, "Alloc VariableMemoryAssigner failed."); - return ge::FAILED; + GELOGE(ge::FAILED, "[New][Object:VariableMemoryAssigner]graph_id:%u, graph_name:%s", + compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); } if (variable_assigner->AssignMemory2HasRefAttrNode() != ge::SUCCESS) { return ge::FAILED; @@ -161,17 +170,18 @@ ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &out int64_t &batch_dim_num, int64_t &out_size) { graphStatus graph_status = ge::TensorUtils::GetSize(*output_desc, out_size); if (graph_status != GRAPH_SUCCESS) { - GELOGE(FAILED, "Opdesc GetSize failed!"); + GELOGE(FAILED, "[Get][TensorSize]"); + REPORT_INNER_ERROR("E19999", "New Object:VariableMemoryAssigner failed when assign graph memory"); return FAILED; } GeShape output_shape = output_desc->GetShape(); std::vector output_dims = output_shape.GetDims(); if (dim_index >= static_cast(output_dims.size())) { - std::string error = "Invaild value" + FmtToStr(dim_index) + - " of attr _reuse_input_on_dim_index, which is out of data range [0," - + std::to_string(output_dims.size()) + ")"; - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "Inner param dim_index value:%ld invalid, bigger than dim size:%lu in shape:%s", + dim_index, output_dims.size(), output_shape.ToString().c_str()); + GELOGE(FAILED, "[Check][Param:dim_index]value:%ld invalid, bigger than dim size:%lu in shape:%s", + dim_index, output_dims.size(), output_shape.ToString().c_str()); return FAILED; } @@ -187,14 +197,23 @@ ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &out graph_status = ge::TensorUtils::CalcTensorMemSize(output_shape, out_format, data_type, output_mem_size); if (graph_status != GRAPH_SUCCESS) { - GELOGE(graph_status, "Opdesc CalcTensorMemSize failed!"); + GELOGE(graph_status, "[Calc][TensorSize]"); return FAILED; } if (output_mem_size < 0) { - std::string error = "After calculating tensor memory size, output_mem_size" + FmtToStr(output_mem_size) + - " is out of data range [0," + std::to_string(INT64_MAX) + "]"; - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "After calculating, tensor memory size:%ld invalid, less than 0. " + "shape:%s, format:%s, dtype:%s, maybe has dynamic shape", + output_mem_size, + output_shape.ToString().c_str(), + TypeUtils::FormatToSerialString(out_format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); + GELOGE(FAILED, "[Check][TensorSize]value:%ld invalid after calc, less than 0. shape:%s, format:%s, dtype:%s, " + "maybe has dynamic shape", + output_mem_size, + output_shape.ToString().c_str(), + TypeUtils::FormatToSerialString(out_format).c_str(), + TypeUtils::DataTypeToSerialString(data_type).c_str()); return FAILED; } @@ -203,7 +222,10 @@ ge::Status CalculateTensorRealSizeAndOutSize(const ge::ConstGeTensorDescPtr &out Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map &mem_type_to_offset) { if (memory_offset_.empty()) { - GELOGE(FAILED, "memory_offset_ is empty."); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ empty, not expected when ReAssignMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData:memory_offset_]empty is not expected, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return ge::FAILED; } @@ -218,8 +240,10 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, mapGetSessionID(); if (total_mem_offset > VarManager::Instance(session_id)->GetGraphMemoryMaxSize()) { - GELOGE(ge::FAILED, "Current memoffset %zu is greater than memory manager malloc max size %zu", total_mem_offset, - VarManager::Instance(session_id)->GetGraphMemoryMaxSize()); + GELOGE(ge::FAILED, "[Check][TotalMemOffset] %zu is greater than memory manager malloc max size %zu, " + "graph_id:%u, graph_name:%s, reduce your batchsize or scale your model may solve problem", + total_mem_offset, VarManager::Instance(session_id)->GetGraphMemoryMaxSize(), + 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", @@ -234,7 +258,13 @@ Status GraphMemoryAssigner::ReAssignMemory(bool is_loop_graph, map &mem_offset, size_t &zero_mem_copy_size) { BlockMemAssignerPtr priority_assigner = std::move(mem_assigner_->GetPriorityAssinger()); - GE_IF_BOOL_EXEC(priority_assigner == nullptr, GELOGE(FAILED, "Get priority_assigner failed."); return ge::FAILED;); + if (priority_assigner == nullptr) { + REPORT_INNER_ERROR("E19999", "InnerData priority_assigner nullptr, not expected when AssignZeroCopyMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData:priority_assigner]nullptr is invalid, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + return ge::FAILED; + } size_t mem_offset_tmp = mem_offset[RT_MEMORY_HBM]; @@ -254,8 +284,11 @@ Status GraphMemoryAssigner::AssignZeroCopyMemory(map &mem_offse zero_mem_copy_size = mem_offset[RT_MEMORY_HBM] - mem_offset_tmp; auto iter = memory_offset_.find(RT_MEMORY_HBM); if (iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type[HBM]"; - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " + "not expected when AssignZeroCopyMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } iter->second.mem_offset_ = mem_offset[RT_MEMORY_HBM]; @@ -304,7 +337,7 @@ uint32_t GetContinuousMemoryType(const OpDescPtr &op_desc) { } if (continuous_type != 0) { - GELOGI("Current node %s continuous type %d.", op_desc->GetName().c_str(), continuous_type); + GELOGI("[Get][MemType:Continuous]Current node %s, value is %d", op_desc->GetName().c_str(), continuous_type); } return continuous_type; } @@ -312,8 +345,9 @@ uint32_t GetContinuousMemoryType(const OpDescPtr &op_desc) { Status GetMemorySize(const OpDescPtr &op_desc, const ge::ConstGeTensorDescPtr &output_desc, uint32_t continuous_type, int64_t &tensor_size, int64_t &nopadding_size) { if ((op_desc == nullptr) || (output_desc == nullptr)) { - GELOGE(FAILED, "Input para is nullptr."); - return FAILED; + REPORT_INNER_ERROR("E19999", "InnerData param op_desc or output_desc is nullptr, " + "not expected when GetMemorySize"); + GELOGE(FAILED, "[Check][Param]op_desc or output_desc is nullptr"); } tensor_size = 0; nopadding_size = 0; @@ -322,7 +356,10 @@ Status GetMemorySize(const OpDescPtr &op_desc, const ge::ConstGeTensorDescPtr &o int64_t attr_dim_index; bool get_attr_dim_flag = ge::AttrUtils::GetInt(op_desc, ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX, attr_dim_index); if (!get_attr_dim_flag) { - GELOGE(FAILED, "Get attr _reuse_input_on_dim_index failed."); + REPORT_INNER_ERROR("E19999", "Get Attr:%s failed when GetMemorySize, op_name:%s", + ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX.c_str(), op_desc->GetName().c_str()); + GELOGE(FAILED, "[Get][Attr:%s]fail for op_name:%s", + ATTR_NAME_REUSE_INPUT_ON_DIM_INDEX.c_str(), op_desc->GetName().c_str()); return FAILED; } @@ -330,17 +367,25 @@ Status GetMemorySize(const OpDescPtr &op_desc, const ge::ConstGeTensorDescPtr &o int64_t batch_dim_num = 1; if (CalculateTensorRealSizeAndOutSize(output_desc, attr_dim_index, nopadding_size, batch_dim_num, tensor_size) != SUCCESS) { - GELOGE(FAILED, "CalculateTensorRealSizeAndOutSize failed for node %s.", op_desc->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "CalculateTensorRealSizeAndOutSize failed, attr_dim_index:%ld, op_name:%s", + attr_dim_index, op_desc->GetName().c_str()); + GELOGE(FAILED, "[Calculate][NopaddingSize]failed for node %s, attr_dim_index:%ld", + op_desc->GetName().c_str(), attr_dim_index); return FAILED; } } else { if (ge::TensorUtils::GetSize(*output_desc, tensor_size) != ge::SUCCESS) { - GELOGE(FAILED, "GetSize failed."); + REPORT_INNER_ERROR("E19999", "Get Tensor Size failed, op_name:%s", op_desc->GetName().c_str()); + GELOGE(FAILED, "[Get][TensorSize]failed in padding case, op_name:%s", op_desc->GetName().c_str()); return FAILED; } } if ((tensor_size < 0) || (nopadding_size < 0)) { - GELOGE(FAILED, "GetMemorySize for node %s failed.", op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "GetMemorySize fail, " + "tensor_size:%ld or nopadding_size:%ld less than 0, invalid, op_name:%s", + tensor_size, nopadding_size, op_desc->GetName().c_str()); + GELOGE(FAILED, "[Get][MemorySize]tensor_size:%ld or nopadding_size:%ld less than 0, invalid, op_name:%s", + tensor_size, nopadding_size, op_desc->GetName().c_str()); return FAILED; } return SUCCESS; @@ -374,7 +419,7 @@ bool IsContinuousInputConflict(const ge::NodePtr &node, const OpDescPtr &peer_op // If GetBool fail, is_peer_reference is false. (void) AttrUtils::GetBool(peer_op_desc, ATTR_NAME_REFERENCE, is_peer_reference); GE_IF_BOOL_EXEC(is_peer_reference, - std::string warning = "Current op" + FmtToStr(node->GetOpDesc()->GetName()) + + std::string warning = "[Check][Continuous]Current op" + FmtToStr(node->GetOpDesc()->GetName()) + " requires continuous input, while the previous op" + FmtToStr(peer_op_desc->GetName()) + " is ref. There may be conflict between the two."; GELOGW("%s", warning.c_str()); @@ -404,7 +449,7 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { if (continuous_input) { if (AssignContinuousInputMemoryWithAtomicProcessDirectly(node, node_2_continuous_type)) { GE_CHK_STATUS_RET(AssignContinuousInputMemoryWithAtomicProcess(node, continuous_type), - "Assign node %s continuous input memory failed.", node->GetName().c_str()) + "[Assign][Memory:Continuous:Input]fail for node:%s", node->GetName().c_str()) } else { nodes_stack.push_back(node); } @@ -413,10 +458,11 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { int64_t memory_type = RT_MEMORY_HBM; bool continuous_output = ((continuous_type & kTypeOutput) != 0) || ((continuous_type & kTypeOutputNoPadding) != 0); if (continuous_output) { - GE_CHK_STATUS_RET(GetNodeMemoryType(node, memory_type, "output"), "Get node memory type failed."); + 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 continuous output memory failed!"); + GELOGE(ret, "[Assign][Memory:Continuous:Ouput]fail for node:%s", node->GetName().c_str()); return ret; } } @@ -427,14 +473,16 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { nodes_stack.pop_back(); auto iter = node_2_continuous_type.find(node); if (iter == node_2_continuous_type.end()) { - GELOGE(FAILED, "node %s has no continuous type!", node->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "Inner data error when process continuous memory alloc for node:%s, " + "but has no continuous type", node->GetName().c_str()); + GELOGE(FAILED, "[Get][ContinuousType] find fail for node:%s", node->GetName().c_str()); return FAILED; } GE_CHK_STATUS_RET(AssignContinuousInputMemoryWithAtomicProcess(node, iter->second, true), - "Assign node %s continuous input memory failed.", node->GetName().c_str()) + "[Assign][Memory:Continuous:Input]fail for node:%s.", node->GetName().c_str()) } for (auto pair : memory_offset_) { - GELOGD("After reassign continuous memory, memory type = %ld, memoffset = %zu.", pair.first, + GELOGD("[Reassign][Memory:Continuous]At last, memory type = %ld, mem offset = %zu.", pair.first, pair.second.mem_offset_); } return ge::SUCCESS; @@ -442,11 +490,13 @@ Status GraphMemoryAssigner::ReAssignContinuousMemory(bool is_loop_graph) { 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("Current node %s needs continuous input.", node->GetName().c_str()); + GELOGI("[Assign][Memory:Input:Continuous]start for Current node %s", node->GetName().c_str()); auto iter = memory_offset_.find(memory_type); if (iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type" + FmtToStr(memory_type); - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "find memory offset fail for mem_type:%ld, " + "when assign continuous input memory for node:%s, ", memory_type, node->GetName().c_str()); + GELOGE(FAILED, "[Find][MemOffset]fail for mem_type:%ld, when AssignContinuousInputMemory for node:%s", + memory_type, node->GetName().c_str()); return FAILED; } // The head and tail of hcom continuous input should be added 512 @@ -459,8 +509,9 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, GE_CHECK_NOTNULL(op_desc); vector output_list_this = op_desc->GetOutputOffset(); if (output_list_this.empty()) { - std::string error = "node:" + FmtToStr(op_desc->GetName()) + "has no output offset"; - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "No output offset in node :%s, not expected when assign continuous input memory", + 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); @@ -480,8 +531,9 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, lx_fusion = lx_fusion && !offsets_of_fusion.empty(); if (lx_fusion) { if (peer_out_data_anchor->GetIdx() >= static_cast(offsets_of_fusion.size())) { - std::string error = "fusion: peer node" + FmtToStr(peer_op_desc->GetName()) + - " index" + FmtToStr(peer_out_data_anchor->GetIdx()) + " is out of range."; + std::string error = "fusion: peer node:" + FmtToStr(peer_op_desc->GetName()) + + " anchor_index:" + FmtToStr(peer_out_data_anchor->GetIdx()) + + " is out of range:" + FmtToStr(offsets_of_fusion.size()); GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); return FAILED; } @@ -497,7 +549,9 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, 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 = "index" + FmtToStr(peer_out_data_anchor->GetIdx()) + " is out of range."; + 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; } @@ -506,17 +560,17 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, bool is_allocated_first_input = is_continuous_input_allocated && (in_data_anchor->GetIdx() == 0); if (is_allocated_first_input) { std::map out2ins; - GE_CHK_STATUS_RET(GetAllRef(node, out2ins), "Node: %s get all ref failed", node->GetName().c_str()); + GE_CHK_STATUS_RET(GetAllRef(node, out2ins), "[Get][AllRef]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("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); + 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(), + 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 @@ -542,7 +596,7 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, } 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[%d].", node->GetOwnerComputeGraph()->GetName().c_str(), + "size[%zu] realsize[%ld] nopadding size[%d]", node->GetOwnerComputeGraph()->GetName().c_str(), peer_op_desc->GetName().c_str(), node->GetType().c_str(), peer_out_data_anchor->GetIdx(), output_list.at(peer_out_data_anchor->GetIdx()), peer_op_desc->GetStreamId(), memory_type, is_continuous_input_allocated ? 0UL : align_size, real_size, is_nopadding); @@ -563,17 +617,32 @@ Status GraphMemoryAssigner::AssignContinuousInputMemory(const ge::NodePtr &node, Status GetFirstInputPeerOutOutputOffset(const ge::NodePtr &node, int64_t &mem_offset) { auto in_data_anchor_list = node->GetAllInDataAnchors(); if (in_data_anchor_list.empty()) { - GELOGE(FAILED, "Node %s's in data anchor is empty.", node->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "InAnchor list empty in node:%s, not expect when GetFirstInputPeerOutOutputOffset", + node->GetName().c_str()); + GELOGE(FAILED, "[Get][InAnchor]empty is invalid, node:%s", node->GetName().c_str()); return FAILED; } auto peer_out_data_anchor = in_data_anchor_list.at(0)->GetPeerOutAnchor(); - GE_IF_BOOL_EXEC(peer_out_data_anchor == nullptr, GELOGE(ge::FAILED, "peer_out_data_anchor is null."); + GE_IF_BOOL_EXEC(peer_out_data_anchor == nullptr, + REPORT_INNER_ERROR("E19999", "PeerAcnhor is null, " + "not expect when GetFirstInputPeerOutOutputOffset for node:%s", + node->GetName().c_str()); + GELOGE(ge::FAILED, "[Check][PeerAnchor]null is invalid, node:%s", node->GetName().c_str()); return ge::FAILED); auto peer_op_desc = peer_out_data_anchor->GetOwnerNode()->GetOpDesc(); - GE_IF_BOOL_EXEC(peer_op_desc == nullptr, GELOGE(ge::FAILED, "peer_op_desc is null."); return ge::FAILED); + GE_IF_BOOL_EXEC(peer_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "PeerOpDesc is null, " + "not expect when GetFirstInputPeerOutOutputOffset for node:%s", + node->GetName().c_str()); + GELOGE(ge::FAILED, "[Check][PeerOpDesc]null is invalid, node:%s", node->GetName().c_str()); + return ge::FAILED); vector in_node_output_offsets = peer_op_desc->GetOutputOffset(); if (peer_out_data_anchor->GetIdx() >= static_cast(in_node_output_offsets.size())) { - GELOGE(FAILED, "Index : %d is out of range.", peer_out_data_anchor->GetIdx()); + REPORT_INNER_ERROR("E19999", "PeerAnchorIndex:%d bigger than in_offset size:%lu, " + "judge invalid when GetFirstInputPeerOutOutputOffset for node:%s", + peer_out_data_anchor->GetIdx(), in_node_output_offsets.size(), node->GetName().c_str()); + GELOGE(FAILED, "[Check][Index:PeerOutDataAnchor]PeerIndex:%d bigger than in_offset size:%lu, node:%s", + peer_out_data_anchor->GetIdx(), in_node_output_offsets.size(), node->GetName().c_str()); return FAILED; } mem_offset = in_node_output_offsets.at(peer_out_data_anchor->GetIdx()); @@ -584,11 +653,18 @@ Status GraphMemoryAssigner::AssignContinuousOutputMemory(const ge::NodePtr &node uint32_t continuous_type) { GELOGI("Current node %s needs continuous output.", node->GetName().c_str()); auto out_op_desc = node->GetOpDesc(); - GE_IF_BOOL_EXEC(out_op_desc == nullptr, GELOGE(ge::FAILED, "out_op_desc is null."); return ge::FAILED); + GE_IF_BOOL_EXEC(out_op_desc == nullptr, + REPORT_INNER_ERROR("E19999", "OpDesc is null, " + "not expect when AssignContinuousOutputMemory for node:%s", + node->GetName().c_str()); + GELOGE(ge::FAILED, "[Check][OpDesc]null is invalid, node:%s", node->GetName().c_str())); vector output_list = out_op_desc->GetOutputOffset(); if ((out_op_desc->GetOutputsSize() > output_list.size()) || (output_list.size() == 0)) { - GELOGE(ge::FAILED, "The size %zu of node output desc is more than output_list's size %zu.", - out_op_desc->GetOutputsSize(), output_list.size()); + REPORT_INNER_ERROR("E19999", "Output size:%zu more than output offset size:%zu, invalid in node:%s, " + "when AssignContinuousOutputMemory", + out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); + GELOGE(ge::FAILED, "[Check][InnerData]Output size:%zu more than output offset size:%zu, invalid in node:%s", + out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); return ge::FAILED; } @@ -647,14 +723,18 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { map> connecting_output_atomic_nodes; Status status = FilterAtomicNodesForMemoryAssign(normal_atomic_and_clean_nodes_map, connecting_output_atomic_nodes); if (status != SUCCESS) { - GELOGE(status, "Failed to filter atomic nodes for memory assignment."); + GELOGE(status, "[Filter][AtomicNode]failed in graph_id:%u, graph_name:%s", + compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return status; } auto mem_iter = memory_offset_.find(RT_MEMORY_HBM); if (mem_iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " + "not expected when ReAssignAtomicMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } @@ -670,7 +750,7 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { vector mem_offset_end; status = AssignAtomicOutputAndWorkspaceMemory(atomic_node, mem_offset_end); if (status != SUCCESS) { - GELOGE(status, "Assign atomic output and workspace memory failed, node name is %s.", + GELOGE(status, "[Assign][Memory]output atomic mem and workspace mem, fail for node name is %s.", atomic_node->GetName().c_str()); return status; } @@ -679,7 +759,7 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { int64_t atomic_mem_size = static_cast(mem_iter->second.mem_offset_) - atomic_mem_start; if (atomic_mem_size != 0) { GE_CHK_STATUS_RET(SetAtomicCleanAttr(iter.first, {atomic_mem_start}, {atomic_mem_size}, RT_MEMORY_HBM), - "Failed to set attr for atomic addr clean node %s.", iter.first->GetName().c_str()); + "[Set][Attr]fail for atomic addr clean node %s.", iter.first->GetName().c_str()); } } batch_max_mem_offset = std::max(batch_max_mem_offset, static_cast(mem_iter->second.mem_offset_)); @@ -690,7 +770,8 @@ Status GraphMemoryAssigner::ReAssignAtomicMemory(bool is_loop_graph) { for (auto &iter_batch : connecting_output_atomic_nodes) { mem_iter->second.mem_offset_ = batch_atomic_mem_start; if (AssignConnectNetOutputAtomicMemory(iter_batch.second) != SUCCESS) { - GELOGE(FAILED, "Failed to assign memory of nodes that connect to netoutput."); + GELOGE(FAILED, "[Assign][Memory]for nodes that connect to netoutput failed." + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } batch_max_mem_offset = std::max(batch_max_mem_offset, static_cast(mem_iter->second.mem_offset_)); @@ -721,9 +802,10 @@ Status GraphMemoryAssigner::FilterAtomicNodesForMemoryAssign( // If GetBool fail, is_reference is false. (void) ge::AttrUtils::GetBool(peer_in_node_desc, ATTR_NAME_REFERENCE, is_reference); if (is_reference) { - std::string error = "Op" + FmtToStr(peer_in_node_desc->GetName()) + - " cannot have both atomic and is_reference attribute."; - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "Op:%s cannot have both atomic and is_reference attribute, " + "not support now", peer_in_node_desc->GetName().c_str()); + GELOGE(FAILED, "[Check][Attr]Op:%s cannot have both atomic and is_reference attribute, " + "not support now", peer_in_node_desc->GetName().c_str()); return ge::PARAM_INVALID; } @@ -761,7 +843,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP // Assign atomic node output memory Status ret = AssignAtomicOutputMemory(node, mem_offset_end); if (ret != SUCCESS) { - GELOGE(ret, "Failed to assign atomic output memory, node is %s.", node_op_desc->GetName().c_str()); + GELOGE(ret, "[Assign][Memory:Ouput:Atomic]Failed for node:%s.", node_op_desc->GetName().c_str()); return ret; } @@ -781,7 +863,7 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP ret = AssignOrdinaryAtomicWorkspaceMemory(node_op_desc, atomic_workspace_info, mem_offset_end); } if (ret != SUCCESS) { - GELOGE(ret, "Assign atomic workspace memory failed, node is %s.", node_op_desc->GetName().c_str()); + GELOGE(ret, "[Assign][Memory:Atomic:Workspace]fail for node:%s.", node_op_desc->GetName().c_str()); return ret; } } else { @@ -794,8 +876,11 @@ Status GraphMemoryAssigner::AssignAtomicOutputAndWorkspaceMemory(const ge::NodeP Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector &connect_netoutput_nodes) { auto iter = memory_offset_.find(RT_MEMORY_HBM); if (iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " + "not expected when AssignConnectNetOutputAtomicMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } for (auto &node : connect_netoutput_nodes) { @@ -811,13 +896,14 @@ Status GraphMemoryAssigner::AssignConnectNetOutputAtomicMemory(vector & node->GetName().c_str(), node->GetOpDesc()->GetType().c_str(), original_atomic_mem_start); vector mem_offset_end; if (AssignAtomicOutputAndWorkspaceMemory(node, mem_offset_end) != SUCCESS) { - GELOGE(FAILED, "Assign atomic output and workspace memory failed, node is %s.", node->GetName().c_str()); + GELOGE(FAILED, "[Assign][Memory]output atomic mem and workspace mem, fail for node name is %s.", + node->GetName().c_str()); return FAILED; } // All atomic nodes use atomic_addr_clean op independently, so we need to set the attr separately. if (SetIndependentAtomicAttr(node, original_atomic_mem_start, mem_offset_end, RT_MEMORY_HBM) != SUCCESS) { - GELOGE(FAILED, "Failed to set atomic attr separately."); + GELOGE(FAILED, "[Set][Attr:IndependentAtomic]fail for node:%s", node->GetName().c_str()); return FAILED; } } @@ -842,8 +928,11 @@ Status GraphMemoryAssigner::AssignReferenceMemory() { vector output_list = out_op_desc->GetOutputOffset(); if (out_op_desc->GetOutputsSize() > output_list.size()) { - GELOGE(ge::FAILED, "The size %zu of node output desc is more than output_list's size %zu.", - out_op_desc->GetOutputsSize(), output_list.size()); + REPORT_INNER_ERROR("E19999", "Output size:%zu more than output offset size:%zu, judge invalid in node:%s " + "when AssignReferenceMemory", + out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); + GELOGE(ge::FAILED, "[Check][InnerData]Output size:%zu more than output offset size:%zu, invalid in node:%s", + out_op_desc->GetOutputsSize(), output_list.size(), node->GetName().c_str()); return ge::FAILED; } @@ -896,9 +985,12 @@ bool GraphMemoryAssigner::CheckInputIsSupportAtomic(const ge::NodePtr &node) { } if ((peer_op_desc->GetType() == CONSTANTOP) || (peer_op_desc->GetType() == AIPP_DATA_TYPE) || (peer_op_desc->GetType() == VARIABLE)) { - std::string error = "Op" + FmtToStr(node->GetName()) + "'s peer out node" + - FmtToStr(peer_op_desc->GetName()) + " is invalid, Constant/AippData/Variable is not supported"; - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "node(type:%s, name:%s) link to atomic node(name:%s), " + "this situation not supported now", + peer_op_desc->GetType().c_str(), peer_op_desc->GetName().c_str(), node->GetName().c_str()); + GELOGE(ge::FAILED, "[Check][Link]node(type:%s, name:%s) link to atomic node(name:%s), " + "this situation not supported now", + peer_op_desc->GetType().c_str(), peer_op_desc->GetName().c_str(), node->GetName().c_str()); return false; } } @@ -918,22 +1010,27 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve // Check atomic output vector output_list = op_desc->GetOutputOffset(); if (atomic_output_index.size() > output_list.size()) { - std::string error = "Op" + FmtToStr(node->GetName()) + - "'s size of atomic_output_index is more than the size of output_list"; + std::string error = + "Op:" + FmtToStr(node->GetName()) + "'s size:" + FmtToStr(atomic_output_index.size()) + + " of atomic_output_index is more than the size:" + FmtToStr(output_list.size()) + " of output_list"; GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); return ge::FAILED; } auto output_list_size = static_cast(output_list.size()); auto iter = memory_offset_.find(RT_MEMORY_HBM); if (iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " + "not expected when AssignAtomicOutputMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } for (auto &output_index : atomic_output_index) { if (output_index >= output_list_size) { - std::string error = "Op" + FmtToStr(node->GetName()) + "'s output index" + FmtToStr(output_index) + - " is more than the size" + FmtToStr(output_list_size) + " of output_list."; + std::string error = + "Op:" + FmtToStr(node->GetName()) + "'s atomic_output index:" + FmtToStr(output_index) + + " is more than the size:" + FmtToStr(output_list_size) + " of output_list."; GE_ERRORLOG_AND_ERRORMSG(ge::PARAM_INVALID, error.c_str()); return ge::PARAM_INVALID; } @@ -941,7 +1038,8 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve // If the input of the cascade op needs to clear the atomic addr, there is no need to clear it separately here bool is_assigned_mem = false; if (GetMemoryAssignmentStatus(node, output_index, is_assigned_mem) != SUCCESS) { - GELOGE(ge::FAILED, "Failed to get memory assignment of node %s.", node->GetName().c_str()); + GELOGE(ge::FAILED, "[Get][MemoryAssignmentStatus]fail for node %s, out_index:%ld", + node->GetName().c_str(), output_index); return ge::FAILED; } @@ -981,8 +1079,9 @@ Status GraphMemoryAssigner::AssignAtomicOutputMemory(const ge::NodePtr &node, ve Status GraphMemoryAssigner::GetMemoryAssignmentStatus(const ge::NodePtr &node, int64_t output_index, bool &is_mem_assigned) { if (static_cast(output_index) >= node->GetAllOutDataAnchors().size()) { - std::string error = "Op" + FmtToStr(node->GetName()) + "'s output index" + FmtToStr(output_index) + - " is more than the size of node's AllOutDataAnchors."; + std::string error = + "Op:" + FmtToStr(node->GetName()) + "'s output index:" + FmtToStr(output_index) + + " is more than the size:" + FmtToStr(node->GetAllOutDataAnchors().size()) + " of node's AllOutDataAnchors."; GE_ERRORLOG_AND_ERRORMSG(ge::PARAM_INVALID, error.c_str()); return ge::PARAM_INVALID; } @@ -1010,8 +1109,11 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc GELOGI("Begin to reassign normal atomic memory, node = %s.", op_desc->GetName().c_str()); auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); if (mem_type_iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " + "not expected when AssignOrdinaryAtomicWorkspaceMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } vector workspace_vector = op_desc->GetWorkspace(); @@ -1032,8 +1134,9 @@ Status GraphMemoryAssigner::AssignOrdinaryAtomicWorkspaceMemory(const ge::OpDesc auto workspace_index = static_cast(info_iter.first); auto workspace_size = info_iter.second; if (workspace_index >= workspace_vector.size()) { - std::string error = "The workspace index" + FmtToStr(workspace_index) + - " is more than the size" + FmtToStr(workspace_vector.size()) + " of workspace vector."; + std::string error = "The workspace index:" + FmtToStr(workspace_index) + + " is more than the size:" + FmtToStr(workspace_vector.size()) + " of workspace vector in op:" + + op_desc->GetName().c_str(); GE_ERRORLOG_AND_ERRORMSG(ge::PARAM_INVALID, error.c_str()); return ge::PARAM_INVALID; } @@ -1063,8 +1166,11 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt GELOGI("Begin to reassign fusion atomic memory, node = %s.", op_desc->GetName().c_str()); auto mem_type_iter = memory_offset_.find(RT_MEMORY_HBM); if (mem_type_iter == memory_offset_.end()) { - std::string error = "Memory offset does not have memory type" + FmtToStr(RT_MEMORY_HBM); - GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ does not have type[HBM], " + "not expected when AssignFusionAtomicWorkspaceMemory, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData]memory_offset_ does not have memory type[HBM]" + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); return FAILED; } map> sub_node_workspace_offset; @@ -1095,7 +1201,10 @@ Status GraphMemoryAssigner::AssignFusionAtomicWorkspaceMemory(const ge::OpDescPt sub_node_workspace_offset.insert(std::make_pair(iter.first, index_offset)); } if (!(op_desc->SetExtAttr(EXT_ATTR_ATOMIC_WORKSPACE_OFFSET, sub_node_workspace_offset))) { - GELOGE(FAILED, "Set EXT_ATTR_ATOMIC_WORKSPACE_OFFSET failed, op name:%s.", op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "Set Attr:%s fail for node:%s when AssignFusionAtomicWorkspaceMemory", + EXT_ATTR_ATOMIC_WORKSPACE_OFFSET.c_str(), op_desc->GetName().c_str()); + GELOGE(FAILED, "[Set][Attr:%s]fail for node:%s.", + EXT_ATTR_ATOMIC_WORKSPACE_OFFSET.c_str(), op_desc->GetName().c_str()); return FAILED; } @@ -1106,7 +1215,7 @@ Status GraphMemoryAssigner::CheckOffset() { std::map anchor_to_symbol; std::map> symbol_to_anchors; if (GraphUtils::GetRefMapping(compute_graph_, symbol_to_anchors, anchor_to_symbol) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Get ref-mapping for graph %s failed.", compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Get][RefMapping]fail for graph %s", compute_graph_->GetName().c_str()); return FAILED; } for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { @@ -1148,7 +1257,6 @@ Status GraphMemoryAssigner::CheckOffset() { std::string error = "Invalid workspace" + FmtToStr(ge::kInvalidOffset) + + " in node" + FmtToStr(node->GetName()); GE_ERRORLOG_AND_ERRORMSG(FAILED, error.c_str()); - GELOGE(FAILED, "Invalid workspace in node: %s workspace: %ld.", node->GetName().c_str(), ge::kInvalidOffset); return FAILED; } } @@ -1158,8 +1266,10 @@ Status GraphMemoryAssigner::CheckOffset() { ge::Status GraphMemoryAssigner::SetInputOffset() { if (memory_offset_.empty()) { - GELOGE(FAILED, "memory_offset_ is empty."); - return FAILED; + REPORT_INNER_ERROR("E19999", "InnerData memory_offset_ empty, not expected when SetInputOffset, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); + GELOGE(FAILED, "[Check][InnerData:memory_offset_]empty is not expected, " + "graph_id:%u, graph_name:%s", compute_graph_->GetGraphID(), compute_graph_->GetName().c_str()); } for (auto pair : memory_offset_) { GEEVENT("[IMAS]AfterAssignMemory : %s memoffset[%zu], memtype[%ld]", compute_graph_->GetName().c_str(), @@ -1168,7 +1278,7 @@ ge::Status GraphMemoryAssigner::SetInputOffset() { for (const ge::NodePtr &node : compute_graph_->GetAllNodes()) { if (UpdateOpInputOffset(node) != ge::SUCCESS) { - GELOGE(ge::FAILED, "Update op input offset failed"); + GELOGE(ge::FAILED, "[Update][Offset:Input]fail for op:%s", node->GetName().c_str()); return ge::FAILED; } } @@ -1316,12 +1426,12 @@ ge::Status GraphMemoryAssigner::UpdateOpInputOffset(const NodePtr &node) const { } } else if (node->GetType() == DATA_TYPE) { if (UpdateConstArgsOffset(node, input_list) != SUCCESS) { - GELOGE(FAILED, "Update data: %s args offset failed.", node->GetName().c_str()); + GELOGE(FAILED, "[Update][Offset:Input:Const]fail for node:%s ", node->GetName().c_str()); return FAILED; } } else { if (UpdateOpInputOffset(node, input_list) != SUCCESS) { - GELOGE(FAILED, "Update node: %s input offset failed.", node->GetName().c_str()); + GELOGE(FAILED, "[Update][Offset:Input]fail for node:%s", node->GetName().c_str()); return FAILED; } } @@ -1361,7 +1471,7 @@ Status GraphMemoryAssigner::SetIndependentAtomicAttr(const ge::NodePtr &node, in peer_out_node_desc->GetName().c_str(), peer_out_node_desc->GetType().c_str()); if (peer_out_node_desc->GetType() == ATOMICADDRCLEAN) { if (SetAtomicCleanAttr(peer_out_node, memory_offset_start, memory_offset_size, memory_type) != SUCCESS) { - GELOGE(FAILED, "Set atomic clean attr failed."); + GELOGE(FAILED, "[Set][AtomicCleanAttr]fail for node:%s", peer_out_node->GetName().c_str()); return FAILED; } } @@ -1387,7 +1497,10 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector); mem_start_vector.insert(mem_start_vector.end(), atomic_mem_start.begin(), atomic_mem_start.end()); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_START, mem_start_vector), - GELOGE(FAILED, "SetListInt failed."); + REPORT_INNER_ERROR("E19999", "Set Attr:%s failed when SetAtomicCleanAttr, op_name:%s", + ATTR_NAME_AUTOMIC_ADD_START.c_str(), node_op_desc->GetName().c_str()); + GELOGE(FAILED, "[Set][Attr:%s]fail for op_name:%s", + ATTR_NAME_AUTOMIC_ADD_START.c_str(), node_op_desc->GetName().c_str()); return FAILED); std::vector mem_size_vector; @@ -1395,7 +1508,10 @@ ge::Status GraphMemoryAssigner::SetAtomicCleanAttr(const NodePtr &node, const ve (void) ge::AttrUtils::GetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector); mem_size_vector.insert(mem_size_vector.end(), atomic_mem_size.begin(), atomic_mem_size.end()); GE_CHK_BOOL_EXEC(ge::AttrUtils::SetListInt(node_op_desc, ATTR_NAME_AUTOMIC_ADD_MEM_SIZE, mem_size_vector), - GELOGE(FAILED, "SetListInt failed."); + REPORT_INNER_ERROR("E19999", "Set Attr:%s failed when SetAtomicCleanAttr, op_name:%s", + ATTR_NAME_AUTOMIC_ADD_MEM_SIZE.c_str(), node_op_desc->GetName().c_str()); + GELOGE(FAILED, "[Set][Attr:%s]fail for op_name:%s", + ATTR_NAME_AUTOMIC_ADD_MEM_SIZE.c_str(), node_op_desc->GetName().c_str()); return FAILED); std::stringstream ss; @@ -1437,12 +1553,14 @@ ge::Status GraphMemoryAssigner::GetNodeListMemoryType(const vector &nod // In the dynamic batch scenario, the memory attributes of nodes are the same. for (auto &n : nodes) { if (mem_reuse_model == kVirtualInputNodeMemoryReuse) { - GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), "Get node memory type failed.") + GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "input"), + "[Get][MemType:input]fail for node:%s", n->GetName().c_str()) break; } if (mem_reuse_model == kVirtualOutputNodeMemoryReuse) { - GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), "Get node memory type failed."); + GE_CHK_STATUS_RET(GetNodeMemoryType(n, memory_type, "output"), + "[Get][MemType:output]fail for node:%s", n->GetName().c_str()) break; } } @@ -1478,7 +1596,7 @@ ge::Status GraphMemoryAssigner::GetNodeMemoryType(const NodePtr &node, int64_t & } if (!CheckContinuousMemType(mem_type_list)) { - GELOGE(FAILED, "Check continuous memory type failed."); + GELOGE(FAILED, "[Check][MemType:Continuous]fail for node:%s", node->GetName().c_str()); return FAILED; } // It is continuous memory and memory type is the same, so use the first memory. @@ -1526,7 +1644,11 @@ ge::Status GraphMemoryAssigner::GetAllRef(const NodePtr &node, mapGetInDataAnchor(reuse_in_index) != nullptr) { out2ins.emplace(out_data_anchor->GetIdx(), reuse_in_index); } else { - GELOGE(FAILED, "Invalid reuse_input value %d on output %d of node %s, please check attr reuse_input", + REPORT_INNER_ERROR("E19999", "Invalid reuse_input value %d on output %d of node %s, " + "please check attr reuse_input", + reuse_in_index, out_data_anchor->GetIdx(), node->GetName().c_str()); + GELOGE(FAILED, "[Check][Attr]Invalid reuse_input value %d on output %d of node %s, " + "please check attr reuse_input", reuse_in_index, out_data_anchor->GetIdx(), node->GetName().c_str()); return FAILED; } @@ -1549,7 +1671,7 @@ bool GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcessDirectly( auto continuous_type = iter->second; bool continuous_input = ((continuous_type & kTypeInput) != 0) || ((continuous_type & kTypeInputNoPadding) != 0); if (continuous_input) { - GELOGI("node %s 's precursor node %s need assign continuous input memory, store node firstly.", + GELOGI("[Store][Node] of %s cause it's precursor node %s need assign continuous input memory", input_continuous_node->GetName().c_str(), in_node->GetName().c_str()); return false; } @@ -1559,7 +1681,7 @@ bool GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcessDirectly( node_2_continuous_type.emplace(out_node, continuous_type); bool continuous_input = ((continuous_type & kTypeInput) != 0) || ((continuous_type & kTypeInputNoPadding) != 0); if (continuous_input) { - GELOGI("node %s 's succeed node %s need assign continuous input memory, store node firstly.", + GELOGI("[Store][Node] of %s cause it's succeed node %s need assign continuous input memory", input_continuous_node->GetName().c_str(), out_node->GetName().c_str()); return false; } @@ -1575,11 +1697,12 @@ ge::Status GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcess(con int64_t mem_clean_size = 0; int64_t memory_type = RT_MEMORY_HBM; - GE_CHK_STATUS_RET(GetNodeMemoryType(input_continuous_node, memory_type, "input"), "Get node memory type failed."); + GE_CHK_STATUS_RET(GetNodeMemoryType(input_continuous_node, memory_type, "input"), + "[Get][MemType]fail for node:%s", input_continuous_node->GetName().c_str()); auto ret = AssignContinuousInputMemory(input_continuous_node, mem_clean_start, mem_clean_size, memory_type, continuous_type, reverse_refresh); if (ret != ge::SUCCESS) { - GELOGE(ret, "Assign continuous input memory failed!"); + GELOGE(ret, "[Assign][Memory:Input:continuous]fail for node:%s", input_continuous_node->GetName().c_str()); return ret; } @@ -1590,7 +1713,6 @@ ge::Status GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcess(con if (!input_indexes.empty() && input_indexes[0] == kAllInputAddrIsAtomic) { // check whether there is an atomic conflict between the current node and the peer out node if (!CheckInputIsSupportAtomic(input_continuous_node)) { - GELOGE(ge::FAILED, "There is an atomic conflict between the current node and the peer out node, not supported!"); return ge::FAILED; } @@ -1602,7 +1724,7 @@ ge::Status GraphMemoryAssigner::AssignContinuousInputMemoryWithAtomicProcess(con if (peer_out_node->GetType() == ATOMICADDRCLEAN) { ret = SetAtomicCleanAttr(peer_out_node, {mem_clean_start}, {mem_clean_size}, memory_type); if (ret != SUCCESS) { - GELOGE(ret, "Failed to set attr for atomic addr clean node %s.", peer_out_node->GetName().c_str()); + GELOGE(ret, "[Set][AtomicCleanAttr]fail for node:%s", peer_out_node->GetName().c_str()); return ret; } } diff --git a/ge/graph/build/model_builder.cc b/ge/graph/build/model_builder.cc index 7256c7be..1a14374d 100755 --- a/ge/graph/build/model_builder.cc +++ b/ge/graph/build/model_builder.cc @@ -261,7 +261,9 @@ Status ModelBuilder::SetInputOutputDesc() { GE_IF_BOOL_EXEC(n->GetInAllNodes().empty() && n->GetOutAllNodes().empty(), continue;); SetInputIsConst(n); - if (IsGeLocalOp(n->GetOpDesc())) { + bool is_unknow = false; + (void)NodeUtils::GetNodeUnknownShapeStatus(*n, is_unknow); + if ((IsGeLocalOp(n->GetOpDesc())) && (!is_unknow)) { GE_CHK_STATUS_RET(CalcOutputSize(n), "Calculate output size failed"); } ret = AdjustConstWeightSize(n, weight_offset_); @@ -364,8 +366,11 @@ void ModelBuilder::InitL1FusionOption() { string buffer_optimize = "off_optimize"; graphStatus ret = ge::GetContext().GetOption(BUFFER_OPTIMIZE, buffer_optimize); if (ret == GRAPH_SUCCESS) { - is_l1_fusion_enable_ = (buffer_optimize == "l1_optimize"); - GELOGD("The value of %s is %s.", BUFFER_OPTIMIZE.c_str(), buffer_optimize.c_str()); + bool off_superkernel = false; + (void)AttrUtils::GetBool(compute_graph_, ATTR_NAME_OFF_SUPERKERNEL_ATTR, off_superkernel); + is_l1_fusion_enable_ = ((buffer_optimize == "l1_optimize") && (!off_superkernel)); + GELOGI("Compute graph %s the value of %s is %s, superkernel flag %d.", compute_graph_->GetName().c_str(), + BUFFER_OPTIMIZE.c_str(), buffer_optimize.c_str(), is_l1_fusion_enable_); } else { GELOGW("The value of %s is empty.", kEnableL1Fusion.c_str()); } @@ -707,7 +712,7 @@ Status ModelBuilder::BuildModelForGetTask(ge::Model &model) { GE_TIMESTAMP_START(SetInputOutputOffset); SetInputOutputOffsetPass input_output_offset; GE_CHK_STATUS_RET(input_output_offset.Run(compute_graph_), "Set input output offset failed."); - GE_TIMESTAMP_END(SetInputOutputOffset, "SetInputOutputOffsetPass::Run."); + GE_TIMESTAMP_END(SetInputOutputOffset, "SetInputOutputOffsetPass::Run"); // Compile single op in graph build stage GE_TIMESTAMP_START(CompileSingleOp); diff --git a/ge/graph/execute/graph_execute.cc b/ge/graph/execute/graph_execute.cc index dd7e50ea..5212f279 100755 --- a/ge/graph/execute/graph_execute.cc +++ b/ge/graph/execute/graph_execute.cc @@ -361,6 +361,10 @@ Status GraphExecutor::ExecuteGraphWithStream(GraphId graph_id, std::vector &output_tensor, rtStream_t stream) { GELOGI("[GraphExecutor] Start to execute graph with stream, graph_id=%u", graph_id); + if (!init_flag_) { + GELOGE(GE_GRAPH_EXECUTE_NOT_INIT, "[GraphExecutor] AI Core Engine without calling SetCondition!"); + return GE_GRAPH_EXECUTE_NOT_INIT; + } if (graph_id != last_graph_id_) { auto ret = FreeExecuteMemory(); if (ret != SUCCESS) { @@ -368,11 +372,6 @@ Status GraphExecutor::ExecuteGraphWithStream(GraphId graph_id, } } last_graph_id_ = graph_id; - - if (!init_flag_) { - GELOGE(GE_GRAPH_EXECUTE_NOT_INIT, "[GraphExecutor] AI Core Engine without calling SetCondition!"); - return GE_GRAPH_EXECUTE_NOT_INIT; - } GE_CHECK_NOTNULL_EXEC(ge_root_model, return FAILED); auto model_manager = ge::ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); @@ -382,11 +381,11 @@ Status GraphExecutor::ExecuteGraphWithStream(GraphId graph_id, return model_manager->SyncExecuteModel(model_id, input_tensor, output_tensor); } - std::vector inputs_desc; + std::vector input_desc; std::vector output_desc; GELOGI("[ExecuteGraph] GetInputOutputDescInfo via new ome begin."); - Status ret = GetInputOutputDescInfo(model_id, inputs_desc, output_desc); + Status ret = GetInputOutputDescInfo(model_id, input_desc, output_desc); if (ret != SUCCESS) { GELOGE(GE_GRAPH_GET_IN_OUT_FAILED, "[GraphExecutor] GetInputOutputDescInfo failed, modelId=%u.", model_id); return GE_GRAPH_GET_IN_OUT_FAILED; diff --git a/ge/graph/load/model_manager/data_dumper.cc b/ge/graph/load/model_manager/data_dumper.cc index 235cffa9..5f48fe8e 100644 --- a/ge/graph/load/model_manager/data_dumper.cc +++ b/ge/graph/load/model_manager/data_dumper.cc @@ -385,7 +385,7 @@ Status DataDumper::DumpRefOutput(const DataDumper::InnerDumpInfo &inner_dump_inf Status DataDumper::DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task) { const auto &output_descs = inner_dump_info.op->GetAllOutputsDesc(); - const std::vector output_addrs = ModelUtils::GetOutputDataAddrs(runtime_param_, inner_dump_info.op); + const std::vector output_addrs = ModelUtils::GetOutputDataAddrs(*runtime_param_, inner_dump_info.op); if (output_descs.size() != output_addrs.size()) { GELOGE(PARAM_INVALID, "Invalid output desc addrs size %zu, op %s has %zu output desc.", output_addrs.size(), inner_dump_info.op->GetName().c_str(), output_descs.size()); @@ -436,7 +436,7 @@ Status DataDumper::DumpOutput(const InnerDumpInfo &inner_dump_info, aicpu::dump: // else data, const or variable op aicpu::dump::Output output; auto output_tensor = inner_dump_info.op->GetOutputDescPtr(inner_dump_info.output_anchor_index); - const std::vector output_addrs = ModelUtils::GetOutputDataAddrs(runtime_param_, inner_dump_info.op); + const std::vector output_addrs = ModelUtils::GetOutputDataAddrs(*runtime_param_, inner_dump_info.op); if (output_tensor == nullptr) { GELOGE(PARAM_INVALID, "output_tensor is null, index: %d, size: %zu.", inner_dump_info.output_anchor_index, inner_dump_info.op->GetOutputsSize()); @@ -540,7 +540,7 @@ Status DataDumper::DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info Status DataDumper::DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task) { GELOGI("Start dump input"); const auto &input_descs = inner_dump_info.op->GetAllInputsDesc(); - const std::vector input_addrs = ModelUtils::GetInputDataAddrs(runtime_param_, inner_dump_info.op); + const std::vector input_addrs = ModelUtils::GetInputDataAddrs(*runtime_param_, inner_dump_info.op); if (input_descs.size() != input_addrs.size()) { GELOGE(PARAM_INVALID, "Invalid input desc addrs size %zu, op %s has %zu input desc.", input_addrs.size(), inner_dump_info.op->GetName().c_str(), input_descs.size()); diff --git a/ge/graph/load/model_manager/data_dumper.h b/ge/graph/load/model_manager/data_dumper.h index 8e612688..06b42afd 100755 --- a/ge/graph/load/model_manager/data_dumper.h +++ b/ge/graph/load/model_manager/data_dumper.h @@ -36,7 +36,7 @@ namespace ge { class DataDumper { public: - explicit DataDumper(const RuntimeParam &rsh) + explicit DataDumper(RuntimeParam *rsh) : model_name_(), model_id_(0), runtime_param_(rsh), @@ -106,7 +106,7 @@ class DataDumper { std::string om_name_; uint32_t model_id_; - const RuntimeParam &runtime_param_; + RuntimeParam *runtime_param_; void *dev_mem_load_; void *dev_mem_unload_; @@ -125,10 +125,9 @@ class DataDumper { uintptr_t loop_per_iter_; uintptr_t loop_cond_; ComputeGraphPtr compute_graph_; // release after DavinciModel::Init - std::map ref_info_; // release after DavinciModel::Init + std::map ref_info_; // release after DavinciModel::Init void *l1_fusion_addr_ = nullptr; - uint32_t op_debug_task_id_ = 0; uint32_t op_debug_stream_id_ = 0; void *op_debug_addr_ = nullptr; @@ -144,20 +143,16 @@ class DataDumper { Status DumpOutputWithTask(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpInput(const InnerDumpInfo &inner_dump_info, aicpu::dump::Task &task); Status DumpRefInput(const DataDumper::InnerDumpInfo &inner_dump_info, aicpu::dump::Input &input, size_t i, - const std::string &node_name_index); + const std::string &node_name_index); Status ExecuteLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); void SetEndGraphIdToAicpu(uint32_t task_id, uint32_t stream_id, aicpu::dump::OpMappingInfo &op_mapping_info); void SetOpDebugIdToAicpu(uint32_t task_id, uint32_t stream_id, void *op_debug_addr, aicpu::dump::OpMappingInfo &op_mapping_info); Status ExecuteUnLoadDumpInfo(aicpu::dump::OpMappingInfo &op_mapping_info); - Status GenerateInput(aicpu::dump::Input &input, - const OpDesc::Vistor &tensor_descs, - const uintptr_t &addr, - size_t index); - Status GenerateOutput(aicpu::dump::Output &output, - const OpDesc::Vistor &tensor_descs, - const uintptr_t &addr, - size_t index); + Status GenerateInput(aicpu::dump::Input &input, const OpDesc::Vistor &tensor_descs, + const uintptr_t &addr, size_t index); + Status GenerateOutput(aicpu::dump::Output &output, const OpDesc::Vistor &tensor_descs, + const uintptr_t &addr, size_t index); void GenerateOpBuffer(const int64_t &size, aicpu::dump::Task &task); }; struct DataDumper::InnerDumpInfo { diff --git a/ge/graph/load/model_manager/davinci_model.cc b/ge/graph/load/model_manager/davinci_model.cc index b7bb97ce..c053ad63 100755 --- a/ge/graph/load/model_manager/davinci_model.cc +++ b/ge/graph/load/model_manager/davinci_model.cc @@ -31,6 +31,7 @@ #include "common/scope_guard.h" #include "common/thread_pool.h" #include "framework/common/debug/ge_log.h" +#include "framework/common/util.h" #include "graph/common/ge_call_wrapper.h" #include "graph/compute_graph.h" #include "graph/debug/ge_attr_define.h" @@ -184,7 +185,7 @@ DavinciModel::DavinciModel(int32_t priority, const std::shared_ptrRelease(), "Release task failed."); } } + + for (auto &item : label_goto_args_) { + GE_FREE_RT_LOG(item.second.first); + } + label_goto_args_.clear(); } Status DavinciModel::Assign(const GeModelPtr &ge_model) { @@ -532,20 +538,20 @@ Status DavinciModel::DoTaskSink() { GE_CHK_STATUS_RET(BindModelStream(), "Bind model stream failed."); if (known_node_) { - GE_CHK_STATUS_RET(MallocKnownArgs(), "Mallloc known node args failed."); + GE_CHK_STATUS_RET(MallocKnownArgs(), "Mallloc known node's args failed"); } - GE_CHK_STATUS_RET(InitTaskInfo(*model_task_def.get()), "InitTaskInfo failed."); + GE_CHK_STATUS_RET(InitTaskInfo(*model_task_def.get()), "InitTaskInfo failed"); - GE_CHK_STATUS_RET(ModelManager::GetInstance()->LaunchCustAicpuSo(), "Launch cust aicpu so failed."); + GE_CHK_STATUS_RET(ModelManager::GetInstance()->LaunchCustAicpuSo(), "Launch cust aicpu so failed"); - GE_CHK_STATUS_RET(ModelManager::GetInstance()->CheckAicpuOpList(ge_model_), "Check aicpu op type failed."); + GE_CHK_STATUS_RET(ModelManager::GetInstance()->CheckAicpuOpList(ge_model_), "Check aicpu op type failed"); - GE_CHK_STATUS_RET(InitEntryTask(), "InitEntryTask failed."); + GE_CHK_STATUS_RET(InitEntryTask(), "InitEntryTask failed"); - GE_CHK_STATUS_RET(InitL1DataDumperArgs(), "InitL1DataDumperArgs failed."); + GE_CHK_STATUS_RET(InitL1DataDumperArgs(), "InitL1DataDumperArgs failed"); - GE_CHK_STATUS_RET(DistributeTask(), "Distribute failed."); + GE_CHK_STATUS_RET(DistributeTask(), "Distribute failed"); GE_CHK_RT_RET(rtModelLoadComplete(rt_model_handle_)); @@ -568,77 +574,21 @@ Status DavinciModel::SetTSDevice() { } Status DavinciModel::OpDebugRegister() { - bool is_op_debug = false; - (void)ge::AttrUtils::GetBool(ge_model_, ATTR_OP_DEBUG_FLAG, is_op_debug); - GELOGD("The value of op debug in ge_model is %d.", is_op_debug); - if (is_op_debug) { - debug_reg_mutex_.lock(); - rtError_t rt_ret = rtMalloc(&op_debug_addr_, kOpDebugMemorySize, RT_MEMORY_DDR); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); - } - - uint64_t debug_addrs_tmp = static_cast(reinterpret_cast(op_debug_addr_)); - - // For data dump, aicpu needs the pointer to pointer that save the real debug address. - rt_ret = rtMalloc(&p2p_debug_addr_, kDebugP2pSize, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMalloc error, ret: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); - } - rt_ret = rtMemcpy(p2p_debug_addr_, sizeof(uint64_t), &debug_addrs_tmp, sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtMemcpy to p2p_addr error: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); - } - - uint32_t op_debug_mode = 0; - (void)ge::AttrUtils::GetInt(ge_model_, ATTR_OP_DEBUG_MODE, op_debug_mode); - GELOGD("The value of op_debug_mode in ge_model_ is %u.", op_debug_mode); - uint32_t debug_task_id = 0; - uint32_t debug_stream_id = 0; - rt_ret = rtDebugRegister(rt_model_handle_, op_debug_mode, op_debug_addr_, &debug_stream_id, &debug_task_id); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "rtDebugRegister error, ret: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); + if (GetDumpProperties().IsOpDebugOpen()) { + uint32_t op_debug_mode = GetDumpProperties().GetOpDebugMode(); + auto ret = opdebug_register_.RegisterDebugForModel(rt_model_handle_, op_debug_mode, data_dumper_); + if (ret != SUCCESS) { + GELOGE(ret,"Register known shape op debug failed, ret: 0x%X",ret); + return ret; } - GELOGI("debug_task_id:%d, debug_stream_id:%u", debug_task_id, debug_stream_id); is_op_debug_reg_ = true; - - data_dumper_.SaveOpDebugId(debug_task_id, debug_stream_id, p2p_debug_addr_, is_op_debug); } - return SUCCESS; } void DavinciModel::OpDebugUnRegister() { if (is_op_debug_reg_) { - debug_reg_mutex_.unlock(); - rtError_t rt_ret = RT_ERROR_NONE; - if (rt_model_handle_ != nullptr) { - GELOGD("start call debug_unregister."); - rt_ret = rtDebugUnRegister(rt_model_handle_); - if (rt_ret != RT_ERROR_NONE) { - GELOGW("rtDebugUnRegister failed, ret: 0x%X", rt_ret); - } - } - - if (op_debug_addr_ != nullptr) { - rt_ret = rtFree(op_debug_addr_); - if (rt_ret != RT_ERROR_NONE) { - GELOGW("rtFree failed, ret: 0x%X", rt_ret); - } - op_debug_addr_ = nullptr; - } - - if (p2p_debug_addr_ != nullptr) { - rt_ret = rtFree(p2p_debug_addr_); - if (rt_ret != RT_ERROR_NONE) { - GELOGW("rtFree failed, ret: 0x%X", rt_ret); - } - p2p_debug_addr_ = nullptr; - } + opdebug_register_.UnregisterDebugForModel(rt_model_handle_); is_op_debug_reg_ = false; } return; @@ -710,12 +660,12 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size runtime_param_.graph_id = compute_graph->GetGraphID(); // op debug register - GE_CHK_STATUS_RET(OpDebugRegister(), "OpDebugRegister failed."); + GE_CHK_STATUS_RET(OpDebugRegister(), "OpDebugRegister failed"); GE_TIMESTAMP_START(TransAllVarData); - GE_CHK_STATUS_RET(TransAllVarData(compute_graph, runtime_param_.graph_id), "TransAllVarData failed."); + GE_CHK_STATUS_RET(TransAllVarData(compute_graph, runtime_param_.graph_id), "TransAllVarData failed"); GE_TIMESTAMP_END(TransAllVarData, "GraphLoader::TransAllVarData"); - GE_CHK_STATUS_RET(TransVarDataUtils::CopyVarData(compute_graph, session_id_, device_id_), "copy var data failed."); + GE_CHK_STATUS_RET(TransVarDataUtils::CopyVarData(compute_graph, session_id_, device_id_), "copy var data failed"); GE_TIMESTAMP_START(InitModelMem); GELOGD("Known node is %d.", known_node_); @@ -723,7 +673,7 @@ Status DavinciModel::Init(void *dev_ptr, size_t mem_size, void *weight_ptr, size if (!known_node_) { GE_CHK_STATUS_RET_NOLOG(InitFeatureMapAndP2PMem(dev_ptr, mem_size)); data_inputer_ = new (std::nothrow) DataInputer(); - GE_CHK_BOOL_RET_STATUS(data_inputer_ != nullptr, MEMALLOC_FAILED, "data_inputer_ is nullptr."); + GE_CHK_BOOL_RET_STATUS(data_inputer_ != nullptr, MEMALLOC_FAILED, "data_inputer_ is nullptr"); } fixed_mem_base_ = reinterpret_cast(mem_base_); GE_TIMESTAMP_END(InitModelMem, "GraphLoader::InitModelMem"); @@ -1390,6 +1340,39 @@ void DavinciModel::ParseDynamicOutShape(const std::vector &str_info } } +Status DavinciModel::GetLabelGotoAddr(uint32_t label_index, rtMemType_t mem_type, void *&arg_addr, uint32_t &arg_size) { + std::lock_guard lock(label_args_mutex_); + auto it = label_goto_args_.find(label_index); + if (it != label_goto_args_.end()) { + arg_addr = it->second.first; + arg_size = it->second.second; + return SUCCESS; + } + + if (label_index >= label_list_.size()) { + GELOGE(INTERNAL_ERROR, "Invalid label id:%u, label size:%zu", label_index, label_list_.size()); + return INTERNAL_ERROR; + } + GE_CHECK_NOTNULL(label_list_[label_index]); + vector label_used = { label_list_[label_index] }; + + arg_size = label_used.size() * sizeof(rtLabelDevInfo); + rtError_t rt_ret = rtMalloc(&arg_addr, arg_size, mem_type); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtMalloc failed, error: %#x", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + + label_goto_args_[label_index] = { arg_addr, arg_size }; + rt_ret = rtLabelListCpy(label_used.data(), label_used.size(), arg_addr, arg_size); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtLabelListCpy failed, error: %#x", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + + return SUCCESS; +} + /// @ingroup ge /// @brief LabelSet Op Initialize. /// @param [in] op_desc: LabelSet Op descriptor. @@ -2966,16 +2949,14 @@ Status DavinciModel::MallocKnownArgs() { return ret; } } + rtError_t rt_ret; // malloc args memory - if (total_args_size_ == 0) { - GELOGW("DavinciModel::MallocKnownArgs total_args_size_ equals to zero."); - return SUCCESS; - } - - rtError_t rt_ret = rtMalloc(&args_, total_args_size_, RT_MEMORY_HBM); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); + if (total_args_size_ != 0) { + rt_ret = rtMalloc(&args_, total_args_size_, RT_MEMORY_HBM); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtMalloc failed, ret: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } } // malloc dynamic and static hybrid memory if (total_hybrid_args_size_ != 0) { @@ -3891,7 +3872,7 @@ Status DavinciModel::TransAllVarData(ComputeGraphPtr &graph, uint32_t graph_id) } std::vector variable_node_list; - for (ge::NodePtr &node : graph->GetDirectNode()) { + for (ge::NodePtr &node : graph->GetAllNodes()) { if (node == nullptr) { continue; } diff --git a/ge/graph/load/model_manager/davinci_model.h b/ge/graph/load/model_manager/davinci_model.h index 4e29a4f4..58478b0f 100755 --- a/ge/graph/load/model_manager/davinci_model.h +++ b/ge/graph/load/model_manager/davinci_model.h @@ -29,6 +29,7 @@ #include "common/helper/om_file_helper.h" #include "common/opskernel/ge_task_info.h" #include "common/properties_manager.h" +#include "common/dump/opdebug_register.h" #include "common/types.h" #include "framework/common/util.h" #include "graph/debug/ge_attr_define.h" @@ -272,6 +273,8 @@ class DavinciModel { const vector &GetLabelList() const { return label_list_; } + Status GetLabelGotoAddr(uint32_t label_index, rtMemType_t memory_type, void *&addr, uint32_t &size); + Status DestroyThread(); // get Op @@ -929,6 +932,9 @@ class DavinciModel { vector label_list_; set label_id_indication_; + mutex label_args_mutex_; + map> label_goto_args_; + mutex outside_addrs_mutex_; vector zero_copy_tasks_; // Task used Data or NetOutput addr. set copy_only_addrs_; // Address need copy to original place. @@ -984,6 +990,7 @@ class DavinciModel { int64_t maxDumpOpNum_; // for data dump DataDumper data_dumper_; + OpdebugRegister opdebug_register_; uint64_t iterator_count_; bool is_l1_fusion_enable_; map saved_task_addrs_; // release after DavinciModel::Init @@ -1021,8 +1028,6 @@ class DavinciModel { // for op debug mutex debug_reg_mutex_; bool is_op_debug_reg_ = false; - void *op_debug_addr_ = nullptr; - void *p2p_debug_addr_ = nullptr; bool is_online_infer_dynamic_ = false; bool is_getnext_sink_dynamic_ = false; vector cur_dynamic_dims_; diff --git a/ge/graph/load/model_manager/model_manager.cc b/ge/graph/load/model_manager/model_manager.cc index e46bef88..27cbd526 100755 --- a/ge/graph/load/model_manager/model_manager.cc +++ b/ge/graph/load/model_manager/model_manager.cc @@ -286,6 +286,17 @@ ge::Status ModelManager::DoLoadHybridModelOnline(uint32_t model_id, const string return SUCCESS; } +bool ModelManager::IsNeedHybridLoad(ge::GeRootModel &ge_root_model) { + auto root_graph = ge_root_model.GetRootGraph(); + if (root_graph == nullptr) { + GELOGE(FAILED, "no model on root model"); + return false; + } + bool is_shape_unknown = root_graph->GetGraphUnknownFlag(); + bool is_dsp_partitioned_graph = false; + (void)AttrUtils::GetBool(root_graph, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, is_dsp_partitioned_graph); + return is_shape_unknown || is_dsp_partitioned_graph || GetContext().GetHostExecFlag(); +} /// /// @ingroup domi_ome /// @brief load model online @@ -297,12 +308,9 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrGetSubgraphInstanceNameToModel(); string model_name = ""; - GE_CHK_STATUS_RET(ge_root_model->CheckIsUnknownShape(is_shape_unknown), "CheckIsUnknownShape failed, model id:%u", - model_id); - if (is_shape_unknown || GetContext().GetHostExecFlag()) { + if (IsNeedHybridLoad(*ge_root_model)) { return DoLoadHybridModelOnline(model_id, model_name, ge_root_model, listener); } @@ -324,7 +332,6 @@ Status ModelManager::LoadModelOnline(uint32_t &model_id, const shared_ptrGetRootGraph(); GE_CHECK_NOTNULL(root_graph); string root_model_name = root_graph->GetName(); - auto name_to_model = ge_root_model->GetSubgraphInstanceNameToModel(); GeModelPtr ge_model = name_to_model[root_model_name]; Status ret = SUCCESS; do { diff --git a/ge/graph/load/model_manager/model_manager.h b/ge/graph/load/model_manager/model_manager.h index f2d55db7..b537943b 100755 --- a/ge/graph/load/model_manager/model_manager.h +++ b/ge/graph/load/model_manager/model_manager.h @@ -294,6 +294,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { std::vector &output_dims); bool IsDynamicShape(uint32_t model_id); + bool IsNeedHybridLoad(ge::GeRootModel &ge_root_model); ge::Status GetOpDescInfo(uint32_t device_id, uint32_t stream_id, uint32_t task_id, OpDescInfo &op_desc_info); ge::Status EnableExceptionDump(const std::map &options); @@ -340,6 +341,7 @@ class FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY ModelManager { void GenModelId(uint32_t *id); + std::map> model_map_; std::map> hybrid_model_map_; std::map> model_aicpu_kernel_; diff --git a/ge/graph/load/model_manager/model_utils.cc b/ge/graph/load/model_manager/model_utils.cc index 8648d892..015fefcc 100755 --- a/ge/graph/load/model_manager/model_utils.cc +++ b/ge/graph/load/model_manager/model_utils.cc @@ -384,7 +384,8 @@ Status ModelUtils::GetVarAddr(const RuntimeParam &model_param, const ConstOpDesc switch (mem_type) { case RT_MEMORY_RDMA_HBM: if (offset < 0) { - GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p", reinterpret_cast(offset)); + GELOGE(PARAM_INVALID, "rdma var addr is invalid, addr=%p", + reinterpret_cast(static_cast(offset))); return PARAM_INVALID; } var_addr = reinterpret_cast(static_cast(offset)); diff --git a/ge/graph/load/model_manager/task_info/kernel_task_info.cc b/ge/graph/load/model_manager/task_info/kernel_task_info.cc index c8d9f97a..9e0250de 100755 --- a/ge/graph/load/model_manager/task_info/kernel_task_info.cc +++ b/ge/graph/load/model_manager/task_info/kernel_task_info.cc @@ -124,7 +124,8 @@ Status KernelTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci return FAILED; } - ret = InitTVMTask(args_offset_tmp[0], kernel_def); + io_addr_offset_ = args_offset_tmp[0]; + ret = InitTVMTask(io_addr_offset_, kernel_def); } else if (kernel_type_ == ccKernelType::CUSTOMIZED) { ret = InitAICPUCustomTask(context.op_index(), kernel_def); } else if (kernel_type_ == ccKernelType::AI_CPU || kernel_type_ == ccKernelType::CUST_AI_CPU) { @@ -380,7 +381,8 @@ Status KernelTaskInfo::Distribute() { GELOGD("KernelTaskInfo Distribute Start."); if (davinci_model_->IsKnownNode()) { if (kernel_type_ == ccKernelType::TE) { - args_ = davinci_model_->GetCurrentArgsAddr(args_offset_); + args_ = l2_buffer_on_ ? davinci_model_->GetCurrentHybridArgsAddr(hybrid_args_offset_) + : davinci_model_->GetCurrentArgsAddr(args_offset_); } else if (kernel_type_ == ccKernelType::AI_CPU || kernel_type_ == ccKernelType::CUST_AI_CPU) { args_ = davinci_model_->GetCurrentHybridArgsAddr(hybrid_args_offset_); } @@ -449,29 +451,39 @@ void KernelTaskInfo::SetIoAddrs(const OpDescPtr &op_desc) { } } +Status KernelTaskInfo::CopyNoncontinuousArgs(uint16_t offset) { + GE_CHECK_NOTNULL(davinci_model_); + davinci_model_->UpdateKnownZeroCopyAddr(io_addrs_); + auto addr_size = kAddrLen * io_addrs_.size(); + + // copy io addr + errno_t sec_ret = memcpy_s(args_addr.get() + offset, addr_size, io_addrs_.data(), addr_size); + if (sec_ret != EOK) { + GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); + return FAILED; + } + + // copy args to device + rtError_t rt_ret = rtMemcpy(args_, args_size_, args_addr.get(), args_size_, RT_MEMCPY_HOST_TO_DEVICE); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rt api(rtMemcpy) failed, ret: 0x%X", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + GELOGD("Copy noncontinuous args success, kernel type %d.", kernel_type_); + return SUCCESS; +} + Status KernelTaskInfo::UpdateArgs() { GELOGI("KernelTaskInfo::UpdateArgs in."); + GE_CHECK_NOTNULL(davinci_model_); if (kernel_type_ == ccKernelType::TE) { + if (l2_buffer_on_) { + return CopyNoncontinuousArgs(io_addr_offset_); + } davinci_model_->SetTotalIOAddrs(io_addrs_); } else if (kernel_type_ == ccKernelType::AI_CPU || kernel_type_ == ccKernelType::CUST_AI_CPU) { - vector io_addrs = io_addrs_; - davinci_model_->UpdateKnownZeroCopyAddr(io_addrs); - uintptr_t io_addr = reinterpret_cast(args_addr.get()) + sizeof(aicpu::AicpuParamHead); - auto addrs_size = sizeof(uint64_t) * io_addrs.size(); - errno_t sec_ret = memcpy_s(reinterpret_cast(io_addr), addrs_size, io_addrs.data(), addrs_size); - if (sec_ret != EOK) { - GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); - return FAILED; - } - // copy args to device - rtError_t rt_ret = rtMemcpy(args_, args_size_, args_addr.get(), args_size_, RT_MEMCPY_HOST_TO_DEVICE); - if (rt_ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api(rtMemcpy) failed, ret: 0x%X", rt_ret); - return RT_ERROR_TO_GE_STATUS(rt_ret); - } + return CopyNoncontinuousArgs(sizeof(aicpu::AicpuParamHead)); } - - GELOGI("KernelTaskInfo::UpdateArgs success."); return SUCCESS; } @@ -516,8 +528,8 @@ Status KernelTaskInfo::UpdateL2Data(const domi::KernelDef &kernel_def) { return SUCCESS; } - char *sm_contrl = const_cast(sm_desc.data()); - rtL2Ctrl_t *l2_ctrl_info = reinterpret_cast(sm_contrl); + char *sm_control = const_cast(sm_desc.data()); + rtL2Ctrl_t *l2_ctrl_info = reinterpret_cast(sm_control); uint64_t gen_base_addr = davinci_model_->GetRtBaseAddr(); // There is no weight for te op now. Update L2_mirror_addr by data memory base. @@ -545,19 +557,31 @@ Status KernelTaskInfo::UpdateL2Data(const domi::KernelDef &kernel_def) { return SUCCESS; } +void KernelTaskInfo::SetContinuousArgs(uint32_t args_size, DavinciModel *davinci_model) { + args_offset_ = davinci_model->GetTotalArgsSize(); + davinci_model->SetTotalArgsSize(args_size); +} + +void KernelTaskInfo::SetNoncontinuousArgs(uint32_t args_size, DavinciModel *davinci_model) { + hybrid_args_offset_ = davinci_model->GetHybridArgsSize(); + davinci_model->SetHybridArgsSize(args_size); +} + Status KernelTaskInfo::CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) { + GE_CHECK_NOTNULL(davinci_model); const domi::KernelDef &kernel_def = task_def.kernel(); const domi::KernelContext &context = kernel_def.context(); kernel_type_ = static_cast(context.kernel_type()); + uint32_t args_size = kernel_def.args_size(); if (kernel_type_ == ccKernelType::TE) { - uint32_t args_size = kernel_def.args_size(); - args_offset_ = davinci_model->GetTotalArgsSize(); - davinci_model->SetTotalArgsSize(args_size); - GELOGI("kernel task name , args_size %u, args_offset %u", args_size, args_offset_); + if (kernel_def.sm_desc().empty()) { + SetContinuousArgs(args_size, davinci_model); + return SUCCESS; + } + l2_buffer_on_ = true; + SetNoncontinuousArgs(args_size, davinci_model); } else if (kernel_type_ == ccKernelType::AI_CPU || kernel_type_ == ccKernelType::CUST_AI_CPU) { - hybrid_args_offset_ = davinci_model->GetHybridArgsSize(); - davinci_model->SetHybridArgsSize(kernel_def.args_size()); - GELOGI("aicpu kernel task name , args_size %u, args_offset %u", kernel_def.args_size(), hybrid_args_offset_); + SetNoncontinuousArgs(args_size, davinci_model); } return SUCCESS; } @@ -568,8 +592,23 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne // get tvm op desc OpDescPtr op_desc = davinci_model_->GetOpByIndex(ctx_.opIndex); GE_CHECK_NOTNULL(op_desc); + + args_addr = std::unique_ptr(new (std::nothrow) uint8_t[args_size_]); + errno_t sec_ret = memcpy_s(args_addr.get(), args_size_, kernel_def.args().data(), args_size_); + if (sec_ret != EOK) { + GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); + return FAILED; + } + + Status ge_ret = UpdateL2Data(kernel_def); + // update origin l2 data + if (ge_ret != SUCCESS) { + return ge_ret; + } + if (davinci_model_->IsKnownNode()) { - args_ = davinci_model_->GetCurrentArgsAddr(args_offset_); + args_ = l2_buffer_on_ ? davinci_model_->GetCurrentHybridArgsAddr(hybrid_args_offset_) + : davinci_model_->GetCurrentArgsAddr(args_offset_); InitDumpTask(offset); return SUCCESS; } @@ -609,12 +648,6 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } - vector args_info(args_size_); - errno_t sec_ret = memcpy_s(args_info.data(), args_size_, kernel_def.args().data(), args_size_); - if (sec_ret != EOK) { - GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); - return FAILED; - } if ((args_size_ <= offset) || (args_size_ - offset < kAddrLen * tensor_device_addrs.size())) { GELOGE(FAILED, "offset >= kernelInfo.argsSize or copy content beyond applied memory."); @@ -628,7 +661,7 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); } - sec_ret = memcpy_s(args_info.data() + offset, args_size_ - offset, tensor_device_addrs.data(), + sec_ret = memcpy_s(args_addr.get() + offset, args_size_ - offset, tensor_device_addrs.data(), kAddrLen * tensor_device_addrs.size()); if (sec_ret != EOK) { GELOGE(FAILED, "memcpy failed, ret: %d", sec_ret); @@ -640,19 +673,13 @@ Status KernelTaskInfo::InitTVMTask(uint16_t offset, const domi::KernelDef &kerne GE_CHK_BOOL_TRUE_EXEC_INFO(davinci_model_->GetOpDugReg(), dump_args_ = static_cast(args_) + offset, "Op debug is open in TVM task info"); - Status ge_ret = UpdateL2Data(kernel_def); - // update origin l2 data - if (ge_ret != SUCCESS) { - return ge_ret; - } - vector virtual_io_addrs; // use virtual address for zero copy key. virtual_io_addrs.insert(virtual_io_addrs.end(), input_data_addrs.begin(), input_data_addrs.end()); virtual_io_addrs.insert(virtual_io_addrs.end(), output_data_addrs.begin(), output_data_addrs.end()); if (op_desc->GetType() == ATOMICADDRCLEAN) { virtual_io_addrs.insert(virtual_io_addrs.end(), workspace_data_addrs.begin(), workspace_data_addrs.end()); } - davinci_model_->SetZeroCopyAddr(op_desc, virtual_io_addrs, args_info.data(), args_, args_size_, offset); + davinci_model_->SetZeroCopyAddr(op_desc, virtual_io_addrs, args_addr.get(), args_, args_size_, offset); GELOGD("Do InitTVMTask end"); return SUCCESS; diff --git a/ge/graph/load/model_manager/task_info/kernel_task_info.h b/ge/graph/load/model_manager/task_info/kernel_task_info.h index 7cabf259..4156c511 100644 --- a/ge/graph/load/model_manager/task_info/kernel_task_info.h +++ b/ge/graph/load/model_manager/task_info/kernel_task_info.h @@ -129,6 +129,9 @@ class KernelTaskInfo : public TaskInfo { bool IsL1FusionOp(const OpDescPtr &op_desc); void SetIoAddrs(const OpDescPtr &op_desc); void InitDumpTask(uint32_t offset); + void SetContinuousArgs(uint32_t args_size, DavinciModel *davinci_model); + void SetNoncontinuousArgs(uint32_t args_size, DavinciModel *davinci_model); + Status CopyNoncontinuousArgs(uint16_t offset); // For super kernel Status SaveSKTDumpInfo(); @@ -163,6 +166,8 @@ class KernelTaskInfo : public TaskInfo { uint32_t hybrid_args_offset_ = 0; int64_t fixed_addr_offset_ = 0; std::unique_ptr args_addr = nullptr; + uint16_t io_addr_offset_ = 0; + bool l2_buffer_on_ = false; bool call_save_dump_ = false; // aicpu ext_info device mem diff --git a/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.cc b/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.cc index 1921c85d..c651e6df 100755 --- a/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.cc +++ b/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.cc @@ -17,9 +17,15 @@ #include "graph/load/model_manager/task_info/label_goto_ex_task_info.h" #include "graph/load/model_manager/davinci_model.h" -#include "graph/debug/ge_attr_define.h" namespace ge { +constexpr uint8_t kGotoBranchMax = 1; + +LabelGotoExTaskInfo::~LabelGotoExTaskInfo() { + args_ = nullptr; + GE_FREE_RT_LOG(index_value_); +} + Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) { GELOGI("LabelGotoExTaskInfo Init Start."); GE_CHECK_NOTNULL(davinci_model); @@ -28,7 +34,7 @@ Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da return FAILED; } - // Get LabelGoto task def + // Get LabelGotoEx task def const domi::LabelGotoExDef &label_goto = task_def.label_goto_ex(); OpDescPtr op_desc = davinci_model->GetOpByIndex(label_goto.op_index()); if (op_desc == nullptr) { @@ -43,20 +49,38 @@ Status LabelGotoExTaskInfo::Init(const domi::TaskDef &task_def, DavinciModel *da return INTERNAL_ERROR; } - const vector &label_list = davinci_model->GetLabelList(); - if (label_index >= label_list.size()) { - GELOGE(PARAM_INVALID, "LabelGotoExTaskInfo: Invalid label id:%u, label size:%zu", label_index, label_list.size()); - return INTERNAL_ERROR; + rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; + GELOGI("memory_type: %u", memory_type); + + GE_CHK_STATUS_RET_NOLOG(davinci_model->GetLabelGotoAddr(label_index, memory_type, args_, args_size_)); + + rtError_t rt_ret = rtMalloc(&index_value_, sizeof(uint64_t), memory_type); + if (rt_ret != RT_ERROR_NONE) { + GELOGE(RT_FAILED, "Call rtMalloc failed, error: %#x", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); } - label_ = label_list[label_index]; - GELOGI("LabelGotoExTaskInfo Init Success, label id:%u, label:%p.", label_index, label_); + 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 rtMemcpy failed, error: %#x", rt_ret); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + + GELOGI("LabelGotoExTaskInfo Init Success, label id:%u", label_index); return SUCCESS; } Status LabelGotoExTaskInfo::Distribute() { GELOGI("LabelGotoExTaskInfo Distribute Start."); - rtError_t rt_ret = rtLabelGotoEx(label_, stream_); + GE_CHECK_NOTNULL(args_); + GE_CHECK_NOTNULL(index_value_); + if (args_size_ == 0) { + GELOGE(PARAM_INVALID, "branch max: %u, args size: %u invalid.", kGotoBranchMax, args_size_); + return PARAM_INVALID; + } + + rtError_t rt_ret = rtLabelSwitchByIndex(index_value_, kGotoBranchMax, args_, stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); diff --git a/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.h b/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.h index 25310368..a3668354 100755 --- a/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.h +++ b/ge/graph/load/model_manager/task_info/label_goto_ex_task_info.h @@ -14,24 +14,26 @@ * limitations under the License. */ -#ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_GOTO_EX_TASK_INFO_H_ -#define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_GOTO_EX_TASK_INFO_H_ +#ifndef GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_GOTO_EX_TASK_INFO_H_ +#define GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_GOTO_EX_TASK_INFO_H_ #include "graph/load/model_manager/task_info/task_info.h" namespace ge { class LabelGotoExTaskInfo : public TaskInfo { public: - LabelGotoExTaskInfo() : label_(nullptr) {} + LabelGotoExTaskInfo() = default; - ~LabelGotoExTaskInfo() override { label_ = nullptr; } + ~LabelGotoExTaskInfo() override; Status Init(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; Status Distribute() override; private: - void *label_; + void *index_value_{nullptr}; // switch index input. + void *args_{nullptr}; // label info memory. + uint32_t args_size_{0}; // label info length. }; } // namespace ge -#endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_GOTO_EX_TASK_INFO_H_ +#endif // GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_GOTO_EX_TASK_INFO_H_ diff --git a/ge/graph/load/model_manager/task_info/label_set_task_info.h b/ge/graph/load/model_manager/task_info/label_set_task_info.h index 36e41f1b..64dabddf 100644 --- a/ge/graph/load/model_manager/task_info/label_set_task_info.h +++ b/ge/graph/load/model_manager/task_info/label_set_task_info.h @@ -14,8 +14,8 @@ * limitations under the License. */ -#ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_SET_TASK_INFO_H_ -#define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_SET_TASK_INFO_H_ +#ifndef GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_SET_TASK_INFO_H_ +#define GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_SET_TASK_INFO_H_ #include "graph/load/model_manager/task_info/task_info.h" @@ -34,4 +34,4 @@ class LabelSetTaskInfo : public TaskInfo { void *label_; }; } // namespace ge -#endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_SET_TASK_INFO_H_ +#endif // GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_SET_TASK_INFO_H_ diff --git a/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.cc b/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.cc index c2997678..cf162f7e 100644 --- a/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.cc +++ b/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.cc @@ -16,20 +16,13 @@ #include "graph/load/model_manager/task_info/label_switch_by_index_task_info.h" -#include "graph/debug/ge_attr_define.h" #include "graph/load/model_manager/davinci_model.h" namespace ge { constexpr uint8_t kLabelSwitchIndexNum = 1; LabelSwitchByIndexTaskInfo::~LabelSwitchByIndexTaskInfo() { - if (args_ != nullptr) { - rtError_t ret = rtFree(args_); - if (ret != RT_ERROR_NONE) { - GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", ret); - } - } - args_ = nullptr; + GE_FREE_RT_LOG(args_); index_value_ = nullptr; } @@ -37,13 +30,12 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo GELOGI("LabelSwitchByIndexTaskInfo Init Start."); GE_CHECK_NOTNULL(davinci_model); - const vector &label_list = davinci_model->GetLabelList(); Status ret = SetStream(task_def.stream_id(), davinci_model->GetStreamList()); if (ret != SUCCESS) { return FAILED; } - // Get LabelSwitch task def + // Get LabelSwitchByIndex task def const domi::LabelSwitchByIndexDef &label_switch = task_def.label_switch_by_index(); OpDescPtr op_desc = davinci_model->GetOpByIndex(label_switch.op_index()); if (op_desc == nullptr) { @@ -68,7 +60,7 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo davinci_model->DisableZeroCopy(index_value_); - std::vector label_idx_list; + vector label_idx_list; if (!AttrUtils::GetListInt(op_desc, ATTR_NAME_LABEL_SWITCH_LIST, label_idx_list)) { GELOGE(INTERNAL_ERROR, "LabelSwitchByIndexTaskInfo: %s Get attr %s failed.", op_desc->GetName().c_str(), ATTR_NAME_LABEL_SWITCH_LIST.c_str()); @@ -81,7 +73,8 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo return INTERNAL_ERROR; } - label_list_.resize(branch_max_, nullptr); + vector label_used(branch_max_, nullptr); + const vector &label_list = davinci_model->GetLabelList(); for (size_t idx = 0; idx < label_idx_list.size(); ++idx) { uint32_t label_id = label_idx_list[idx]; if (label_id >= label_list.size()) { @@ -90,8 +83,7 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo return INTERNAL_ERROR; } GE_CHECK_NOTNULL(label_list[label_id]); - - label_list_[idx] = label_list[label_id]; + label_used[idx] = label_list[label_id]; } rtMemType_t memory_type = op_desc->HasAttr(ATTR_NAME_MEMORY_TYPE_RANGE) ? RT_MEMORY_TS_4G : RT_MEMORY_HBM; @@ -103,7 +95,7 @@ Status LabelSwitchByIndexTaskInfo::Init(const domi::TaskDef &task_def, DavinciMo return RT_ERROR_TO_GE_STATUS(rt_ret); } - rt_ret = rtLabelListCpy(label_list_.data(), label_list_.size(), args_, args_size_); + rt_ret = rtLabelListCpy(label_used.data(), label_used.size(), args_, args_size_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); return RT_ERROR_TO_GE_STATUS(rt_ret); @@ -125,7 +117,7 @@ Status LabelSwitchByIndexTaskInfo::Distribute() { rtError_t rt_ret = rtLabelSwitchByIndex(index_value_, branch_max_, args_, stream_); if (rt_ret != RT_ERROR_NONE) { GELOGE(RT_FAILED, "Call rt api failed, ret: 0x%X", rt_ret); - return RT_FAILED; + return RT_ERROR_TO_GE_STATUS(rt_ret); } GELOGI("LabelSwitchByIndexTaskInfo Distribute Success."); diff --git a/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.h b/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.h index 00ca0844..5a8ac05a 100644 --- a/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.h +++ b/ge/graph/load/model_manager/task_info/label_switch_by_index_task_info.h @@ -14,16 +14,15 @@ * limitations under the License. */ -#ifndef GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_SWITCH_BY_INDEX_TASK_INFO_H_ -#define GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_SWITCH_BY_INDEX_TASK_INFO_H_ +#ifndef GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_SWITCH_BY_INDEX_TASK_INFO_H_ +#define GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_SWITCH_BY_INDEX_TASK_INFO_H_ #include "graph/load/model_manager/task_info/task_info.h" namespace ge { class LabelSwitchByIndexTaskInfo : public TaskInfo { public: - LabelSwitchByIndexTaskInfo() - : index_value_(nullptr), branch_max_(0), args_(nullptr), args_size_(0), fixed_addr_offset_(0) {} + LabelSwitchByIndexTaskInfo() = default; ~LabelSwitchByIndexTaskInfo() override; @@ -34,12 +33,11 @@ class LabelSwitchByIndexTaskInfo : public TaskInfo { Status CalculateArgs(const domi::TaskDef &task_def, DavinciModel *davinci_model) override; private: - void *index_value_; // switch index input. - uint32_t branch_max_; // max branch count. - void *args_; // label info memory. - uint32_t args_size_; // label info length. - std::vector label_list_; - int64_t fixed_addr_offset_; + void *index_value_{nullptr}; // switch index input. + uint32_t branch_max_{0}; // max branch count. + void *args_{nullptr}; // label info memory. + uint32_t args_size_{0}; // label info length. + int64_t fixed_addr_offset_{0}; }; } // namespace ge -#endif // GE_GRAPH_LOAD_NEW_MODEL_MANAGER_TASK_INFO_LABEL_SWITCH_BY_INDEX_TASK_INFO_H_ \ No newline at end of file +#endif // GE_GRAPH_LOAD_MODEL_MANAGER_TASK_INFO_LABEL_SWITCH_BY_INDEX_TASK_INFO_H_ \ No newline at end of file diff --git a/ge/graph/manager/graph_caching_allocator.cc b/ge/graph/manager/graph_caching_allocator.cc index 03ca352e..5822056d 100644 --- a/ge/graph/manager/graph_caching_allocator.cc +++ b/ge/graph/manager/graph_caching_allocator.cc @@ -40,7 +40,7 @@ static bool BlockComparator(const Block *left, const Block *right) { } bool CanMerge(Block *block) { - if (block == nullptr || block->allocated || !block->IsSplit()) { + if ((block == nullptr) || block->allocated || !block->IsSplit()) { return false; } return true; @@ -52,7 +52,7 @@ size_t GetBinIndex(size_t size) { if (size <= range) { break; } - ++index; + index++; } if (index > kNumBins - 1) { index = kNumBins - 1; @@ -87,15 +87,15 @@ bool ShouldSplit(const Block *block, size_t size) { void IncreaseCount(std::map &count, size_t size) { auto it = count.find(size); - if (it != count.end()) { - it->second++; - } else { + if (it == count.end()) { count.emplace(size, 1); + } else { + it->second++; } } CachingAllocator::CachingAllocator(rtMemType_t memory_type) : memory_type_(memory_type), memory_allocator_(nullptr) { - for (uint32_t i = 0; i < kNumBins; ++i) { + for (uint32_t i = 0; i < kNumBins; i++) { free_block_bins_[i] = nullptr; } } @@ -105,7 +105,7 @@ Status CachingAllocator::Initialize(uint32_t device_id) { // when redo Initialize free old memory FreeBlocks(); std::lock_guard lock(mutex_); - for (uint32_t i = 0; i < kNumBins; ++i) { + for (uint32_t i = 0; i < kNumBins; i++) { if (free_block_bins_[i] != nullptr) { continue; } @@ -132,18 +132,18 @@ void CachingAllocator::Finalize(uint32_t device_id) { uint8_t *CachingAllocator::Malloc(size_t size, uint8_t *org_ptr, uint32_t device_id) { GELOGI("Start malloc pool memory, size = %zu, device id = %u", size, device_id); - uint8_t *ptr = nullptr; size = GetBlockSize(size); + uint8_t *ptr = nullptr; Block *block = FindFreeBlock(size, org_ptr, device_id); - if (block != nullptr) { - ptr = block->ptr; - } else { + if (block == nullptr) { if (ge::SUCCESS == TryExtendCache(size, device_id)) { block = FindFreeBlock(size, org_ptr, device_id); if (block != nullptr) { ptr = block->ptr; } } + } else { + ptr = block->ptr; } if (ptr == nullptr) { GELOGE(FAILED, "Malloc failed device id = %u, size= %zu", device_id, size); @@ -171,7 +171,7 @@ Status CachingAllocator::Free(uint8_t *ptr, uint32_t device_id) { } void CachingAllocator::FreeBlock(Block *block) { - if (block == nullptr || !block->allocated) { + if ((block == nullptr) || !block->allocated) { return; } GELOGI("Free block size = %zu", block->size); @@ -187,7 +187,7 @@ void CachingAllocator::FreeBlock(Block *block) { } void CachingAllocator::MergeBlocks(Block *dst, Block *src, BlockBin &bin) { - if (!CanMerge(dst) || !CanMerge(src)) { + if (!CanMerge(src) || !CanMerge(dst)) { return; } @@ -316,7 +316,7 @@ size_t CachingAllocator::FreeCachedBlocks() { GELOGI("Free cached blocks"); std::lock_guard lock(mutex_); size_t free_cached_memory_size = 0; - for (uint32_t i = 0; i < kNumBins; ++i) { + for (uint32_t i = 0; i < kNumBins; i++) { auto pool = free_block_bins_[i]; if (pool == nullptr) { continue; @@ -324,7 +324,8 @@ size_t CachingAllocator::FreeCachedBlocks() { for (auto it = pool->begin(); it != pool->end();) { Block *block = *it; // free block memory that has not been split - if ((block != nullptr) && (block->ptr != nullptr) && (block->prev == nullptr) && (block->next == nullptr) && + if ((block != nullptr) && (block->ptr != nullptr) && + (block->prev == nullptr) && (block->next == nullptr) && (memory_allocator_->FreeMemory(block->ptr) == ge::SUCCESS)) { auto itcount = malloced_memory_.find(block->size); free_cached_memory_size += block->size; @@ -345,7 +346,7 @@ size_t CachingAllocator::FreeCachedBlocks() { } void CachingAllocator::FreeBlocks() { - GELOGI("Free blocks"); + GELOGI("Free blocks."); std::lock_guard lock(mutex_); // free allocated blocks and put to cache for (auto &it : allocated_blocks_) { @@ -356,9 +357,9 @@ void CachingAllocator::FreeBlocks() { } void CachingAllocator::FreeBlockBins() { - GELOGI("Free block bins"); + GELOGI("Free block bins."); std::lock_guard lock(mutex_); - for (uint32_t i = 0; i < kNumBins; ++i) { + for (uint32_t i = 0; i < kNumBins; i++) { if (free_block_bins_[i] != nullptr) { delete free_block_bins_[i]; free_block_bins_[i] = nullptr; @@ -367,9 +368,9 @@ void CachingAllocator::FreeBlockBins() { } void PrintCount(std::map &count, const std::string &name, size_t total_size, size_t total_count) { - GELOGI("%6s total[size:%10zu count:%10zu]", name.c_str(), total_size, total_count); + GELOGI("%6s total[size:%10zu count:%10zu].", name.c_str(), total_size, total_count); for (auto &it : count) { - GELOGI(" |- block[size:%10zu count:%10zu]", it.first, it.second); + GELOGI(" |- block[size:%10zu count:%10zu].", it.first, it.second); } } @@ -383,20 +384,20 @@ void CachingAllocator::PrintStatics() { size_t total_free_count = 0; size_t total_malloc_size = 0; size_t total_malloc_count = 0; - std::map using_block; - std::map free_block; - std::map malloc_block; + std::map using_block_stat; + std::map free_block_stat; + std::map malloc_block_stat; do { std::lock_guard lock(mutex_); - for (uint32_t i = 0; i < kNumBins; ++i) { + for (uint32_t i = 0; i < kNumBins; i++) { auto pool = free_block_bins_[i]; if (pool == nullptr) { continue; } - for (auto it = pool->begin(); it != pool->end(); ++it) { + for (auto it = pool->begin(); it != pool->end(); it++) { if ((*it) != nullptr) { total_free_size += (*it)->size; - IncreaseCount(free_block, (*it)->size); + IncreaseCount(free_block_stat, (*it)->size); total_free_count++; } } @@ -405,7 +406,7 @@ void CachingAllocator::PrintStatics() { for (auto &it : allocated_blocks_) { if (it.second != nullptr) { total_using_size += it.second->size; - IncreaseCount(using_block, it.second->size); + IncreaseCount(using_block_stat, it.second->size); total_using_count++; } } @@ -413,12 +414,12 @@ void CachingAllocator::PrintStatics() { for (auto &it : malloced_memory_) { total_malloc_size += it.first * it.second; total_malloc_count += it.second; - malloc_block[it.first] = it.second; + malloc_block_stat[it.first] = it.second; } } while (0); - PrintCount(malloc_block, "Malloc", total_malloc_size, total_malloc_count); - PrintCount(using_block, "Using", total_using_size, total_using_count); - PrintCount(free_block, "Free", total_free_size, total_free_count); + PrintCount(malloc_block_stat, "Malloc", total_malloc_size, total_malloc_count); + PrintCount(using_block_stat, "Using", total_using_size, total_using_count); + PrintCount(free_block_stat, "Free", total_free_size, total_free_count); } } // namespace ge diff --git a/ge/graph/manager/graph_manager.cc b/ge/graph/manager/graph_manager.cc index 7bc158ca..f1f455f2 100755 --- a/ge/graph/manager/graph_manager.cc +++ b/ge/graph/manager/graph_manager.cc @@ -93,6 +93,7 @@ #include "graph/passes/global_step_insert_pass.h" #include "graph/passes/memcpy_addr_async_pass.h" #include "graph/passes/hccl_continuous_memcpy_pass.h" +#include "graph/passes/parallel_group_pass.h" #include "graph/build/label_allocator.h" #include "graph/utils/tensor_adapter.h" #include "inc/pass_manager.h" @@ -359,7 +360,10 @@ Status GraphManager::AddGraph(const GraphId &graph_id, const Graph &graph, std::shared_ptr graph_ptr = MakeShared(graph); GE_IF_BOOL_EXEC(graph_ptr == nullptr, GELOGE(FAILED, "GraphPtr make shared failed"); return FAILED); - + // update option about tuning graph + ParseOption(options, BUILD_MODE, options_.build_mode); + ParseOption(options, BUILD_STEP, options_.build_step); + ParseOption(options, TUNING_PATH, options_.tuning_path); graph_node->SetGraph(graph_ptr); graph_node->SetOptions(options); AddGraphNode(graph_id, graph_node); @@ -433,6 +437,10 @@ Status GraphManager::AddGraphWithCopy(const GraphId &graph_id, const Graph &grap GELOGE(FAILED, "GraphPtr make shared failed"); return FAILED; } + // update option about tuning graph + ParseOption(options, BUILD_MODE, options_.build_mode); + ParseOption(options, BUILD_STEP, options_.build_step); + ParseOption(options, TUNING_PATH, options_.tuning_path); graph_node->SetGraph(graph_ptr); graph_node->SetOptions(options); @@ -1564,6 +1572,10 @@ Status GraphManager::ParseOptions(const std::map &opti GE_IF_BOOL_EXEC(ret != SUCCESS, GELOGE(GE_GRAPH_OPTIONS_INVALID, "Key:ge.compressFlag value is invalid, must be 0 or 1."); return GE_GRAPH_OPTIONS_INVALID); + // Set Build model and step + ParseOption(options, BUILD_MODE, options_.build_mode); + ParseOption(options, BUILD_STEP, options_.build_step); + ParseOption(options, BUILD_STEP, options_.tuning_path); // ge.graphType. options_.run_graph_flag = true; @@ -1612,10 +1624,6 @@ Status GraphManager::ParseOptions(const std::map &opti GELOGD("Dynamic dims params: input shape is %s, dynamic dims is %s, dynamic node type is %d", options_.input_shape.c_str(), options_.dynamic_dims.c_str(), options_.dynamic_node_type); - // Set Build model and step - ParseOption(options, BUILD_MODE, options_.build_mode); - ParseOption(options, BUILD_STEP, options_.build_step); - return SUCCESS; } @@ -1647,6 +1655,7 @@ void GraphManager::ParseOption(const std::map &options std::string &option) { auto iter = options.find(key); if (iter != options.end()) { + GELOGD("Set option %s from value %s to value%s", key.c_str(), option.c_str(), iter->second.c_str()); option = iter->second; } } @@ -2471,6 +2480,12 @@ Status GraphManager::OptimizeStage2(ge::ComputeGraphPtr &compute_graph) { GE_CHK_STATUS_RET(memcpy_addr.Run(compute_graph), "Add memcpy_addr_async node failed."); GE_TIMESTAMP_END(AddMemcpyAddrAsyncNode, "MemcpyAddrAsyncPass::Run."); + // Handle parallel group . + GE_TIMESTAMP_START(ParallelGroup); + ParallelGroupPass parallel_group_pass; + GE_CHK_STATUS_RET(parallel_group_pass.Run(compute_graph), "Handle parallel group failed."); + GE_TIMESTAMP_END(ParallelGroup, "ParallelGroupPass::Run."); + // After while sub graph handle, mark all node rw type auto result = GetCompilerStages(compute_graph->GetGraphID()).optimizer.HandleMemoryRWConflict(compute_graph); if (result != SUCCESS) { @@ -2987,9 +3002,9 @@ void GraphManager::RunThread(GraphManager *graph_manager) { graph_manager->graph_executor_.SetTrainFlag(graph_manager->options_.train_graph_flag); } + args.graph_node->SetRunFlag(false); ret = graph_manager->graph_executor_.ExecuteGraphAsync(args.graph_id, args.graph_node->GetGeRootModel(), args.input_tensor); - args.graph_node->SetRunFlag(false); if (ret != SUCCESS) { ReturnError(graph_manager, args.callback, ret, "ExecuteGraphAsync failed, thread exit."); args.graph_node->Unlock(); @@ -3188,6 +3203,15 @@ Status GraphManager::OptimizeSubgraph(const GraphNodePtr &graph_node, ComputeGra sub_graph->SetSessionID(session_id); sub_graph->SetGraphID(graph_node->GetGraphId()); } + bool off_superkernel = false; + if (AttrUtils::GetBool(compute_graph, ATTR_NAME_OFF_SUPERKERNEL_ATTR, off_superkernel)) { + GELOGI("Compute graph %s get superkernel flag %d.", compute_graph->GetName().c_str(), off_superkernel); + if (!AttrUtils::SetBool(merged_compute_graph, ATTR_NAME_OFF_SUPERKERNEL_ATTR, off_superkernel)) { + GELOGE(FAILED, "Compute graph %s set superkernel flag %d failed", merged_compute_graph->GetName().c_str(), + off_superkernel); + return FAILED; + } + } GE_TIMESTAMP_EVENT_END(MergeSubgraph, "OptimizeSubgraph::MergeSubGraph"); GE_DUMP(merged_compute_graph, "mergedComputeGraph"); compute_graph = merged_compute_graph; @@ -3221,6 +3245,21 @@ Status GraphManager::ConvertGraphToFile(ComputeGraphPtr &compute_graph, GraphPar non_tuning_subgraphs.push_back(sub_graph_tmp); } } + // for function graphs to tune + for (auto &function_graph : compute_graph->GetAllSubgraphs()) { + auto subgraph_list = sub_graph_map[function_graph]; + for (const auto &sub_graph_info_ptr : subgraph_list) { + GE_CHECK_NOTNULL(sub_graph_info_ptr); + ComputeGraphPtr sub_graph_tmp = sub_graph_info_ptr->GetSubGraph(); + // need to tuning + if (sub_graph_info_ptr->GetEngineName() == kVectorEngine || + sub_graph_info_ptr->GetEngineName() == kAIcoreEngine) { + tuning_subgraphs.push_back(sub_graph_tmp); + } else { + non_tuning_subgraphs.push_back(sub_graph_tmp); + } + } + } return TuningUtils::ConvertGraphToFile(tuning_subgraphs, non_tuning_subgraphs, exe_flag, path); } diff --git a/ge/graph/manager/graph_manager_utils.h b/ge/graph/manager/graph_manager_utils.h index dc7b9a32..31dd6c11 100644 --- a/ge/graph/manager/graph_manager_utils.h +++ b/ge/graph/manager/graph_manager_utils.h @@ -252,6 +252,7 @@ struct GraphManagerOptions { std::string save_original_model; std::string build_mode; std::string build_step; + std::string tuning_path; std::string input_shape; std::string dynamic_dims; int32_t dynamic_node_type = -1; @@ -278,7 +279,8 @@ struct GraphManagerOptions { is_single_op(false), save_original_model("false"), build_mode(""), - build_step("") {} + build_step(""), + tuning_path(""){} }; } // namespace ge diff --git a/ge/graph/manager/graph_var_manager.cc b/ge/graph/manager/graph_var_manager.cc index d0292885..de75344d 100755 --- a/ge/graph/manager/graph_var_manager.cc +++ b/ge/graph/manager/graph_var_manager.cc @@ -347,14 +347,18 @@ ge::Status VarManager::Init(const uint32_t &version, const uint64_t &session_id, const uint64_t &job_id) { std::lock_guard lock(mutex_); GELOGI("VarManager::Init, session id = %lu.", session_id); - version_ = version; - device_id_ = device_id; - session_id_ = session_id; - job_id_ = job_id; - var_resource_ = std::unique_ptr(new (std::nothrow) VarResource(session_id_)); if (var_resource_ == nullptr) { - GELOGW("VarManager has not been init."); - return ge::INTERNAL_ERROR; + version_ = version; + device_id_ = device_id; + session_id_ = session_id; + job_id_ = job_id; + var_resource_ = std::unique_ptr(new (std::nothrow) VarResource(session_id_)); + if (var_resource_ == nullptr) { + GELOGW("VarManager init failed session id = %lu.", session_id); + return ge::INTERNAL_ERROR; + } + } else { + GELOGW("VarManager::has been inited, session id = %lu.", session_id); } return SUCCESS; } diff --git a/ge/graph/partition/dynamic_shape_partition.cc b/ge/graph/partition/dynamic_shape_partition.cc index 5736e39a..bd95d0c5 100755 --- a/ge/graph/partition/dynamic_shape_partition.cc +++ b/ge/graph/partition/dynamic_shape_partition.cc @@ -48,50 +48,23 @@ namespace ge { using Cluster = DynamicShapePartitioner::Cluster; using ClusterPtr = std::shared_ptr; -static bool IsInExperimentalMode(const ComputeGraphPtr &root_graph) { +static bool IsSingleOpScene(const ComputeGraphPtr &root_graph) { for (const auto &node : root_graph->GetAllNodes()) { GE_CHECK_NOTNULL(node->GetOpDesc()); // not do partition in single op scene. bool is_singleop = false; (void)AttrUtils::GetBool(node->GetOpDesc(), ATTR_SINGLE_OP_SCENE, is_singleop); if (is_singleop) { - return false; - } - - for (const auto &input_desc : node->GetOpDesc()->GetAllInputsDesc()) { - auto type = input_desc.GetDataType(); - if (type == DT_STRING || type == DT_RESOURCE || type == DT_STRING_REF) { - if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { - return false; - } else { - GEEVENT("In dynamic shape scene, model contains data type:" - "DT_STRING/DT_RESOURCE/DT_STRING_REF may not be supported well " - "temporarily, please retry with \"unset EXPERIMENTAL_DYNAMIC_PARTITION\"."); - break; - } - } - } - for (const auto &output_desc : node->GetOpDesc()->GetAllOutputsDesc()) { - auto type = output_desc.GetDataType(); - if (type == DT_STRING || type == DT_RESOURCE || type == DT_STRING_REF) { - if (std::getenv("EXPERIMENTAL_DYNAMIC_PARTITION") == nullptr) { - return false; - } else { - GEEVENT("In dynamic shape scene, model contains data type:" - "DT_STRING/DT_RESOURCE/DT_STRING_REF may not be supported well " - "temporarily, please retry with \"unset EXPERIMENTAL_DYNAMIC_PARTITION\"."); - break; - } - } + return true; } } - return true; + return false; } Status DynamicShapePartitioner::Partition() { REQUIRE_NOT_NULL(root_graph_, "Graph is nullptr."); - if (!IsInExperimentalMode(root_graph_)) { - GELOGD("Skip dynamic shape partition as not in experimental mode."); + if (IsSingleOpScene(root_graph_)) { + GELOGD("Skip dynamic shape partition as in single op scene."); REQUIRE(AttrUtils::SetBool(*root_graph_, ATTR_NAME_DYNAMIC_SHAPE_PARTITIONED, false), "Failed set dynamic shape partitioned flag on root graph."); return SUCCESS; diff --git a/ge/graph/passes/base_pass.cc b/ge/graph/passes/base_pass.cc index 3b854c18..0868b729 100755 --- a/ge/graph/passes/base_pass.cc +++ b/ge/graph/passes/base_pass.cc @@ -30,8 +30,15 @@ constexpr int kMaxRePassTimes = 10000; constexpr size_t kMaxOneInNodes = 1000; // Each iteration, we take about 0.3k memory on the stack, we should change the recursion to loop later constexpr int kMaxRecursiveDepth = 20; +struct DuringPassNodeSets { + std::unordered_set nodes_seen; + std::unordered_set nodes_deleted; + std::unordered_set nodes_re_pass; + std::unordered_set nodes_re_pass_immediately; + std::unordered_set nodes_last; +}; -void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::queue &input_edge_nodes, +void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::deque &input_edge_nodes, std::unordered_set &nodes_seen, std::unordered_set &nodes_last) { nodes_last.clear(); for (auto &node : graph->GetDirectNode()) { @@ -40,7 +47,7 @@ void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::queue &i } size_t in_nums = node->GetInNodes().size(); if (in_nums == 0) { - input_edge_nodes.push(node); + input_edge_nodes.push_back(node); nodes_seen.insert(node.get()); } else if (in_nums > kMaxOneInNodes) { nodes_last.insert(node); @@ -48,7 +55,7 @@ void GetAllNodesNoInputEdge(const ComputeGraphPtr &graph, std::queue &i } } -void AddNextIterNodes(const Node::Vistor &nodes, std::queue &nodes_to_pass, +void AddNextIterNodes(const Node::Vistor &nodes, std::deque &nodes_to_pass, std::unordered_set &nodes_seen, std::unordered_set &nodes_last) { for (auto &node : nodes) { if (node == nullptr) { @@ -60,13 +67,30 @@ void AddNextIterNodes(const Node::Vistor &nodes, std::queue &n bool all_in_nodes_seen = node->IsAllInNodesSeen(nodes_seen); if (all_in_nodes_seen && nodes_seen.insert(node.get()).second) { - nodes_to_pass.push(node); + nodes_to_pass.push_back(node); } } } -Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, std::unordered_set &nodes_re_pass, - std::unordered_set &nodes_deleted, std::unordered_set &nodes_seen) { +void PushToRePassIfSeen(NodePtr &node, const std::pair &name_to_pass, + std::unordered_set &nodes_seen, std::unordered_set &nodes_to_re_pass, + std::unordered_set &nodes_re_pass) { + for (const auto &node_to_re_pass : nodes_to_re_pass) { + if (node_to_re_pass == nullptr) { + GELOGW("Found null re-pass node when executing %s on node %s type %s", name_to_pass.first.c_str(), + node->GetName().c_str(), node->GetType().c_str()); + continue; + } + if (nodes_seen.count(node_to_re_pass.get()) > 0 || node_to_re_pass->IsAllInNodesSeen(nodes_seen)) { + GELOGD("The node %s will be re-pass.", node_to_re_pass->GetName().c_str()); + nodes_re_pass.insert(node_to_re_pass); + } else { + GELOGD("The node %s are not all seen, don't set repass this time", node_to_re_pass->GetName().c_str()); + } + } +} + +Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, DuringPassNodeSets &during_pass_node_set) { if (node == nullptr) { GELOGE(FAILED, "parameter is null."); return FAILED; @@ -90,22 +114,15 @@ Status RunPasses(NodePtr &node, const NamesToPass &names_to_passes, std::unorder } auto nodes_to_re_pass = name_to_pass.second->GetNodesNeedRePass(); - for (const auto &node_to_re_pass : nodes_to_re_pass) { - if (node_to_re_pass == nullptr) { - GELOGW("Found null re-pass node when executing %s on node %s type %s", name_to_pass.first.c_str(), - node->GetName().c_str(), node->GetType().c_str()); - continue; - } - if (nodes_seen.count(node_to_re_pass.get()) > 0 || node_to_re_pass->IsAllInNodesSeen(nodes_seen)) { - GELOGD("The node %s will be re-pass later", node_to_re_pass->GetName().c_str()); - nodes_re_pass.insert(node_to_re_pass); - } else { - GELOGD("The node %s are not all seen, don't set repass this time", node_to_re_pass->GetName().c_str()); - } - } + PushToRePassIfSeen(node, name_to_pass, during_pass_node_set.nodes_seen, nodes_to_re_pass, + during_pass_node_set.nodes_re_pass); + + auto nodes_to_re_pass_immediately = name_to_pass.second->GetNodesNeedRePassImmediately(); + PushToRePassIfSeen(node, name_to_pass, during_pass_node_set.nodes_seen, nodes_to_re_pass_immediately, + during_pass_node_set.nodes_re_pass_immediately); auto nodes_deleted_by_pass = name_to_pass.second->GetNodesDeleted(); - nodes_deleted.insert(nodes_deleted_by_pass.begin(), nodes_deleted_by_pass.end()); + during_pass_node_set.nodes_deleted.insert(nodes_deleted_by_pass.begin(), nodes_deleted_by_pass.end()); if (nodes_deleted_by_pass.count(node) > 0) { GELOGD("The node %s was deleted by pass %s, stop the remain passes", node->GetName().c_str(), name_to_pass.first.c_str()); @@ -181,36 +198,33 @@ Status GEPass::Run(const NamesToPass &names_to_passes) { Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { GELOGD("Begin to run pass on graph, passes count %zu", names_to_passes.size()); - std::queue nodes; - std::unordered_set nodes_seen; - std::unordered_set nodes_deleted; - std::unordered_set nodes_re_pass; - std::unordered_set nodes_last; - GetAllNodesNoInputEdge(graph_, nodes, nodes_seen, nodes_last); + std::deque nodes; + DuringPassNodeSets during_pass_node_set; + GetAllNodesNoInputEdge(graph_, nodes, during_pass_node_set.nodes_seen, during_pass_node_set.nodes_last); GELOGD("Start points count %zu", nodes.size()); int re_pass_times = 0; do { - for (auto &node : nodes_re_pass) { - nodes.push(node); - nodes_seen.insert(node.get()); + for (auto &node : during_pass_node_set.nodes_re_pass) { + nodes.push_back(node); + during_pass_node_set.nodes_seen.insert(node.get()); } - nodes_re_pass.clear(); + during_pass_node_set.nodes_re_pass.clear(); while (!nodes.empty()) { NodePtr node = nodes.front(); - nodes.pop(); + nodes.pop_front(); - (void)nodes_re_pass.erase(node); + (void)during_pass_node_set.nodes_re_pass.erase(node); GE_IF_BOOL_EXEC(node == nullptr, GELOGW("node is null"); continue); - if (nodes_deleted.count(node) > 0) { + if (during_pass_node_set.nodes_deleted.count(node) > 0) { GELOGD("The node %s was deleted before, skip it.", node->GetName().c_str()); continue; } - AddNextIterNodes(node->GetOutNodes(), nodes, nodes_seen, nodes_last); + AddNextIterNodes(node->GetOutNodes(), nodes, during_pass_node_set.nodes_seen, during_pass_node_set.nodes_last); - auto ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); + auto ret = RunPasses(node, names_to_passes, during_pass_node_set); if (ret != SUCCESS) { GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", node->GetName().c_str(), node->GetType().c_str(), ret); @@ -227,7 +241,7 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { if (has_sub_graph) { GELOGD("There are subgraphs on node %s, run passes for for the second time", node->GetName().c_str()); SetFlagOption(kOptimizeAfterSubGraph, names_to_passes); - ret = RunPasses(node, names_to_passes, nodes_re_pass, nodes_deleted, nodes_seen); + ret = RunPasses(node, names_to_passes, during_pass_node_set); if (ret != SUCCESS) { GELOGE(ret, "Failed to process passes on node %s type %s, error code: %u", node->GetName().c_str(), node->GetType().c_str(), ret); @@ -239,16 +253,21 @@ Status GEPass::RunPassesOneGraph(const NamesToPass &names_to_passes) { // should be called each time at the begin of the iteration ClearOption(names_to_passes); } + for (const auto &node : during_pass_node_set.nodes_re_pass_immediately) { + GELOGD("The node %s will be re-pass immediately.", node->GetName().c_str()); + nodes.push_front(node); + } + during_pass_node_set.nodes_re_pass_immediately.clear(); } - for (auto &node : nodes_last) { - bool all_in_nodes_seen = node->IsAllInNodesSeen(nodes_seen); - if (all_in_nodes_seen && nodes_seen.insert(node.get()).second) { - nodes.push(node); + for (auto &node : during_pass_node_set.nodes_last) { + bool all_in_nodes_seen = node->IsAllInNodesSeen(during_pass_node_set.nodes_seen); + if (all_in_nodes_seen && during_pass_node_set.nodes_seen.insert(node.get()).second) { + nodes.push_back(node); } } - nodes_last.clear(); - } while ((!nodes_re_pass.empty() || !nodes.empty()) && ++re_pass_times < kMaxRePassTimes); + during_pass_node_set.nodes_last.clear(); + } while ((!during_pass_node_set.nodes_re_pass.empty() || !nodes.empty()) && ++re_pass_times < kMaxRePassTimes); if (re_pass_times == kMaxRePassTimes) { GELOGW("re_pass_times should not come to %d", kMaxRePassTimes); diff --git a/ge/graph/passes/base_pass.h b/ge/graph/passes/base_pass.h index bb41691d..a9f4f000 100644 --- a/ge/graph/passes/base_pass.h +++ b/ge/graph/passes/base_pass.h @@ -53,6 +53,8 @@ class BaseNodePass { std::unordered_set GetNodesNeedRePass() { return nodes_need_re_pass_; } + std::unordered_set GetNodesNeedRePassImmediately() { return nodes_need_re_pass_immediately_; } + std::unordered_set GetNodesDeleted() { return nodes_deleted_; } void SetOption(NodePassOption option, const std::string &value) { options_[option] = value; } @@ -62,6 +64,7 @@ class BaseNodePass { void init() { nodes_need_re_pass_.clear(); nodes_deleted_.clear(); + nodes_need_re_pass_immediately_.clear(); } protected: @@ -79,6 +82,14 @@ class BaseNodePass { /// void AddRePassNode(NodePtr &node) { nodes_need_re_pass_.insert(node); } + /// + /// Add a node to be optimized immediately again. If you add a new node to the graph, or + /// change a node connections, and you want to make sure the node will be + /// optimized by other passes, call this function. + /// @param node + /// + void AddImmediateRePassNode(NodePtr &node) { nodes_need_re_pass_immediately_.insert(node); } + /// /// Add a node and it's input/output data nodes to be optimized again. /// @param node @@ -109,6 +120,7 @@ class BaseNodePass { private: std::unordered_set nodes_need_re_pass_; + std::unordered_set nodes_need_re_pass_immediately_; std::unordered_set nodes_deleted_; std::map options_; }; diff --git a/ge/graph/passes/cast_translate_pass.cc b/ge/graph/passes/cast_translate_pass.cc index 01b5c96b..2e95c19f 100644 --- a/ge/graph/passes/cast_translate_pass.cc +++ b/ge/graph/passes/cast_translate_pass.cc @@ -167,7 +167,7 @@ bool CastTranslatePass::IsOpSupportedOptimize(NodePtr &cast_node, NodePtr &trans trans_op_outdesc->SetDataType(cast_out_datatype); } - if (!TranslateCheckAccuracySupported(trans_op_desc)) { + if (!TranslateCheckAccuracySupported(trans_node)) { if (is_src_cast) { trans_op_desc->MutableInputDesc(0)->SetDataType(trans_in_datatype); } else { @@ -271,7 +271,8 @@ Status CastTranslatePass::FuseDstNTranslates(NodePtr &node) { return SUCCESS; } -bool CastTranslatePass::TranslateCheckAccuracySupported(const OpDescPtr &op_desc) { +bool CastTranslatePass::TranslateCheckAccuracySupported(NodePtr &node) { + const OpDescPtr &op_desc = node->GetOpDesc(); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { GELOGW("GE is not initialized or is finalized."); @@ -293,7 +294,7 @@ bool CastTranslatePass::TranslateCheckAccuracySupported(const OpDescPtr &op_desc auto kernel_info_store = kernel_map.find(kernel_name); if (kernel_info_store != kernel_map.end()) { if (kernel_info_store->second != nullptr && - kernel_info_store->second->CheckAccuracySupported(op_desc, unsupported_reason)) { + kernel_info_store->second->CheckAccuracySupported(node, unsupported_reason)) { return true; } } diff --git a/ge/graph/passes/cast_translate_pass.h b/ge/graph/passes/cast_translate_pass.h index 04c03d42..5c1dcd9a 100755 --- a/ge/graph/passes/cast_translate_pass.h +++ b/ge/graph/passes/cast_translate_pass.h @@ -35,7 +35,7 @@ class CastTranslatePass : public BaseNodePass { bool IsOpSupportedOptimize(NodePtr &cast_node, NodePtr &trans_node, bool &is_src_cast); bool CheckOpSupportOptimize(NodePtr &node, bool &is_src_cast); Status FuseDstNTranslates(NodePtr &node); - bool TranslateCheckAccuracySupported(const OpDescPtr &op_desc); + bool TranslateCheckAccuracySupported(NodePtr &node); }; } // namespace ge #endif // GE_GRAPH_PASSES_CAST_TRANSLATE_PASS_H_ diff --git a/ge/graph/passes/compile_nodes_pass.cc b/ge/graph/passes/compile_nodes_pass.cc index 1ed9caf0..7de7fd48 100755 --- a/ge/graph/passes/compile_nodes_pass.cc +++ b/ge/graph/passes/compile_nodes_pass.cc @@ -110,7 +110,7 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: return ge::GE_GRAPH_PARAM_NULLPTR; } // begin accuracy supported check - if (!CheckAccuracySupport(kernel_info, instance, op_desc)) { + if (!CheckAccuracySupport(kernel_info, instance, node)) { // if check accuracy support failed , try to go to other engine. GELOGD("Check Accuracy Supported return not support, node name is %s. Try to go to other engine.", op_desc->GetName().c_str()); @@ -123,7 +123,7 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: continue; } OpsKernelInfoStorePtr tmp_kernel_info = it->second; - if (CheckAccuracySupport(tmp_kernel_info, instance, op_desc)) { + if (CheckAccuracySupport(tmp_kernel_info, instance, node)) { kernel_lib_name = tmp_kernel_name; GELOGD("Find kernel lib %s support node:%s, type:%s , get kernel lib success.", tmp_kernel_name.c_str(), node->GetName().c_str(), op_desc->GetType().c_str()); @@ -138,14 +138,9 @@ graphStatus CompileNodesPass::GetSupportedKernel(const NodePtr &node, const std: } bool CompileNodesPass::CheckAccuracySupport(const OpsKernelInfoStorePtr &kernel_info, - const std::shared_ptr instance, OpDescPtr &op_desc) { - auto ge_desc = MakeShared(op_desc); - if (ge_desc == nullptr) { - GELOGE(GE_GRAPH_MEMORY_ALLOC_FAILED, "Fail to malloc op desc."); - return false; - } + const std::shared_ptr instance, const NodePtr &node) { string reason; - if (!(kernel_info->CheckAccuracySupported(*ge_desc, reason, true))) { + if (!(kernel_info->CheckAccuracySupported(node, reason, true))) { return false; } return true; diff --git a/ge/graph/passes/compile_nodes_pass.h b/ge/graph/passes/compile_nodes_pass.h index e2fb59c2..e9a77e07 100644 --- a/ge/graph/passes/compile_nodes_pass.h +++ b/ge/graph/passes/compile_nodes_pass.h @@ -39,7 +39,7 @@ class CompileNodesPass : public GraphPass { private: graphStatus GetSupportedKernel(const NodePtr &node, const std::shared_ptr instance, string &kernel_lib_name); bool CheckAccuracySupport(const OpsKernelInfoStorePtr &kernel_info, const std::shared_ptr instance, - OpDescPtr &op_desc); + const NodePtr &node); graphStatus CompileNodes(const std::shared_ptr instance, std::unordered_map> &kernel_to_compile_nodes); }; diff --git a/ge/graph/passes/dimension_adjust_pass.cc b/ge/graph/passes/dimension_adjust_pass.cc index 5701faf5..9677fa5f 100755 --- a/ge/graph/passes/dimension_adjust_pass.cc +++ b/ge/graph/passes/dimension_adjust_pass.cc @@ -29,13 +29,13 @@ const int kRemoveInputIndex = 1; Status DimensionAdjustPass::Run(ge::NodePtr &node) { if (node == nullptr) { - GELOGE(PARAM_INVALID, "node is nullptr"); + GELOGE(PARAM_INVALID, "node is nullptr."); return PARAM_INVALID; } OpDescPtr op_desc_ptr = node->GetOpDesc(); if (op_desc_ptr == nullptr) { - GELOGE(PARAM_INVALID, "GetOpDesc return nullptr"); + GELOGE(PARAM_INVALID, "GetOpDesc return nullptr."); return PARAM_INVALID; } diff --git a/ge/graph/passes/flow_ctrl_pass.cc b/ge/graph/passes/flow_ctrl_pass.cc index 5fc1733a..435130b3 100755 --- a/ge/graph/passes/flow_ctrl_pass.cc +++ b/ge/graph/passes/flow_ctrl_pass.cc @@ -33,11 +33,11 @@ Status FlowCtrlPass::Run(ComputeGraphPtr compute_graph) { GE_CHECK_NOTNULL(compute_graph); if (!PassUtils::IsNeedTrainIteFlowCtrl(compute_graph)) { - GELOGI("No need FlowCtrl for graph %u", compute_graph->GetGraphID()); + GELOGI("No need FlowCtrl for graph %u.", compute_graph->GetGraphID()); return NOT_CHANGED; } - GELOGI("FlowCtrl pass begin.graph is [%s]", compute_graph->GetName().c_str()); + GELOGI("FlowCtrl pass begin.graph is [%s].", compute_graph->GetName().c_str()); bool graph_change = false; // 1. Add FP/BP flow ctrl (big cycle) for (auto &node : compute_graph->GetDirectNode()) { @@ -347,11 +347,11 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c NodePtr assign_node = InsertAssignOp(compute_graph, ASSIGN, NODE_NAME_FLOWCTRL_LOOP_ASSIGN, loop_cond_node, loop_reset_node); if (assign_node == nullptr || switch_node == nullptr) { - GELOGE(PARAM_INVALID, "assign_node or switch node is null"); + GELOGE(PARAM_INVALID, "assign_node or switch node is null."); return FAILED; } - GE_CHK_STATUS_RET(SetStreamLabel(assign_node, switch_node->GetName()), "set stream label failed"); + GE_CHK_STATUS_RET(SetStreamLabel(assign_node, switch_node->GetName()), "set stream label failed."); graphStatus add_ret = GraphUtils::AddEdge(switch_node->GetOutControlAnchor(), assign_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { @@ -370,7 +370,7 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c } GE_CHK_STATUS_RET(SetStreamLabel(active_node, switch_node->GetName()), "set stream label failed"); GE_CHK_STATUS_RET(SetSwitchBranchNodeLabel(active_node, switch_node->GetName()), - "set switch branch node label failed"); + "set switch branch node label failed."); string model_exit_name = switch_node->GetName() + "_ModelExit"; GE_CHK_STATUS_RET(SetActiveLabelList(active_node, { model_exit_name }), "set active label list failed"); @@ -401,7 +401,7 @@ Status FlowCtrlPass::CreateIterCtrlFalseBranch(ComputeGraphPtr &compute_graph, c } Status FlowCtrlPass::AddFpBpIteratorCtrl(ComputeGraphPtr &compute_graph, NodePtr &pre_node) { - GE_IF_BOOL_EXEC(pre_node == nullptr, DOMI_LOGE("pre_node is nullptr"); return FAILED); + GE_IF_BOOL_EXEC(pre_node == nullptr, DOMI_LOGE("pre_node is nullptr."); return FAILED); string pre_node_name = pre_node->GetName(); GELOGI("Add FpBp Iterator ctrl, pre node:%s.", pre_node_name.c_str()); // 1. Get or add variables @@ -477,7 +477,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, * itersPerLoop loopCond */ GE_IF_BOOL_EXEC(loop_after_node == nullptr || compute_graph == nullptr, - DOMI_LOGE("loop after node or compute graph is null"); return FAILED); + DOMI_LOGE("loop after node or compute graph is null."); return FAILED); InDataAnchorPtr in_anchor = loop_after_node->GetInDataAnchor(0); if (in_anchor == nullptr || in_anchor->GetPeerOutAnchor() == nullptr) { GELOGE(FAILED, "Find %s in data anchor failed.", loop_after_node->GetName().c_str()); @@ -498,7 +498,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, } // 2. Add StreamSwitch and edges to switch_node. - GE_IF_BOOL_EXEC(loop_pre_node == nullptr, DOMI_LOGE("loop pre node is null"); return FAILED); + GE_IF_BOOL_EXEC(loop_pre_node == nullptr, DOMI_LOGE("loop pre node is null."); return FAILED); string switch_name = loop_pre_node->GetName() + "_" + NODE_NAME_STREAM_SWITCH; NodePtr switch_node = InsertStreamSwitchOp(compute_graph, switch_name, loop_cond_node, iter_per_loop_node); if (switch_node == nullptr) { @@ -506,7 +506,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, return FAILED; } - GE_CHK_STATUS_RET(SetStreamLabel(switch_node, switch_name), "set stream label failed"); + GE_CHK_STATUS_RET(SetStreamLabel(switch_node, switch_name), "set stream label failed."); graphStatus add_ret = GraphUtils::AddEdge(loop_pre_node->GetOutControlAnchor(), switch_node->GetInControlAnchor()); if (add_ret != GRAPH_SUCCESS) { @@ -529,7 +529,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, return FAILED; } - GE_CHK_STATUS_RET(SetStreamLabel(active_node, active_name), "set stream label failed"); + GE_CHK_STATUS_RET(SetStreamLabel(active_node, active_name), "set stream label failed."); GE_IF_BOOL_EXEC(!AttrUtils::SetBool(active_node->GetOpDesc(), ATTR_NAME_IS_LOOP_ACTIVE, true), DOMI_LOGE("set ATTR_NAME_IS_LOOP_ACTIVE failed"); return FAILED); @@ -542,7 +542,7 @@ Status FlowCtrlPass::AddSpecialNodeIteratorCtrl(ComputeGraphPtr &compute_graph, } // used for stream assign to find true branch - GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, { active_name }), "set active label list failed"); + GE_CHK_STATUS_RET(SetActiveLabelList(switch_node, { active_name }), "set active label list failed."); // used for stream assign to find active stream GE_CHK_STATUS_RET(SetActiveLabelList(active_node, { loop_pre_node->GetName() }), "set active label list failed"); active_nodes_in_iter_loop_.push_back(active_node); diff --git a/ge/graph/passes/infershape_pass.cc b/ge/graph/passes/infershape_pass.cc index 7b8f7b50..a54a15c1 100755 --- a/ge/graph/passes/infershape_pass.cc +++ b/ge/graph/passes/infershape_pass.cc @@ -25,6 +25,7 @@ namespace ge { Status InferShapePass::Run(NodePtr &node) { + // kOptimizeAfterSubGraph exist means after subgraph auto ret = ShapeRefiner::InferShapeAndType(node, !OptionExists(kOptimizeAfterSubGraph)); if (ret != GRAPH_SUCCESS) { // select INFERSHAPE failed info @@ -41,6 +42,20 @@ Status InferShapePass::Run(NodePtr &node) { GELOGE(GE_GRAPH_INFERSHAPE_FAILED, "infershape failed. node: %s", node->GetName().c_str()); return GE_GRAPH_INFERSHAPE_FAILED; } + bool need_repass = false; + auto has_attr = AttrUtils::GetBool(node->GetOpDesc(), "need_infer_again_", need_repass); + if (has_attr) { + if (!OptionExists(kOptimizeAfterSubGraph)) { + return SUCCESS; + } + if (need_repass) { + AddImmediateRePassNode(node); + GELOGD("Node %s need repass immediately.", node->GetName().c_str()); + } else { + // clear attr on while + node->GetOpDesc()->DelAttr("need_infer_again_"); + } + } return SUCCESS; } } // namespace ge diff --git a/ge/graph/passes/link_gen_mask_nodes_pass.cc b/ge/graph/passes/link_gen_mask_nodes_pass.cc index 9bd991aa..5c4df98b 100755 --- a/ge/graph/passes/link_gen_mask_nodes_pass.cc +++ b/ge/graph/passes/link_gen_mask_nodes_pass.cc @@ -93,7 +93,7 @@ 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) { + if (node->GetType() != DROPOUTDOMASK && node->GetType() != DROPOUTDOMASKV3 && node->GetType() != DROPOUTDOMASKV3D) { continue; } diff --git a/ge/graph/passes/net_output_pass.cc b/ge/graph/passes/net_output_pass.cc index c553607f..b203438e 100644 --- a/ge/graph/passes/net_output_pass.cc +++ b/ge/graph/passes/net_output_pass.cc @@ -555,6 +555,8 @@ void NetOutputPass::AddInOutForNetOutputOp(const ComputeGraphPtr &graph, OpDescP return; } ge::GeTensorDesc out_desc = src_node->GetOpDesc()->GetOutputDesc(src_index); + out_desc.SetFormat(FORMAT_ND); + out_desc.SetOriginFormat(FORMAT_ND); GE_IF_BOOL_EXEC(net_output_desc->AddInputDesc(out_desc) != SUCCESS, GELOGW("add input desc failed"); return ); is_input_const.push_back(PassUtils::IsConstant(src_node)); ++iter; diff --git a/ge/graph/passes/next_iteration_pass.cc b/ge/graph/passes/next_iteration_pass.cc index cf46f09d..8d76da32 100644 --- a/ge/graph/passes/next_iteration_pass.cc +++ b/ge/graph/passes/next_iteration_pass.cc @@ -22,6 +22,10 @@ using std::string; namespace ge { +namespace { +const int64_t kLoopType = 1; +} + Status NextIterationPass::Run(ComputeGraphPtr graph) { GELOGD("NextIterationPass Enter"); /// Enter-----------+ @@ -121,7 +125,10 @@ Status NextIterationPass::FindWhileGroups() { if (switch_node == nullptr) { continue; } - + if (!AttrUtils::SetInt(switch_node->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_TYPE, kLoopType)) { + GELOGE(INTERNAL_ERROR, "set int failed"); + 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()); diff --git a/ge/graph/passes/parallel_group_pass.cc b/ge/graph/passes/parallel_group_pass.cc new file mode 100644 index 00000000..0d033fbf --- /dev/null +++ b/ge/graph/passes/parallel_group_pass.cc @@ -0,0 +1,354 @@ +/** + * 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 "graph/passes/parallel_group_pass.h" + +#include "framework/common/debug/ge_log.h" +#include "common/ge/ge_util.h" +#include "framework/common/ge_inner_error_codes.h" +#include "graph/debug/ge_attr_define.h" +#include "graph/utils/graph_utils.h" +#include "graph/utils/node_utils.h" + +namespace ge { +namespace { +const int32_t kMaxRecursionDepth = 10; +const int64_t kLoopType = 1; +} + +Status ParallelGroupPass::Run(ComputeGraphPtr graph) { + GELOGD("ParallelGroupPass running"); + if (graph == nullptr) { + GELOGE(PARAM_INVALID, "[Check][Graph]Input param graph is null, skip ParallelGroupPass."); + REPORT_INNER_ERROR("E19999", "Input param graph is null, skip ParallelGroupPass."); + return PARAM_INVALID; + } + + if (graph->GetParentGraph() != nullptr) { + GELOGD("Current graph %s is a subgraph, this pass only support root graph.", + graph->GetName().c_str()); + return SUCCESS; + } + + if (graph->TopologicalSorting() != GRAPH_SUCCESS) { + GELOGE(FAILED, "[TopoSort][Graph]Graph:%s topological sort failed.", graph->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "Graph:%s topological sort failed when ParallelGroupPass run.", + graph->GetName().c_str()); + return FAILED; + } + + std::unordered_set parallel_groups; + int depth = 0; + if (ProcessGraphGroupNodes(graph, depth, parallel_groups) != SUCCESS) { + GELOGE(INTERNAL_ERROR, "[Process][Graph]Process group nodes of graph %s failed.", graph->GetName().c_str()); + return INTERNAL_ERROR; + } + + if (graph->TopologicalSorting() != GRAPH_SUCCESS) { + GELOGE(FAILED, "[TopoSort][Graph]Graph:%s topological sort failed.", graph->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "Graph:%s topological sort failed when ParallelGroupPass run.", + graph->GetName().c_str()); + return FAILED; + } + + return SUCCESS; +} + +Status ParallelGroupPass::ProcessGraphGroupNodes(ComputeGraphPtr graph, int32_t depth, + std::unordered_set ¶llel_groups) { + if (depth >= kMaxRecursionDepth) { + GELOGE(FAILED, "[Process][SubGraph]There are too much subgraphs:%d > %d(max subgraphs)", depth, kMaxRecursionDepth); + REPORT_INNER_ERROR("E19999", "There are too much subgraphs:%d > %d(max subgraphs)", depth, kMaxRecursionDepth); + return FAILED; + } + std::map> group_nodes; + auto candidates = graph->GetDirectNode(); + auto root_graph = GraphUtils::FindRootGraph(graph); + for (const auto &node : candidates) { + OpDescPtr op_desc = node->GetOpDesc(); + if (op_desc == nullptr) { + continue; + } + std::string group_name; + if (AttrUtils::GetStr(op_desc, ATTR_NAME_PARALLEL_GROUP, group_name)) { + group_nodes[group_name].push_back(node); + parallel_groups.insert(group_name); + GELOGD("Find group node:%s, group_name:%s", node->GetName().c_str(), group_name.c_str()); + } + + const auto &subgraph_name = op_desc->GetSubgraphInstanceNames(); + GE_CHECK_NOTNULL(root_graph); + for (auto name_iter = subgraph_name.rbegin(); name_iter != subgraph_name.rend(); ++name_iter) { + const auto &sub_graph = root_graph->GetSubgraph(*name_iter); + GE_CHECK_NOTNULL(sub_graph); + // if the pass add control edge for known and unknown graph, then the known graph will become unknown graph + // the order between known and unknown graph is guaranteed by dynamic shape executor + // so the parallel group pass do nothing for unknown graph + if (sub_graph->GetGraphUnknownFlag()) { + continue; + } + std::unordered_set sub_parallel_groups; + auto ret = ProcessGraphGroupNodes(sub_graph, depth + 1, sub_parallel_groups); + if (ret != SUCCESS) { + GELOGE(FAILED, "[Process][SubGraph]Process sub graph %s failed.", sub_graph->GetName().c_str()); + return FAILED; + } + for (const auto &sub_parallel_group : sub_parallel_groups) { + parallel_groups.insert(sub_parallel_group); + group_nodes[sub_parallel_group].emplace_back(node); + } + } + } + + std::map, NodePtr>> node_2_switch_merge; + if (ProcessGroupNodeInSwitch(graph, node_2_switch_merge) != SUCCESS) { + GELOGE(FAILED, "[Process][Node]Process group node in switch failed, graph:%s.", graph->GetName().c_str()); + return FAILED; + } + + for (const auto &itr : group_nodes) { + const auto &nodes = itr.second; + if (nodes.empty()) { + continue; + } + NodePtr pre_node = nodes[0]; + NodePtr cur_node = nullptr; + for (std::size_t i = 1; i < nodes.size(); i++) { + cur_node = nodes[i]; + GELOGD("Original add ctrl anchor for node:%s->%s", pre_node->GetName().c_str(), + cur_node->GetName().c_str()); + if (ReplaceWithSwitchAndMerge(pre_node, cur_node, node_2_switch_merge) != SUCCESS) { + GELOGE(FAILED, "[Replace][Node]Replace switch and merges for nodes: %s and %s failed.", + pre_node->GetName().c_str(), cur_node->GetName().c_str()); + return FAILED; + } + pre_node = cur_node; + } + } + + return SUCCESS; +} + +Status ParallelGroupPass::AddCtrlEdge(NodePtr pre_node, NodePtr cur_node) { + if (pre_node == cur_node) { + GELOGD("Pre_node and cur_node are same, no need add anchor"); + return SUCCESS; + } + auto in_nodes = cur_node->GetInAllNodes(); + for (const auto &node : in_nodes) { + if (pre_node == node) { + GELOGD("Node:%s and %s already linked", pre_node->GetName().c_str(), + cur_node->GetName().c_str()); + return SUCCESS; + } + } + GELOGD("Finally add ctrl anchor for node:%s->%s", pre_node->GetName().c_str(), + cur_node->GetName().c_str()); + return GraphUtils::AddEdge(pre_node->GetOutControlAnchor(), + cur_node->GetInControlAnchor()); +} + +Status ParallelGroupPass::ProcessGroupNodeInSwitch(ComputeGraphPtr graph, + std::map, NodePtr>> &node_2_switch_merge) { + + std::string type; + auto direct_nodes = graph->GetDirectNode(); + for (const auto &node : direct_nodes) { + type = node->GetType(); + if (type != STREAMSWITCH) { + continue; + } + + if (IsBigSmallLoopStreamSwitch(node->GetOpDesc()) || + IsWhileStreamSwitch(node->GetOpDesc())) { + continue; + } + + std::vector merge_nodes; + std::set group_nodes; + std::set stream_labels; + + FindGroupNodeAndMerge(node, group_nodes, merge_nodes, stream_labels); + + if (merge_nodes.empty() || (!group_nodes.empty() && stream_labels.size() > 1)) { + GELOGE(FAILED, "[Process][Node]Cannot find merge node or exist switch nestification, switch node:%s," + "merge_vec size:%zu, stream_labels size:%zu, graph:%s.", node->GetName().c_str(), + merge_nodes.size(), stream_labels.size(), graph->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "Cannot find merge node or exist switch nest, switch node:%s," + "merge_vec size: %zu, stream_labels size: %zu, graph:%s.", node->GetName().c_str(), + merge_nodes.size(), stream_labels.size(), graph->GetName().c_str()); + return FAILED; + } + + std::sort(merge_nodes.begin(), merge_nodes.end(), + [] (NodePtr a, NodePtr b) -> bool { + return (a->GetOpDesc()->GetId() < b->GetOpDesc()->GetId()); + }); + + NodePtr cast_node = NodeUtils::GetInDataNodeByIndex(*node, 0); + GE_CHECK_NOTNULL(cast_node); + if (MappingNodeToSwitchAndMerge(group_nodes, merge_nodes, + cast_node, node, + node_2_switch_merge) != SUCCESS) { + GELOGE(FAILED, "[Mapping][Node]Mapping node to switch and merge failed, graph:%s.", graph->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "[Mapping][Node]Mapping node to switch and merge failed, graph:%s.", + graph->GetName().c_str()); + return FAILED; + } + } + + return SUCCESS; +} + +void ParallelGroupPass::FindGroupNodeAndMerge(NodePtr stream_switch_node, std::set &group_nodes, + std::vector &merge_nodes, std::set &stream_labels) { + std::string type; + std::deque candidates; + std::set visited; + + candidates.push_back(stream_switch_node); + while (!candidates.empty()) { + NodePtr tmp_node = candidates.front(); + candidates.pop_front(); + for (const auto &out_node : tmp_node->GetOutAllNodes()) { + type = out_node->GetType(); + if (type == STREAMMERGE) { + merge_nodes.emplace_back(out_node); + continue; + } + const auto &op = out_node->GetOpDesc(); + if (op != nullptr && op->HasAttr(ATTR_NAME_PARALLEL_GROUP)) { + group_nodes.emplace(out_node); + } + if (visited.count(out_node) > 0) { + continue; + } + candidates.push_back(out_node); + visited.insert(out_node); + std::string stream_label; + if (ge::AttrUtils::GetStr(out_node->GetOpDesc(), ATTR_NAME_STREAM_LABEL, stream_label)) { + stream_labels.insert(stream_label); + } + } + } +} + +Status ParallelGroupPass::MappingNodeToSwitchAndMerge(const std::set &group_nodes, + const std::vector &merge_nodes, + const NodePtr &cast_node, const NodePtr &switch_node, + std::map, NodePtr>> &node_2_switch_merge) { + for (const auto &group_node : group_nodes) { + auto itr = node_2_switch_merge.find(group_node); + if (itr != node_2_switch_merge.end()) { + auto &tmp = itr->second; + auto &switch_set = tmp.first; + const auto &merge_node = tmp.second; + GELOGD("Find group node: %s in switch %s and merge %s.", + group_node->GetName().c_str(), switch_node->GetName().c_str(), merge_node->GetName().c_str()); + if (merge_node != merge_nodes.back()) { + GELOGE(FAILED, "[Mapping][Node]Has two different merge nodes: %s and %s, graph's structure is invalid", + merge_node->GetName().c_str(), merge_nodes.back()->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "Has two different merge nodes: %s and %s," + "graph's structure is invalid", + merge_node->GetName().c_str(), merge_nodes.back()->GetName().c_str()); + return FAILED; + } + switch_set.insert(cast_node); + } else { + node_2_switch_merge.emplace(group_node, + std::make_pair(std::set{cast_node}, merge_nodes.back())); + } + } + return SUCCESS; +} + +Status ParallelGroupPass::ReplaceWithSwitchAndMerge(NodePtr pre_node, NodePtr cur_node, + const std::map, NodePtr>> &node_2_switch_merge) { + auto pre_itr = node_2_switch_merge.find(pre_node); + auto cur_itr = node_2_switch_merge.find(cur_node); + if (pre_itr != node_2_switch_merge.end()) { + if (cur_itr != node_2_switch_merge.end()) { + const auto &pre_set = pre_itr->second.first; + const auto &cur_set = cur_itr->second.first; + if (!HasSameSwitch(pre_set, cur_set)) { + pre_node = pre_itr->second.second; + for (const auto &switch_node : cur_itr->second.first) { + if (AddCtrlEdge(pre_node, switch_node) != SUCCESS) { + GELOGE(FAILED, "[AddEdge][Node]Add edge for nodes: %s->%s failed.", + pre_node->GetName().c_str(), switch_node->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "[AddEdge][Node]Add edge for nodes: %s->%s failed.", + pre_node->GetName().c_str(), switch_node->GetName().c_str()); + return FAILED; + } + } + } + return SUCCESS; + } else { + pre_node = pre_itr->second.second; + return AddCtrlEdge(pre_node, cur_node); + } + } else { + if (cur_itr != node_2_switch_merge.end()) { + for (const auto &switch_node : cur_itr->second.first) { + int64_t pre_id = pre_node->GetOpDesc()->GetId(); + int64_t switch_id = switch_node->GetOpDesc()->GetId(); + // avoid ring + if (pre_id > switch_id) { + auto merge_node = cur_itr->second.second; + if (AddCtrlEdge(merge_node, pre_node) != SUCCESS) { + GELOGE(FAILED, "[AddEdge][Node]Add edge for nodes: %s->%s failed.", + pre_node->GetName().c_str(), switch_node->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "[AddEdge][Node]Add edge for nodes: %s->%s failed.", + pre_node->GetName().c_str(), switch_node->GetName().c_str()); + return FAILED; + } + } else { + if (AddCtrlEdge(pre_node, switch_node) != SUCCESS) { + GELOGE(FAILED, "[AddEdge][Node]Add edge for nodes: %s->%s failed.", + pre_node->GetName().c_str(), switch_node->GetName().c_str()); + REPORT_CALL_ERROR("E19999", "[AddEdge][Node]Add edge for nodes: %s->%s failed.", + pre_node->GetName().c_str(), switch_node->GetName().c_str()); + return FAILED; + } + } + } + } else { + return AddCtrlEdge(pre_node, cur_node); + } + } + return SUCCESS; +} + +bool ParallelGroupPass::HasSameSwitch(const std::set &switch_set1, const std::set &switch_set2) { + for (const auto &node1 : switch_set1) { + auto itr = switch_set2.find(node1); + if (itr != switch_set2.end()) { + return true; + } + } + return false; +} + +bool ParallelGroupPass::IsBigSmallLoopStreamSwitch(OpDescPtr switch_op_desc) { + return !AttrUtils::HasAttr(switch_op_desc, ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG); +} + +bool ParallelGroupPass::IsWhileStreamSwitch(OpDescPtr switch_op_desc) { + int64_t stream_switch_type = -1; + return (AttrUtils::GetInt(switch_op_desc, ATTR_NAME_STREAM_SWITCH_TYPE, stream_switch_type) && + stream_switch_type == kLoopType); +} +} // namespace ge diff --git a/ge/graph/passes/parallel_group_pass.h b/ge/graph/passes/parallel_group_pass.h new file mode 100644 index 00000000..9b895598 --- /dev/null +++ b/ge/graph/passes/parallel_group_pass.h @@ -0,0 +1,53 @@ +/** + * 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_GRAPH_PASSES_PARALLEL_GROUP_PASS_H +#define GE_GRAPH_PASSES_PARALLEL_GROUP_PASS_H + +#include +#include +#include "graph/graph.h" +#include "inc/graph_pass.h" + +namespace ge { +class ParallelGroupPass : public GraphPass { + public: + Status Run(ComputeGraphPtr graph) override; + private: + Status ProcessGraphGroupNodes(ComputeGraphPtr graph, int32_t depth, std::unordered_set ¶llel_group); + + Status AddCtrlEdge(NodePtr pre_node, NodePtr cur_node); + + Status ReplaceWithSwitchAndMerge(NodePtr pre_node, NodePtr cur_node, + const std::map, NodePtr>> &node_2_switch_merge); + + bool HasSameSwitch(const std::set &a, const std::set &b); + + Status ProcessGroupNodeInSwitch(ComputeGraphPtr graph, + std::map, NodePtr>> &node_2_switch_merge); + + void FindGroupNodeAndMerge(NodePtr stream_switch_node, std::set &group_nodes, + std::vector &merge_nodes, std::set &stream_labels); + + Status MappingNodeToSwitchAndMerge(const std::set &group_set, const std::vector &merge_vec, + const NodePtr &cast_node, const NodePtr &switch_node, + std::map, NodePtr>> &node_2_switch_merge); + + bool IsBigSmallLoopStreamSwitch(OpDescPtr switch_op_desc); + bool IsWhileStreamSwitch(OpDescPtr switch_op_desc); +}; +} // namespace ge +#endif // GE_GRAPH_PASSES_PARALLEL_GROUP_PASS_H diff --git a/ge/graph/passes/resource_pair_add_control_pass.cc b/ge/graph/passes/resource_pair_add_control_pass.cc index 432bff9e..29a19f26 100755 --- a/ge/graph/passes/resource_pair_add_control_pass.cc +++ b/ge/graph/passes/resource_pair_add_control_pass.cc @@ -63,16 +63,17 @@ Status ResourcePairAddControlPass::Run(ComputeGraphPtr graph) { NodePtr from_node = prefix_2_node.second; GE_CHECK_NOTNULL(from_node); auto to_item_prefix_2_node = prefix_2_node_per_type.find(resource_type_pair.second); + // stackpush and stackpop may exist in two subgraphs, no necessary to report error if (to_item_prefix_2_node == prefix_2_node_per_type.end()) { - GELOGE(PARAM_INVALID, "find peer type node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), + GELOGW("find peer type node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), resource_type_pair.first.c_str(), resource_type_pair.second.c_str()); - return PARAM_INVALID; + continue; } auto to_prefix_2_node = to_item_prefix_2_node->second.find(prefix); if (to_prefix_2_node == to_item_prefix_2_node->second.end()) { - GELOGE(PARAM_INVALID, "find peer prefix node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), + GELOGW("find peer prefix node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), resource_type_pair.first.c_str(), resource_type_pair.second.c_str()); - return PARAM_INVALID; + continue; } NodePtr to_node = to_prefix_2_node->second; GE_CHECK_NOTNULL(to_node); diff --git a/ge/graph/passes/resource_pair_remove_control_pass.cc b/ge/graph/passes/resource_pair_remove_control_pass.cc index 83fc7081..7048ed1d 100755 --- a/ge/graph/passes/resource_pair_remove_control_pass.cc +++ b/ge/graph/passes/resource_pair_remove_control_pass.cc @@ -63,16 +63,17 @@ Status ResourcePairRemoveControlPass::Run(ComputeGraphPtr graph) { NodePtr from_node = prefix_2_node.second; GE_CHECK_NOTNULL(from_node); auto to_item_prefix_2_node = prefix_2_node_per_type.find(resource_type_pair.second); + // stackpush and stackpop may exist in two subgraphs, no necessary to report error if (to_item_prefix_2_node == prefix_2_node_per_type.end()) { - GELOGE(INTERNAL_ERROR, "find peer type node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), + GELOGW("find peer type node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), resource_type_pair.first.c_str(), resource_type_pair.second.c_str()); - return domi::PARAM_INVALID; + continue; } auto to_prefix_2_node = to_item_prefix_2_node->second.find(prefix); if (to_prefix_2_node == to_item_prefix_2_node->second.end()) { - GELOGE(INTERNAL_ERROR, "find peer prefix node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), + GELOGW("find peer prefix node fail, suffix:%s, from_type:%s, to_type:%s", prefix.c_str(), resource_type_pair.first.c_str(), resource_type_pair.second.c_str()); - return domi::PARAM_INVALID; + continue; } NodePtr to_node = to_prefix_2_node->second; GE_CHECK_NOTNULL(to_node); diff --git a/ge/graph/passes/switch_to_stream_switch_pass.cc b/ge/graph/passes/switch_to_stream_switch_pass.cc index 392968e7..8cc90eb1 100644 --- a/ge/graph/passes/switch_to_stream_switch_pass.cc +++ b/ge/graph/passes/switch_to_stream_switch_pass.cc @@ -307,6 +307,13 @@ NodePtr SwitchToStreamSwitchPass::CreateStreamSwitchNode(const ComputeGraphPtr & hccl_group_id.c_str()); } + int64_t switch_type; + if (AttrUtils::GetInt(switch_node->GetOpDesc(), ATTR_NAME_STREAM_SWITCH_TYPE, switch_type)) { + (void)AttrUtils::SetInt(op_desc, ATTR_NAME_STREAM_SWITCH_TYPE, switch_type); + GELOGD("Set attr ATTR_NAME_STREAM_SWITCH_TYPE for Stream_Switch %s, value is %ld.", node_name.c_str(), + switch_type); + } + if (!AttrUtils::SetInt(op_desc, ATTR_NAME_SWITCH_DATA_TYPE, RT_SWITCH_INT32) || !AttrUtils::SetInt(op_desc, ATTR_NAME_STREAM_SWITCH_COND, (int64_t)RT_EQUAL)) { GELOGE(INTERNAL_ERROR, "set int failed"); diff --git a/ge/graph/passes/transpose_transdata_pass.cc b/ge/graph/passes/transpose_transdata_pass.cc index 2178eac7..810f5639 100644 --- a/ge/graph/passes/transpose_transdata_pass.cc +++ b/ge/graph/passes/transpose_transdata_pass.cc @@ -86,7 +86,7 @@ Status TransposeTransDataPass::Run(NodePtr &node) { if (CheckOneInAndOneOutDataAnchor(out_node)) { return FAILED; } - if (!FusionIfNeed(op_desc, out_op_desc)) { + if (!FusionIfNeed(op_desc, out_node)) { continue; } CopyInputEdges(node, out_node); @@ -152,7 +152,8 @@ Status TransposeTransDataPass::RemoveTranspose(NodePtr &node) { return SUCCESS; } -bool TransposeTransDataPass::FusionIfNeed(OpDescPtr &op_desc, OpDescPtr &transdata_op_desc) { +bool TransposeTransDataPass::FusionIfNeed(OpDescPtr &op_desc, NodePtr &node) { + auto transdata_op_desc = node->GetOpDesc(); GE_CHECK_NOTNULL(op_desc); GE_CHECK_NOTNULL(transdata_op_desc); auto out_input_desc = transdata_op_desc->MutableInputDesc(0); @@ -187,7 +188,7 @@ bool TransposeTransDataPass::FusionIfNeed(OpDescPtr &op_desc, OpDescPtr &transda out_input_desc->SetFormat(src_format); out_input_desc->SetShape(src_shape); - if (!TransDataCheckAccuracySupported(transdata_op_desc)) { + if (!TransDataCheckAccuracySupported(node)) { out_input_desc->SetFormat(out_input_format); out_input_desc->SetShape(out_input_shape); return false; @@ -224,7 +225,8 @@ void TransposeTransDataPass::CopyInputEdges(NodePtr &origin_node, NodePtr &new_n GraphUtils::CopyInCtrlEdges(origin_node, new_node) != GRAPH_SUCCESS, GELOGW("Copy in ctrl edges failed"); return); } -bool TransposeTransDataPass::TransDataCheckAccuracySupported(const OpDescPtr &op_desc) { +bool TransposeTransDataPass::TransDataCheckAccuracySupported(NodePtr &node) { + const OpDescPtr &op_desc = node->GetOpDesc(); std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if ((instance_ptr == nullptr) || (!instance_ptr->InitFlag())) { GELOGW("GELib not initialized"); @@ -244,7 +246,7 @@ bool TransposeTransDataPass::TransDataCheckAccuracySupported(const OpDescPtr &op auto &kernel_name = it.opKernelLib; auto kernel_info_store = kernel_map.find(kernel_name); if (kernel_info_store != kernel_map.end()) { - if (kernel_info_store->second->CheckAccuracySupported(op_desc, unsupported_reason, true)) { + if (kernel_info_store->second->CheckAccuracySupported(node, unsupported_reason, true)) { return true; } } diff --git a/ge/graph/passes/transpose_transdata_pass.h b/ge/graph/passes/transpose_transdata_pass.h index a72893f6..c6ef0b36 100644 --- a/ge/graph/passes/transpose_transdata_pass.h +++ b/ge/graph/passes/transpose_transdata_pass.h @@ -26,9 +26,9 @@ class TransposeTransDataPass : public BaseNodePass { private: Status CheckOneInAndOneOutDataAnchor(NodePtr &node) const; Status RemoveTranspose(NodePtr &node); - bool FusionIfNeed(OpDescPtr &op_desc, OpDescPtr &transdata_op_desc); + bool FusionIfNeed(OpDescPtr &op_desc, NodePtr &node); void CopyInputEdges(NodePtr &origin_node, NodePtr &new_node); - bool TransDataCheckAccuracySupported(const OpDescPtr &op_desc); + bool TransDataCheckAccuracySupported(NodePtr &node); }; } // namespace ge #endif // GE_GRAPH_PASSES_TRANSPOSE_TRANSDATA_PASS_H_ diff --git a/ge/graph/passes/variable_op_pass.cc b/ge/graph/passes/variable_op_pass.cc index f1843d94..8f33335d 100644 --- a/ge/graph/passes/variable_op_pass.cc +++ b/ge/graph/passes/variable_op_pass.cc @@ -119,8 +119,9 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { return INTERNAL_ERROR; } + auto graph_id = GraphUtils::FindRootGraph(graph)->GetGraphID(); GELOGD("Begin to run variable op pass on graph %s, session %lu, graph id %u", graph->GetName().c_str(), - GetContext().SessionId(), graph->GetGraphID()); + GetContext().SessionId(), graph_id); if (var_accelerate_ctrl_ == nullptr) { GELOGE(INTERNAL_ERROR, "Failed to run var op pass, the variable accelerate control is null"); @@ -176,7 +177,7 @@ Status VariableOpPass::Run(ge::ComputeGraphPtr graph) { GELOGE(INTERNAL_ERROR, "Failed to update the format fusion road for var %s", node->GetName().c_str()); return INTERNAL_ERROR; } - ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph->GetGraphID()); + ret = VarManager::Instance(graph->GetSessionID())->SetChangedGraphId(node->GetName(), graph_id); if (ret != SUCCESS) { GELOGE(INTERNAL_ERROR, "Failed to update the graph id for var %s", node->GetName().c_str()); return INTERNAL_ERROR; diff --git a/ge/graph/preprocess/graph_preprocess.cc b/ge/graph/preprocess/graph_preprocess.cc index db17e091..b5b0daa4 100644 --- a/ge/graph/preprocess/graph_preprocess.cc +++ b/ge/graph/preprocess/graph_preprocess.cc @@ -23,6 +23,7 @@ #include "common/formats/format_transfers/format_transfer_nhwc_nc1hwc0.h" #include "common/formats/format_transfers/format_transfer_transpose.h" #include "common/formats/utils/formats_trans_utils.h" +#include "common/util/error_manager/error_manager.h" #include "common/helper/model_helper.h" #include "common/math/math_util.h" #include "common/op/ge_op_utils.h" @@ -1304,7 +1305,8 @@ Status GraphPrepare::UpdateInput(const std::vector &user_input, auto format = desc.GetFormat(); auto origin_format = desc.GetOriginFormat(); // data maybe internal format [FRACTAL_NZ] at singleop process such as GEMM. - bool need_check_internal_format = (!IsTansDataOpData(input_node)) && (!options_.is_single_op); + 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) { @@ -1346,19 +1348,22 @@ Status GraphPrepare::UpdateInput(const std::vector &user_input, return FAILED; } ge::TensorUtils::SetSize(desc, shape_size); - graphStatus graph_ret = op->UpdateInputDesc(0, desc); - if (graph_ret != GRAPH_SUCCESS) { - GELOGE(graph_ret, "UpdateInputDesc fail, graph_ret:%u", graph_ret); - return graph_ret; - } - // Size will be recalculated in the build stage - ge::TensorUtils::SetSize(desc, 0); - graph_ret = op->UpdateOutputDesc(0, desc); - if (graph_ret != GRAPH_SUCCESS) { - GELOGE(graph_ret, "UpdateOutputDesc fail, graph_ret:%u", graph_ret); - return graph_ret; + if (!tune_flag) { + graphStatus graph_ret = op->UpdateInputDesc(0, desc); + if (graph_ret != GRAPH_SUCCESS) { + GELOGE(graph_ret, "UpdateInputDesc fail, graph_ret:%u", graph_ret); + return graph_ret; + } + // Size will be recalculated in the build stage + ge::TensorUtils::SetSize(desc, 0); + graph_ret = op->UpdateOutputDesc(0, desc); + if (graph_ret != GRAPH_SUCCESS) { + GELOGE(graph_ret, "UpdateOutputDesc fail, graph_ret:%u", graph_ret); + return graph_ret; + } + } else { + GELOGI("data %s skip update info in tune mode", op->GetName().c_str()); } - if (!dynamic_shape_range_vec.empty()) { ret = UpdateDynamicInputShapeRange(index, dynamic_shape_range_vec, op, desc); GE_CHK_STATUS_RET(ret, "Fail to update dynamic input shape range on %s.", op->GetName().c_str()); @@ -1763,13 +1768,13 @@ Status GraphPrepare::CheckUserInput(const std::vector &user_input) { GeTensorDesc desc(user_input[index].GetTensorDesc()); for (size_t i = 0; i < desc.GetShape().GetDimNum(); ++i) { - if (desc.GetShape().GetDim(i) < 0) { - std::string situation = "data dim[" + std::to_string(i) + "][" + - std::to_string(desc.GetShape().GetDim(i)) + "]" ; - std::string reason = "it need >= 0"; - ErrorManager::GetInstance().ATCReportErrMessage("E19025", {"situation", "reason"}, {situation, reason}); - GELOGE(GE_GRAPH_INIT_FAILED, "data dim %zu is not supported, need >= 0, real:%ld.", i, - desc.GetShape().GetDim(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"; + REPORT_INPUT_ERROR( + "E19025", std::vector({"situation", "reason"}), std::vector({situation, 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/insert_op/ge_aipp_op.cc b/ge/graph/preprocess/insert_op/ge_aipp_op.cc index 7c8d9073..25af98b8 100755 --- a/ge/graph/preprocess/insert_op/ge_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/ge_aipp_op.cc @@ -428,7 +428,8 @@ Status AippOp::ConvertRelatedInputNameToRank() { if (!convert_flag) { 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."; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error_msg.c_str()); + GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); + REPORT_INPUT_ERROR("E19021", 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 b1534eb4..d8ae676c 100755 --- a/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc +++ b/ge/graph/preprocess/insert_op/util_insert_aipp_op.cc @@ -1,4 +1,4 @@ -/** + /** * Copyright 2020 Huawei Technologies Co., Ltd * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -124,13 +124,15 @@ Status InsertNewOpUtil::CheckInputNamePositionNotRepeat() { if (another_item->related_input_name().empty()) { 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)."; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error_msg.c_str()); + GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); + REPORT_INPUT_ERROR("E19021", 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."; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error_msg.c_str()); + GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); + REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } } @@ -150,13 +152,15 @@ Status InsertNewOpUtil::CheckInputRankPositionNoRepeat() { if (!another_item->related_input_name().empty()) { 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)."; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error_msg.c_str()); + GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); + REPORT_INPUT_ERROR("E19021", 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."; - GE_ERRORLOG_AND_ERRORMSG(PARAM_INVALID, error_msg.c_str()); + GELOGE(PARAM_INVALID, "[Check][InputParam]%s", error_msg.c_str()); + REPORT_INPUT_ERROR("E19021", std::vector({"reason"}), std::vector({error_msg})); return PARAM_INVALID; } } @@ -212,7 +216,7 @@ Status InsertNewOpUtil::CheckGraph(const ComputeGraphPtr &graph) { } } } - GE_CHK_LOG_AND_ERRORMSG((aippNodes.size() == 0) || (aippNodes.size() == next_nodes_cnt), + GE_CHK_LOG_AND_ERRORMSG((aippNodes.size() == 0) || (aippNodes.size() == next_nodes_cnt), PARAM_INVALID, "Can not config part of outputs of Data node to support AIPP, config all " "of the outputs of Data to support AIPP, or config none of them"); diff --git a/ge/host_cpu_engine/CMakeLists.txt b/ge/host_cpu_engine/CMakeLists.txt index 13cb7434..8d84ee28 100644 --- a/ge/host_cpu_engine/CMakeLists.txt +++ b/ge/host_cpu_engine/CMakeLists.txt @@ -3,6 +3,7 @@ set(PROTO_LIST ) protobuf_generate(ge PROTO_SRCS PROTO_HDRS ${PROTO_LIST}) +protobuf_generate(ge_atcstub PROTO_ATCSTUB_SRCS PROTO_ATCSTUB_HDRS ${PROTO_LIST}) set(SRC_LIST "engine/host_cpu_engine.cc" @@ -61,7 +62,7 @@ target_link_libraries(host_cpu_engine PRIVATE ) ############ atcstub/libhost_cpu_engine.so ############ -add_library(atc_host_cpu_engine SHARED ${SRC_LIST} ${PROTO_HDRS}) +add_library(atc_host_cpu_engine SHARED ${SRC_LIST} ${PROTO_ATCSTUB_HDRS}) target_compile_options(atc_host_cpu_engine PRIVATE -Werror @@ -84,7 +85,7 @@ target_include_directories(atc_host_cpu_engine PRIVATE ${METADEF_DIR}/inc/external ${METADEF_DIR}/inc/external/graph ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/proto/ge + ${CMAKE_BINARY_DIR}/proto/ge_atcstub #### yellow zone #### ${GE_CODE_DIR}/../inc #### blue zone #### diff --git a/ge/host_cpu_engine/engine/host_cpu_engine.cc b/ge/host_cpu_engine/engine/host_cpu_engine.cc index cdbad1ed..5e8394f0 100644 --- a/ge/host_cpu_engine/engine/host_cpu_engine.cc +++ b/ge/host_cpu_engine/engine/host_cpu_engine.cc @@ -18,6 +18,7 @@ #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" @@ -34,7 +35,8 @@ Status HostCpuEngine::Initialize(const std::map &options) { if (ops_kernel_store_ == nullptr) { ops_kernel_store_ = MakeShared(); if (ops_kernel_store_ == nullptr) { - GELOGE(FAILED, "Make HostCpuOpsKernelInfoStore failed."); + GELOGE(FAILED, "[Create][HostCpuEngine]Make HostCpuOpsKernelInfoStore failed."); + REPORT_INNER_ERROR("E19999", "HostCpuEngine::Initialize failed for new HostCpuEngine."); return FAILED; } } diff --git a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc index adb252bc..47809ae1 100644 --- a/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc +++ b/ge/host_cpu_engine/ops_kernel_store/host_cpu_ops_kernel_builder.cc @@ -21,6 +21,7 @@ #include "graph/utils/node_utils.h" #include "graph/utils/tensor_utils.h" #include "graph/utils/type_utils.h" +#include #include "framework/common/debug/ge_log.h" #include "host_cpu_engine/common/constant/constant.h" #include "register/ops_kernel_builder_registry.h" @@ -39,7 +40,8 @@ Status HostCpuOpsKernelBuilder::Initialize(const map & Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { OpDescPtr op_desc = ge_node.GetOpDesc(); if (op_desc == nullptr) { - GELOGE(FAILED, "CalcOpRunningParam failed, as op desc is null"); + GELOGE(FAILED, "[Get][OpDesc]CalcOpRunningParam failed, as op desc is null"); + REPORT_INNER_ERROR("E19999", "GetOpDesc failed."); return FAILED; } @@ -73,9 +75,14 @@ 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 op[%s:%s] out[%zu] mem size failed, 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()); + 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.", @@ -84,8 +91,13 @@ Status HostCpuOpsKernelBuilder::CalcOpRunningParam(Node &ge_node) { TensorUtils::SetSize(output_tensor, output_mem_size); if (op_desc->UpdateOutputDesc(static_cast(i), output_tensor) != GRAPH_SUCCESS) { - GELOGE(FAILED, "Update op[%s:%s] out[%zu] desc failed, 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()); return FAILED; } } diff --git a/ge/host_kernels/concat_offset_kernel.cc b/ge/host_kernels/concat_offset_kernel.cc index ff597873..b6940eb4 100644 --- a/ge/host_kernels/concat_offset_kernel.cc +++ b/ge/host_kernels/concat_offset_kernel.cc @@ -33,7 +33,7 @@ const int kNumOne = 1; } // namespace Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector &input, vector &v_output) { - GELOGI("ConcatOffsetKernel in."); + GELOGD("ConcatOffsetKernel in"); if (op_desc_ptr == nullptr) { GELOGE(PARAM_INVALID, "input opdesc is nullptr."); return PARAM_INVALID; @@ -41,7 +41,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector(reinterpret_cast(input_0->GetData().data()))); // validate inputs if ((static_cast(input.size()) != (N + kNumOne)) || (input.size() <= kConcatOffsetInputIndexOne)) { - GELOGW("The number of input for concat offset must be equal to %d, and must be more than one.", (N + kNumOne)); + GELOGW("The number of input for concat offset must be equal to %d, and must be more than one", (N + kNumOne)); return NOT_CHANGED; } @@ -61,7 +61,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vectorMutableTensorDesc().SetShape(output_shape); GE_IF_BOOL_EXEC(output_ptr->SetData(reinterpret_cast(buf.get()), static_cast(sizeof(DT_INT32) * output_size)) != GRAPH_SUCCESS, - GELOGW("set data failed"); + GELOGW("set data failed."); return NOT_CHANGED); v_output.push_back(output_ptr); // caculate offset @@ -99,7 +99,7 @@ Status ConcatOffsetKernel::Compute(const OpDescPtr op_desc_ptr, const vector &inp int32_t merged_first_dim = 0; int64_t indices_shape_size = 0; for (int i = 0; i < n_; i++) { - indices_shape_size = input[i]->GetTensorDesc().GetShape().GetShapeSize(); - indices_shape_size = indices_shape_size == 0 ? 1 : indices_shape_size; + // shape is [] means scalar + indices_shape_size = + input[i]->GetTensorDesc().GetShape().GetDims().empty() ? 1 : input[i]->GetTensorDesc().GetShape().GetShapeSize(); const int32_t *input_indices = reinterpret_cast(input[i]->GetData().data()); for (int64_t j = 0; j < indices_shape_size; j++) { merged_first_dim = std::max(merged_first_dim, input_indices[j]); diff --git a/ge/host_kernels/gather_v2_kernel.cc b/ge/host_kernels/gather_v2_kernel.cc index ee73626b..5702954c 100644 --- a/ge/host_kernels/gather_v2_kernel.cc +++ b/ge/host_kernels/gather_v2_kernel.cc @@ -278,7 +278,7 @@ Status GatherV2Kernel::SaveIndicesByDataType(ConstGeTensorPtr indices_tensor_ptr auto indices_ptr = const_cast(reinterpret_cast(indices_tensor_ptr->GetData().data())); for (int64_t i = 0; i < indices_shape.GetShapeSize(); i++) { if (*(indices_ptr + i) < 0 || *(indices_ptr + i) >= x_shape.GetDim(axis)) { - GELOGW("indices %ld value is not in range [0, %ld)", i, x_shape.GetDim(axis)); + GELOGW("indices %ld value is not in range [0, %ld).", i, x_shape.GetDim(axis)); return NOT_CHANGED; } indicates_.push_back(*(indices_ptr + i)); @@ -288,7 +288,7 @@ Status GatherV2Kernel::SaveIndicesByDataType(ConstGeTensorPtr indices_tensor_ptr auto indices_ptr = const_cast(reinterpret_cast(indices_tensor_ptr->GetData().data())); for (int64_t i = 0; i < indices_shape.GetShapeSize(); i++) { if (*(indices_ptr + i) < 0 || *(indices_ptr + i) >= x_shape.GetDim(axis)) { - GELOGW("indices %ld value is not in range [0, %ld)", i, x_shape.GetDim(axis)); + GELOGW("indices %ld value is not in range [0, %ld).", i, x_shape.GetDim(axis)); return NOT_CHANGED; } indicates_.push_back(*(indices_ptr + i)); @@ -344,30 +344,30 @@ Status GatherV2Kernel::Check(const OpDescPtr &op_desc_ptr, const vectorGetTensorDesc().GetDataType(); bool is_valid_indices_data_type = indices_data_type == DT_INT32 || indices_data_type == DT_INT64; if (!is_valid_indices_data_type) { - GELOGW("indices datatype must be DT_INT32 or DT_INT64"); + GELOGW("indices datatype must be DT_INT32 or DT_INT64."); return NOT_CHANGED; } if (indices_shape.GetDimNum() > kMaxIndicatesDims) { - GELOGW("indices input only support 0 or 1 dims"); + GELOGW("indices input only support 0 or 1 dims."); return NOT_CHANGED; } return SUCCESS; } void GatherV2Kernel::DebugPrint(int64_t axis, const GeShape &x_shape, const GeShape &indices_shape, const std::vector &y_shape) { - GELOGD("GatherV2Kernel axis:%ld x_shape:%zu indices_shape:%zu y_shape:%zu", axis, x_shape.GetDimNum(), + GELOGD("GatherV2Kernel axis:%ld x_shape:%zu indices_shape:%zu y_shape:%zu.", axis, x_shape.GetDimNum(), indices_shape.GetDimNum(), y_shape.size()); for (size_t i = 0; i < x_shape.GetDimNum(); i++) { - GELOGD("GatherV2Kernel x_shape[%zu]: %ld", i, x_shape.GetDim(i)); + GELOGD("GatherV2Kernel x_shape[%zu]: %ld.", i, x_shape.GetDim(i)); } for (size_t i = 0; i < indices_shape.GetDimNum(); i++) { - GELOGD("GatherV2Kernel indices_shape[%zu]: %ld", i, indices_shape.GetDim(i)); + GELOGD("GatherV2Kernel indices_shape[%zu]: %ld.", i, indices_shape.GetDim(i)); } for (size_t i = 0; i < y_shape.size(); i++) { - GELOGD("GatherV2Kernel y_shape[%zu]: %ld", i, y_shape[i]); + GELOGD("GatherV2Kernel y_shape[%zu]: %ld.", i, y_shape[i]); } for (auto ele : indicates_) { - GELOGD("GatherV2Kernel indices:%ld", ele); + GELOGD("GatherV2Kernel indices:%ld.", ele); } } @@ -376,10 +376,10 @@ Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vectorGetName().c_str()); + GELOGI("GatherV2Kernel[%s] start Process", op_desc_ptr->GetName().c_str()); ConstGeTensorPtr tensor0 = input.at(kGatherV2InputIndexZero); ConstGeTensorPtr tensor1 = input.at(kGatherV2InputIndexOne); ConstGeTensorPtr tensor2 = input.at(kGatherV2InputIndexTwo); @@ -394,7 +394,7 @@ Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vector= 0 ? axis : axis + x_shape.GetDimNum(); // check axis value if (axis < 0 || (axis + 1) > static_cast(x_shape.GetDimNum())) { - GELOGW("axis is invalid"); + GELOGW("axis is invalid!"); return NOT_CHANGED; } auto indices_data_type = tensor1->GetTensorDesc().GetDataType(); @@ -407,7 +407,8 @@ Status GatherV2Kernel::Compute(const OpDescPtr op_desc_ptr, const vectorGetTensorDesc().GetDataType(); if (supported_type.find(x_data_type) == supported_type.end()) { - GELOGI("GatherV2Kernel does not support this Data type:%s", TypeUtils::DataTypeToSerialString(x_data_type).c_str()); + GELOGI("GatherV2Kernel does not support this Data type:%s.", + TypeUtils::DataTypeToSerialString(x_data_type).c_str()); return NOT_CHANGED; } // calc output shape diff --git a/ge/host_kernels/identity_kernel.cc b/ge/host_kernels/identity_kernel.cc index 702f5c93..ef1446a8 100644 --- a/ge/host_kernels/identity_kernel.cc +++ b/ge/host_kernels/identity_kernel.cc @@ -61,4 +61,5 @@ Status IdentityKernel::Compute(const ge::OpDescPtr op_desc, const std::vector &input, vector &input, vector &v_output) { - GELOGD("StridedSliceKernel in."); + GELOGD("StridedSliceKernel in"); // 1.Check input and attrs if (CheckAndGetAttr(attr) != SUCCESS) { - GELOGW("Check and get attrs failed.Ignore kernel."); + GELOGW("Check and get attrs failed.Ignore kernel"); return NOT_CHANGED; } if (CheckInputParam(input) != SUCCESS) { - GELOGW("Check input params failed.Ignore kernel."); + GELOGW("Check input params failed.Ignore kernel"); return NOT_CHANGED; } // 2.Init param with mask attrs. @@ -120,7 +120,7 @@ Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector(data_size), data_type, input_dims, begin_vec, output_dims, output_ptr.get(), stride_vec); if (ret != SUCCESS) { - GELOGE(INTERNAL_ERROR, "SetOutputSliceData failed."); + GELOGE(INTERNAL_ERROR, "SetOutputSliceData failed"); return NOT_CHANGED; } @@ -133,7 +133,7 @@ Status StridedSliceKernel::Compute(const ge::OpDescPtr attr, const std::vector & return PARAM_INVALID; } if (kIndexNumberType.find(begin_tensor_desc.GetDataType()) == kIndexNumberType.end()) { - GELOGW("Data type of StridedSlice OP(begin,end,strides) must be int32 or int64."); + GELOGW("Data type of StridedSlice OP(begin,end,strides) must be int32 or int64"); return PARAM_INVALID; } @@ -250,7 +250,7 @@ Status StridedSliceKernel::InitParamWithAttrs(const std::vector &lis future_ = std::async(std::launch::async, [&]() -> Status { GetThreadLocalContext() = *executor_->GetContext()->ge_context; GetContext().SetSessionId(executor_->GetContext()->session_id); + GetContext().SetContextId(executor_->GetContext()->context_id); return RunInternal(); }); @@ -85,6 +86,10 @@ Status HybridModelAsyncExecutor::Stop() { ret = future_.get(); } + if (is_op_debug_reg_) { + op_debug_register_.UnregisterDebugForStream(stream_); + } + if (stream_ != nullptr) { GE_CHK_RT(rtStreamDestroy(stream_)); stream_ = nullptr; @@ -101,6 +106,7 @@ Status HybridModelAsyncExecutor::Init() { executor_ = std::unique_ptr(new(std::nothrow) HybridModelExecutor(model_, device_id_, stream_)); GE_CHECK_NOTNULL(executor_); GE_CHK_STATUS_RET(executor_->Init(), "Failed to init hybrid engine"); + GE_CHK_STATUS_RET(DumpOpDebug(), "Dump op debug failed in hybrid engine"); GELOGI("HybridModel stage nums:%zu", model_->GetRootGraphItem()->NumGroups()); if (model_->GetRootGraphItem()->NumGroups() >= kMinimumPiplineStages) { @@ -161,6 +167,7 @@ Status HybridModelAsyncExecutor::RunInternal() { } else { GELOGI("HybridModel will execute in singleline mode"); ge::GetContext().SetSessionId(executor_->GetContext()->session_id); + ge::GetContext().SetContextId(executor_->GetContext()->context_id); ret = executor_->Execute(args); } ret = HandleResult(ret, current_data.index, args, data_wrapper->GetOutput()); @@ -439,31 +446,20 @@ Status HybridModelAsyncExecutor::Execute(const std::vector &inputs, TensorValue tensor_value(inputs[i].data, inputs[i].length); args.inputs[i] = tensor_value; } + for (size_t i = 0; i < outputs.size(); ++i) { + args.outputs.emplace_back(TensorValue(outputs[i].data, outputs[i].length)); + } + // usr must designate input tensorDesc when input shape is dynamic in inference + for (size_t i = 0; i < input_desc.size(); ++i) { + ConstGeTensorDescPtr tensor_desc_ptr = MakeShared(input_desc[i]); + args.input_desc.emplace_back(tensor_desc_ptr); + } + GE_CHK_STATUS_RET(executor_->Execute(args), "Failed to execute model."); for (const auto &output_tensor_desc : args.output_desc) { output_desc.emplace_back(*output_tensor_desc); } - for (size_t i = 0; i < args.outputs.size(); ++i) { - int64_t output_real_size = 0; - ge::graphStatus graph_status = TensorUtils::GetTensorSizeInBytes(output_desc[i], output_real_size); - if (graph_status != GRAPH_SUCCESS) { - GELOGE(FAILED, "Get tensor size in bytes failed."); - return FAILED; - } - if (output_real_size > 0) { - if (outputs[i].length < static_cast(output_real_size)) { - GELOGE(FAILED, "output idx[%zu], the memory size of output[%lu] given by " - "user should be greater than or equal to the real size of output[%ld]", - i, outputs[i].length, output_real_size); - return FAILED; - } - GE_CHK_RT_RET(rtMemcpy(outputs[i].data, outputs[i].length, args.outputs[i].GetData(), output_real_size, - RT_MEMCPY_DEVICE_TO_DEVICE)); - } - outputs[i].length = output_real_size; - } - return SUCCESS; } @@ -508,5 +504,40 @@ Status HybridModelAsyncExecutor::Execute(const vector &inputs, vector< return SUCCESS; } +Status HybridModelAsyncExecutor::DumpOpDebug() { + const DumpProperties &dump_properties = executor_->GetContext()->dump_properties; + if (dump_properties.IsOpDebugOpen()) { + GELOGD("Opdebug is open in hybrid engine"); + uint32_t op_debug_mode = dump_properties.GetOpDebugMode(); + GE_CHK_RT_RET(op_debug_register_.RegisterDebugForStream(stream_, op_debug_mode, data_dumper_)); + is_op_debug_reg_ = true; + data_dumper_.SetDumpProperties(dump_properties); + data_dumper_.SetModelName(model_->GetModelName()); + data_dumper_.SetModelId(model_->GetModelId()); + data_dumper_.SetDeviceId(model_->GetDeviceId()); + void *global_step = nullptr; + TensorValue *varible_global_step = model_->GetVariable(NODE_NAME_GLOBAL_STEP); + if (varible_global_step != nullptr) { + global_step = const_cast(varible_global_step->GetData()); + } + + void *loop_per_iter = nullptr; + TensorValue *varible_loop_per_iter = model_->GetVariable(NODE_NAME_FLOWCTRL_LOOP_PER_ITER); + if (varible_loop_per_iter != nullptr) { + loop_per_iter = const_cast(varible_loop_per_iter->GetData()); + } + + void *loop_cond = nullptr; + TensorValue *varible_loop_cond = model_->GetVariable(NODE_NAME_FLOWCTRL_LOOP_COND); + if (varible_loop_cond != nullptr) { + loop_cond = const_cast(varible_loop_cond->GetData()); + } + data_dumper_.SetLoopAddr(global_step, loop_per_iter, loop_cond); + GE_CHK_STATUS_RET(data_dumper_.LoadDumpInfo(), "LoadDumpInfo failed in hybrid engine"); + GELOGD("Dump op debug SUCCESS in hybrid engine"); + } + return SUCCESS; +} + } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/executor/hybrid_model_async_executor.h b/ge/hybrid/executor/hybrid_model_async_executor.h index 4790248b..69d8a3f4 100644 --- a/ge/hybrid/executor/hybrid_model_async_executor.h +++ b/ge/hybrid/executor/hybrid_model_async_executor.h @@ -21,7 +21,9 @@ #include #include "external/ge/ge_api_error_codes.h" #include "external/ge/ge_api_types.h" +#include "common/dump/opdebug_register.h" #include "graph/load/model_manager/data_inputer.h" +#include "graph/load/model_manager/data_dumper.h" #include "hybrid/executor/hybrid_model_executor.h" #include "hybrid/executor/hybrid_model_pipeline_executor.h" #include "runtime/stream.h" @@ -77,6 +79,8 @@ class HybridModelAsyncExecutor { Status PrepareInputs(const InputData ¤t_data, HybridModelExecutor::ExecuteArgs &args); + Status DumpOpDebug(); + std::mutex mu_; HybridModel *model_; uint32_t device_id_ = 0U; @@ -94,6 +98,9 @@ class HybridModelAsyncExecutor { std::vector is_input_dynamic_; std::shared_ptr listener_; string om_name_; + DataDumper data_dumper_; + bool is_op_debug_reg_ = false; + OpdebugRegister op_debug_register_; }; } // namespace hybrid } // namespace ge diff --git a/ge/hybrid/executor/hybrid_model_executor.cc b/ge/hybrid/executor/hybrid_model_executor.cc index 80b8983a..4b589a03 100755 --- a/ge/hybrid/executor/hybrid_model_executor.cc +++ b/ge/hybrid/executor/hybrid_model_executor.cc @@ -33,6 +33,9 @@ HybridModelExecutor::~HybridModelExecutor() { if (context_.rt_gen_context != nullptr) { (void) rtCtxDestroy(context_.rt_gen_context); } + if (context_.global_step != nullptr) { + (void) rtFree(context_.global_step); + } } Status HybridModelExecutor::Init() { @@ -47,6 +50,8 @@ Status HybridModelExecutor::Execute(HybridModelExecutor::ExecuteArgs &args) { auto root_graph_item = model_->GetRootGraphItem(); GE_CHECK_NOTNULL(root_graph_item); + GE_CHK_RT_RET(rtMemcpyAsync(context_.global_step, sizeof(uint64_t), &context_.iteration, + sizeof(uint64_t), RT_MEMCPY_HOST_TO_DEVICE_EX, context_.stream)); SubgraphExecutor executor(model_->GetRootGraphItem(), &context_); auto ret = ExecuteGraphInternal(executor, args); Cleanup(); @@ -97,6 +102,7 @@ Status HybridModelExecutor::InitExecutionContext() { GE_CHK_RT_RET(rtCtxGetCurrent(&context_.rt_context)); GE_CHK_RT_RET(rtCtxCreate(&context_.rt_gen_context, RT_CTX_GEN_MODE, 0)); GE_CHK_RT_RET(rtCtxSetCurrent(context_.rt_context)); + GE_CHK_RT_RET(rtMalloc(&context_.global_step, sizeof(uint64_t), RT_MEMORY_HBM)); context_.stream = stream_; context_.model = model_; diff --git a/ge/hybrid/executor/node_state.cc b/ge/hybrid/executor/node_state.cc index 3ec967d3..3834478c 100644 --- a/ge/hybrid/executor/node_state.cc +++ b/ge/hybrid/executor/node_state.cc @@ -44,6 +44,27 @@ ShapeInferenceState::ShapeInferenceState(const NodeItem &node_item) : node_item( } } +Status ShapeInferenceState::CheckInputShapeByShapeRange(const GeTensorDesc &tensor_desc, + const GeTensorDesc &target_tensor_desc) const { + std::vector> shape_range; + if (tensor_desc.GetShapeRange(shape_range) != SUCCESS) { + GELOGE(PARAM_INVALID, "Get shape range failed."); + return PARAM_INVALID; + } + if (shape_range.empty()) { + GELOGD("Shape range is empty, no need to check input shape."); + return SUCCESS; + } + + GeShape target_shape = target_tensor_desc.GetShape(); + if (TensorUtils::CheckShapeByShapeRange(target_shape, shape_range) != SUCCESS) { + GELOGE(PARAM_INVALID, "Check shape by shape range failed."); + return PARAM_INVALID; + } + + return SUCCESS; +} + Status ShapeInferenceState::UpdateInputShape(int idx, const GeTensorDesc &target) { if (node_item.IsInputShapeStatic(idx)) { GELOGD("[%s] Trying to update static shape, idx = %d. old shape = [%s], new shape = [%s]", @@ -54,19 +75,27 @@ Status ShapeInferenceState::UpdateInputShape(int idx, const GeTensorDesc &target return SUCCESS; } + std::lock_guard lk(mu_); + auto &input_desc = input_tensor_desc[idx]; + GeShape shape = target.GetShape(); + input_desc.SetShape(shape); + input_desc.SetOriginShape(target.GetOriginShape()); int64_t tensor_size = -1; (void) TensorUtils::GetSize(target, tensor_size); + if (tensor_size <= 0) { + Format format = input_desc.GetFormat(); + DataType data_type = input_desc.GetDataType(); + if (TensorUtils::CalcTensorMemSize(shape, format, data_type, tensor_size) != GRAPH_SUCCESS) { + GELOGE(FAILED, "[%s] Calculate tensor memory size failed.", node_item.NodeName().c_str()); + return FAILED; + } + } GELOGD("[%s] Update input shape [%d] with Shape: [%s] and OriginalShape: [%s], size = %ld", node_item.NodeName().c_str(), idx, - target.GetShape().ToString().c_str(), + shape.ToString().c_str(), target.GetOriginShape().ToString().c_str(), tensor_size); - - std::lock_guard lk(mu_); - auto &input_desc = input_tensor_desc[idx]; - input_desc.SetShape(target.GetShape()); - input_desc.SetOriginShape(target.GetOriginShape()); (void) TensorUtils::SetSize(input_desc, tensor_size); if (--num_pending_shapes_ <= 0) { ready_cv_.notify_all(); diff --git a/ge/hybrid/executor/node_state.h b/ge/hybrid/executor/node_state.h index 84a52abd..2da4184d 100644 --- a/ge/hybrid/executor/node_state.h +++ b/ge/hybrid/executor/node_state.h @@ -58,6 +58,8 @@ struct ShapeInferenceState { const vector &GetOutputTensorDesc() const; + Status CheckInputShapeByShapeRange(const GeTensorDesc &tensor_desc, const GeTensorDesc &target_tensor_desc) const; + const NodeItem &node_item; private: diff --git a/ge/hybrid/executor/subgraph_executor.cc b/ge/hybrid/executor/subgraph_executor.cc index 45db9936..57e4052d 100644 --- a/ge/hybrid/executor/subgraph_executor.cc +++ b/ge/hybrid/executor/subgraph_executor.cc @@ -227,6 +227,7 @@ Status SubgraphExecutor::PrepareNodes(int group) { if (node_item.is_dynamic) { auto prepare_future = pre_run_pool_.commit([this, p_node_state]() -> Status { GetContext().SetSessionId(context_->session_id); + GetContext().SetContextId(context_->context_id); GE_CHK_STATUS_RET_NOLOG(InferShape(shape_inference_engine_.get(), *p_node_state)); return PrepareForExecution(context_, *p_node_state); }); @@ -273,10 +274,8 @@ Status SubgraphExecutor::PrepareNodes(int group) { } Status SubgraphExecutor::InferShape(ShapeInferenceEngine *shape_inference_engine, NodeState &node_state) const { - GetContext().SetSessionId(context_->context_id); HYBRID_CHK_STATUS_RET(shape_inference_engine->InferShape(node_state), "[%s] Failed to InferShape.", node_state.GetName().c_str()); - GetContext().SetSessionId(context_->session_id); HYBRID_CHK_STATUS_RET(shape_inference_engine->PropagateOutputShapes(node_state), "[%s] Failed to PropagateOutputShapes.", node_state.GetName().c_str()); return SUCCESS; @@ -345,6 +344,7 @@ Status SubgraphExecutor::ScheduleTasks(int group) { GELOGD("[%s] Start to schedule prepare workers.", graph_item_->GetName().c_str()); auto prepare_future = std::async(std::launch::async, [&]() -> Status { GetContext().SetSessionId(context_->session_id); + GetContext().SetContextId(context_->context_id); auto ret = PrepareNodes(group); ready_queue_.Push(nullptr); return ret; diff --git a/ge/hybrid/executor/worker/execution_engine.cc b/ge/hybrid/executor/worker/execution_engine.cc index 63d9126b..de3bdc37 100755 --- a/ge/hybrid/executor/worker/execution_engine.cc +++ b/ge/hybrid/executor/worker/execution_engine.cc @@ -231,12 +231,6 @@ Status NodeDoneCallback::DumpDynamicNode() { uint32_t model_id = model->GetModelId(); dump_op_.SetDynamicModelInfo(dynamic_model_name, model_id); - void *global_step = nullptr; - TensorValue *varible_global_step = context_->GetVariable(NODE_NAME_GLOBAL_STEP); - if (varible_global_step != nullptr) { - global_step = const_cast(varible_global_step->GetData()); - } - void *loop_per_iter = nullptr; TensorValue *varible_loop_per_iter = context_->GetVariable(NODE_NAME_FLOWCTRL_LOOP_PER_ITER); if (varible_loop_per_iter != nullptr) { @@ -248,6 +242,7 @@ Status NodeDoneCallback::DumpDynamicNode() { if (varible_loop_cond != nullptr) { loop_cond = const_cast(varible_loop_cond->GetData()); } + void *global_step = context_->GetExecutionContext()->global_step; dump_op_.SetLoopAddr(global_step, loop_per_iter, loop_cond); GE_CHK_STATUS_RET(dump_op_.LaunchDumpOp(), "Failed to launch dump op in hybird model"); @@ -266,9 +261,9 @@ Status NodeDoneCallback::OnNodeDone() { RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[Compute] End"); RECORD_CALLBACK_EVENT(graph_context_, context_->GetNodeName(), "[Callback] Start"); - auto dump_path = context_->GetDumpProperties().GetDumpPath(); - if (!dump_path.empty()) { - GELOGI("Start to dump dynamic shape,dump_path is %s", dump_path.c_str()); + const DumpProperties &dump_properties = context_->GetDumpProperties(); + if (dump_properties.IsDumpOpen() || context_->IsOverFlow()) { + GELOGI("Start to dump dynamic shape op"); GE_CHK_STATUS_RET(DumpDynamicNode(), "Failed to dump dynamic node"); } diff --git a/ge/hybrid/executor/worker/shape_inference_engine.cc b/ge/hybrid/executor/worker/shape_inference_engine.cc index bb6281e1..27919589 100755 --- a/ge/hybrid/executor/worker/shape_inference_engine.cc +++ b/ge/hybrid/executor/worker/shape_inference_engine.cc @@ -41,7 +41,7 @@ Status ShapeInferenceEngine::InferShape(NodeState &node_state) { // Wait for "const input nodes" if node's shape inference function requires any. // Even if output shape is static, there are cases that the const-input will be used in OpTiling and Execution GE_CHK_STATUS_RET_NOLOG(AwaitDependentNodes(node_state)); - if (node_item.is_output_shape_static) { + if (node_item.is_output_shape_static && !node_item.is_need_force_infershape) { return SUCCESS; } diff --git a/ge/hybrid/model/hybrid_model.cc b/ge/hybrid/model/hybrid_model.cc index 77c9be2b..a0217d52 100644 --- a/ge/hybrid/model/hybrid_model.cc +++ b/ge/hybrid/model/hybrid_model.cc @@ -225,23 +225,19 @@ Status HybridModel::GetInputDescInfo(vector &input_desc, st GE_CHECK_NOTNULL(op_desc->GetInputDescPtr(0)); Format format = op_desc->GetInputDescPtr(0)->GetFormat(); - input.data_type = op_desc->GetInputDescPtr(0)->GetDataType(); + DataType data_type = op_desc->GetInputDescPtr(0)->GetDataType(); + input.data_type = static_cast(data_type); input.name = op_desc->GetName(); - - int64_t input_size = 0; - GE_CHK_STATUS_RET(TensorUtils::GetSize(*op_desc->GetInputDescPtr(0), input_size), "get input size failed."); - - // support dynamic shape - if (input_size < 0) { - GELOGD("dynamic shape scene, input size is unknown. " - "format=%d, data_type=%d, input_size=%ld", - format, input.data_type, input_size); - input_size = kMemSizeUnknownShape; // -1 + GeShape shape = op_desc->GetInputDescPtr(0)->GetShape(); + int64_t tensor_size = 0; + if (TensorUtils::CalcTensorMemSize(shape, format, data_type, tensor_size) != GRAPH_SUCCESS) { + GELOGE(FAILED, "Calculate tensor mem size failed."); + return FAILED; } - - // not support dynamic shape input for now, so input_size here will be not less than zero. - input.size = input_size; - + if (tensor_size == kMemSizeUnknownShape) { + tensor_size = 0; + } + input.size = static_cast(tensor_size); CreateInputDimsInfo(op_desc, input); formats.push_back(format); @@ -284,6 +280,9 @@ void HybridModel::CreateOutput(ConstGeTensorDescPtr &output_desc, } int64_t tensor_size = 0; (void)TensorUtils::CalcTensorMemSize(shape, format, data_type, tensor_size); + if (tensor_size == kMemSizeUnknownShape) { + tensor_size = 0; + } output_desc_info.size = static_cast(tensor_size); output_desc_info.data_type = output_desc->GetDataType(); } diff --git a/ge/hybrid/model/hybrid_model.h b/ge/hybrid/model/hybrid_model.h index 500f0472..fae53679 100644 --- a/ge/hybrid/model/hybrid_model.h +++ b/ge/hybrid/model/hybrid_model.h @@ -61,6 +61,10 @@ class HybridModel { device_id_ = device_id; } + uint32_t GetDeviceId() { + return device_id_; + } + void SetModelId(uint32_t model_id) { model_id_ = model_id; } @@ -150,6 +154,7 @@ class HybridModel { uint32_t model_id_ = 0; uint8_t *var_mem_base_ = nullptr; std::unique_ptr weight_buffer_; + std::map> weight_buffer_map_; RuntimeParam root_runtime_param_; string om_name_; }; diff --git a/ge/hybrid/model/hybrid_model_builder.cc b/ge/hybrid/model/hybrid_model_builder.cc index ac57b2ea..a3b1da20 100755 --- a/ge/hybrid/model/hybrid_model_builder.cc +++ b/ge/hybrid/model/hybrid_model_builder.cc @@ -50,6 +50,7 @@ const char *const kProfilingBpNode = "ProfilingBpNode"; const char *const kProfilingEndNode = "ProfilingEndNode"; const char *const kProfilingArNode = "ProfilingAllReduceNode"; const char *const kEngineNameRts = "DNN_VM_RTS_OP_STORE"; +const char *const kForceInfershape = "_force_infershape_when_running"; Status SetOutputNameAttr(ComputeGraph &graph) { vector output_names; @@ -171,6 +172,9 @@ Status HybridModelBuilder::ValidateParams() { Status HybridModelBuilder::BuildNodeItem(const NodePtr &node, NodeItem &node_item) { auto op_desc = node->GetOpDesc(); + GE_CHK_STATUS_RET(ParseForceInfershapeNodes(node, node_item), + "[%s] Failed to parse force_infershape node.", + node_item.NodeName().c_str()); vector dependencies = node->GetOpDesc()->GetOpInferDepends(); GE_CHK_STATUS_RET(ParseDependentInputNodes(node_item, dependencies), "[%s] Failed to parse node dependencies.", @@ -263,6 +267,17 @@ Status HybridModelBuilder::GetOrCreateNodeItem(const NodePtr &node, NodeItem **n return SUCCESS; } +Status HybridModelBuilder::ParseForceInfershapeNodes(const NodePtr &node, NodeItem &node_item) { + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + // not care result, if no this attr, stand for the op does not need force infershape + (void)AttrUtils::GetBool(op_desc, kForceInfershape, node_item.is_need_force_infershape); + GELOGD("node [%s] is need do infershape , flag is %d", + op_desc->GetName().c_str(), + node_item.is_need_force_infershape); + return SUCCESS; +} + Status HybridModelBuilder::ParseDependentInputNodes(NodeItem &node_item, const std::vector &dependencies) { std::set dependent_input_nodes; auto &ge_node = node_item.node; @@ -997,70 +1012,65 @@ Status HybridModelBuilder::InitVariableTensors() { Status HybridModelBuilder::InitWeights() { // For constant in root graph - const auto &root_graph = ge_root_model_->GetRootGraph(); - const auto &subgraph_models = ge_root_model_->GetSubgraphInstanceNameToModel(); - auto iter = subgraph_models.find(root_graph->GetName()); - if (iter == subgraph_models.end()) { - GELOGD("Root graph model not found"); - return SUCCESS; - } + for (const auto &subgraph_model : ge_root_model_->GetSubgraphInstanceNameToModel()) { + const auto &weight_buffer = subgraph_model.second->GetWeight(); + if (weight_buffer.GetSize() == 0) { + GELOGD("weight is empty"); + return SUCCESS; + } - auto &root_model = iter->second; - const auto &weight_buffer = root_model->GetWeight(); - if (weight_buffer.GetSize() == 0) { - GELOGD("weight is empty"); - return SUCCESS; - } + auto allocator = NpuMemoryAllocator::GetAllocator(); + GE_CHECK_NOTNULL(allocator); + auto sub_weight_buffer = TensorBuffer::Create(allocator, weight_buffer.size()); + GE_CHECK_NOTNULL(sub_weight_buffer); + auto weight_base = reinterpret_cast(sub_weight_buffer->GetData()); + GE_CHK_RT_RET(rtMemcpy(weight_base, + sub_weight_buffer->GetSize(), + weight_buffer.GetData(), + weight_buffer.GetSize(), + RT_MEMCPY_HOST_TO_DEVICE)); + + GELOGI("Init weight mem successfully, weight base %p, weight size = %zu", + weight_base, + sub_weight_buffer->GetSize()); + auto root_graph = GraphUtils::GetComputeGraph(subgraph_model.second->GetGraph()); + hybrid_model_.weight_buffer_map_.emplace(root_graph->GetName(),std::move(sub_weight_buffer)); + for (auto &node : root_graph->GetDirectNode()) { + if (node->GetType() != CONSTANT) { + continue; + } - auto allocator = NpuMemoryAllocator::GetAllocator(); - GE_CHECK_NOTNULL(allocator); - hybrid_model_.weight_buffer_ = TensorBuffer::Create(allocator, weight_buffer.size()); - GE_CHECK_NOTNULL(hybrid_model_.weight_buffer_); - auto weight_base = reinterpret_cast(hybrid_model_.weight_buffer_->GetData()); - GE_CHK_RT_RET(rtMemcpy(weight_base, - hybrid_model_.weight_buffer_->GetSize(), - weight_buffer.GetData(), - weight_buffer.GetSize(), - RT_MEMCPY_HOST_TO_DEVICE)); - - GELOGI("Init weight mem successfully, weight base %p, weight size = %zu", - weight_base, - hybrid_model_.weight_buffer_->GetSize()); - for (auto &node : root_graph->GetDirectNode()) { - if (node->GetType() != CONSTANT) { - continue; - } + auto op_desc = node->GetOpDesc(); + auto v_weights = ModelUtils::GetWeights(op_desc); + if (v_weights.empty()) { + GELOGE(INTERNAL_ERROR, "[%s] Constant has no value", node->GetName().c_str()); + return INTERNAL_ERROR; + } + auto *ge_tensor = const_cast(v_weights[0].get()); + GE_CHECK_NOTNULL(ge_tensor); + const GeTensorDesc &tensor_desc = ge_tensor->GetTensorDesc(); + int64_t tensor_size = 0; + GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*op_desc->MutableOutputDesc(0), tensor_size), + "[%s] Failed to get tensor size", + node->GetName().c_str()); + int64_t data_offset = 0; + GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetDataOffset(tensor_desc, data_offset), + "[%s] Failed to get data offset", + node->GetName().c_str()); + GELOGD("[%s] Start to init Constant node [%s], size = %ld, offset = %ld", + GetGraphName(), + node->GetName().c_str(), + tensor_size, + data_offset); - auto op_desc = node->GetOpDesc(); - auto v_weights = ModelUtils::GetWeights(op_desc); - if (v_weights.empty()) { - GELOGE(INTERNAL_ERROR, "[%s] Constant has no value", node->GetName().c_str()); - return INTERNAL_ERROR; + auto tensor_buffer = TensorBuffer::Create(weight_base + data_offset, tensor_size); + GE_CHECK_NOTNULL(tensor_buffer); + std::unique_ptr constant_tensor(new (std::nothrow)TensorValue(std::move(tensor_buffer))); + GE_CHECK_NOTNULL(constant_tensor); + constant_tensor->SetName("Constant_" + op_desc->GetName()); + hybrid_model_.constant_tensors_.emplace(node, std::move(constant_tensor)); + GELOGD("[%s] Constant node [%s] added, size = %ld", GetGraphName(), node->GetName().c_str(), tensor_size); } - auto *ge_tensor = const_cast(v_weights[0].get()); - GE_CHECK_NOTNULL(ge_tensor); - const GeTensorDesc &tensor_desc = ge_tensor->GetTensorDesc(); - int64_t tensor_size = 0; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetSize(*op_desc->MutableOutputDesc(0), tensor_size), - "[%s] Failed to get tensor size", - node->GetName().c_str()); - int64_t data_offset = 0; - GE_CHK_GRAPH_STATUS_RET(TensorUtils::GetDataOffset(tensor_desc, data_offset), - "[%s] Failed to get data offset", - node->GetName().c_str()); - GELOGD("[%s] Start to init Constant node [%s], size = %ld, offset = %ld", - GetGraphName(), - node->GetName().c_str(), - tensor_size, - data_offset); - - auto tensor_buffer = TensorBuffer::Create(weight_base + data_offset, tensor_size); - GE_CHECK_NOTNULL(tensor_buffer); - std::unique_ptr constant_tensor(new (std::nothrow)TensorValue(std::move(tensor_buffer))); - GE_CHECK_NOTNULL(constant_tensor); - constant_tensor->SetName("Constant_" + op_desc->GetName()); - hybrid_model_.constant_tensors_.emplace(node, std::move(constant_tensor)); - GELOGD("[%s] Constant node [%s] added, size = %ld", GetGraphName(), node->GetName().c_str(), tensor_size); } return SUCCESS; } diff --git a/ge/hybrid/model/hybrid_model_builder.h b/ge/hybrid/model/hybrid_model_builder.h index 71663a6e..313d5ca6 100644 --- a/ge/hybrid/model/hybrid_model_builder.h +++ b/ge/hybrid/model/hybrid_model_builder.h @@ -62,6 +62,7 @@ class HybridModelBuilder { Status IdentifySameInputs(NodeItem &node_item); Status BuildNodeItem(const NodePtr &node, NodeItem &node_item); Status GetOrCreateNodeItem(const NodePtr &node, NodeItem **node_item); + Status ParseForceInfershapeNodes(const NodePtr &node, NodeItem &node_item); Status ParseDependentInputNodes(NodeItem &node_item, const std::vector &dependencies); Status ParseDependentForFusedSubgraph(NodeItem &node_item); Status IndexTaskDefs(); diff --git a/ge/hybrid/model/node_item.cc b/ge/hybrid/model/node_item.cc index 100530fc..805064be 100644 --- a/ge/hybrid/model/node_item.cc +++ b/ge/hybrid/model/node_item.cc @@ -149,14 +149,16 @@ Status NodeItem::InitInputsAndOutputs() { if (AttrUtils::GetInt(op_desc, ::ge::ATTR_STAGE_LEVEL, group)) { GELOGD("[%s] Got stage level from op_desc = %d", op_desc->GetName().c_str(), group); } else { - if (AttrUtils::GetInt(node->GetOwnerComputeGraph(), ::ge::ATTR_STAGE_LEVEL, group)) { - GELOGD("[%s] Got stage level from parent graph = %d", op_desc->GetName().c_str(), group); - } else { - auto parent_node = node->GetOwnerComputeGraph()->GetParentNode(); - if ((parent_node != nullptr) && (AttrUtils::GetInt(parent_node->GetOpDesc(), ::ge::ATTR_STAGE_LEVEL, group))) { - GELOGD("[%s] Got stage level from parent node = %d", op_desc->GetName().c_str(), group); + if (node->GetOwnerComputeGraph() != nullptr) { + if (AttrUtils::GetInt(node->GetOwnerComputeGraph(), ::ge::ATTR_STAGE_LEVEL, group)) { + GELOGD("[%s] Got stage level from parent graph = %d", op_desc->GetName().c_str(), group); } else { - GELOGD("[%s] Node do not set stage level", op_desc->GetName().c_str()); + auto parent_node = node->GetOwnerComputeGraph()->GetParentNode(); + if ((parent_node != nullptr) && (AttrUtils::GetInt(parent_node->GetOpDesc(), ::ge::ATTR_STAGE_LEVEL, group))) { + GELOGD("[%s] Got stage level from parent node = %d", op_desc->GetName().c_str(), group); + } else { + GELOGD("[%s] Node do not set stage level", op_desc->GetName().c_str()); + } } } } diff --git a/ge/hybrid/model/node_item.h b/ge/hybrid/model/node_item.h index 300744d1..631dbd9e 100644 --- a/ge/hybrid/model/node_item.h +++ b/ge/hybrid/model/node_item.h @@ -83,6 +83,7 @@ struct NodeItem { bool has_observer = false; bool has_optional_inputs = false; bool is_output_shape_static = true; + bool is_need_force_infershape = false; UnknowShapeOpType shape_inference_type = DEPEND_IN_SHAPE; std::string node_name; std::string node_type; diff --git a/ge/hybrid/node_executor/aicore/aicore_node_executor.cc b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc index 1640ad3b..119db0af 100755 --- a/ge/hybrid/node_executor/aicore/aicore_node_executor.cc +++ b/ge/hybrid/node_executor/aicore/aicore_node_executor.cc @@ -17,6 +17,7 @@ #include "aicore_node_executor.h" #include "framework/common/taskdown_common.h" #include "hybrid/executor/hybrid_execution_context.h" +#include "external/runtime/rt_error_codes.h" namespace ge { namespace hybrid { @@ -189,6 +190,7 @@ Status AiCoreNodeTask::ExecuteAsync(TaskContext &context, std::function } RECORD_EXECUTION_EVENT(context.GetExecutionContext(), context.GetNodeName(), "[AiCoreNodeLaunchKernel] Start"); GE_CHK_STATUS_RET_NOLOG((*it)->LaunchKernel(context.GetStream())); + GE_CHK_STATUS_RET_NOLOG(CheckOverflow(context)); // save profiling data uint32_t task_id = 0; uint32_t stream_id = 0; @@ -259,6 +261,25 @@ void AiCoreNodeTask::SetWorkspaceSizes(const vector &workspace_sizes) { workspace_sizes_ = workspace_sizes; } +Status AiCoreNodeTask::CheckOverflow(TaskContext &context) { + const DumpProperties &dump_properties = context.GetDumpProperties(); + if (dump_properties.IsOpDebugOpen()) { + GELOGD("Op %s is doing overflow check in hybrid engine", context.GetNodeName()); + auto rt_ret = rtStreamSynchronize(context.GetStream()); + if (rt_ret == ACL_ERROR_RT_AICORE_OVER_FLOW) { + context.SetOverFlow(true); + GELOGW("Dynamic shape op %s is over flow", context.GetNodeName()); + return SUCCESS; + } else if (rt_ret != RT_ERROR_NONE) { + GELOGE(rt_ret, "rtstreamsynchronize failed"); + return RT_ERROR_TO_GE_STATUS(rt_ret); + } + return SUCCESS; + } + GELOGD("Opdebug is not open in hybrid engine"); + return SUCCESS; +} + TaskCompilerFactory &TaskCompilerFactory::GetInstance() { static TaskCompilerFactory instance; return instance; diff --git a/ge/hybrid/node_executor/aicore/aicore_node_executor.h b/ge/hybrid/node_executor/aicore/aicore_node_executor.h index 2095b41d..c352764d 100755 --- a/ge/hybrid/node_executor/aicore/aicore_node_executor.h +++ b/ge/hybrid/node_executor/aicore/aicore_node_executor.h @@ -62,6 +62,7 @@ class AiCoreNodeTask : public NodeTask { const vector &GetWorkspaceSizes() const; void SetWorkspaceSizes(const vector &workspace_sizes); private: + Status CheckOverflow(TaskContext &context); std::vector> tasks_; std::vector workspace_sizes_; }; diff --git a/ge/hybrid/node_executor/aicore/aicore_op_task.cc b/ge/hybrid/node_executor/aicore/aicore_op_task.cc index 07c2ddb5..6af2fd4a 100644 --- a/ge/hybrid/node_executor/aicore/aicore_op_task.cc +++ b/ge/hybrid/node_executor/aicore/aicore_op_task.cc @@ -307,11 +307,9 @@ Status AiCoreOpTask::UpdateTilingInfo(TaskContext &context) { auto execution_context = context.GetExecutionContext(); - GetContext().SetSessionId(execution_context->context_id); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CalcTilingInfo] Start"); GE_CHK_STATUS_RET(CalcTilingInfo(node, tiling_info)); RECORD_EXECUTION_EVENT(execution_context, context.GetNodeName(), "[CalcTilingInfo] End"); - GetContext().SetSessionId(execution_context->session_id); // update op args by tiling info block_dim_ = static_cast(tiling_info.block_dim); diff --git a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc index 1d6e814b..bb96c275 100755 --- a/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc +++ b/ge/hybrid/node_executor/compiledsubgraph/known_node_executor.cc @@ -124,13 +124,9 @@ Status KnownNodeTask::Init(TaskContext &context) { } if (!load_flag_) { auto dump_properties = context.GetDumpProperties(); - if (dump_properties.IsDumpOpen()) { + if (dump_properties.IsDumpOpen() || dump_properties.IsOpDebugOpen()) { davinci_model_->SetDumpProperties(dump_properties); - void *global_step = nullptr; - TensorValue *varible_global_step = context.GetVariable(NODE_NAME_GLOBAL_STEP); - if (varible_global_step != nullptr) { - global_step = varible_global_step->MutableData(); - } + void *global_step = context.GetExecutionContext()->global_step; davinci_model_->SetKnownShapeGlobalStep(global_step); } int32_t device_id = 0; diff --git a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc index 3d2e3084..9d92420e 100755 --- a/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc +++ b/ge/hybrid/node_executor/ge_local/ge_local_node_executor.cc @@ -33,6 +33,7 @@ const std::map> {RESHAPE, {}}, {EXPANDDIMS, {}}, {SQUEEZE, {}}, + {UNSQUEEZE, {}}, {BROADCASTGRADIENTARGS, {}} }; diff --git a/ge/hybrid/node_executor/task_context.cc b/ge/hybrid/node_executor/task_context.cc index 08cce30c..f4271551 100644 --- a/ge/hybrid/node_executor/task_context.cc +++ b/ge/hybrid/node_executor/task_context.cc @@ -236,7 +236,7 @@ Status TaskContext::AllocateOutput(int index, ref_node->GetName().c_str(), ref_node->GetType().c_str()); - TensorValue *ref_tensor = execution_context_->model->GetVariable(ref_node->GetName()); + TensorValue *ref_tensor = execution_context_->model->GetTensor(ref_node); GE_CHECK_NOTNULL(ref_tensor); outputs_start_[index] = *ref_tensor; } else { @@ -350,6 +350,14 @@ void TaskContext::SetStreamId(uint32_t stream_id) { stream_id_ = stream_id; } +void TaskContext::SetOverFlow(bool is_over_flow) { + is_over_flow_ = is_over_flow; +} + +bool TaskContext::IsOverFlow() { + return is_over_flow_; +} + Status TaskContext::AllocateWorkspace(size_t size, void **buffer, void *ori_addr) { GE_CHECK_NOTNULL(buffer); if (ori_addr == nullptr) { diff --git a/ge/hybrid/node_executor/task_context.h b/ge/hybrid/node_executor/task_context.h index 645c1234..e00c5048 100644 --- a/ge/hybrid/node_executor/task_context.h +++ b/ge/hybrid/node_executor/task_context.h @@ -65,6 +65,7 @@ class TaskContext { int64_t GetSessionId() const; uint64_t GetIterationNumber() const; + void NodeDone(); void OnError(Status error); @@ -106,6 +107,9 @@ class TaskContext { uint32_t GetStreamId() const; void SetStreamId(uint32_t stream_id); + void SetOverFlow(bool is_over_flow); + bool IsOverFlow(); + Status Synchronize(); bool IsForceInferShape() const; @@ -138,6 +142,7 @@ class TaskContext { uint32_t task_id_ = 0; uint32_t stream_id_ = 0; std::vector task_desc_info; + bool is_over_flow_ = false; }; } // namespace hybrid } // namespace ge diff --git a/ge/init/gelib.cc b/ge/init/gelib.cc index 17e257c0..ab7fbb29 100644 --- a/ge/init/gelib.cc +++ b/ge/init/gelib.cc @@ -68,7 +68,8 @@ Status GELib::Initialize(const map &options) { // Multiple initializations are not allowed instancePtr_ = MakeShared(); if (instancePtr_ == nullptr) { - GELOGE(GE_CLI_INIT_FAILED, "GeLib initialize failed, malloc shared_ptr failed."); + GELOGE(GE_CLI_INIT_FAILED, "[Create][GELib]GeLib initialize failed, malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "GELib Init failed for new GeLib failed."); return GE_CLI_INIT_FAILED; } @@ -76,13 +77,15 @@ Status GELib::Initialize(const map &options) { map new_options; Status ret = instancePtr_->SetRTSocVersion(options, new_options); if (ret != SUCCESS) { - GELOGE(ret, "GeLib initial failed."); + GELOGE(ret, "[Set][RTSocVersion]GeLib initial: SetRTSocVersion failed."); + REPORT_CALL_ERROR("E19999", "SetRTSocVersion failed."); return ret; } ret = instancePtr_->SetAiCoreNum(new_options); if (ret != SUCCESS) { - GELOGE(ret, "GeLib initial: SetAiCoreNum failed."); + GELOGE(ret, "[Set][AiCoreNum]GeLib initial: SetAiCoreNum failed."); + REPORT_CALL_ERROR("E19999", "SetAiCoreNum failed."); return ret; } @@ -97,7 +100,8 @@ Status GELib::Initialize(const map &options) { GE_TIMESTAMP_START(Init); ret = instancePtr_->InnerInitialize(new_options); if (ret != SUCCESS) { - GELOGE(ret, "GeLib initial failed."); + GELOGE(ret, "[Init][GeLib]GeLib initial failed."); + REPORT_CALL_ERROR("E19999", "GELib::InnerInitialize failed."); instancePtr_ = nullptr; return ret; } @@ -118,7 +122,7 @@ Status GELib::InnerInitialize(const map &options) { Status initSystemStatus = SystemInitialize(options); GE_TIMESTAMP_END(SystemInitialize, "InnerInitialize::SystemInitialize"); if (initSystemStatus != SUCCESS) { - GELOGE(initSystemStatus, "GE system initial failed."); + GELOGE(initSystemStatus, "[Init][GESystem]GE system initial failed."); RollbackInit(); return initSystemStatus; } @@ -129,7 +133,8 @@ Status GELib::InnerInitialize(const map &options) { Status initEmStatus = engineManager_.Initialize(options); GE_TIMESTAMP_END(EngineInitialize, "InnerInitialize::EngineInitialize"); if (initEmStatus != SUCCESS) { - GELOGE(initEmStatus, "GE engine manager initial failed."); + GELOGE(initEmStatus, "[Init][EngineManager]GE engine manager initial failed."); + REPORT_CALL_ERROR("E19999", "EngineManager initialize failed."); RollbackInit(); return initEmStatus; } @@ -140,7 +145,8 @@ Status GELib::InnerInitialize(const map &options) { Status initOpsStatus = opsManager_.Initialize(options); GE_TIMESTAMP_END(OpsManagerInitialize, "InnerInitialize::OpsManagerInitialize"); if (initOpsStatus != SUCCESS) { - GELOGE(initOpsStatus, "GE ops manager initial failed."); + GELOGE(initOpsStatus, "[Init][OpsManager]GE ops manager initial failed."); + REPORT_CALL_ERROR("E19999", "OpsManager initialize failed."); RollbackInit(); return initOpsStatus; } @@ -151,7 +157,8 @@ Status GELib::InnerInitialize(const map &options) { Status initOpsBuilderStatus = OpsKernelBuilderManager::Instance().Initialize(options); GE_TIMESTAMP_END(OpsKernelBuilderManagerInitialize, "InnerInitialize::OpsKernelBuilderManager"); if (initOpsBuilderStatus != SUCCESS) { - GELOGE(initOpsBuilderStatus, "GE ops builder manager initial failed."); + GELOGE(initOpsBuilderStatus, "[Init][OpsKernelBuilderManager]GE ops builder manager initial failed."); + REPORT_CALL_ERROR("E19999", "OpsBuilderManager initialize failed."); RollbackInit(); return initOpsBuilderStatus; } @@ -162,7 +169,8 @@ Status GELib::InnerInitialize(const map &options) { Status initSmStatus = sessionManager_.Initialize(options); GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize"); if (initSmStatus != SUCCESS) { - GELOGE(initSmStatus, "GE session manager initial failed."); + GELOGE(initSmStatus, "[Init][SessionManager] GE session manager initial failed."); + REPORT_CALL_ERROR("E19999", "SessionManager initialize failed."); RollbackInit(); return initSmStatus; } @@ -172,7 +180,8 @@ Status GELib::InnerInitialize(const map &options) { Status initHostCpuEngineStatus = HostCpuEngine::GetInstance().Initialize(); GE_TIMESTAMP_END(HostCpuEngineInitialize, "InnerInitialize::HostCpuEngineInitialize"); if (initHostCpuEngineStatus != SUCCESS) { - GELOGE(initHostCpuEngineStatus, "Failed to initialize HostCpuEngine"); + GELOGE(initHostCpuEngineStatus, "[Init][HostCpuEngine]Failed to initialize HostCpuEngine."); + REPORT_CALL_ERROR("E19999", "HostCpuEngine initialize failed."); RollbackInit(); return initHostCpuEngineStatus; } @@ -180,7 +189,8 @@ Status GELib::InnerInitialize(const map &options) { GELOGI("Start to init Analyzer!"); Status init_analyzer_status = ge::Analyzer::GetInstance()->Initialize(); if (init_analyzer_status != SUCCESS) { - GELOGE(init_analyzer_status, "Failed to initialize HostCpuEngine"); + GELOGE(init_analyzer_status, "[Init][Analyzer]Failed to initialize Analyzer."); + REPORT_CALL_ERROR("E19999", "ge::Analyzer initialize failed."); RollbackInit(); return init_analyzer_status; } @@ -205,7 +215,8 @@ Status GELib::SystemInitialize(const map &options) { auto model_manager = ModelManager::GetInstance(); GE_CHECK_NOTNULL(model_manager); GE_IF_BOOL_EXEC(model_manager->EnableExceptionDump(options) != SUCCESS, - GELOGE(FAILED, "Enable exception dump failed"); + REPORT_CALL_ERROR("E19999", "ModelManager EnableExceptionDump failed."); + GELOGE(FAILED, "[Enable][ExceptionDump] failed."); return FAILED); // 1.`is_train_mode_` means case: train // 2.`(!is_train_mode_) && (options_.device_id != kDefaultDeviceIdForInfer)` means case: online infer @@ -259,7 +270,10 @@ Status GELib::SetRTSocVersion(const map &options, map &options) { options.emplace(std::make_pair(AICORE_NUM, std::to_string(aicore_num))); return SUCCESS; } - GELOGE(FAILED, "rtGetAiCoreCount failed."); + GELOGE(FAILED, "[Get][AiCoreCount]rtGetAiCoreCount failed."); + REPORT_CALL_ERROR("E19999", "rtGetAiCoreCount failed."); return FAILED; } @@ -355,7 +370,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithOpt mem_type.push_back(RT_MEMORY_P2P_DDR); Status initMmStatus = MemManager::Instance().Initialize(mem_type); if (initMmStatus != SUCCESS) { - GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); + GELOGE(initMmStatus, "[Init][MemManager] MemoryAllocatorManager initialize failed."); + REPORT_CALL_ERROR("E19999", "MemManager initialize failed."); return initMmStatus; } @@ -363,7 +379,7 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithOpt // Update CSA file CsaInteract::GetInstance().Init(options.device_id, GetContext().TraceId()); Status ret = CsaInteract::GetInstance().WriteJobState(JOBSTATE_RUNNING, JOBSUBSTATE_ENV_INIT); - GE_LOGE_IF(ret != SUCCESS, "write job state failed, ret:%u", ret); + GE_LOGE_IF(ret != SUCCESS, "[Write][JobState] failed, ret:%u ", ret); // set device id GELOGI("set logical device id:%u", options.device_id); @@ -394,7 +410,7 @@ Status GELib::SystemShutdownWithOptions(const Options &options) { // Update CSA file Status ret = CsaInteract::GetInstance().WriteJobState(JOBSTATE_SUCCEED); - GE_LOGE_IF(ret != SUCCESS, "write job state failed, ret:%u", ret); + GE_LOGE_IF(ret != SUCCESS, "[Write][JobState] failed, ret:%u ", ret); is_system_inited = false; is_shutdown = true; @@ -410,7 +426,8 @@ FMK_FUNC_HOST_VISIBILITY FMK_FUNC_DEV_VISIBILITY Status GELib::InitSystemWithout mem_type.push_back(RT_MEMORY_P2P_DDR); Status initMmStatus = MemManager::Instance().Initialize(mem_type); if (initMmStatus != SUCCESS) { - GELOGE(initMmStatus, "[Initialize] MemoryAllocatorManager initialize failed."); + GELOGE(initMmStatus, "[Init][MemoryManager] initialize failed."); + REPORT_CALL_ERROR("E19999", "MemManager initialize failed."); return initMmStatus; } GE_CHK_STATUS_RET(HostMemManager::Instance().Initialize()); @@ -506,7 +523,8 @@ Status GELib::Finalize() { instancePtr_ = nullptr; init_flag_ = false; if (final_state != SUCCESS) { - GELOGE(FAILED, "finalization failed."); + GELOGE(FAILED, "[Check][State]finalization failed."); + REPORT_INNER_ERROR("E19999", "GELib::Finalize failed."); return final_state; } GELOGI("finalization success."); diff --git a/ge/ir_build/atc_ir_common.cc b/ge/ir_build/atc_ir_common.cc index 42a78dde..5c18fa7a 100755 --- a/ge/ir_build/atc_ir_common.cc +++ b/ge/ir_build/atc_ir_common.cc @@ -19,7 +19,9 @@ #include "framework/common/string_util.h" #include "framework/common/types.h" #include "framework/common/util.h" +#include "graph/compute_graph.h" #include "graph/utils/type_utils.h" +#include "graph/utils/tensor_utils.h" using std::pair; using std::string; @@ -32,6 +34,8 @@ const int64_t kDynamicImageSizeNum = 2; const size_t kMaxDynamicDimNum = 100; const size_t kMaxNDDimNum = 4; const size_t kMinNDDimNum = 1; +const size_t kSquareBracketsSize = 2; +const size_t kRangePairSize = 2; // 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}}; @@ -52,6 +56,11 @@ const char *const kCompressWeightError = "it must be appointed when appoint para const char *const kSelectImplmodeError = "only support high_performance, high_precision"; const char *const kDynamicBatchSizeError = "It can only contains digit, \",\", \" \""; const char *const kKeepDtypeError = "file not found"; +const char *const kInputShapeRangeInvalid = "format of shape range is invalid"; +const char *const kShapeRangeValueConvertError = "transfer from string to int64 error"; +const char *const kInputShapeRangeSample1 = "\"input_name1:[n1~n2,c1,h1,w1]\""; +const char *const kInputShapeRangeSample2 = "\"[]\""; +const char *const kInputShapeRangeSample3 = "\"[1~20,3,3~6,-1]\""; vector SplitInputShape(const std::string &input_shape) { vector shape_pair_vec; @@ -71,7 +80,7 @@ Status CheckInputFormat(const string &input_format) { if (!ge::TypeUtils::IsFormatValid(input_format.c_str())) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_format", input_format, "input format is invalid!"}); - GELOGE(ge::PARAM_INVALID, "input format [%s] is invalid!", input_format.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][InputFormat] --input_format[%s] is invalid!", input_format.c_str()); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -84,7 +93,8 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map vector shape = iter->second; if (shape.empty()) { ErrorManager::GetInstance().ATCReportErrMessage("E10012"); - GELOGE(ge::PARAM_INVALID, "--input_shape's shape size can not be less than 1 when set --dynamic_batch_size."); + GELOGE(ge::PARAM_INVALID, + "[Check][DynamicBatchSizeInputShape] shape size can not be less than 1 when set --dynamic_batch_size."); return false; } @@ -100,7 +110,8 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map if (size == 0) { ErrorManager::GetInstance().ATCReportErrMessage("E10031"); - GELOGE(ge::PARAM_INVALID, "At least one batch n must be equal to -1 when set --dynamic_batch_size."); + GELOGE(ge::PARAM_INVALID, + "[Check][DynamicBatchSizeInputShape]At least one batch n must be equal to -1 when set dynamic_batch_size."); return false; } @@ -108,8 +119,8 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map if (!isdigit(c) && (c != ',') && (c != ' ')) { ErrorManager::GetInstance().ATCReportErrMessage( "E10033", {"value", "reason"}, {dynamic_batch_size, kDynamicBatchSizeError}); - GELOGE(ge::PARAM_INVALID, "Input parameter[--dynamic_batch_size]'s value[%s] is invalid. reason: %s", - dynamic_batch_size.c_str(), kDynamicBatchSizeError); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] --dynamic_batch_size:%s is invalid. reason: %s", + dynamic_batch_size.c_str(), kDynamicBatchSizeError); return false; } } @@ -122,7 +133,8 @@ bool CheckDynamicBatchSizeInputShapeValid(map> shape_map bool CheckDynamicImagesizeInputShapeValid(map> shape_map, const std::string input_format, std::string &dynamic_image_size) { if (!input_format.empty() && !ge::TypeUtils::IsFormatValid(input_format.c_str())) { - GELOGE(ge::PARAM_INVALID, "user input format [%s] is not found!", input_format.c_str()); + GELOGE(ge::PARAM_INVALID, + "[Check][DynamicImagesizeInputShape] input_format [%s] invalid, can not support now.", input_format.c_str()); return false; } int32_t size = 0; @@ -132,8 +144,9 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map if (shape.size() != DIM_DEFAULT_SIZE) { if (std::count(shape.begin(), shape.end(), kDynamicInputDim) > 0) { ErrorManager::GetInstance().ATCReportErrMessage("E10019"); - GELOGE(ge::PARAM_INVALID, - "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); + GELOGE(ge::PARAM_INVALID, + "[Check][DynamicImagesizeInputShape] --input_shape invalid," + " only height and width can be -1 when set --dynamic_image_size."); return false; } continue; @@ -152,7 +165,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map if (size == 0) { ErrorManager::GetInstance().ATCReportErrMessage("E10019"); GELOGE(ge::PARAM_INVALID, - "--input_shape's shape is invalid, only height and width can be -1 when set --dynamic_image_size."); + "[Check][DynamicImagesizeInputShape]--input shape invalid, " + "only height and width can be -1 when set --dynamic_image_size."); return false; } @@ -167,9 +181,8 @@ bool CheckDynamicImagesizeInputShapeValid(map> shape_map ErrorManager::GetInstance().ATCReportErrMessage("E10020", {"DynamicImageSizeNum"}, {std::to_string(kDynamicImageSizeNum)}); GELOGE(ge::PARAM_INVALID, - "--dynamic_image_size's number of dimensions of each " - "group must be %ld.", - kDynamicImageSizeNum); + "[Check][DynamicImagesizeInputShape] invalid value:%s number of dimensions of each group must be %ld.", + dynamic_image_size.c_str(), kDynamicImageSizeNum); return false; } } @@ -183,7 +196,7 @@ bool CheckDynamicDimsInputShapeValid(const map> &shape_m ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_format", input_format.c_str(), "input_format must be ND when set dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "input_format must be ND when set dynamic_dims."); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]--input_format must be ND when set dynamic_dims."); return false; } @@ -194,7 +207,8 @@ bool CheckDynamicDimsInputShapeValid(const map> &shape_m ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_shape's dim", std::to_string(shapes.size()), "Dim num must within [1, 4] when set dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "Dim num must within [%zu, %zu] when set dynamic_dims.", kMinNDDimNum, kMaxNDDimNum); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]Dim num must within [%zu, %zu] when set dynamic_dims.", + kMinNDDimNum, kMaxNDDimNum); return false; } dynamic_dim += std::count(shapes.begin(), shapes.end(), kDynamicInputDim); @@ -203,12 +217,13 @@ bool CheckDynamicDimsInputShapeValid(const map> &shape_m ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--input_shape's dynamic dim num", "0", "at least one dim should be -1 when set dynamic_dims"}); - GELOGE(ge::PARAM_INVALID, "input_shape's shape is invalid, at least one dim should be -1 when set dynamic_dims."); + GELOGE(ge::PARAM_INVALID, + "[Check][DynamicDimsInputShape]--input_shape invalid, at least one dim should be -1 when set dynamic_dims."); return false; } if (!CheckAndParseDynamicDims(dynamic_dim, dynamic_dims)) { - GELOGE(ge::PARAM_INVALID, "Check and parse dynamic dims: %s failed.", dynamic_dims.c_str()); + GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims]: %s failed.", dynamic_dims.c_str()); return false; } @@ -221,7 +236,7 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--dynamic_dims", dynamic_dims.c_str(), "dynamic_dims can not be empty"}); - GELOGE(ge::PARAM_INVALID, "dynamic_dims can not be empty."); + GELOGE(ge::PARAM_INVALID, "[CheckAndParse][DynamicDims]--dynamic_dims can not be empty."); return false; } // Different parameter sets are split by ';' @@ -229,7 +244,8 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &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"}); - GELOGE(ge::PARAM_INVALID, "dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); + GELOGE(ge::PARAM_INVALID, + "[CheckAndParse][DynamicDims]dynamic_dims's num of parameter set can not exceed %zu.", kMaxDynamicDimNum); return false; } for (auto split_dim : split_set) { @@ -238,8 +254,9 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims ErrorManager::GetInstance().ATCReportErrMessage( "E10042", {"parameter", "reason"}, {"dynamic_dims", "Each gear setting needs to be consistent with the number of -1 in the inputshape"}); - GELOGE(ge::PARAM_INVALID, "Input parameter --dynamic_dims parse failed, " - "reason: 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()); return false; } for (auto dim : one_set) { @@ -248,7 +265,9 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--dynamic_dims's parameter", dim.c_str(), "must be positive integer"}); - GELOGE(ge::PARAM_INVALID, "dynamic_dims's parameter must be positive integer."); + GELOGE(ge::PARAM_INVALID, + "[CheckAndParse][DynamicDims]--dynamic_dims:%s parameter must be positive integer.", + dynamic_dims.c_str()); return false; } } @@ -257,18 +276,147 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims return true; } +bool StringToLongNoThrow(const string &str, long &val) { + try { + val = std::stol(str); + return true; + } catch (const std::invalid_argument) { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, + {str, kShapeRangeValueConvertError, kInputShapeRangeSample3}); + GELOGE(PARAM_INVALID, "[Parse][Parameter] str:%s invalid, reason: %s, correct sample is %s.", + str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); + } catch (const std::out_of_range) { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, + {str, kShapeRangeValueConvertError, kInputShapeRangeSample3}); + GELOGE(PARAM_INVALID, "[Parse][Parameter] str:%s invalid, reason: %s, correct sample is %s.", + str.c_str(), kShapeRangeValueConvertError, kInputShapeRangeSample3); + } + return false; +} + +bool ParseSingleShapeRange(std::string &shape_range, vector> &shape_range_vec) { + vector square_brackets; + for (auto ch : shape_range) { + if (ch == '[' || ch == ']') { + square_brackets.push_back(ch); + } + } + + bool is_square_brackets = (square_brackets[0] == '[') && (square_brackets[1] == ']') && + (square_brackets.size() == kSquareBracketsSize); + if (!is_square_brackets) { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, + {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample2}); + GELOGE(PARAM_INVALID, "[Parse][Parameter] shape_range:%s invalid, reason: %s, correct sample is %s.", + shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample2); + return false; + } + // trim start bytes, after that, single input should be "1~20,3,3~6,-1" + if (ge::StringUtils::StartWith(shape_range, "[")) { + shape_range = shape_range.substr(1, shape_range.size() - 1); + } + // parse shape_range of single input. eg. "1~20,3,3~6,-1" + vector dim_range_set = ge::StringUtils::Split(shape_range, ','); + for (const auto &range_pair_str : dim_range_set) { + vector range_pair_set = ge::StringUtils::Split(range_pair_str, '~'); + pair range_pair; + if (range_pair_set.size() == 1) { + long range_value = 0; + if (!StringToLongNoThrow(range_pair_set.at(0), range_value)) { + return false; + } + if (range_value < 0) { + range_pair = std::make_pair(1, range_value); + } else { + range_pair = std::make_pair(range_value, range_value); + } + } else if (range_pair_set.size() == kRangePairSize) { + // unknown dim, should get range. + long range_left = 0; + if (!StringToLongNoThrow(range_pair_set.at(0), range_left)) { + return false; + } + long range_right = 0; + if (!StringToLongNoThrow(range_pair_set.at(1), range_right)) { + return false; + } + if (range_left < 0 || (range_right < 0)) { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, + {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample3}); + GELOGE(PARAM_INVALID, + "Parse input parameter [--input_shape_range]'s shape range[%s] failed," + "reason: %s, correct sample is %s.", + shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample3); + return false; + } + range_pair = std::make_pair(range_left, range_right); + } else { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, + {shape_range, kInputShapeRangeInvalid, kInputShapeRangeSample3}); + GELOGE(PARAM_INVALID,"[Parse][Parameter]shape_range:%s invalid, reason: %s, correct sample is %s.", + shape_range.c_str(), kInputShapeRangeInvalid, kInputShapeRangeSample3); + return false; + } + shape_range_vec.emplace_back(range_pair); + } + return true; +} + +bool ParseInputShapeRange(const std::string &shape_range, + std::map>> &shape_range_map) { + GELOGD("Input shape range %s", shape_range.c_str()); + + vector shape_range_vec = StringUtils::Split(shape_range, ';'); + const int DEFAULT_SHAPE_RANGE_PAIR_SIZE = 2; + for (const auto &shape_range_item : shape_range_vec) { + vector shape_range_pair_vec = SplitInputShape(shape_range_item); + if (shape_range_pair_vec.size() != DEFAULT_SHAPE_RANGE_PAIR_SIZE) { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape_range", "reason", "sample"}, + {shape_range, kSplitError1, kInputShapeRangeSample1}); + GELOGE(PARAM_INVALID, "[Parse][Parameter]--input shape_range:%s invalid, reason: %s, correct sample is %s.", + shape_range.c_str(), kSplitError1, kInputShapeRangeSample1); + return false; + } + if (shape_range_pair_vec[1].empty()) { + ErrorManager::GetInstance().ATCReportErrMessage("E10048", {"shape", "reason", "sample"}, + {shape_range, kEmptyError, kInputShapeRangeSample1}); + GELOGE(PARAM_INVALID, "[Parse][Parameter]shape_range:%s invalid,reason: %s, correct sample is %s.", + shape_range.c_str(), kEmptyError, kInputShapeRangeSample1); + return false; + } + + string shape_range_str = shape_range_pair_vec[1]; + vector> shape_range_val; + if (!ParseSingleShapeRange(shape_range_str, shape_range_val)) { + GELOGE(PARAM_INVALID, "[Parse][Param] shape_range_str: %s invalid.", shape_range_str.c_str()); + return false; + } + shape_range_map.emplace(make_pair(StringUtils::Trim(shape_range_pair_vec[0]), shape_range_val)); + } + + return true; +} + Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_image_size, string &dynamic_dims, - const string input_shape, const string input_format, bool &is_dynamic_input) { + const string input_shape, const string input_shape_range, const string input_format,bool &is_dynamic_input){ int32_t param_size = static_cast(!dynamic_batch_size.empty()) + - static_cast(!dynamic_image_size.empty()) + static_cast(!dynamic_dims.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"}); - GELOGE(ge::PARAM_INVALID, "dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one"); + GELOGE(ge::PARAM_INVALID, + "[Parse][Param]dynamic_batch_size, dynamic_image_size and dynamic_dims can only be set one"); return ge::PARAM_INVALID; } if (param_size == 0) { + if (!input_shape_range.empty()) { + std::map>> shape_range_map; + if (!ParseInputShapeRange(input_shape_range, shape_range_map)) { + GELOGE(ge::PARAM_INVALID, "Failed to parse input shape range: %s", input_shape_range.c_str()); + return ge::PARAM_INVALID; + } + } return ge::SUCCESS; } @@ -277,33 +425,34 @@ Status CheckDynamicInputParamValid(string &dynamic_batch_size, string &dynamic_i is_dynamic_input = true; if (input_shape.empty()) { ErrorManager::GetInstance().ATCReportErrMessage("E10004", {"parameter"}, {"input_shape"}); - GELOGE(ge::PARAM_INVALID, "The input_shape can not be empty in dynamic input size scenario."); + GELOGE(ge::PARAM_INVALID, "[Check][Param]The input_shape can not be empty in dynamic input size scenario."); return ge::PARAM_INVALID; } if (!ParseInputShape(input_shape, shape_map, user_shape_map, is_dynamic_input)) { - GELOGE(ge::PARAM_INVALID, "Failed to parse input shape: %s", input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Parse][InputShape]input_shape: %s invalid.", input_shape.c_str()); return ge::PARAM_INVALID; } if (!dynamic_batch_size.empty()) { if (!CheckDynamicBatchSizeInputShapeValid(shape_map, dynamic_batch_size)) { - GELOGE(ge::PARAM_INVALID, "Check dynamic batch size input shape failed: %s", input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicBatchSizeInputShape] input_shape: %s invalid.", input_shape.c_str()); return ge::PARAM_INVALID; } } if (!dynamic_image_size.empty()) { if (!CheckDynamicImagesizeInputShapeValid(shape_map, input_format, dynamic_image_size)) { - GELOGE(ge::PARAM_INVALID, "Check dynamic image size input shape failed: %s", input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicImagesizeInputShape] %s invalid. dynamic_image_size:%s ", + input_shape.c_str(), dynamic_image_size.c_str()); return ge::PARAM_INVALID; } } if (!dynamic_dims.empty()) { if (!CheckDynamicDimsInputShapeValid(shape_map, input_format, dynamic_dims)) { - GELOGE(ge::PARAM_INVALID, "Check dynamic dims: %s of input shape: %s failed.", dynamic_dims.c_str(), - input_shape.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][DynamicDimsInputShape]: %s of input shape: %s failed.", dynamic_dims.c_str(), + input_shape.c_str()); return ge::PARAM_INVALID; } } @@ -354,7 +503,8 @@ bool ParseInputShape(const string &input_shape, map> &sh if (!isdigit(c)) { ErrorManager::GetInstance().ATCReportErrMessage("E10002", {"shape", "reason", "sample"}, {shape, kDigitError, kInputShapeSample2}); - GELOGE(PARAM_INVALID, "--input_shape's shape value[%s] is not digit", shape_value_str.c_str()); + GELOGE(PARAM_INVALID, "[Check][Param]--input_shape's shape value[%s] is not digit", + shape_value_str.c_str()); return false; } } @@ -377,7 +527,8 @@ bool ParseInputShape(const string &input_shape, map> &sh int64_t result = left_result; // - 1 is not currently supported if (!is_dynamic_input && result <= 0) { - ErrorManager::GetInstance().ATCReportErrMessage("E10011", {"shape", "result"}, {shape, std::to_string(result)}); + ErrorManager::GetInstance().ATCReportErrMessage("E10011", {"shape", "result"}, + {shape, std::to_string(result)}); GELOGW( "Input parameter[--input_shape]’s shape value[%s] is invalid, " "expect positive integer, but value is %ld.", @@ -399,7 +550,7 @@ Status CheckOutputTypeParamValid(const std::string output_type) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--output_type", output_type, kOutputTypeSupport}); GELOGE(ge::PARAM_INVALID, - "Invalid value for --output_type[%s], %s.", output_type.c_str(), kOutputTypeSupport); + "[Check][Param]Invalid value for --output_type[%s], %s.", output_type.c_str(), kOutputTypeSupport); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -411,30 +562,34 @@ Status CheckBufferOptimizeParamValid(const std::string buffer_optimize) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--buffer_optimize", buffer_optimize, kBufferOptimizeSupport}); GELOGE(ge::PARAM_INVALID, - "Invalid value for --buffer_optimize[%s], %s.", buffer_optimize.c_str(), kBufferOptimizeSupport); + "[Check][BufferOptimize]Invalid value for [%s], %s.", buffer_optimize.c_str(), kBufferOptimizeSupport); return ge::PARAM_INVALID; } return ge::SUCCESS; } -Status CheckCompressWeightParamValid(const std::string enable_compress_weight, const std::string compress_weight_conf) { +Status CheckCompressWeightParamValid(const std::string enable_compress_weight, + const std::string compress_weight_conf) { if ((!compress_weight_conf.empty()) && (!CheckInputPathValid(compress_weight_conf, "--compress_weight_conf"))) { - GELOGE(ge::PARAM_INVALID, "compress weight config file not found, file_name:%s", compress_weight_conf.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][CompressWeight]compress weight config file not found, file_name:%s", + compress_weight_conf.c_str()); return ge::PARAM_INVALID; } if ((enable_compress_weight != "") && (enable_compress_weight != "true") && (enable_compress_weight != "false")) { ErrorManager::GetInstance().ATCReportErrMessage( "E10005", {"parameter", "value"}, {"enable_compress_weight", enable_compress_weight}); GELOGE(ge::PARAM_INVALID, - "Input parameter[--enable_compress_weight]'s value[%s] must be true or false.", enable_compress_weight.c_str()); + "[Check][CompressWeight]Input parameter[--enable_compress_weight]'s value[%s] must be true or false.", + enable_compress_weight.c_str()); return ge::PARAM_INVALID; } if ((enable_compress_weight == "true") && (!compress_weight_conf.empty())) { ErrorManager::GetInstance().ATCReportErrMessage("E10047", {"parameter0", "parameter1"}, {"enable_compress_weight", "compress_weight_conf"}); - GELOGE(ge::PARAM_INVALID, "enable_compress_weight and compress_weight_conf can not both exist!!"); + GELOGE(ge::PARAM_INVALID, + "[Check][CompressWeight]enable_compress_weight and compress_weight_conf can not both exist!!"); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -444,7 +599,7 @@ Status CheckKeepTypeParamValid(const std::string &keep_dtype) { if ((!keep_dtype.empty()) && (!CheckInputPathValid(keep_dtype, "--keep_dtype"))) { ErrorManager::GetInstance().ATCReportErrMessage( "E10001", {"parameter", "value", "reason"}, {"--keep_dtype", keep_dtype, kKeepDtypeError}); - GELOGE(ge::PARAM_INVALID, "keep dtype config file not found, file_name:%s", keep_dtype.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][InputPath::--keep_dtype] file not found, file_name:%s", keep_dtype.c_str()); return ge::PARAM_INVALID; } @@ -466,11 +621,12 @@ int CheckLogParamValidAndSetLogLevel(const std::string log) { } else if (log == "error") { ret = dlog_setlevel(-1, DLOG_ERROR, 1); } else { - GELOGE(ge::PARAM_INVALID, "invalid value for log:%s, only support debug, info, warning, error, null", log.c_str()); + GELOGE(ge::PARAM_INVALID, + "[Check][LogParam]log:%s invalid, only support debug, info, warning, error, null", log.c_str()); return ret; } if (ret != 0) { - GELOGE(ge::PARAM_INVALID, "Log setlevel fail !"); + GELOGE(ge::PARAM_INVALID, "[Set][LogLevel] fail, level:%s.",log.c_str()); } return ret; } @@ -478,7 +634,7 @@ int CheckLogParamValidAndSetLogLevel(const std::string log) { Status CheckInsertOpConfParamValid(const std::string insert_op_conf) { if ((!insert_op_conf.empty()) && (!CheckInputPathValid(insert_op_conf, "--insert_op_conf"))) { - GELOGE(ge::PARAM_INVALID, "insert op config file not found: %s", insert_op_conf.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][InputPath]file not found: %s", insert_op_conf.c_str()); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -487,7 +643,7 @@ 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"}); - GELOGE(ge::PARAM_INVALID, "Input parameter[--disable_reuse_memory]'s value must be 1 or 0."); + GELOGE(ge::PARAM_INVALID, "[Check][DisableReuseMemory]disable_reuse_memory must be 1 or 0."); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -497,8 +653,8 @@ Status CheckEnableSingleStreamParamValid(const std::string enable_single_stream) if ((enable_single_stream != "") && (enable_single_stream != "true") && (enable_single_stream != "false")) { ErrorManager::GetInstance().ATCReportErrMessage( "E10005", {"parameter", "value"}, {"enable_single_stream", enable_single_stream}); - GELOGE(ge::PARAM_INVALID, "Input parameter[--enable_single_stream]'s value[%s] must be true or false.", - enable_single_stream.c_str()); + GELOGE(ge::PARAM_INVALID, "[Check][Param:--enable_single_stream] value:%s must be true or false.", + enable_single_stream.c_str()); return ge::PARAM_INVALID; } return ge::SUCCESS; @@ -509,8 +665,8 @@ Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std:: if (optypelist_for_implmode != "" && op_select_implmode == "") { ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, {"--op_select_implmode", op_select_implmode.c_str(), kCompressWeightError}); - GELOGE(ge::PARAM_INVALID, "Invalid value for --op_select_implmode[%s], %s.", - op_select_implmode.c_str(), kCompressWeightError); + GELOGE(ge::PARAM_INVALID, "[Check][Param:--op_select_implmode]value:%s invalid, %s.", + op_select_implmode.c_str(),kCompressWeightError); return ge::PARAM_INVALID; } // op_select_implmode default value is high_performance @@ -521,7 +677,7 @@ Status CheckImplmodeParamValid(const std::string &optypelist_for_implmode, std:: op_select_implmode != IR_OPTION_OP_SELECT_IMPLMODE_PRECISON) { ErrorManager::GetInstance().ATCReportErrMessage("E10001", {"parameter", "value", "reason"}, {"--op_select_implmode", op_select_implmode.c_str(), kSelectImplmodeError}); - GELOGE(ge::PARAM_INVALID, "Invalid value for --op_select_implmode[%s], %s.", + GELOGE(ge::PARAM_INVALID, "[Check][Implmode]Invalid value for --op_select_implmode[%s], %s.", op_select_implmode.c_str(), kSelectImplmodeError); return ge::PARAM_INVALID; } @@ -546,4 +702,122 @@ void EraseEndSemicolon(string ¶m) { param.erase(param.end() - 1); } } + +Status UpdateDataOpShape(const OpDescPtr &op, map> &shape_map) { + GE_CHECK_NOTNULL(op); + if (shape_map.empty()) { + GELOGI("Shape map of data op [%s] is empty, no need to update.", op->GetName().c_str()); + return SUCCESS; + } + + auto tensor_input = op->MutableInputDesc(0); + auto tensor_output = op->MutableOutputDesc(0); + GE_CHECK_NOTNULL(tensor_input); + GE_CHECK_NOTNULL(tensor_output); + string data_op_name = op->GetName(); + auto iter = shape_map.find(data_op_name); + if (iter != shape_map.end()) { + tensor_input->SetShape(ge::GeShape(iter->second)); + tensor_output->SetShape(ge::GeShape(iter->second)); + GELOGI("Update input [%s] shape info", data_op_name.c_str()); + } else { + GELOGI("No need update input [%s] attr because not found from input_shape.", data_op_name.c_str()); + } + + return SUCCESS; +} + +Status UpdateDataOpShapeRange(const OpDescPtr &op, + map>> &shape_range_map) { + GE_CHECK_NOTNULL(op); + if (shape_range_map.empty()) { + GELOGI("Shape range map of data op [%s] is empty.", op->GetName().c_str()); + return SUCCESS; + } + + auto tensor_input = op->MutableInputDesc(0); + auto tensor_output = op->MutableOutputDesc(0); + GE_CHECK_NOTNULL(tensor_input); + GE_CHECK_NOTNULL(tensor_output); + string data_op_name = op->GetName(); + auto origin_shape = tensor_input->GetShape(); + auto iter = shape_range_map.find(data_op_name); + if (iter != shape_range_map.end()) { + auto cur_shape_range = iter->second; + if (TensorUtils::CheckShapeByShapeRange(origin_shape, cur_shape_range) != SUCCESS) { + GELOGE(PARAM_INVALID, "[Check][OpDescPtr] Check shape by shape range failed for op:%s.", data_op_name.c_str()); + return PARAM_INVALID; + } + for (size_t idx = 0; idx < cur_shape_range.size(); idx++) { + auto left_range = cur_shape_range[idx].first; + auto right_range = cur_shape_range[idx].second; + if (left_range != right_range) { + origin_shape.SetDim(idx, UNKNOWN_DIM); + } + } + tensor_input->SetShape(origin_shape); + tensor_input->SetShapeRange(cur_shape_range); + tensor_output->SetShape(origin_shape); + tensor_output->SetShapeRange(cur_shape_range); + GELOGI("Update input [%s] shape range info", data_op_name.c_str()); + } else { + GELOGI("No need to update input [%s] attr because not found from input_shape_range.", data_op_name.c_str()); + } + + return SUCCESS; +} + +static Status CheckInputShapeRangeNode(const ComputeGraphPtr &compute_graph, + const map>> &shape_range_map) { + for (const auto &it : shape_range_map) { + std::string node_name = it.first; + ge::NodePtr node = compute_graph->FindNode(node_name); + if (node == nullptr) { + REPORT_INPUT_ERROR("E10016", std::vector({"parameter", "opname"}), + std::vector({"input_shape_range", node_name})); + GELOGE(PARAM_INVALID, "[Check][InputNode]Input parameter[--input_shape_range]'s opname[%s] is not exist in model", + node_name.c_str()); + return PARAM_INVALID; + } + if (node->GetType() != DATA) { + REPORT_INPUT_ERROR("E10017", std::vector({"parameter", "opname"}), + std::vector({"input_shape_range", node_name})); + GELOGE(PARAM_INVALID, "[Check][InputNode]Input parameter[--input_shape_range]'s opname[%s] is not a input opname", + node_name.c_str()); + return PARAM_INVALID; + } + } + return SUCCESS; +} + +Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, const string &input_shape_range) { + if (input_shape_range.empty()) { + return SUCCESS; + } + GE_CHECK_NOTNULL(compute_graph); + + map>> shape_range_map; + if (!ParseInputShapeRange(input_shape_range, shape_range_map)) { + GELOGE(PARAM_INVALID, "[Parse][InputShapeRange] input_shape_range:%s invalid.", input_shape_range.c_str()); + return PARAM_INVALID; + } + + if (CheckInputShapeRangeNode(compute_graph, shape_range_map) != SUCCESS) { + GELOGE(PARAM_INVALID, "[Check][InputShapeRange]check input shape range:%s failed.", input_shape_range.c_str()); + return PARAM_INVALID; + } + + for (NodePtr &input_node : compute_graph->GetDirectNode()) { + GE_CHECK_NOTNULL(input_node); + OpDescPtr op = input_node->GetOpDesc(); + GE_CHECK_NOTNULL(op); + if (op->GetType() == DATA) { + if (UpdateDataOpShapeRange(op, shape_range_map) != SUCCESS) { + GELOGE(FAILED, "[Update][InputShapeRange] fail for op:%s.", op->GetName().c_str()); + return FAILED; + } + } + } + return SUCCESS; +} } // namespace ge diff --git a/ge/ir_build/atc_ir_common.h b/ge/ir_build/atc_ir_common.h index 2ad4efa8..6ff40547 100644 --- a/ge/ir_build/atc_ir_common.h +++ b/ge/ir_build/atc_ir_common.h @@ -31,7 +31,7 @@ namespace ge { static std::set caffe_support_input_format = {"NCHW", "ND"}; static std::set tf_support_input_format = {"NCHW", "NHWC", "ND", "NCDHW", "NDHWC"}; -static std::set onnx_support_input_format = {"NCHW", "ND"}; +static std::set onnx_support_input_format = {"NCHW", "ND", "NCDHW"}; static std::map input_format_str_to_geformat = { {"ND", domi::DOMI_TENSOR_ND}, @@ -59,10 +59,13 @@ bool CheckAndParseDynamicDims(int32_t dynamic_dim_num, std::string &dynamic_dims Status CheckDynamicInputParamValid(std::string &dynamic_batch_size, std::string &dynamic_image_size, std::string &dynamic_dims, const std::string input_shape, - const std::string input_format, bool &is_dynamic_input); + const std::string input_shape_range, const std::string input_format, + bool &is_dynamic_input); bool ParseInputShape(const std::string &input_shape, std::map> &shape_map, std::vector>> &user_shape_map, bool is_dynamic_input = false); +bool ParseInputShapeRange(const std::string &shape_range, + std::map>> &shape_range_map); Status CheckOutputTypeParamValid(const std::string output_type); Status CheckBufferOptimizeParamValid(const std::string buffer_optimize); @@ -76,5 +79,9 @@ Status CheckInputFormat(const string &input_format); Status CheckKeepTypeParamValid(const std::string &keep_dtype); void PrintOptionMap(std::map &options, std::string tips); void EraseEndSemicolon(std::string ¶m); +Status UpdateDataOpShape(const OpDescPtr &op, std::map> &shape_map); +Status UpdateDataOpShapeRange(const OpDescPtr &op, + std::map>> &shape_range_map); +Status UpdateDynamicInputShapeRange(const ge::ComputeGraphPtr &compute_graph, const string &input_shape_range); } #endif // FRAMEWORK_DOMI_ATC_IR_COMMON_H_ diff --git a/ge/ir_build/ge_ir_build.cc b/ge/ir_build/ge_ir_build.cc index 747a1ec7..2465b5bc 100644 --- a/ge/ir_build/ge_ir_build.cc +++ b/ge/ir_build/ge_ir_build.cc @@ -55,6 +55,7 @@ const std::string IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT = "0"; const std::string IR_OPTION_ENABLE_COMPRESS_WEIGHT_DEFAULT = "false"; const std::string KEEP_DTYPE_OPTION = "keep_dtype"; const std::string kInputShape = "input_shape"; +const std::string kInputShapeRange = "input_shape_range"; const std::string kInputFormat = "input_format"; /** @@ -64,7 +65,7 @@ const std::string kInputFormat = "input_format"; * @param cfg_path [IN] the config file path * @return graphStatus */ -typedef graphStatus (*SetOpAttrFun)(ComputeGraphPtr &graph, const std::string &cfg_path); +using SetOpAttrFun = graphStatus (*)(ComputeGraphPtr &graph, const std::string &cfg_path); const std::map kAttrTypeFuncMap = { {ATTR_TYPE_KEEP_DTYPE, KeepDtypeFunc}, @@ -84,21 +85,21 @@ static graphStatus CheckGlobalOptions(std::map &global ? IR_OPTION_DISABLE_REUSE_MEMORY_DEFAULT : global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY]; GE_CHK_BOOL_EXEC(ge::CheckDisableReuseMemoryParamValid(disable_reuse_memory) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check disable_reuse_memory failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][DisableReuseMemory] failed!"); global_options[ge::ir_option::EXEC_DISABLE_REUSED_MEMORY] = disable_reuse_memory; // check buffer_optimize std::string buffer_optimize = global_options.find(ge::ir_option::BUFFER_OPTIMIZE) == global_options.end() ? IR_OPTION_BUFFER_OPTIMIZE_DEFAULT : global_options[ge::ir_option::BUFFER_OPTIMIZE]; GE_CHK_BOOL_EXEC(ge::CheckBufferOptimizeParamValid(buffer_optimize) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check buffer optimize failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][BufferOptimize] failed!"); global_options[ge::ir_option::BUFFER_OPTIMIZE] = buffer_optimize; // check enable_single_stream std::string enable_single_stream = global_options.find(ge::ir_option::ENABLE_SINGLE_STREAM) == global_options.end() ? "" : global_options[ge::ir_option::ENABLE_SINGLE_STREAM]; GE_CHK_BOOL_EXEC(ge::CheckEnableSingleStreamParamValid(enable_single_stream) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check enable single stream failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][EnableSingleStream] failed!"); // check compress_weight std::string enable_compress_weight = global_options.find(ge::ir_option::ENABLE_COMPRESS_WEIGHT) == global_options.end() @@ -108,7 +109,7 @@ static graphStatus CheckGlobalOptions(std::map &global ? "" : global_options[ge::ir_option::COMPRESS_WEIGHT_CONF]; GE_CHK_BOOL_EXEC(ge::CheckCompressWeightParamValid(enable_compress_weight, compress_weight_conf) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check compress weight failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][CompressWeight] failed!"); global_options[ge::ir_option::ENABLE_COMPRESS_WEIGHT] = (enable_compress_weight == "true") ? ge::kEnableCompressWeightTrue : ge::kEnableCompressWeightFalse; @@ -123,7 +124,7 @@ static graphStatus CheckGlobalOptions(std::map &global : global_options[ge::ir_option::OP_SELECT_IMPL_MODE]; GE_CHK_BOOL_EXEC( ge::CheckImplmodeParamValid(optypelist_for_implmode, op_select_implmode) == ge::SUCCESS, - return ge::GRAPH_PARAM_INVALID, "check optypelist_for_implmode and op_select_implmode failed!"); + return ge::GRAPH_PARAM_INVALID, "[Check][Implmode] failed!"); global_options[ge::ir_option::OP_SELECT_IMPL_MODE] = op_select_implmode; // set precision mode default value @@ -143,7 +144,7 @@ static void GetOpsProtoPath(string &opsproto_path) { string path = path_env; string file_path = RealPath(path.c_str()); if (file_path.empty()) { - GELOGE(FAILED, "File path %s is invalid.", path.c_str()); + GELOGE(FAILED, "[Check][Path] %s is invalid.", path.c_str()); return; } opsproto_path = (path + "/op_proto/custom/" + ":") + (path + "/op_proto/built-in/"); @@ -171,7 +172,7 @@ graphStatus aclgrphBuildInitializeImpl(std::map &globa GELOGD("Enter aclgrphInitialize start!"); // check global options if (CheckGlobalOptions(global_options) != GRAPH_SUCCESS) { - GELOGE(GRAPH_PARAM_INVALID, "Check global options falied!"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Global Options] falied!"); return GRAPH_PARAM_INVALID; } @@ -185,7 +186,7 @@ graphStatus aclgrphBuildInitializeImpl(std::map &globa GELOGI("aclgrphInitialize start!"); auto ret = ge::GELib::Initialize(global_options); if (ret != ge::SUCCESS) { - GELOGE(ret, "GE initialize failed!"); + GELOGE(ret, "[Init][GELib] failed!"); return GRAPH_FAILED; } } @@ -210,7 +211,7 @@ graphStatus aclgrphBuildInitialize(std::map &global_ std::map tmp_global_options; for (auto &option : global_options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); + GELOGE(GRAPH_FAILED, "[Check][Options]AclgrphBuildInitialize option is nullptr."); return GRAPH_FAILED; } std::string key = option.first.GetString(); @@ -280,7 +281,7 @@ graphStatus Impl::InferShapePrepare(const ComputeGraphPtr &compute_graph) { auto ret = prepare_infershape.Run(compute_graph); if ((ret != SUCCESS) && (ret != NOT_CHANGED)) { - GELOGE(ret, "Prepair for infershape failed, ret:%d", ret); + GELOGE(ret, "[Prepair][InferShape] failed, ret:%d", ret); return ret; } GELOGD("Prepair for infershape success!"); @@ -289,13 +290,20 @@ graphStatus Impl::InferShapePrepare(const ComputeGraphPtr &compute_graph) { graphStatus Impl::UpdateDataOpAttr(const Graph &graph) { GELOGD("Enter Update Data Attr Process!"); - if (options_.find(kInputShape) == options_.end()) { - return GRAPH_SUCCESS; - } + std::string input_shape = (options_.find(kInputShape) == options_.end()) ? "" : options_[kInputShape]; + std::string input_shape_range = (options_.find(kInputShapeRange) == options_.end()) ? "" : options_[kInputShapeRange]; + map> shape_map; vector>> user_shape_map; - GE_CHK_BOOL_EXEC(ParseInputShape(options_[kInputShape], shape_map, user_shape_map, true), - return GRAPH_PARAM_INVALID, "parse input shape failed!"); + if (!input_shape.empty()) { + GE_CHK_BOOL_EXEC(ParseInputShape(input_shape, shape_map, user_shape_map, true), + return GRAPH_PARAM_INVALID, "[Parse][InputShape] failed!"); + } + std::map>> shape_range_map; + if (!input_shape_range.empty()) { + GE_CHK_BOOL_EXEC(ParseInputShapeRange(input_shape_range, shape_range_map), + return GRAPH_PARAM_INVALID, "[Parse][InputShapeRange] failed."); + } auto compute_graph = ge::GraphUtils::GetComputeGraph(graph); GE_CHECK_NOTNULL(compute_graph); for (ge::NodePtr &input_node : compute_graph->GetDirectNode()) { @@ -303,21 +311,17 @@ graphStatus Impl::UpdateDataOpAttr(const Graph &graph) { ge::OpDescPtr op = input_node->GetOpDesc(); GE_CHECK_NOTNULL(op); if (op->GetType() == DATA) { - auto tensor_input = op->MutableInputDesc(0); - auto tensor_output = op->MutableOutputDesc(0); - GE_CHECK_NOTNULL(tensor_input); - GE_CHECK_NOTNULL(tensor_output); - string data_op_name = op->GetName(); - auto iter = shape_map.find(data_op_name); - if (iter != shape_map.end()) { - tensor_input->SetShape(ge::GeShape(iter->second)); - tensor_output->SetShape(ge::GeShape(iter->second)); - GELOGD("update input [%s] shape info", data_op_name.c_str()); - } else { - GELOGI("no need update input [%s] attr because not found from input_shape.", data_op_name.c_str()); + if (UpdateDataOpShape(op, shape_map) != SUCCESS) { + GELOGE(GRAPH_FAILED, "[Update][DataOpShape] fail for op:%s.", op->GetName().c_str()); + return GRAPH_FAILED; } + if (UpdateDataOpShapeRange(op, shape_range_map) != SUCCESS) { + GELOGE(GRAPH_FAILED, "[Update][DataOpShapeRange] fail for op:%s.", op->GetName().c_str()); + return GRAPH_FAILED; + } } } + return GRAPH_SUCCESS; } @@ -327,8 +331,8 @@ graphStatus Impl::CheckOptions(const std::map &options if (it == ge::ir_option::ir_builder_suppported_options.end()) { auto it_lx_fusion = ir_builder_supported_options_for_lx_fusion.find(ele.first); if (it_lx_fusion == ir_builder_supported_options_for_lx_fusion.end()) { - GELOGE(GRAPH_PARAM_INVALID, "input options include unsupported option(%s).Please check!", - ele.first.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Check][Options] unsupported option(%s), Please check!", + ele.first.c_str()); return GRAPH_PARAM_INVALID; } } @@ -339,7 +343,7 @@ graphStatus Impl::CheckOptions(const std::map &options auto it = options_.find(BUILD_MODE); if (it != options_.end() && !(it->second.empty())) { if (build_mode_options.find(it->second) == build_mode_options.end()) { - GELOGE(GRAPH_PARAM_INVALID, "Build mode:%s is unsupported. Please check!", it->second.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Check][BuildMode]:%s is unsupported. Please check!", it->second.c_str()); return GRAPH_PARAM_INVALID; } build_mode = it->second; @@ -347,12 +351,12 @@ graphStatus Impl::CheckOptions(const std::map &options it = options_.find(BUILD_STEP); if (it != options_.end() && !(it->second.empty())) { if (build_step_options.find(it->second) == build_step_options.end()) { - GELOGE(GRAPH_PARAM_INVALID, "Build step:%s is unsupported. Please check!", it->second.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Check][BuildStep]:%s is unsupported. Please check!", it->second.c_str()); return GRAPH_PARAM_INVALID; } } else { if (build_mode == BUILD_MODE_TUNING) { - GELOGE(GRAPH_PARAM_INVALID, "Build mode tuning must specify build step. Please check!"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][BuildMode] tuning must specify build step. Please check!"); return GRAPH_PARAM_INVALID; } } @@ -372,7 +376,7 @@ graphStatus Impl::Init(const Graph &graph, const std::map(string(IR_OPTION_MODE), to_string(0))); @@ -442,7 +448,7 @@ graphStatus Impl::Init(const Graph &graph, const std::mapsecond; } else { - GELOGE(GRAPH_PARAM_INVALID, "Input format %s not support , expect ND/NCHW/NHWC/CHWN/NC1HWC0/NHWC1C0.", + GELOGE(GRAPH_PARAM_INVALID, "[Check][Param:InputForamt] %s not support , expect ND/NCHW/NHWC/CHWN/NC1HWC0/NHWC1C0.", input_format.c_str()); return GRAPH_PARAM_INVALID; } @@ -558,7 +564,7 @@ graphStatus Impl::InitDomiOmgContext(const string &input_shape, const string &in } if (!ParseInputShape(input_shape, omg_context_.input_dims, omg_context_.user_input_dims, is_dynamic_input)) { - GELOGE(GRAPH_PARAM_INVALID, "Failed to parse input shape: %s", input_shape.c_str()); + GELOGE(GRAPH_PARAM_INVALID, "[Parse][InputShape:ImputShape] Failed, shape: %s", input_shape.c_str()); return GRAPH_PARAM_INVALID; } return GRAPH_SUCCESS; @@ -579,7 +585,7 @@ graphStatus aclgrphBuildModel(const ge::Graph &graph, const std::map tmp_build_options; for (auto &option : build_options) { if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { - GELOGE(GRAPH_FAILED, "AclgrphBuildInitialize option is nullptr."); + GELOGE(GRAPH_FAILED, "[Check][Options]AclgrphBuildInitialize option is nullptr."); return GRAPH_FAILED; } std::string key = option.first.GetString(); @@ -595,7 +601,7 @@ graphStatus aclgrphSaveModel(const string &output_file, const ModelBufferData &m ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGD("Enter aclmdlSaveModel process!"); if (model.data.get() == nullptr || model.length == 0) { - GELOGE(GRAPH_PARAM_INVALID, "input model is illegal"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][ModelBufferData] model is illegal"); return GRAPH_PARAM_INVALID; } return FileSaver::SaveToFile((output_file + ".om"), reinterpret_cast(model.data.get()), @@ -606,11 +612,11 @@ graphStatus aclgrphSaveModel(const char *output_file, const ModelBufferData &mod ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); GELOGD("Enter aclmdlSaveModel process!"); if (model.data.get() == nullptr || model.length == 0) { - GELOGE(GRAPH_PARAM_INVALID, "Input model is illegal"); + GELOGE(GRAPH_PARAM_INVALID, "[Check][ModelBufferData]model is illegal"); return GRAPH_PARAM_INVALID; } if (output_file == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Output file is nullptr."); + GELOGE(GRAPH_PARAM_INVALID, "[Check][OutputFile]file is nullptr."); return GRAPH_PARAM_INVALID; } std::string str_output_file = output_file; @@ -635,7 +641,7 @@ graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const siz GE_CHECK_NOTNULL(file); if (len > PATH_MAX || len != strlen(file) || strlen(file) == 0) { - GELOGE(GRAPH_PARAM_INVALID, "File path invalid."); + GELOGE(GRAPH_PARAM_INVALID, "[Check][FilePath]file invalid."); return GRAPH_PARAM_INVALID; } @@ -669,7 +675,7 @@ graphStatus aclgrphDumpGraph(const ge::Graph &graph, const char *file, const siz char path[PATH_MAX] = {0}; if (realpath(file_path.c_str(), path) == nullptr) { - GELOGE(GRAPH_PARAM_INVALID, "Dump file path:%s is invalid.", file); + GELOGE(GRAPH_PARAM_INVALID, "[Check][DumpFile] path:%s is invalid.", file); return GRAPH_PARAM_INVALID; } @@ -704,7 +710,7 @@ graphStatus aclgrphGenerateForOp(const AscendString &op_type, const vectorAddInputDesc(tensor_desc) != ge::GRAPH_SUCCESS) { - GELOGE(ge::FAILED, "AddInputDesc fail."); + GELOGE(ge::FAILED, "[Add][InputDesc] fail."); return ge::FAILED; } input_tensors.emplace_back(tensor_desc); @@ -728,7 +734,7 @@ graphStatus aclgrphGenerateForOp(const AscendString &op_type, const vector &options, std::string output } else { std::map atc_params; atc_params.insert(std::pair("input_shape", FLAGS_input_shape)); + atc_params.insert(std::pair(ge::INPUT_SHAPE_RANGE, FLAGS_input_shape_range)); atc_params.insert(std::pair("out_nodes", FLAGS_out_nodes)); atc_params.insert(std::pair("input_format", FLAGS_input_format)); atc_params.insert(std::pair("check_report", FLAGS_check_report)); diff --git a/ge/omm/csa_interact.cc b/ge/omm/csa_interact.cc index 1b33ddbd..fbcc96be 100644 --- a/ge/omm/csa_interact.cc +++ b/ge/omm/csa_interact.cc @@ -78,7 +78,8 @@ void CsaInteract::Init(int32_t dev_index, int64_t job_id) { Status CsaInteract::WriteJobState(JobState job_state, JobSubState job_sub_state, uint32_t module_ret_errcode, ErrorModule error_module) { if (!is_init_) { - GELOGE(INTERNAL_ERROR, "CsaInteract has not init, can't WriteJobState"); + GELOGE(INTERNAL_ERROR, "[Init][CsaInteract] obj has not init, can't WriteJobState"); + REPORT_INNER_ERROR("E19999", "WriteJobState failed before init. "); return INTERNAL_ERROR; } if ((curr_state_ == JOBSTATE_FAILED) || (curr_state_ == JOBSTATE_KILLED)) { @@ -107,7 +108,10 @@ Status CsaInteract::WriteJobState(JobState job_state, JobSubState job_sub_state, content = content_json.dump(); } catch (const nlohmann::json::exception &e) { - GELOGE(INTERNAL_ERROR, "build jobstate content json string failed, exception:%s job_state:%u", e.what(), job_state); + GELOGE(INTERNAL_ERROR, "[Create][JsonObject] exception:%s job_state:%u job_sub_state:%u.", + e.what(), job_state,job_sub_state); + REPORT_INNER_ERROR("E19999", "Create json object failed. exception:%s job_state:%u job_sub_state:%u.", + e.what(), job_state,job_sub_state); return INTERNAL_ERROR; } @@ -168,7 +172,8 @@ void CsaInteract::WriteInternalErrorCode() { /// Status CsaInteract::WriteHcomDetection(const std::string &content) { if (!is_init_) { - GELOGE(INTERNAL_ERROR, "CsaInteract has not init, can't WriteJobState"); + GELOGE(INTERNAL_ERROR, "[Init][CsaInteract] obj has not init, can't WriteJobState"); + REPORT_INNER_ERROR("E19999", "WriteHcomDetection failed before init."); return INTERNAL_ERROR; } @@ -192,28 +197,33 @@ Status CsaInteract::WriteFile(const std::string &file_name, const std::string &c int32_t fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD); if (fd == EN_ERROR) { if (MakePath(file_name) != SUCCESS) { - GELOGE(INTERNAL_ERROR, "csainteract create file path fail, errno is %d", errno); + GELOGE(INTERNAL_ERROR, "[Create][File Path] errno is %d", errno); + REPORT_CALL_ERROR("E19999", "MakePath failed. errno is %d", errno); return INTERNAL_ERROR; } fd = mmOpen2(file_name.c_str(), flags, M_IRUSR | M_IWUSR | M_UMASK_GRPREAD); if (fd == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "open file fail, errno is %d", errno); + GELOGE(INTERNAL_ERROR, "[Open][File] errno is %d file_name: %s", errno, file_name.c_str()); + REPORT_CALL_ERROR("E19999", "mmOpen2 failed. errno is %d file_name: %s", errno, file_name.c_str()); return INTERNAL_ERROR; } } mmSsize_t ret = mmWrite(fd, reinterpret_cast(const_cast(content.c_str())), content.length()); if (ret == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "write file fail, errno is %d", errno); + GELOGE(INTERNAL_ERROR, "[Write][File] errno is %d", errno); + REPORT_CALL_ERROR("E19999", "mmWrite failed. errno is %d", errno); ret = mmClose(fd); if (ret == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "close file fail, error is %d", errno); + GELOGE(INTERNAL_ERROR, "[Close][File] error is %d", errno); + REPORT_CALL_ERROR("E19999", "mmClose failed. error is %d", errno); } return INTERNAL_ERROR; } ret = mmClose(fd); if (ret == EN_ERROR) { - GELOGE(INTERNAL_ERROR, "close file fail, error is %d", errno); + GELOGE(INTERNAL_ERROR, "[Close][File] error is %d", errno); + REPORT_CALL_ERROR("E19999", "mmClose failed. error is %d", errno); return INTERNAL_ERROR; } @@ -242,7 +252,8 @@ Status CsaInteract::MakePath(const std::string &file_name) { std::string pre_path = file_path.substr(0, found + 1); if (mmAccess(pre_path.c_str()) != EN_OK) { if (mmMkdir(pre_path.c_str(), M_IRWXU) != EN_OK) { - GELOGE(INTERNAL_ERROR, "csainteract mkdir fail, errno is %d", errno); + GELOGE(INTERNAL_ERROR, "[Create][FileDir] fail, errno is %d, pre_path:%s", errno, pre_path.c_str()); + REPORT_CALL_ERROR("E19999", "mmMkdir failed. errno is %d pre_path:%s", errno, pre_path.c_str()); return INTERNAL_ERROR; } } diff --git a/ge/opskernel_manager/ops_kernel_builder_manager.cc b/ge/opskernel_manager/ops_kernel_builder_manager.cc index 37bdcf7a..0a24d6a9 100644 --- a/ge/opskernel_manager/ops_kernel_builder_manager.cc +++ b/ge/opskernel_manager/ops_kernel_builder_manager.cc @@ -50,7 +50,8 @@ Status OpsKernelBuilderManager::Initialize(const map & GE_CHK_STATUS_RET_NOLOG(GetLibPaths(options, lib_paths)); plugin_manager_.reset(new (std::nothrow)PluginManager()); GE_CHECK_NOTNULL(plugin_manager_); - GE_CHK_STATUS_RET(plugin_manager_->LoadSo(lib_paths), "Failed to load libs"); + GE_CHK_STATUS_RET(plugin_manager_->LoadSo(lib_paths), + "[Load][Libs]Failed, lib_paths=%s.", lib_paths.c_str()); } auto &kernel_builders = OpsKernelBuilderRegistry::GetInstance().GetAll(); @@ -61,8 +62,7 @@ Status OpsKernelBuilderManager::Initialize(const map & GELOGI("Initialize ops kernel util for %s", kernel_lib_name.c_str()); GE_CHECK_NOTNULL(it.second); GE_CHK_STATUS_RET(it.second->Initialize(options), - "Failed to invoke Initialize, kernel lib name = %s", - kernel_lib_name.c_str()); + "[Invoke][Initialize]failed, kernel lib name = %s", kernel_lib_name.c_str()); ops_kernel_builders_.emplace(kernel_lib_name, it.second); } @@ -100,7 +100,8 @@ OpsKernelBuilderPtr OpsKernelBuilderManager::GetOpsKernelBuilder(const string &n return nullptr; } -Status OpsKernelBuilderManager::GetLibPaths(const std::map &options, std::string &lib_paths) { +Status OpsKernelBuilderManager::GetLibPaths(const std::map &options, std::string &lib_paths) { GELOGD("Start to execute GetLibPaths"); std::string path_base = PluginManager::GetPath(); std::string so_path = "plugin/opskernel/"; @@ -128,18 +129,17 @@ Status OpsKernelBuilderManager::CalcOpRunningParam(Node &node) const { const std::string &lib_name = op_desc->GetOpKernelLibName(); auto it = ops_kernel_builders_.find(lib_name); if (it == ops_kernel_builders_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + GELOGE(INTERNAL_ERROR,"[Find][LibName] fail for libName = %s, node = %s.", + lib_name.c_str(), op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", + "find LibName for CalcOpRunningParam failed, libName = %s, node = %s not exist.", + lib_name.c_str(), op_desc->GetName().c_str()); return INTERNAL_ERROR; } GELOGD("To invoke CalcOpRunningParam, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); GE_CHK_STATUS_RET(it->second->CalcOpRunningParam(node), - "Failed to invoke CalcOpRunningParam, libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + "[Invoke][CalcOpRunningParam]failed, libName = %s, node = %s", lib_name.c_str(), op_desc->GetName().c_str()); GELOGD("Done invoking CalcOpRunningParam successfully"); return SUCCESS; } @@ -152,20 +152,16 @@ Status OpsKernelBuilderManager::GenerateTask(const Node &node, const std::string &lib_name = op_desc->GetOpKernelLibName(); auto it = ops_kernel_builders_.find(lib_name); if (it == ops_kernel_builders_.end()) { - GELOGE(INTERNAL_ERROR, - "Failed to get OpKernelStore. libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + GELOGE(INTERNAL_ERROR, "[Find][LibName]fail for libName = %s, node:%s", lib_name.c_str(), op_desc->GetName().c_str()); + REPORT_INNER_ERROR("E19999", "find LibName for GenerateTask failed, libName = %s, node = %s not exist", + lib_name.c_str(), op_desc->GetName().c_str()); return INTERNAL_ERROR; } GELOGD("To invoke GenerateTask, node = %s, lib name = %s", op_desc->GetName().c_str(), lib_name.c_str()); GE_CHK_STATUS_RET(it->second->GenerateTask(node, context, tasks), - "Failed to invoke GenerateTask, libName = %s, node = %s", - lib_name.c_str(), - op_desc->GetName().c_str()); + "[Invoke][GenerateTask]failed, libName = %s, node = %s", lib_name.c_str(), op_desc->GetName().c_str()); GELOGD("Done invoking GenerateTask successfully"); return SUCCESS; } - -} // namespace ge +} // namespace ge \ No newline at end of file diff --git a/ge/opskernel_manager/ops_kernel_manager.cc b/ge/opskernel_manager/ops_kernel_manager.cc index 30f39c0d..ae71fc92 100644 --- a/ge/opskernel_manager/ops_kernel_manager.cc +++ b/ge/opskernel_manager/ops_kernel_manager.cc @@ -56,7 +56,8 @@ Status OpsKernelManager::Initialize(const map &options_const) { std::map options(options_const); Status ret = InitPluginOptions(options); if (ret != SUCCESS) { - GELOGE(ret, "[OpsKernelManager] [Initialize] parse pluginFlag from ge options failed."); + GELOGE(ret, "[Init][PluginOptions] parse pluginFlag from ge options failed."); + REPORT_CALL_ERROR("E19999", "InitPluginOptions failed."); return ret; } @@ -85,7 +86,8 @@ Status OpsKernelManager::Initialize(const map &options_const) { initialize_ = options; Status rst0 = plugin_manager_.InvokeAll &, Status>(kInitialize, initialize_); if (rst0 == FAILED) { - GELOGE(GE_OPS_GET_NO_VALID_SO, "There is invalid so about OpsKernelInfoStore."); + GELOGE(GE_OPS_GET_NO_VALID_SO, "[Invoke][OpsKernelInfo]PluginManager InvokeAll failed."); + REPORT_INNER_ERROR("E19999", "PluginManager InvokeAll failed.") return GE_OPS_GET_NO_VALID_SO; } Status rst1 = @@ -114,18 +116,21 @@ Status OpsKernelManager::Initialize(const map &options_const) { } ret = InitGraphOptimizerPriority(); if ((ret != SUCCESS)) { - GELOGE(ret, "Init graph optimizer priority failed."); + GELOGE(ret, "[Init][GraphOptimizerPriority] failed."); + REPORT_CALL_ERROR("E19999", "InitGraphOptimizerPriority failed."); return ret; } init_flag_ = true; return SUCCESS; } else { - GELOGE(ret, "Failed to find any valid so file."); + GELOGE(ret, "[Check][SoFile] not find any valid so file."); + REPORT_INNER_ERROR("E19999", "OpsKernelManager::Initialize failed for not find any valid so file."); return ret; } } -void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, const std::map& options) { +void OpsKernelManager::GetExternalEnginePath(std::string &extern_engine_path, + const std::map& options) { GELOGI("Enter get external engine so path schedule"); const char *path_env = std::getenv("ASCEND_ENGINE_PATH"); if (path_env != nullptr) { @@ -175,21 +180,35 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, } else if (flag == 1) { enable_flag = true; } else { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", - plugin_name.c_str(), iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, + "[Parse][PluginOptions]option_key:%s, its value %s is invalid, it must be 0 or 1.", + plugin_name.c_str(), iter->second.c_str()); + REPORT_INNER_ERROR("E19999", "ParsePluginOptions failed, option_key:%s, " + "its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } catch (std::invalid_argument &) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", - iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, + "[Parse][PluginOptions] failed, option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", + iter->second.c_str()); + REPORT_INNER_ERROR("E19999", + "ParsePluginOptions failed, option_key:ge.feFlag, its value %s is invalid_argument, it must be 0 or 1.", + iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } catch (std::out_of_range &) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", - iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, + "[Parse][PluginOptions]failed, option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", + iter->second.c_str()); + REPORT_INNER_ERROR("E19999", + "ParsePluginOptions failed, option_key:ge.feFlag, its value %s is out of range, it must be 0 or 1.", + iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } catch (...) { - GELOGE(GE_GRAPH_OPTIONS_INVALID, "option_key:%s, its value %s is invalid, it must be 0 or 1.", - plugin_name.c_str(), iter->second.c_str()); + GELOGE(GE_GRAPH_OPTIONS_INVALID, + "[Parse][PluginOptions]option_key:%s, its value %s is invalid, it must be 0 or 1.", + plugin_name.c_str(), iter->second.c_str()); + REPORT_INNER_ERROR("E19999", "ParsePluginOptions failed, option_key:%s, " + "its value %s is invalid, it must be 0 or 1.", plugin_name.c_str(), iter->second.c_str()); return GE_GRAPH_OPTIONS_INVALID; } } else { @@ -203,13 +222,15 @@ Status OpsKernelManager::ParsePluginOptions(const map &options, Status OpsKernelManager::CheckPluginPtr() const { for (auto iter = ops_kernel_store_.begin(); iter != ops_kernel_store_.end(); ++iter) { if (iter->second == nullptr) { - GELOGE(INTERNAL_ERROR, "CheckPluginPtr OpsKernelInfoStorePtr is null"); + GELOGE(INTERNAL_ERROR, "[Check][PluginPtr] OpsKernelInfoStorePtr key=%s is null", iter->first.c_str()); + REPORT_INNER_ERROR("E19999", "CheckPluginPtr OpsKernelInfoStorePtr key=%s is null", iter->first.c_str()); return FAILED; } } for (auto iter1 = graph_optimizers_.begin(); iter1 != graph_optimizers_.end(); ++iter1) { if (iter1->second == nullptr) { - GELOGE(INTERNAL_ERROR, "CheckPluginPtr GraphOptimizerPtr is null"); + GELOGE(INTERNAL_ERROR, "[Check][PluginPtr] GraphOptimizerPtr key=%s is null", iter1->first.c_str()); + REPORT_INNER_ERROR("E19999", "GraphOptimizerPtr key=%s is null", iter1->first.c_str()); return FAILED; } } @@ -222,7 +243,9 @@ Status OpsKernelManager::InitOpKernelInfoStores(const map &optio GELOGI("OpKernelInfoStore name: %s.", (it.first).c_str()); Status ret = it.second->Initialize(options); if (ret != SUCCESS) { - GELOGE(GE_OPS_KERNEL_STORE_INIT_FAILED, "OpKernelInfoStore: %s initialize failed.", (it.first).c_str()); + GELOGE(GE_OPS_KERNEL_STORE_INIT_FAILED, + "[Init][OpKernelLib]OpKernelInfoStore: %s initialize failed.", (it.first).c_str()); + REPORT_CALL_ERROR("E19999", "OpKernelInfoStore: %s initialize failed.", (it.first).c_str()); return GE_OPS_KERNEL_STORE_INIT_FAILED; } } @@ -247,7 +270,8 @@ void OpsKernelManager::InitOpsKernelInfo() { } std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "InitOpsKernelInfo failed."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib]malloc instance_ptr failed."); + REPORT_INNER_ERROR("E19999", "InitOpsKernelInfo failed for new GELib."); return; } // sort opinfo of ops_kernel_info_ @@ -291,7 +315,8 @@ Status OpsKernelManager::InitGraphOptimzers(const map &options) GE_CHK_STATUS_RET(it.second->GetAttributes(attrs)) std::shared_ptr instance_ptr = ge::GELib::GetInstance(); if (instance_ptr == nullptr) { - GELOGE(GE_CLI_GE_NOT_INITIALIZED, "InitGraphOptimzers failed."); + GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[Get][GELib]malloc instance_ptr failed."); + REPORT_INNER_ERROR("E19999", "InitGraphOptimzers failed for new GELib."); return GE_CLI_GE_NOT_INITIALIZED; } if (!instance_ptr->DNNEngineManagerObj().IsEngineRegistered(attrs.engineName)) { @@ -300,7 +325,9 @@ Status OpsKernelManager::InitGraphOptimzers(const map &options) } Status ret = it.second->Initialize(options); if (ret != SUCCESS) { - GELOGE(GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED, "GraphOptimzer: %s initialize failed.", (it.first).c_str()); + GELOGE(GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED, + "[Init][GraphOptimzer]GraphOptimzer: %s initialize failed.", (it.first).c_str()); + REPORT_CALL_ERROR("E19999", "InitGraphOptimzers failed. %s initialize failed.", (it.first).c_str()); return GE_OPS_GRAPH_OPTIMIZER_INIT_FAILED; } } @@ -317,7 +344,8 @@ Status OpsKernelManager::Finalize() { GELOGI("OpsKernelStore finalize, name: %s.", (iter->first).c_str()); Status status = iter->second->Finalize(); if (SUCCESS != status) { - GELOGE(status, "OpsKernelStore finalize failed, name: %s.", (iter->first).c_str()); + GELOGE(status, "[Check][Status]OpsKernelStore finalize failed, name: %s.", (iter->first).c_str()); + REPORT_CALL_ERROR("E19999", "OpsKernelStore finalize failed, name: %s.", (iter->first).c_str()); return status; } } @@ -325,14 +353,16 @@ Status OpsKernelManager::Finalize() { GELOGI("GraphOptimzers finalize, name: %s.", (iter->first).c_str()); Status status = iter->second->Finalize(); if (status != SUCCESS) { - GELOGE(status, "GraphOptimzers finalize failed, name: %s.", (iter->first).c_str()); + GELOGE(status, "[Check][Status]GraphOptimzers finalize failed, name: %s.", (iter->first).c_str()); + REPORT_CALL_ERROR("E19999", "GraphOptimzers finalize failed, name: %s.", (iter->first).c_str()); return status; } } Status ret = FinalizeOpsKernel(); if (ret != SUCCESS) { - GELOGE(ret, "free ops kernel resource failed."); + GELOGE(ret, "[Free][Ops Kernel Resource] failed."); + REPORT_CALL_ERROR("E19999", "FinalizeOpsKernel failed, Free Ops kernel resource failed."); return ret; } @@ -443,7 +473,8 @@ Status OpsKernelManager::FinalizeOpsKernel() { GELOGI("ge invoke ops kernal finalize."); Status ret = plugin_manager_.InvokeAll(kFinalize); if (ret != SUCCESS) { - GELOGE(ret, "[Finalize] invoke Fe finalize failed."); + GELOGE(ret, "[Finalize][Check][Status] invoke Fe finalize failed."); + REPORT_INNER_ERROR("E19999", "PluginManager InvokeAll failed."); return ret; } diff --git a/ge/plugin/engine/CMakeLists.txt b/ge/plugin/engine/CMakeLists.txt index e5736b51..3aace4ac 100644 --- a/ge/plugin/engine/CMakeLists.txt +++ b/ge/plugin/engine/CMakeLists.txt @@ -41,6 +41,7 @@ target_link_options(engine PRIVATE target_link_libraries(engine PRIVATE $ -Wl,--no-as-needed + c_sec slog -Wl,--as-needed -lrt diff --git a/ge/plugin/engine/engine_manage.cc b/ge/plugin/engine/engine_manage.cc index a14c92ea..9615672f 100644 --- a/ge/plugin/engine/engine_manage.cc +++ b/ge/plugin/engine/engine_manage.cc @@ -21,6 +21,7 @@ #include #include "common/ge/ge_util.h" +#include "securec.h" #include "framework/common/debug/ge_log.h" #include "plugin/engine/dnnengines.h" @@ -29,7 +30,8 @@ std::unique_ptr> EngineManager::engine_map_; Status EngineManager::RegisterEngine(const std::string &engine_name, DNNEnginePtr engine_ptr) { if (engine_ptr == nullptr) { - GELOGE(FAILED, "enginePtr is nullptr"); + GELOGE(FAILED, "[Register][Engine] failed, as input engine_ptr is nullptr"); + REPORT_INNER_ERROR("E19999", "RegisterEngine failed for input engine_ptr is nullptr."); return FAILED; } @@ -64,7 +66,8 @@ void RegisterAiCoreEngine() { DNNEngineAttribute attr_aicore = {ai_core, mem_type_aicore, COST_0, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr aicore_engine_ptr = MakeShared(attr_aicore); if (aicore_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make aiCoreEnginePtr failed"); + GELOGE(ge::FAILED, "[Register][AiCoreEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCoreEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(ai_core, aicore_engine_ptr) != SUCCESS) { @@ -80,7 +83,8 @@ void RegisterVectorEngine() { DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vectorcore_engine_ptr = MakeShared(attr_vector_core); if (vectorcore_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vectorCoreEnginePtr failed"); + GELOGE(ge::FAILED, "[Register][VectorEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterVectorEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vector_core, vectorcore_engine_ptr) != SUCCESS) { @@ -95,7 +99,8 @@ void RegisterAiCpuEngine() { DNNEngineAttribute attr_aicpu = {vm_aicpu, mem_type_aicpu, COST_3, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu); if (vm_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vm_engine_ptr failed"); + GELOGE(ge::FAILED, "[Register][AiCpuEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterAiCpuEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_aicpu, vm_engine_ptr) != SUCCESS) { @@ -110,7 +115,8 @@ void RegisterAiCpuTFEngine() { DNNEngineAttribute attr_aicpu_tf = {vm_aicpu_tf, mem_type_aicpu_tf, COST_2, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr vm_engine_ptr = MakeShared(attr_aicpu_tf); if (vm_engine_ptr == nullptr) { - GELOGE(ge::FAILED, "make vm_engine_ptr failed"); + GELOGE(ge::FAILED, "[Register][AiCpuTFEngine]make vm_engine_ptr failed"); + REPORT_INNER_ERROR("E19999", "RegisterAiCpuTFEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_aicpu_tf, vm_engine_ptr) != SUCCESS) { @@ -126,7 +132,8 @@ void RegisterGeLocalEngine() { DNNEngineAttribute attr_ge_local = {vm_ge_local, mem_type_ge_local, COST_9, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr ge_local_engine = MakeShared(attr_ge_local); if (ge_local_engine == nullptr) { - GELOGE(ge::FAILED, "make ge_local_engine failed"); + GELOGE(ge::FAILED, "[Register][GeLocalEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterGeLocalEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_ge_local, ge_local_engine) != SUCCESS) { @@ -139,10 +146,12 @@ void RegisterHostCpuEngine() { std::vector mem_type_host_cpu; mem_type_host_cpu.emplace_back(GE_ENGINE_ATTR_MEM_TYPE_HBM); // HostCpu use minimum priority, set it as 10 - DNNEngineAttribute attr_host_cpu = {vm_host_cpu, mem_type_host_cpu, COST_10, HOST, FORMAT_RESERVED, FORMAT_RESERVED}; + DNNEngineAttribute attr_host_cpu = {vm_host_cpu, mem_type_host_cpu, COST_10, + HOST, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr host_cpu_engine = MakeShared(attr_host_cpu); if (host_cpu_engine == nullptr) { - GELOGE(ge::FAILED, "make host_cpu_engine failed"); + GELOGE(ge::FAILED, "[Register][HostCpuEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterHostCpuEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_host_cpu, host_cpu_engine) != SUCCESS) { @@ -157,7 +166,8 @@ void RegisterRtsEngine() { DNNEngineAttribute attr_rts = {vm_rts, mem_type_rts, COST_1, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr rts_engine = MakeShared(attr_rts); if (rts_engine == nullptr) { - GELOGE(ge::FAILED, "make rts_engine failed"); + GELOGE(ge::FAILED, "[Register][RtsEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterRtsEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(vm_rts, rts_engine) != SUCCESS) { @@ -172,7 +182,8 @@ void RegisterHcclEngine() { DNNEngineAttribute attr_hccl = {dnn_hccl, mem_type_hccl, COST_1, DEVICE, FORMAT_RESERVED, FORMAT_RESERVED}; DNNEnginePtr hccl_engine = MakeShared(attr_hccl); if (hccl_engine == nullptr) { - GELOGE(ge::FAILED, "make hccl_engine failed"); + GELOGE(ge::FAILED, "[Register][HcclEngine] failed, as malloc shared_ptr failed."); + REPORT_INNER_ERROR("E19999", "RegisterHcclEngine failed for new DNNEnginePtr failed."); return; } if (EngineManager::RegisterEngine(dnn_hccl, hccl_engine) != SUCCESS) { diff --git a/ge/session/omg.cc b/ge/session/omg.cc index bd1fd67c..961bc8c7 100755 --- a/ge/session/omg.cc +++ b/ge/session/omg.cc @@ -99,8 +99,9 @@ static void ParseAtcParms(const std::map &atc_params, } } -static Status CheckInputShapeNode(const ComputeGraphPtr &graph, const bool is_dynamic_input, RunMode run_mode) { - if (!is_dynamic_input && run_mode != MODEL_TO_JSON) { +static Status CheckInputShapeNode(const ComputeGraphPtr &graph, bool is_dynamic_input, + const std::string &input_shape_range, RunMode run_mode) { + if (!is_dynamic_input && run_mode != MODEL_TO_JSON && input_shape_range.empty()) { for (auto node : graph->GetDirectNode()) { if (node->GetType() == DATA) { auto data_op_desc = node->GetOpDesc(); @@ -576,6 +577,7 @@ Status InitDomiOmgContext(const string &input_shape, const string &input_format, GELOGE(PARAM_INVALID, "Failed to parse input shape: %s", input_shape.c_str()); return PARAM_INVALID; } + return SUCCESS; } @@ -759,8 +761,9 @@ FMK_FUNC_HOST_VISIBILITY Status ParseGraph(ge::Graph &graph, const std::mapGetGraph()); + GE_CHECK_NOTNULL(comp_graph); + for (const auto &node : comp_graph->GetAllNodes()) { + auto op_desc = node->GetOpDesc(); + GE_CHECK_NOTNULL(op_desc); + const auto &depends = op_desc->GetOpInferDepends(); + if (!depends.empty()) { + flag = true; + return SUCCESS; + } + } + return SUCCESS; +} + +Status NeedHybridModel(GeModelPtr &ge_model, bool &flag) { + bool infer_depend_flag = false; + GE_CHK_STATUS_RET(IfInferDepend(ge_model, infer_depend_flag), "[Check][InferDepend] failed."); auto tasks = ge_model->GetModelTaskDefPtr()->task(); int32_t kernel_task_num = 0; for (int i = 0; i < tasks.size(); ++i) { auto task_type = static_cast(tasks[i].type()); if (task_type == RT_MODEL_TASK_KERNEL || task_type == RT_MODEL_TASK_ALL_KERNEL) { - kernel_task_num++; - if (kernel_task_num > 1) { - return true; + const auto &context = task_type == RT_MODEL_TASK_KERNEL ? tasks[i].kernel().context() : + tasks[i].kernel_with_handle().context(); + auto kernel_type = static_cast(context.kernel_type()); + if (kernel_type == ccKernelType::TE) { + if (infer_depend_flag) { + flag = true; + return SUCCESS; + } + kernel_task_num++; + if (kernel_task_num > 1) { + flag = true; + return SUCCESS; + } } } } - return false; + return SUCCESS; } } // namespace @@ -503,7 +530,9 @@ Status SingleOpModel::BuildDynamicOp(StreamResource &resource, DynamicSingleOp & auto ge_model = model_helper_.GetGeModel(); GE_CHECK_NOTNULL(ge_model); - if (NeedHybridModel(ge_model)) { + bool need_hybrid_model = false; + GE_CHK_STATUS_RET(NeedHybridModel(ge_model, need_hybrid_model), "[Check][NeedHybridModel] failed."); + if (need_hybrid_model) { GELOGD("Build single op HybridModel."); GE_CHK_STATUS_RET_NOLOG(hybrid::NodeExecutorManager::GetInstance().EnsureInitialized()); auto root_model = model_helper_.GetGeRootModel(); diff --git a/ge/single_op/task/op_task.cc b/ge/single_op/task/op_task.cc index 80c16968..f754af28 100755 --- a/ge/single_op/task/op_task.cc +++ b/ge/single_op/task/op_task.cc @@ -491,21 +491,18 @@ Status AiCpuBaseTask::UpdateOutputShape(vector &output_desc) { } GELOGD("Start to update DEPEND_SHAPE_RANGE AiCpuBaseTask outputshape."); - GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_->GetExtInfo(), - aicpu_ext_handle_->GetExtInfoLen(), - ext_info_addr_dev_, - aicpu_ext_handle_->GetExtInfoLen(), - RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(aicpu_ext_handle_->GetExtInfo(), aicpu_ext_handle_->GetExtInfoLen(), ext_info_addr_dev_, + aicpu_ext_handle_->GetExtInfoLen(), RT_MEMCPY_DEVICE_TO_HOST)); for (size_t i = 0; i < num_outputs_; ++i) { GeShape shape; DataType data_type; aicpu_ext_handle_->GetOutputShapeAndType(i, shape, data_type); - GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, output_desc[i]), - "AiCpuCCTask Update [%zu]th output shape failed.", i); + GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(shape, output_desc[i]), "AiCpuCCTask Update [%zu]th output shape failed.", + i); if (DumpManager::GetInstance().GetDumpProperties(kInferSessionId).IsSingleOpNeedDump()) { - GE_CHK_STATUS_RET(op_desc_->UpdateOutputDesc(i, output_desc[i]), - "AiCpuCCTask Update [%zu]th output desc failed.", i); + GE_CHK_STATUS_RET(op_desc_->UpdateOutputDesc(i, output_desc[i]), "AiCpuCCTask Update [%zu]th output desc failed.", + i); } } GELOGD("Update DEPEND_SHAPE_RANGE AiCpuBaseTask outputshape finished."); @@ -697,10 +694,10 @@ Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc) { const auto &shape_hbm = out_shape_hbm_[i]; uint32_t dim_num = result_summary.shape_data_size / sizeof(int64_t); - std::unique_ptr shape_addr(new(std::nothrow) int64_t[dim_num]()); + std::unique_ptr shape_addr(new (std::nothrow) int64_t[dim_num]()); GE_CHECK_NOTNULL(shape_addr); - GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, - shape_hbm, result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); + GE_CHK_RT_RET(rtMemcpy(shape_addr.get(), result_summary.shape_data_size, shape_hbm, + result_summary.shape_data_size, RT_MEMCPY_DEVICE_TO_HOST)); for (uint32_t dim_idx = 0; dim_idx < dim_num; ++dim_idx) { shape_dims.emplace_back(shape_addr[dim_idx]); @@ -711,13 +708,14 @@ Status AiCpuTask::UpdateShapeByHbmBuffer(vector &output_desc) { GE_CHK_STATUS_RET(UpdateShapeToOutputDesc(GeShape(shape_dims), output_desc[i]), "AiCpuTask update [%zu]th output shape failed.", i); if (DumpManager::GetInstance().GetDumpProperties(kInferSessionId).IsSingleOpNeedDump()) { - GE_CHK_STATUS_RET(op_desc_->UpdateOutputDesc(i, output_desc[i]), - "AiCpuTask update [%zu]th output desc failed.", i); + GE_CHK_STATUS_RET(op_desc_->UpdateOutputDesc(i, output_desc[i]), "AiCpuTask update [%zu]th output desc failed.", + i); } } return SUCCESS; } + Status AiCpuTask::UpdateShapeAndDataByResultSummary(vector &output_desc, vector &outputs, rtStream_t stream) { diff --git a/inc/external/ge/ge_api_error_codes.h b/inc/external/ge/ge_api_error_codes.h index 274a9784..d0d7981e 100644 --- a/inc/external/ge/ge_api_error_codes.h +++ b/inc/external/ge/ge_api_error_codes.h @@ -110,9 +110,9 @@ GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_AIPP_MODE_INVALID, "AIPP mode invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_TASK_TYPE_INVALID, "Task type invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID, "Kernel type invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_PLGMGR_PATH_INVALID, "Plugin path is invalid."); -GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID, "Format is invalid when transferring shape."); -GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID, "Shape is invalid when transferring shape."); -GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID, "Datatype is invalid when transferring shape."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_FORMAT_INVALID, "Format is invalid."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_SHAPE_INVALID, "Shape is invalid."); +GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_DATATYPE_INVALID, "Datatype is invalid."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_ALLOCATION, "Memory allocation error."); GE_ERRORNO_EXTERNAL(ACL_ERROR_GE_MEMORY_OPERATE_FAILED, "Failed to operate memory."); diff --git a/inc/external/ge/ge_api_types.h b/inc/external/ge/ge_api_types.h index 834df591..e9166588 100644 --- a/inc/external/ge/ge_api_types.h +++ b/inc/external/ge/ge_api_types.h @@ -311,6 +311,9 @@ const std::string OP_BANK_UPDATE_FLAG = "ge.op_bank_update"; // 0: data multi; 1: model multi; const std::string HCOM_MULTI_MODE = "ge.hcomMultiMode"; +// atc and ir option +const char *const INPUT_SHAPE_RANGE = "input_shape_range"; + // Graph run mode enum GraphRunMode { PREDICTION = 0, TRAIN }; @@ -390,6 +393,7 @@ static const char *const OP_DEBUG_LEVEL = ge::OP_DEBUG_LEVEL.c_str(); #ifdef __GNUC__ const std::set ir_builder_suppported_options = {INPUT_FORMAT, INPUT_SHAPE, + INPUT_SHAPE_RANGE, OP_NAME_MAP, DYNAMIC_BATCH_SIZE, DYNAMIC_IMAGE_SIZE, diff --git a/inc/external/ge/ge_error_codes.h b/inc/external/ge/ge_error_codes.h index b477a18c..cafc5a64 100644 --- a/inc/external/ge/ge_error_codes.h +++ b/inc/external/ge/ge_error_codes.h @@ -53,9 +53,9 @@ static const uint32_t ACL_ERROR_GE_AIPP_MODE_INVALID = 145016; static const uint32_t ACL_ERROR_GE_OP_TASK_TYPE_INVALID = 145017; static const uint32_t ACL_ERROR_GE_OP_KERNEL_TYPE_INVALID = 145018; static const uint32_t ACL_ERROR_GE_PLGMGR_PATH_INVALID = 145019; -static const uint32_t ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID = 145020; -static const uint32_t ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID = 145021; -static const uint32_t ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID = 145022; +static const uint32_t ACL_ERROR_GE_FORMAT_INVALID = 145020; +static const uint32_t ACL_ERROR_GE_SHAPE_INVALID = 145021; +static const uint32_t ACL_ERROR_GE_DATATYPE_INVALID = 145022; static const uint32_t ACL_ERROR_GE_MEMORY_ALLOCATION = 245000; static const uint32_t ACL_ERROR_GE_MEMORY_OPERATE_FAILED = 245001; static const uint32_t ACL_ERROR_GE_INTERNAL_ERROR = 545000; diff --git a/inc/framework/common/debug/ge_log.h b/inc/framework/common/debug/ge_log.h index c1359a20..45db7e93 100644 --- a/inc/framework/common/debug/ge_log.h +++ b/inc/framework/common/debug/ge_log.h @@ -20,6 +20,7 @@ #include #include "framework/common/ge_inner_error_codes.h" +#include "common/util/error_manager/error_manager.h" #include "toolchain/slog.h" #ifdef __GNUC__ #include @@ -55,9 +56,10 @@ inline bool IsLogEnable(int module_name, int log_level) { return (enable == 1); } -#define GELOGE(ERROR_CODE, fmt, ...) \ - dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) " fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ - ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ##__VA_ARGS__) +#define GELOGE(ERROR_CODE, fmt, ...) \ + dlog_error(GE_MODULE_NAME, "%lu %s: ErrorNo: %d(%s) %s" fmt, GeLog::GetTid(), __FUNCTION__, ERROR_CODE, \ + ((GE_GET_ERRORNO_STR(ERROR_CODE)).c_str()), ErrorManager::GetInstance().GetLogHeader().c_str(), \ + ##__VA_ARGS__) #define GELOGW(fmt, ...) \ if (IsLogEnable(GE_MODULE_NAME, DLOG_WARN)) \ dlog_warn(GE_MODULE_NAME, "%lu %s:" fmt, GeLog::GetTid(), __FUNCTION__, ##__VA_ARGS__) diff --git a/inc/framework/common/debug/log.h b/inc/framework/common/debug/log.h index 58cb3693..43fb3224 100644 --- a/inc/framework/common/debug/log.h +++ b/inc/framework/common/debug/log.h @@ -255,10 +255,10 @@ exec_expr1; \ } -#define GE_ERRORLOG_AND_ERRORMSG(_status, errormsg) \ - { \ - GELOGE(_status, "%s", errormsg); \ - ErrorManager::GetInstance().ATCReportErrMessage("E19021", {"reason"}, {errormsg}); \ +#define GE_ERRORLOG_AND_ERRORMSG(_status, errormsg) \ + { \ + GELOGE(_status, "[Check][InnerData]%s", errormsg); \ + REPORT_INNER_ERROR("E19999", "%s", errormsg); \ } #define GE_WARNINGLOG_AND_ERRORMSG(errormsg) \ diff --git a/inc/framework/common/types.h b/inc/framework/common/types.h index 2dbb1753..91759b8f 100644 --- a/inc/framework/common/types.h +++ b/inc/framework/common/types.h @@ -130,6 +130,8 @@ REGISTER_OPTYPE_DECLARE(REFORMAT, "ReFormat"); REGISTER_OPTYPE_DECLARE(DEPCONVOLUTION, "ConvolutionDepthwise"); REGISTER_OPTYPE_DECLARE(DROPOUT, "Dropout"); REGISTER_OPTYPE_DECLARE(DROPOUTDOMASK, "DropOutDoMask"); +REGISTER_OPTYPE_DECLARE(DROPOUTDOMASKV3, "DropOutDoMaskV3"); +REGISTER_OPTYPE_DECLARE(DROPOUTDOMASKV3D, "DropOutDoMaskV3D"); REGISTER_OPTYPE_DECLARE(DROPOUTGENMASK, "DropOutGenMask"); REGISTER_OPTYPE_DECLARE(CONCAT, "Concat"); REGISTER_OPTYPE_DECLARE(ROIPOOLING, "ROIPooling"); diff --git a/inc/framework/common/util.h b/inc/framework/common/util.h index 525cf3ea..b73e7046 100644 --- a/inc/framework/common/util.h +++ b/inc/framework/common/util.h @@ -30,12 +30,12 @@ #include "framework/common/ge_inner_error_codes.h" #include "mmpa/mmpa_api.h" -#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ - do { \ - if (size <= 0) { \ - DOMI_LOGE("param[%s] is not a positive number", #size); \ - return PARAM_INVALID; \ - } \ +#define GE_CHECK_POSITIVE_SIZE_RANGE(size) \ + do { \ + if (size <= 0) { \ + DOMI_LOGE("param[%s] is not a positive number", #size); \ + return PARAM_INVALID; \ + } \ } while (0) #define CHECK_FALSE_EXEC(expr, exec_expr, ...) \ @@ -113,84 +113,75 @@ } while (0) // Check if the parameter is null. If yes, return PARAM_INVALID and record the error -#define GE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("[Check][Param:%s]null is invalid when %s.", #val, __FUNCTION__); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the parameter is null. If yes, just return and record the error -#define GE_CHECK_NOTNULL_JUST_RETURN(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return; \ - } \ +#define GE_CHECK_NOTNULL_JUST_RETURN(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return; \ + } \ } while (0) // Check whether the parameter is null. If so, execute the exec_expr expression and record the error log -#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - exec_expr; \ - } \ +#define GE_CHECK_NOTNULL_EXEC(val, exec_expr) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + exec_expr; \ + } \ } while (0) // Check whether the parameter is null. If yes, return directly and record the error log -#define GE_RT_VOID_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return; \ - } \ +#define GE_RT_VOID_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return; \ + } \ } while (0) // Check if the parameter is null. If yes, return false and record the error log -#define GE_RT_FALSE_CHECK_NOTNULL(val) \ - do { \ - if (val == nullptr) { \ - DOMI_LOGE("param[%s] must not be null.", #val); \ - return false; \ - } \ +#define GE_RT_FALSE_CHECK_NOTNULL(val) \ + do { \ + if (val == nullptr) { \ + DOMI_LOGE("param[%s] must not be null.", #val); \ + return false; \ + } \ } while (0) // Check if the parameter is out of bounds -#define GE_CHECK_SIZE(size) \ - do { \ - if (size == 0) { \ - DOMI_LOGE("param[%s] is out of range", #size); \ - return ge::PARAM_INVALID; \ - } \ - } while (0) - -// Check if the container is empty -#define GE_CHECK_VECTOR_NOT_EMPTY(vector) \ - do { \ - if (vector.empty()) { \ - DOMI_LOGE("param[%s] is empty!", #vector); \ - return ge::FAILED; \ - } \ +#define GE_CHECK_SIZE(size) \ + do { \ + if (size == 0) { \ + DOMI_LOGE("param[%s] is out of range", #size); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the value on the left is greater than or equal to the value on the right -#define GE_CHECK_GE(lhs, rhs) \ - do { \ - if (lhs < rhs) { \ - DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_GE(lhs, rhs) \ + do { \ + if (lhs < rhs) { \ + DOMI_LOGE("param[%s] is less than[%s]", #lhs, #rhs); \ + return ge::PARAM_INVALID; \ + } \ } while (0) // Check if the value on the left is less than or equal to the value on the right -#define GE_CHECK_LE(lhs, rhs) \ - do { \ - if (lhs > rhs) { \ - DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \ - return ge::PARAM_INVALID; \ - } \ +#define GE_CHECK_LE(lhs, rhs) \ + do { \ + if (lhs > rhs) { \ + DOMI_LOGE("param[%s] is greater than[%s]", #lhs, #rhs); \ + return ge::PARAM_INVALID; \ + } \ } while (0) #define GE_DELETE_NEW_SINGLE(var) \ @@ -209,6 +200,17 @@ } \ } while (0) +#define GE_FREE_RT_LOG(addr) \ + do { \ + if (addr != nullptr) { \ + rtError_t error = rtFree(addr); \ + if (error != RT_ERROR_NONE) { \ + GELOGE(RT_FAILED, "Call rtFree failed, error: %#x", error); \ + } \ + addr = nullptr; \ + } \ + } while (0) + /** * @ingroup domi_common * @brief version of om.proto file diff --git a/inc/framework/generator/ge_generator.h b/inc/framework/generator/ge_generator.h index 2d7d007b..4b8caa95 100644 --- a/inc/framework/generator/ge_generator.h +++ b/inc/framework/generator/ge_generator.h @@ -31,6 +31,7 @@ #include "omg/omg_inner_types.h" namespace ge { +class GeRootModel; class GE_FUNC_VISIBILITY GeGenerator { public: static GeGenerator &GetInstance() { @@ -97,8 +98,12 @@ class GE_FUNC_VISIBILITY GeGenerator { Status BuildSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs, const string &model_file_name, OpEngineType engine_type, ModelBufferData &model_buff, bool is_offline = true); + bool CheckNoAicore(const ComputeGraphPtr &graph); Status CheckForSingleOp(OpDescPtr &op_desc, const vector &inputs, const vector &outputs); + using GeRootModelPtr = std::shared_ptr; + Status SetModelNameForDump(const GeRootModelPtr &ge_root_model); + class Impl; std::shared_ptr impl_; diff --git a/metadef b/metadef index 7a51997c..ac0de021 160000 --- a/metadef +++ b/metadef @@ -1 +1 @@ -Subproject commit 7a51997cbd34e1869b9fb4ea5597a021e6427272 +Subproject commit ac0de0213755e49360a9467eb5b13e13a752a35b diff --git a/parser b/parser index 227b1035..eff7e2ec 160000 --- a/parser +++ b/parser @@ -1 +1 @@ -Subproject commit 227b10355427038785e95c81a41cda99893eba08 +Subproject commit eff7e2ecc54ef7887581acd6ea66356de6872e3a diff --git a/tests/depends/error_manager/src/error_manager_stub.cc b/tests/depends/error_manager/src/error_manager_stub.cc index 5d305d75..8fb82141 100644 --- a/tests/depends/error_manager/src/error_manager_stub.cc +++ b/tests/depends/error_manager/src/error_manager_stub.cc @@ -18,6 +18,8 @@ using namespace ErrorMessage; +thread_local Context ErrorManager::error_context_ = {0, "", "", ""}; + ErrorManager &ErrorManager::GetInstance() { static ErrorManager instance; return instance; @@ -40,6 +42,10 @@ using namespace ErrorMessage; return 0; } + int ErrorManager::ReportInterErrMessage(std::string error_code, const std::string &error_msg) { + return 0; + } + /// /// @brief output error message /// @param [in] handle: print handle @@ -84,7 +90,7 @@ using namespace ErrorMessage; void ErrorManager::GenWorkStreamIdBySessionGraph(uint64_t session_id, uint64_t graph_id) {} - const std::string &ErrorManager::GetLogHeader() { return "[TEST][TEST]"; } + const std::string &ErrorManager::GetLogHeader() { return error_context_.log_header; } struct Context &ErrorManager::GetErrorContext() { struct Context error_context; diff --git a/tests/depends/mmpa/src/mmpa_stub.cc b/tests/depends/mmpa/src/mmpa_stub.cc index 5b6dbd22..62499ca1 100644 --- a/tests/depends/mmpa/src/mmpa_stub.cc +++ b/tests/depends/mmpa/src/mmpa_stub.cc @@ -269,7 +269,7 @@ CHAR *mmDlerror() INT32 mmDladdr(VOID *addr, mmDlInfo *info) { - return 0; + return -1; } VOID *mmDlopen(const CHAR *fileName, INT32 mode) diff --git a/tests/depends/runtime/src/runtime_stub.cc b/tests/depends/runtime/src/runtime_stub.cc index e6a7d66b..440b98e7 100644 --- a/tests/depends/runtime/src/runtime_stub.cc +++ b/tests/depends/runtime/src/runtime_stub.cc @@ -431,3 +431,7 @@ rtError_t rtGetTaskIdAndStreamID(uint32_t *taskId, uint32_t *streamId) { return RT_ERROR_NONE; } + +rtError_t rtDebugRegisterForStream(rtStream_t stream, uint32_t flag, const void *addr, uint32_t *streamId, uint32_t *taskId) { + return RT_ERROR_NONE; +} diff --git a/tests/ut/common/graph/CMakeLists.txt b/tests/ut/common/graph/CMakeLists.txt index 1c64dce1..4aac5995 100644 --- a/tests/ut/common/graph/CMakeLists.txt +++ b/tests/ut/common/graph/CMakeLists.txt @@ -38,6 +38,7 @@ include_directories(${GE_CODE_DIR}/metadef/inc) include_directories(${GE_CODE_DIR}/metadef/inc/graph) include_directories(${GE_CODE_DIR}/metadef/inc/common) include_directories(${GE_CODE_DIR}/metadef/third_party) +include_directories(${GE_CODE_DIR}/metadef/third_party/transformer/inc) include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc) include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/ops) include_directories(${CMAKE_BINARY_DIR}) @@ -95,11 +96,12 @@ set(SRC_FILES "${GE_CODE_DIR}/metadef/graph/utils/tensor_utils.cc" "${GE_CODE_DIR}/metadef/ops/op_imp.cpp" "${GE_CODE_DIR}/metadef/graph/opsproto/opsproto_manager.cc" - "${GE_CODE_DIR}/metadef/graph/utils/transformer_utils.cc" "${GE_CODE_DIR}/metadef/graph/runtime_inference_context.cc" "${GE_CODE_DIR}/metadef/graph/ref_relation.cc" - "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cpp" - "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cpp" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cc" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cc" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/expand_dimension.cc" + "${GE_CODE_DIR}/metadef/graph/utils/transformer_utils.cc" ) #add_executable(ut_libgraph ${UT_FILES} ${SRC_FILES} ${PROTO_SRCS} ${PROTO_HDRS}) diff --git a/tests/ut/ge/CMakeLists.txt b/tests/ut/ge/CMakeLists.txt index e9121e95..a26c348c 100755 --- a/tests/ut/ge/CMakeLists.txt +++ b/tests/ut/ge/CMakeLists.txt @@ -45,6 +45,7 @@ include_directories(${GE_CODE_DIR}/inc) include_directories(${GE_CODE_DIR}/metadef/inc) include_directories(${GE_CODE_DIR}/ge) include_directories(${GE_CODE_DIR}/ge/inc) +include_directories(${GE_CODE_DIR}/ge/ir_build) include_directories(${GE_CODE_DIR}/metadef) include_directories(${GE_CODE_DIR}/metadef/graph) include_directories(${GE_CODE_DIR}/inc/external) @@ -54,6 +55,7 @@ include_directories(${GE_CODE_DIR}/metadef/inc/graph) include_directories(${GE_CODE_DIR}/inc/framework) include_directories(${GE_CODE_DIR}/metadef/inc/common) include_directories(${GE_CODE_DIR}/metadef/third_party) +include_directories(${GE_CODE_DIR}/metadef/third_party/transformer/inc) include_directories(${GE_CODE_DIR}/parser) include_directories(${GE_CODE_DIR}/parser/parser) include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc) @@ -61,6 +63,7 @@ include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/cce) include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/ops) include_directories(${GE_CODE_DIR}/third_party/fwkacllib/inc/toolchain) include_directories(${GE_CODE_DIR}/tests/ut/ge) +include_directories(${GE_CODE_DIR}/tests/ut/common) include_directories(${CMAKE_BINARY_DIR}) include_directories(${CMAKE_BINARY_DIR}/proto/ge) include_directories(${CMAKE_BINARY_DIR}/proto/ge/proto) @@ -85,8 +88,9 @@ set(GRAPH_SRC_FILES "${GE_CODE_DIR}/metadef/graph/node.cc" "${GE_CODE_DIR}/metadef/graph/runtime_inference_context.cc" "${GE_CODE_DIR}/metadef/graph/op_desc.cc" - "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cpp" - "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cpp" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/transfer_shape_according_to_format.cc" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/axis_util.cc" + "${GE_CODE_DIR}/metadef/third_party/transformer/src/expand_dimension.cc" "${GE_CODE_DIR}/metadef/graph/operator.cc" "${GE_CODE_DIR}/metadef/graph/operator_factory.cc" "${GE_CODE_DIR}/metadef/graph/operator_factory_impl.cc" @@ -162,6 +166,7 @@ set(COMMON_SRC_FILES "${GE_CODE_DIR}/ge/common/dump/dump_properties.cc" "${GE_CODE_DIR}/ge/common/helper/model_helper.cc" "${GE_CODE_DIR}/ge/common/dump/dump_manager.cc" + "${GE_CODE_DIR}/ge/common/dump/opdebug_register.cc" "${GE_CODE_DIR}/ge/common/helper/om_file_helper.cc" "${GE_CODE_DIR}/ge/model/ge_root_model.cc" "${GE_CODE_DIR}/ge/common/model_parser/model_parser.cc" @@ -269,6 +274,7 @@ set(COMMON_SRC_FILES "${GE_CODE_DIR}/ge/graph/passes/set_input_output_offset_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/remove_same_const_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/useless_control_out_remove_pass.cc" + "${GE_CODE_DIR}/ge/graph/passes/parallel_group_pass.cc" "${GE_CODE_DIR}/ge/model/ge_model.cc" "${GE_CODE_DIR}/ge/common/cust_aicpu_kernel_store.cc" "${GE_CODE_DIR}/ge/graph/load/model_manager/model_utils.cc" @@ -514,6 +520,7 @@ set(GRAPH_PASS_COMMON_SRC_FILES "${GE_CODE_DIR}/ge/graph/passes/compile_nodes_pass.cc" "${GE_CODE_DIR}/ge/graph/common/transop_util.cc" "${GE_CODE_DIR}/ge/graph/passes/flow_ctrl_pass.cc" + "${GE_CODE_DIR}/ge/graph/passes/parallel_group_pass.cc" #"${GE_CODE_DIR}/ge/graph/optimize/optimizer/allreduce_fusion_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/folding_pass.cc" "${GE_CODE_DIR}/ge/graph/passes/variable_op_pass.cc" @@ -690,6 +697,9 @@ set(PASS_TEST_FILES "graph/passes/infershape_pass_unittest.cc" "graph/passes/multi_batch_clone_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" + "graph/passes/parallel_group_pass_unittest.cc" ) set(KERNEL_TEST_FILES @@ -730,9 +740,11 @@ set(KERNEL_TEST_FILES set(MULTI_PARTS_TEST_FILES "graph_ir/ge_operator_factory_unittest.cc" + "graph_ir/ge_ir_build_unittest.cc" "graph/transop_util_unittest.cc" "common/datatype_transfer_unittest.cc" "common/dump_manager_unittest.cc" + "common/opdebug_register_unittest.cc" "common/format_transfer_unittest.cc" "common/format_transfer_transpose_unittest.cc" "common/format_transfer_nchw_5d_unittest.cc" @@ -757,6 +769,7 @@ set(MULTI_PARTS_TEST_FILES "graph/manager/hcom_util_unittest.cc" "graph/manager/run_graph_unittest.cc" "graph/manager/graph_caching_allocator_unittest.cc" + "graph/partition/dynamic_shape_partition_unittest.cc" "session/omg_omg_unittest.cc" "session/ge_api_unittest.cc" ) @@ -1030,7 +1043,8 @@ target_compile_definitions(ut_libge_multiparts_utest PRIVATE target_link_libraries(ut_libge_multiparts_utest $ - ge_build_common ge_load_common ge_execute_common ge_optimize_common ge_partition_common ge_prepare_common ge_single_op ge_ut_common gtest gtest_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl -lgcov + ge_build_common ge_load_common ge_execute_common ge_optimize_common ge_partition_common ge_prepare_common ge_single_op ge_ut_common + gtest gtest_main gmock gmock_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl -lgcov ) # libge_others_utest @@ -1049,7 +1063,8 @@ target_compile_options(ut_libge_others_utest PRIVATE target_link_libraries(ut_libge_others_utest $ - ge_load_common ge_execute_common ge_ut_common gtest gtest_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl -lgcov + ge_load_common ge_execute_common ge_ut_common + gtest gtest_main gmock gmock_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl -lgcov ) # libge_kernel_utest @@ -1067,7 +1082,8 @@ target_compile_options(ut_libge_kernel_utest PRIVATE target_link_libraries(ut_libge_kernel_utest $ - ge_load_common ge_ut_common gtest gtest_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl -lgcov + ge_load_common ge_ut_common + gtest gtest_main gmock gmock_main ascend_protobuf ${COMMON_SHARED_LIBRARIES} json -lrt -ldl -lgcov ) # libge_distinct_load_utest @@ -1092,10 +1108,10 @@ target_compile_definitions(ut_libge_distinct_load_utest PRIVATE ) target_link_libraries(ut_libge_distinct_load_utest - ${COMMON_SHARED_LIBRARIES} - $ - ge_execute_common ge_ut_common_format ge_load_common - ge_single_op ge_prepare_common - ge_optimize_common ge_build_common ge_partition_common ge_ut_common - gtest gtest_main ascend_protobuf json c_sec -lrt -ldl -lpthread -lgcov + ${COMMON_SHARED_LIBRARIES} + $ + ge_execute_common ge_ut_common_format ge_load_common + ge_single_op ge_prepare_common + ge_optimize_common ge_build_common ge_partition_common ge_ut_common + gtest gtest_main gmock gmock_main ascend_protobuf json c_sec -lrt -ldl -lpthread -lgcov ) diff --git a/tests/ut/ge/common/datatype_transfer_unittest.cc b/tests/ut/ge/common/datatype_transfer_unittest.cc index 365556e3..c311a7cf 100644 --- a/tests/ut/ge/common/datatype_transfer_unittest.cc +++ b/tests/ut/ge/common/datatype_transfer_unittest.cc @@ -365,7 +365,7 @@ TEST_F(UtestDataTypeTransfer, invalid_src_data_type) { TransResult result; DataTypeTransfer transfer; - EXPECT_EQ(transfer.TransDataType(args, result), UNSUPPORTED); + EXPECT_EQ(transfer.TransDataType(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } /* @@ -386,8 +386,8 @@ TEST_F(UtestDataTypeTransfer, unsupprot_trans) { TransResult result; DataTypeTransfer transfer; - EXPECT_EQ(transfer.TransDataType(args, result), UNSUPPORTED); - EXPECT_EQ(TransDataType(args, result), UNSUPPORTED); + EXPECT_EQ(transfer.TransDataType(args, result), ACL_ERROR_GE_DATATYPE_INVALID); + EXPECT_EQ(TransDataType(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestDataTypeTransfer, unsupprot_trans2) { @@ -396,8 +396,8 @@ TEST_F(UtestDataTypeTransfer, unsupprot_trans2) { TransResult result; DataTypeTransfer transfer; - EXPECT_EQ(transfer.TransDataType(args, result), UNSUPPORTED); - EXPECT_EQ(TransDataType(args, result), UNSUPPORTED); + EXPECT_EQ(transfer.TransDataType(args, result), ACL_ERROR_GE_DATATYPE_INVALID); + EXPECT_EQ(TransDataType(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_5d_nchw_unittest.cc b/tests/ut/ge/common/format_transfer_5d_nchw_unittest.cc index 64664a5c..0eded4d7 100644 --- a/tests/ut/ge/common/format_transfer_5d_nchw_unittest.cc +++ b/tests/ut/ge/common/format_transfer_5d_nchw_unittest.cc @@ -569,7 +569,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape1) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape2) { @@ -579,7 +579,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_shape2) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape1) { @@ -588,7 +588,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape1) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape2) { @@ -598,7 +598,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_shape2) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_dst_shape_relation) { @@ -608,7 +608,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_dst_shape_relation) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_format) { @@ -618,10 +618,10 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_format) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, UNSUPPORTED); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_format) { @@ -631,7 +631,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_dst_format) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_data_type) { @@ -642,7 +642,7 @@ TEST_F(UTEST_FormatTransferNc1hwc0ToNchw, invalid_src_data_type) { TransResult result; FormatTransferNc1hwc0Nchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_5d_nhwc_unittest.cc b/tests/ut/ge/common/format_transfer_5d_nhwc_unittest.cc index b0a39396..f69c3597 100644 --- a/tests/ut/ge/common/format_transfer_5d_nhwc_unittest.cc +++ b/tests/ut/ge/common/format_transfer_5d_nhwc_unittest.cc @@ -679,7 +679,7 @@ TEST_F(UtestFormatTransfer5dNhwc, nc1hwc0_to_nhwc_float2) { } Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_src_format) { @@ -689,7 +689,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_src_format) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_src_shape1) { @@ -699,7 +699,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_src_shape1) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, InvalidSrcShape2) { @@ -709,7 +709,7 @@ TEST_F(UtestFormatTransfer5dNhwc, InvalidSrcShape2) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_src_data_type) { @@ -719,7 +719,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_src_data_type) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_dst_format) { @@ -729,7 +729,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_dst_format) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_dst_shape1) { @@ -739,7 +739,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_dst_shape1) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_dst_shape2) { @@ -749,7 +749,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_dst_shape2) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransfer5dNhwc, invalid_src_dst_shape_relation) { @@ -759,7 +759,7 @@ TEST_F(UtestFormatTransfer5dNhwc, invalid_src_dst_shape_relation) { TransResult result; FormatTransferNc1hwc0Nhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_c1hwncoc0_hwcn_unittest.cc b/tests/ut/ge/common/format_transfer_c1hwncoc0_hwcn_unittest.cc index 3f195ef2..6304d3fd 100644 --- a/tests/ut/ge/common/format_transfer_c1hwncoc0_hwcn_unittest.cc +++ b/tests/ut/ge/common/format_transfer_c1hwncoc0_hwcn_unittest.cc @@ -39,7 +39,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_data_type_uint8) { TransResult result; FormatTransferC1hwncoc0Hwcn transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_data_type_int32) { @@ -50,7 +50,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_data_type_int32) { reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_HWCN, {1, 4, 4, 1, 16, 16}, {4, 4, 3, 1}, DT_INT32}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_format_nc1khkwhwc0) { @@ -61,7 +61,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_format_nc1khkw reinterpret_cast(data), FORMAT_NC1KHKWHWC0, FORMAT_HWCN, {1, 4, 4, 1, 16, 16}, {4, 4, 3, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_dst_format_nchw) { @@ -72,7 +72,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_dst_format_nchw) { reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_NCHW, {1, 4, 4, 1, 16, 16}, {4, 4, 3, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_shape) { @@ -83,7 +83,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_shape) { reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_HWCN, {1, 4, 4, 1, 16}, {4, 4, 3, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_shape2) { @@ -94,7 +94,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_shape2) { reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_HWCN, {1, 4, 4, 1, 16, -16}, {4, 4, 3, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invali_dst_shape) { @@ -105,7 +105,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invali_dst_shape) { reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_HWCN, {1, 4, 4, 1, 16, 16}, {4, 4, 3}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_dst_shape2) { @@ -116,7 +116,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_dst_shape2) { reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_HWCN, {1, 4, 4, 1, 16, 16}, {4, 4, 3, -1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_dst_shape_relation) { @@ -127,7 +127,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_invalid_src_dst_shape_rela reinterpret_cast(data), FORMAT_C1HWNCoC0, FORMAT_HWCN, {1, 4, 4, 1, 16, 16}, {4, 4, 17, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_fp16_success_lt_cube) { @@ -158,7 +158,7 @@ TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_fp16_success_lt_cube) { } Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferC1hwncoc0Hwcn, sixd_to_hwcn_gp16_success_eq_cube) { diff --git a/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc b/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc index 70c07d45..02f8251a 100644 --- a/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc +++ b/tests/ut/ge/common/format_transfer_fractal_nz_unittest.cc @@ -2332,7 +2332,7 @@ TEST_F(UtestFormatTransferNdFractNz, nd_shape4_fp16) { } EXPECT_EQ( transfer2.TransShape(args2.src_format, args2.src_shape, args2.src_data_type, args2.dst_format, args2.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractNz, nd_shape5_fp16) { @@ -4785,7 +4785,7 @@ TEST_F(UtestFormatTransferNdFractNz, nd_shape4_fp32) { EXPECT_EQ((reinterpret_cast(result2.data.get()))[i], data[i]); } EXPECT_EQ(transfer2.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractNz, nchw_shape4_fp32) { @@ -9058,9 +9058,9 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_shape) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; TransResult result; FormatTransferFractalNz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type) { @@ -9078,9 +9078,9 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type) { DT_UNDEFINED}; TransResult result; FormatTransferFractalNz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID); + ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_src_format) { @@ -9093,9 +9093,9 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_format) { DT_FLOAT16}; TransResult result; FormatTransferFractalNz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_dst_shape) { @@ -9104,7 +9104,7 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_dst_shape) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 1, 4, 4}, {1, 1, 16, 16}, DT_FLOAT16}; TransResult result; FormatTransferFractalNz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), SUCCESS); } @@ -9115,7 +9115,7 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_dst_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_NZ, FORMAT_NHWC, {1, 1, 1, 1, 16, 16}, {1, 4, 4}, DT_FLOAT16}; TransResult result; FormatTransferFractalNzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type2) { @@ -9133,7 +9133,7 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type2) { DT_UNDEFINED}; TransResult result; FormatTransferFractalNzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type3) { @@ -9148,10 +9148,10 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_data_type3) { 4, 4, }, - DT_VARIANT}; + DT_STRING}; TransResult result; FormatTransferFractalNzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_dst_format2) { @@ -9164,8 +9164,8 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_dst_format2) { DT_FLOAT16}; TransResult result; FormatTransferFractalNzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); - EXPECT_EQ(TransFormat(args, result), UNSUPPORTED); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); + EXPECT_EQ(TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_src_shape2) { @@ -9174,7 +9174,7 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_NZ, FORMAT_NHWC, {1, 1, 16, 16}, {1, 1, 4, 4}, DT_FLOAT16}; TransResult result; FormatTransferFractalNzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractNz, invalid_src_dst_shape_relation) { @@ -9187,7 +9187,7 @@ TEST_F(UtestFormatTransferNdFractNz, invalid_src_dst_shape_relation) { DT_FLOAT16}; TransResult result; FormatTransferFractalNzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_fractal_zz_unittest.cc b/tests/ut/ge/common/format_transfer_fractal_zz_unittest.cc index 8b1afa24..a75d177b 100644 --- a/tests/ut/ge/common/format_transfer_fractal_zz_unittest.cc +++ b/tests/ut/ge/common/format_transfer_fractal_zz_unittest.cc @@ -1894,7 +1894,7 @@ TEST_F(UtestFormatTransferNdFractZz, nd_shape4_fp16_1) { } EXPECT_EQ( transfer2.TransShape(args2.src_format, args2.src_shape, args2.src_data_type, args2.dst_format, args2.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractZz, nd_shape4_fp16) { @@ -2071,7 +2071,7 @@ TEST_F(UtestFormatTransferNdFractZz, nd_shape4_fp16) { } EXPECT_EQ( transfer2.TransShape(args2.src_format, args2.src_shape, args2.src_data_type, args2.dst_format, args2.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractZz, nd_shape5_fp16) { @@ -7877,9 +7877,9 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_src_shape) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_ZZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; TransResult result; FormatTransferFractalZz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_src_data_type) { @@ -7897,9 +7897,9 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_src_data_type) { DT_UNDEFINED}; TransResult result; FormatTransferFractalZz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID); + ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_src_format) { @@ -7912,10 +7912,10 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_src_format) { DT_FLOAT16}; TransResult result; FormatTransferFractalZz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); - EXPECT_EQ(TransFormat(args, result), UNSUPPORTED); + ACL_ERROR_GE_SHAPE_INVALID); + EXPECT_EQ(TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_dst_shape) { @@ -7924,7 +7924,7 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_dst_shape) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_ZZ, {1, 1, 4, 4}, {1, 1, 16, 16}, DT_FLOAT16}; TransResult result; FormatTransferFractalZz transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), SUCCESS); } @@ -7935,7 +7935,7 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_dst_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_ZZ, FORMAT_NHWC, {1, 1, 1, 1, 16, 16}, {1, 4, 4}, DT_FLOAT16}; TransResult result; FormatTransferFractalZzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_src_data_type2) { @@ -7953,7 +7953,7 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_src_data_type2) { DT_UNDEFINED}; TransResult result; FormatTransferFractalZzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_dst_format2) { @@ -7966,8 +7966,8 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_dst_format2) { DT_FLOAT16}; TransResult result; FormatTransferFractalZzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); - EXPECT_EQ(TransFormat(args, result), UNSUPPORTED); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); + EXPECT_EQ(TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_src_shape2) { @@ -7976,7 +7976,7 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_src_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_ZZ, FORMAT_NHWC, {1, 1, 16, 16}, {1, 1, 4, 4}, DT_FLOAT16}; TransResult result; FormatTransferFractalZzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNdFractZz, invalid_src_dst_shape_relation) { @@ -7989,7 +7989,7 @@ TEST_F(UtestFormatTransferNdFractZz, invalid_src_dst_shape_relation) { DT_FLOAT16}; TransResult result; FormatTransferFractalZzND transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_fracz_hwcn_unittest.cc b/tests/ut/ge/common/format_transfer_fracz_hwcn_unittest.cc index 25caa741..2bc45323 100644 --- a/tests/ut/ge/common/format_transfer_fracz_hwcn_unittest.cc +++ b/tests/ut/ge/common/format_transfer_fracz_hwcn_unittest.cc @@ -39,7 +39,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_data_type_invalid_dat TransResult result; FormatTransferFracZHwcn transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_format_reserved) { @@ -50,7 +50,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_format_reserved) reinterpret_cast(data), FORMAT_RESERVED, FORMAT_HWCN, {16, 1, 16, 16}, {4, 4, 1, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_dst_format_reserved) { @@ -61,7 +61,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_dst_format_reserved) reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_RESERVED, {16, 1, 16, 16}, {4, 4, 1, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_shape) { @@ -72,7 +72,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_shape) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_HWCN, {16, 1, 1, 16, 16}, {4, 4, 1, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_shape2) { @@ -83,7 +83,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_HWCN, {16, -1, 16, 16}, {4, 4, 1, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_dst_shape) { @@ -94,7 +94,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_dst_shape) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_HWCN, {16, 1, 16, 16}, {4, 4, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_dst_shape2) { @@ -105,7 +105,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_dst_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_HWCN, {16, 1, 16, 16}, {4, 4, -1, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_dst_shape_relation1) { @@ -116,7 +116,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_dst_shape_relatio reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_HWCN, {16, 1, 16, 16}, {4, 4, 17, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_dst_shape_relation2) { @@ -127,7 +127,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_invalid_src_dst_shape_relatio reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_HWCN, {16, 1, 16, 16}, {4, 4, 1, 17}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_fp16_success_lt_cube) { @@ -302,7 +302,7 @@ TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_fp16_success_eq_cube) { } Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFracZHwcn, fracz_to_hwcn_fp16_success_gt_cube) { diff --git a/tests/ut/ge/common/format_transfer_fracz_nchw_unittest.cc b/tests/ut/ge/common/format_transfer_fracz_nchw_unittest.cc index 93160070..15b6b9d3 100644 --- a/tests/ut/ge/common/format_transfer_fracz_nchw_unittest.cc +++ b/tests/ut/ge/common/format_transfer_fracz_nchw_unittest.cc @@ -39,7 +39,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_data_type) { TransResult result; FormatTransferFracZNchw transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_Invalid_src_format_reserved) { @@ -50,7 +50,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_Invalid_src_format_reserved) reinterpret_cast(data), FORMAT_RESERVED, FORMAT_NCHW, {16, 1, 16, 16}, {1, 1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_dst_format_reserved) { @@ -61,7 +61,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_dst_format_reserved) reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_RESERVED, {16, 1, 16, 16}, {1, 1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_shape) { @@ -72,7 +72,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_shape) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NCHW, {16, 1, 1, 16, 16}, {1, 1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_shape2) { @@ -83,7 +83,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NCHW, {16, 1, -16, 16}, {1, 1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_dst_shape) { @@ -94,7 +94,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_dst_shape) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NCHW, {16, 1, 16, 16}, {1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_dst_shape2) { @@ -105,7 +105,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_dst_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NCHW, {16, 1, 16, 16}, {1, -1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_dst_shape_relation1) { @@ -116,7 +116,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_dst_shape_relatio reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NCHW, {16, 1, 16, 16}, {1, 17, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_dst_shape_relation2) { @@ -127,7 +127,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_invalid_src_dst_shape_relatio reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NCHW, {16, 1, 16, 16}, {17, 1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_fp16_success_lt_cube) { @@ -302,7 +302,7 @@ TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_fp16_success_eq_cube) { } Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFraczNchw, fracz_to_nchw_fp16_success_gt_cube) { diff --git a/tests/ut/ge/common/format_transfer_fracz_nhwc_unittest.cc b/tests/ut/ge/common/format_transfer_fracz_nhwc_unittest.cc index e406eb43..a4d6f9ae 100644 --- a/tests/ut/ge/common/format_transfer_fracz_nhwc_unittest.cc +++ b/tests/ut/ge/common/format_transfer_fracz_nhwc_unittest.cc @@ -39,7 +39,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_data_type) { TransResult result; FormatTransferFracZNhwc transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_format_reserved) { @@ -50,7 +50,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_format_reserved) reinterpret_cast(data), FORMAT_RESERVED, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_format_reserved) { @@ -61,7 +61,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_format_reserved) reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_RESERVED, {16, 1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape) { @@ -71,7 +71,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape) { TransArgs args{reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16}, {1, 4, 4, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape2) { @@ -82,7 +82,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, -1, 16, 16}, {1, 4, 4, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape) { @@ -93,7 +93,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape2) { @@ -104,7 +104,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_dst_shape2) { reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, -1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relation1) { @@ -115,7 +115,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relatio reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {17, 4, 4, 1}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relation2) { @@ -126,7 +126,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_invalid_src_dst_shape_relatio reinterpret_cast(data), FORMAT_FRACTAL_Z, FORMAT_NHWC, {16, 1, 16, 16}, {1, 4, 4, 17}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_lt_cube) { @@ -301,7 +301,7 @@ TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_eq_cube) { } Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, UNSUPPORTED); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferFraczNhwc, fracz_to_nhwc_fp16_success_gt_cube) { diff --git a/tests/ut/ge/common/format_transfer_hwcn_c1hwncoc0_unittest.cc b/tests/ut/ge/common/format_transfer_hwcn_c1hwncoc0_unittest.cc index 1e6b90dd..7fafa4c2 100644 --- a/tests/ut/ge/common/format_transfer_hwcn_c1hwncoc0_unittest.cc +++ b/tests/ut/ge/common/format_transfer_hwcn_c1hwncoc0_unittest.cc @@ -42,7 +42,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_data_type_uint8) { TransResult result; FormatTransferHwcnC1hwncoc0 transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_data_type_int32) { @@ -57,7 +57,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_data_type_int32) { reinterpret_cast(data), FORMAT_HWCN, FORMAT_C1HWNCoC0, {4, 4, 3, 1}, {1, 4, 4, 1, 16, 16}, DT_INT32}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_format_nchw) { @@ -72,10 +72,10 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_format_nchw) { reinterpret_cast(data), FORMAT_NCHW, FORMAT_C1HWNCoC0, {4, 4, 3, 1}, {1, 4, 4, 1, 16, 16}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_dst_format_nc1khkwhwc0) { @@ -90,7 +90,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_dst_format_nc1khkwhw reinterpret_cast(data), FORMAT_HWCN, FORMAT_NC1KHKWHWC0, {4, 4, 3, 1}, {1, 4, 4, 1, 16, 16}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_shape) { @@ -105,7 +105,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_shape) { reinterpret_cast(data), FORMAT_HWCN, FORMAT_NC1KHKWHWC0, {4, 4, 3}, {1, 4, 4, 1, 16, 16}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_shape2) { @@ -120,7 +120,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_shape2) { reinterpret_cast(data), FORMAT_HWCN, FORMAT_C1HWNCoC0, {4, 4}, {1, 4, 4, 1, 16, 16}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_shape3) { @@ -139,10 +139,10 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_src_shape3) { DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_dst_format) { @@ -157,7 +157,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_dst_format) { reinterpret_cast(data), FORMAT_HWCN, FORMAT_NC1KHKWHWC0, {4, 4, 3, 1}, {1, 1, 4, 4, 16, 16}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_dst_shape2) { @@ -172,7 +172,7 @@ TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_invalid_dst_shape2) { reinterpret_cast(data), FORMAT_HWCN, FORMAT_C1HWNCoC0, {4, 4, 3, 1}, {2, 4, 4, 1, 16, 16}, DT_FLOAT}; TransResult result; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferHwcnC1hwncoc0, hwcn_to_6d_fp16_success_lt_cube) { diff --git a/tests/ut/ge/common/format_transfer_nchw_5d_unittest.cc b/tests/ut/ge/common/format_transfer_nchw_5d_unittest.cc index 610bd7d3..7b88183e 100644 --- a/tests/ut/ge/common/format_transfer_nchw_5d_unittest.cc +++ b/tests/ut/ge/common/format_transfer_nchw_5d_unittest.cc @@ -640,7 +640,7 @@ TEST_F(UtestFormatTransferNchw5d, invalid_data_format) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_Z, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; FormatTransferNchwNc1hwc0 transfer; EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_nhwc_5d_unittest.cc b/tests/ut/ge/common/format_transfer_nhwc_5d_unittest.cc index bc5a8754..e1218894 100644 --- a/tests/ut/ge/common/format_transfer_nhwc_5d_unittest.cc +++ b/tests/ut/ge/common/format_transfer_nhwc_5d_unittest.cc @@ -691,7 +691,7 @@ TEST_F(UtestFormatTransferNhwc5d, invalid_src_shape1) { TransResult result; FormatTransferNhwcNc1hwc0 transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } /* @@ -716,10 +716,10 @@ TEST_F(UtestFormatTransferNhwc5d, invalid_src_format) { TransResult result; FormatTransferNhwcNc1hwc0 transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); Status status = transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape); - EXPECT_EQ(status, ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + EXPECT_EQ(status, ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNhwc5d, invalid_dst_shape2) { @@ -729,7 +729,7 @@ TEST_F(UtestFormatTransferNhwc5d, invalid_dst_shape2) { TransResult result; FormatTransferNhwcNc1hwc0 transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTransferNhwc5d, invalid_src_data_type) { @@ -739,7 +739,7 @@ TEST_F(UtestFormatTransferNhwc5d, invalid_src_data_type) { TransResult result; FormatTransferNhwcNc1hwc0 transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNhwc5d, unsupport_dst_format) { @@ -749,7 +749,7 @@ TEST_F(UtestFormatTransferNhwc5d, unsupport_dst_format) { TransResult result; FormatTransferNhwcNc1hwc0 transfer; - EXPECT_EQ(transfer.TransFormat(args, result), PARAM_INVALID); + EXPECT_EQ(transfer.TransFormat(args, result), ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNhwc5d, invalid_data_shape) { @@ -758,13 +758,13 @@ TEST_F(UtestFormatTransferNhwc5d, invalid_data_shape) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_Z, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; FormatTransferNhwcNc1hwc0 transfer; EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); TransArgs args2{ reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_Z, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_STRING}; FormatTransferNhwcNc1hwc0 transfer2; EXPECT_EQ(transfer2.TransShape(args2.src_format, args2.src_shape, args2.src_data_type, args2.dst_format, args2.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID); + ACL_ERROR_GE_DATATYPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc b/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc index a6dfffb0..7431440b 100644 --- a/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc +++ b/tests/ut/ge/common/format_transfer_nhwc_fractalz_unittest.cc @@ -5357,10 +5357,10 @@ TEST_F(UtestFormatTransferNhwcFz, build_transfer_uint8) { TEST_F(UtestFormatTransferNhwcFz, invalid_data_type) { uint16_t data[1 * 4 * 4 * 1] = {0}; TransArgs args{ - reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_VARIANT}; + reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_STRING}; FormatTransferFractalZ transfer; EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_DATATYPE_INVALID); + ACL_ERROR_GE_DATATYPE_INVALID); } TEST_F(UtestFormatTransferNhwcFz, invalid_data_format) { @@ -5369,7 +5369,7 @@ TEST_F(UtestFormatTransferNhwcFz, invalid_data_format) { reinterpret_cast(data), FORMAT_CHWN, FORMAT_FRACTAL_NZ, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; FormatTransferFractalZ transfer; EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTransferNhwcFz, invalid_data_shape) { @@ -5378,19 +5378,19 @@ TEST_F(UtestFormatTransferNhwcFz, invalid_data_shape) { reinterpret_cast(data), FORMAT_NHWC, FORMAT_FRACTAL_Z, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; FormatTransferFractalZ transfer; EXPECT_EQ(transfer.TransShape(args.src_format, args.src_shape, args.src_data_type, args.dst_format, args.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); TransArgs args2{ reinterpret_cast(data), FORMAT_HWCN, FORMAT_FRACTAL_Z, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; FormatTransferFractalZ transfer2; EXPECT_EQ(transfer2.TransShape(args2.src_format, args2.src_shape, args2.src_data_type, args2.dst_format, args2.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); TransArgs args3{ reinterpret_cast(data), FORMAT_NCHW, FORMAT_FRACTAL_Z, {1, 4, 4}, {1, 1, 1, 16, 16}, DT_FLOAT16}; FormatTransferFractalZ transfer3; EXPECT_EQ(transfer3.TransShape(args3.src_format, args3.src_shape, args3.src_data_type, args3.dst_format, args3.dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_transpose_unittest.cc b/tests/ut/ge/common/format_transfer_transpose_unittest.cc index d56e06c0..04f2a557 100644 --- a/tests/ut/ge/common/format_transfer_transpose_unittest.cc +++ b/tests/ut/ge/common/format_transfer_transpose_unittest.cc @@ -4659,14 +4659,14 @@ TEST_F(UtestFormatTranspose, invalid_data_shape) { FormatTransferTranspose transfer; std::vector dst_shape; EXPECT_EQ(transfer.TransShape(FORMAT_NCHW, std::vector({}), DT_FLOAT16, FORMAT_HWCN, dst_shape), - ACL_ERROR_GE_TRANSSHAPE_SHAPE_INVALID); + ACL_ERROR_GE_SHAPE_INVALID); } TEST_F(UtestFormatTranspose, invalid_src_format) { FormatTransferTranspose transfer; std::vector dst_shape; EXPECT_EQ(transfer.TransShape(FORMAT_NC1HWC0, std::vector({1, 3, 8, 8}), DT_FLOAT16, FORMAT_HWCN, dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } TEST_F(UtestFormatTranspose, invalid_dst_format) { @@ -4674,7 +4674,7 @@ TEST_F(UtestFormatTranspose, invalid_dst_format) { std::vector dst_shape; std::vector src_shape; EXPECT_EQ(transfer.TransShape(FORMAT_NCHW, src_shape, DT_FLOAT16, FORMAT_C1HWNC0, dst_shape), - ACL_ERROR_GE_TRANSSHAPE_FORMAT_INVALID); + ACL_ERROR_GE_FORMAT_INVALID); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/format_transfer_unittest.cc b/tests/ut/ge/common/format_transfer_unittest.cc index fd2a296c..73b7703d 100644 --- a/tests/ut/ge/common/format_transfer_unittest.cc +++ b/tests/ut/ge/common/format_transfer_unittest.cc @@ -75,11 +75,11 @@ TEST_F(UtestFormatTransfer, get_size_by_data_type) { EXPECT_EQ(GetSizeByDataType(DT_QINT32), 4); EXPECT_EQ(GetSizeByDataType(DT_QUINT8), 1); EXPECT_EQ(GetSizeByDataType(DT_QUINT16), 2); - EXPECT_EQ(GetSizeByDataType(DT_RESOURCE), -1); + EXPECT_EQ(GetSizeByDataType(DT_RESOURCE), 8); EXPECT_EQ(GetSizeByDataType(DT_STRING_REF), -1); EXPECT_EQ(GetSizeByDataType(DT_DUAL), 5); EXPECT_EQ(GetSizeByDataType(DT_UNDEFINED), -1); - EXPECT_EQ(DT_UNDEFINED, 27); + EXPECT_EQ(DT_UNDEFINED, 28); } } // namespace formats } // namespace ge diff --git a/tests/ut/ge/common/opdebug_register_unittest.cc b/tests/ut/ge/common/opdebug_register_unittest.cc new file mode 100644 index 00000000..528fd9e3 --- /dev/null +++ b/tests/ut/ge/common/opdebug_register_unittest.cc @@ -0,0 +1,51 @@ +/** + * 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 "common/dump/opdebug_register.h" +#include "common/debug/log.h" +#include "common/ge_inner_error_codes.h" + +namespace ge { +class UTEST_opdebug_register : public testing::Test { + protected: + void SetUp() {} + void TearDown() {} +}; + +TEST_F(UTEST_opdebug_register, register_debug_for_model_success) { + OpdebugRegister opdebug_register; + rtModel_t model_handle = (void*)0x111; + uint32_t op_debug_mode = 1; + DataDumper data_dumper({}); + auto ret = opdebug_register.RegisterDebugForModel(model_handle, op_debug_mode, data_dumper); + opdebug_register.UnregisterDebugForModel(model_handle); + EXPECT_EQ(ret, ge::SUCCESS); +} + +TEST_F(UTEST_opdebug_register, register_debug_for_stream_success) { + OpdebugRegister opdebug_register; + rtStream_t stream = (void*)0x111; + uint32_t op_debug_mode = 1; + DataDumper data_dumper({}); + auto ret = opdebug_register.RegisterDebugForStream(stream, op_debug_mode, data_dumper); + opdebug_register.UnregisterDebugForStream(stream); + EXPECT_EQ(ret, ge::SUCCESS); +} + + +} // namespace ge \ No newline at end of file diff --git a/tests/ut/ge/executor/ge_executor_unittest.cc b/tests/ut/ge/executor/ge_executor_unittest.cc index a98f9290..a4606320 100644 --- a/tests/ut/ge/executor/ge_executor_unittest.cc +++ b/tests/ut/ge/executor/ge_executor_unittest.cc @@ -39,4 +39,10 @@ TEST_F(UtestGeExecutor, test_single_op_exec) { EXPECT_EQ(exeutor.LoadSingleOp(model_name, model_data, nullptr, nullptr), ACL_ERROR_GE_INTERNAL_ERROR); EXPECT_EQ(exeutor.LoadDynamicSingleOp(model_name, model_data, nullptr, nullptr), PARAM_INVALID); } + +TEST_F(UtestGeExecutor, test_ge_initialize) { + GeExecutor executor; + EXPECT_EQ(executor.Initialize(), SUCCESS); + EXPECT_EQ(executor.Initialize(), SUCCESS); +} } // namespace ge \ No newline at end of file diff --git a/tests/ut/ge/generator/ge_generator_unittest.cc b/tests/ut/ge/generator/ge_generator_unittest.cc index 09ddf2ec..6d0db429 100644 --- a/tests/ut/ge/generator/ge_generator_unittest.cc +++ b/tests/ut/ge/generator/ge_generator_unittest.cc @@ -20,6 +20,12 @@ #define protected public #include "generator/ge_generator.h" #include "graph/utils/tensor_utils.h" +#include "graph/attr_value.h" +#include "graph/debug/ge_attr_define.h" +#include "graph/utils/graph_utils.h" +#include "../graph/passes/graph_builder_utils.h" +#include "../graph/manager/graph_manager.h" +#include "all_ops.h" using namespace std; @@ -31,6 +37,17 @@ class UtestGeGenerator : public testing::Test { void TearDown() {} }; +namespace { +ComputeGraphPtr MakeGraph() { + ge::ut::GraphBuilder builder("graph"); + auto data = builder.AddNode("data", "Data", 1, 1); + auto addn1 = builder.AddNode("addn1", "AddN", 1, 1); + builder.AddDataEdge(data, 0, addn1, 0); + return builder.GetGraph(); +} +} // namespace + +/* TEST_F(UtestGeGenerator, test_build_single_op_offline) { GeTensorDesc tensor_desc(GeShape(), FORMAT_NCHW, DT_FLOAT); TensorUtils::SetSize(tensor_desc, 512); @@ -52,27 +69,63 @@ TEST_F(UtestGeGenerator, test_build_single_op_offline) { generator.Initialize({}); EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, "offline_"), GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED); } +*/ -/* TEST_F(UtestGeGenerator, test_build_single_op_online) { - GeTensorDesc tensor_desc(GeShape(), FORMAT_NCHW, DT_FLOAT); - TensorUtils::SetSize(tensor_desc, 512); - + GeTensorDesc tensor_desc; shared_ptr op_desc = make_shared("Add", "add"); - EXPECT_EQ(op_desc->AddInputDesc(tensor_desc), GRAPH_SUCCESS); - EXPECT_EQ(op_desc->AddInputDesc(tensor_desc), GRAPH_SUCCESS); - EXPECT_EQ(op_desc->AddOutputDesc(tensor_desc), GRAPH_SUCCESS); + op_desc->AddInputDesc(tensor_desc); + op_desc->AddInputDesc(tensor_desc); + op_desc->AddOutputDesc(tensor_desc); GeTensor tensor(tensor_desc); const vector inputs = { tensor, tensor }; const vector outputs = { tensor }; - // not Initialize, impl is null. GeGenerator generator; generator.Initialize({}); ModelBufferData model_buffer; - EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, ENGINE_SYS, model_buffer), GE_GENERATOR_GRAPH_MANAGER_BUILD_GRAPH_FAILED); + EXPECT_EQ(generator.BuildSingleOpModel(op_desc, inputs, outputs, ENGINE_AIVECTOR, model_buffer), FAILED); } -*/ +TEST_F(UtestGeGenerator, test_check_aicore) { + GeGenerator generator; + generator.Initialize({}); + auto graph = MakeGraph(); + EXPECT_EQ(generator.CheckNoAicore(graph), true); +} + +TEST_F(UtestGeGenerator, test_graph_manager) { + GraphManager graph_manager; + GraphPartitioner graph_partitioner; + + auto root_graph = MakeGraph(); + auto sub_graph = MakeGraph(); + root_graph->AddSubGraph(sub_graph); + + auto sgi = MakeShared(); + // set engine name + sgi->SetEngineName("AIcoreEngine"); + sgi->SetSubGraph(sub_graph); + + auto sgi_gelocal = MakeShared(); + // set engine name + sgi_gelocal->SetEngineName("GELOCAL"); + sgi_gelocal->SetSubGraph(sub_graph); + + graph_partitioner.graph_2_input_subgraph_[root_graph] = sgi_gelocal; + graph_partitioner.graph_2_subgraph_list_.insert({root_graph, {sgi, sgi_gelocal}}); + graph_partitioner.graph_2_subgraph_list_.insert({sub_graph, {sgi, sgi_gelocal}}); + EXPECT_EQ(graph_manager.ConvertGraphToFile(root_graph, graph_partitioner, "./"), GRAPH_SUCCESS); +} + +TEST_F(UtestGeGenerator, test_set_model_name) { + GeGenerator generator; + generator.Initialize({}); + GeRootModelPtr ge_root_model = make_shared(GeRootModel()); + ComputeGraphPtr graph = make_shared(ComputeGraph("graph")); + (void)AttrUtils::SetBool(graph, "_dynamic_shape_partitioned", true); + ge_root_model->root_graph_ = std::move(graph); + EXPECT_EQ(generator.SetModelNameForDump(ge_root_model), SUCCESS); +} } // namespace ge diff --git a/tests/ut/ge/graph/build/logical_stream_allocator_unittest.cc b/tests/ut/ge/graph/build/logical_stream_allocator_unittest.cc index 5b87939f..218bfd0d 100644 --- a/tests/ut/ge/graph/build/logical_stream_allocator_unittest.cc +++ b/tests/ut/ge/graph/build/logical_stream_allocator_unittest.cc @@ -32,6 +32,7 @@ #include "graph/compute_graph.h" #include "graph/utils/attr_utils.h" #include "graph/utils/graph_utils.h" +#include "graph/debug/ge_attr_define.h" using namespace std; @@ -153,6 +154,22 @@ class UtestLogicalStreamAllocator : public testing::Test { return CreateSubgraphWithName("graph", engine, stream_label, in_num, out_num); } + SubGraphInfoPtr CreateParallelGroupSubgraphWithName(const string &name, const string &engine, + const string &stream_label = "", + std::string group_name = "1") { + ComputeGraphPtr compute_graph = make_shared(name); + OpDescPtr op_desc = std::make_shared("relu", "Relu"); + op_desc->AddInputDesc(GeTensorDesc()); + op_desc->AddOutputDesc(GeTensorDesc()); + AttrUtils::SetStr(op_desc, ATTR_NAME_PARALLEL_GROUP, group_name); + compute_graph->AddNode(op_desc); + + SubGraphInfoPtr subgraph = BuildSubGraph(compute_graph, engine, stream_label); + AddPlaceHolderAndEnd(subgraph, 1, 1); + + return subgraph; + } + void LinkSubGraph(SubGraphInfoPtr subgraph1, const string &end_name, SubGraphInfoPtr subgraph2, const string &placeholder_name) { NodePtr end_node = subgraph1->GetSubGraph()->FindNode(end_name); @@ -878,4 +895,30 @@ TEST_F(UtestLogicalStreamAllocator, test_all_reduce_parallel_pass) { EXPECT_EQ(ret, NOT_CHANGED); } +TEST_F(UtestLogicalStreamAllocator, test_parallel_group) { + SubGraphInfoPtr data = CreateDataSubgraph(); + SubGraphInfoPtr subgraph1 = CreateParallelGroupSubgraphWithName("graph1", "engine1", ""); + SubGraphInfoPtr subgraph2 = CreateParallelGroupSubgraphWithName("graph2", "engine2", "", "2"); + SubGraphInfoPtr subgraph3 = CreateParallelGroupSubgraphWithName("graph3", "engine3", "", "3"); + SubGraphInfoPtr subgraph4 = CreateParallelGroupSubgraphWithName("graph4", "engine4", "", "4"); + LinkSubGraph(data, "end", subgraph1, "placeholder"); + LinkSubGraph(subgraph1, "end", subgraph2, "placeholder"); + LinkSubGraph(subgraph2, "end", subgraph3, "placeholder"); + LinkSubGraph(subgraph3, "end", subgraph4, "placeholder"); + + EngineConfPtr conf1 = make_shared(); + conf1->id = subgraph1->GetEngineName(); + EngineConfPtr conf2 = make_shared(); + conf2->id = subgraph2->GetEngineName(); + conf2->attach = false; + EngineConfPtr conf3 = make_shared(); + conf3->id = subgraph3->GetEngineName(); + conf3->attach = false; + EngineConfPtr conf4 = make_shared(); + conf4->id = subgraph4->GetEngineName(); + + Status status = AssignLogicalStreams({subgraph1, subgraph2, subgraph3, subgraph4}, {conf1, conf2, conf3, conf4}); + EXPECT_EQ(status, ge::SUCCESS); +} + } // namespace ge diff --git a/tests/ut/ge/graph/load/data_dumper_unittest.cc b/tests/ut/ge/graph/load/data_dumper_unittest.cc index 1866f4eb..68040bf1 100644 --- a/tests/ut/ge/graph/load/data_dumper_unittest.cc +++ b/tests/ut/ge/graph/load/data_dumper_unittest.cc @@ -56,7 +56,7 @@ TEST_F(UtestDataDumper, LoadDumpInfo_no_output_addrs_fail) { TEST_F(UtestDataDumper, UnloadDumpInfo_success) { RuntimeParam rts_param; - DataDumper data_dumper(rts_param); + DataDumper data_dumper(&rts_param); data_dumper.SetModelName("test"); data_dumper.SetModelId(2333); diff --git a/tests/ut/ge/graph/load/davinci_model_unittest.cc b/tests/ut/ge/graph/load/davinci_model_unittest.cc index fe39adf6..18cc622b 100644 --- a/tests/ut/ge/graph/load/davinci_model_unittest.cc +++ b/tests/ut/ge/graph/load/davinci_model_unittest.cc @@ -15,6 +15,7 @@ */ #include +#include #define private public #define protected public @@ -897,4 +898,48 @@ TEST_F(UtestDavinciModel, Sink_time_profile) { model.SinkTimeProfile(current_data); } +class ClassTest { +public: + virtual ~ClassTest() {} + + virtual int func0() { + return 0; + } + virtual int func1(int a) { + return a; + } + virtual int func2(int a, int b) { + return a + b; + } + virtual int func3(int a, int b) const { + return a - b; + } +}; + +class MockTest : public ClassTest { +public: + MOCK_METHOD0(func0, int()); + MOCK_METHOD1(func1, int(int a)); + MOCK_METHOD2(func2, int(int a, int b)); + + MOCK_CONST_METHOD2(func3, int(int a, int b)); +}; + +TEST_F(UtestDavinciModel, simple_test_gmock) { + MockTest mock_stub; + + ON_CALL(mock_stub, func0()).WillByDefault(testing::Return(250)); + EXPECT_EQ(mock_stub.func0(), 250); + EXPECT_EQ(mock_stub.func0(), 250); + EXPECT_EQ(mock_stub.func0(), 250); + + EXPECT_CALL(mock_stub, func1(testing::_)).Times(2).WillOnce(testing::Return(1024)).WillOnce(testing::Return(250)); + EXPECT_EQ(mock_stub.func1(1), 1024); + EXPECT_EQ(mock_stub.func1(1), 250); + + EXPECT_CALL(mock_stub, func2(testing::_, 5)).Times(3).WillRepeatedly(testing::Return(1023)); + EXPECT_EQ(mock_stub.func2(1, 5), 1023); + EXPECT_EQ(mock_stub.func2(2, 5), 1023); + EXPECT_EQ(mock_stub.func2(3, 5), 1023); +} } // namespace ge diff --git a/tests/ut/ge/graph/load/model_helper_unittest.cc b/tests/ut/ge/graph/load/model_helper_unittest.cc index 03605dc7..8fd8f014 100644 --- a/tests/ut/ge/graph/load/model_helper_unittest.cc +++ b/tests/ut/ge/graph/load/model_helper_unittest.cc @@ -36,13 +36,6 @@ class UtestModelHelper : public testing::Test { void TearDown() override {} }; -TEST_F(UtestModelHelper, save_size_to_modeldef_failed) -{ - GeModelPtr ge_model = ge::MakeShared(); - ModelHelper model_helper; - EXPECT_EQ(ACL_ERROR_GE_MEMORY_ALLOCATION, model_helper.SaveSizeToModelDef(ge_model)); -} - TEST_F(UtestModelHelper, save_size_to_modeldef) { GeModelPtr ge_model = ge::MakeShared(); diff --git a/tests/ut/ge/graph/load/model_manager_unittest.cc b/tests/ut/ge/graph/load/model_manager_unittest.cc index 0e65954d..342f6362 100644 --- a/tests/ut/ge/graph/load/model_manager_unittest.cc +++ b/tests/ut/ge/graph/load/model_manager_unittest.cc @@ -151,6 +151,15 @@ class DModelListener : public ModelListener { uint32_t OnComputeDone(uint32_t model_id, uint32_t data_index, uint32_t resultCode) { return 0; } }; +TEST_F(UtestModelManagerModelManager, case_is_need_hybrid_load) { + ModelManager mm; + uint32_t model_id = 0; + ComputeGraphPtr root_graph = std::make_shared("graph"); + ge::GeRootModel model; + EXPECT_EQ(mm.IsNeedHybridLoad(model), false); + model.SetRootGraph(root_graph); + EXPECT_EQ(mm.IsNeedHybridLoad(model), false); +} TEST_F(UtestModelManagerModelManager, case_load_incorrect_param) { ModelManager mm; diff --git a/tests/ut/ge/graph/load/model_utils_unittest.cc b/tests/ut/ge/graph/load/model_utils_unittest.cc index ac886cea..630a75aa 100644 --- a/tests/ut/ge/graph/load/model_utils_unittest.cc +++ b/tests/ut/ge/graph/load/model_utils_unittest.cc @@ -67,4 +67,22 @@ TEST_F(UtestModelUtils, get_var_addr_rdma_hbm) { EXPECT_EQ(reinterpret_cast(offset), var_addr); VarManager::Instance(runtime_param.session_id)->Destory(); } + +TEST_F(UtestModelUtils, get_var_addr_rdma_hbm_negative_offset) { + uint8_t test = 2; + uint8_t *pf = &test; + RuntimeParam runtime_param; + runtime_param.session_id = 0; + runtime_param.logic_var_base = 0; + runtime_param.var_base = pf; + + int64_t offset = -1; + EXPECT_EQ(VarManager::Instance(runtime_param.session_id)->Init(0, 0, 0, 0), SUCCESS); + EXPECT_NE(VarManager::Instance(runtime_param.session_id)->var_resource_, nullptr); + VarManager::Instance(runtime_param.session_id)->var_resource_->var_offset_map_[offset] = RT_MEMORY_RDMA_HBM; + std::shared_ptr op_desc = std::make_shared("test", "test"); + uint8_t *var_addr = nullptr; + EXPECT_NE(ModelUtils::GetVarAddr(runtime_param, op_desc, offset, var_addr), SUCCESS); + VarManager::Instance(runtime_param.session_id)->Destory(); +} } // namespace ge diff --git a/tests/ut/ge/graph/partition/dynamic_shape_partition_unittest.cc b/tests/ut/ge/graph/partition/dynamic_shape_partition_unittest.cc new file mode 100644 index 00000000..b60e0ddd --- /dev/null +++ b/tests/ut/ge/graph/partition/dynamic_shape_partition_unittest.cc @@ -0,0 +1,97 @@ +/** + * 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 "graph/partition/dynamic_shape_partition.h" +#include "compute_graph.h" +#include "inc/framework/common/types.h" +#include "utils/graph_utils.h" +#include "graph/debug/ge_attr_define.h" + + +#define private public +#define protected public + +namespace ge { + +namespace { + +GeTensorDescPtr CreateTensorDesc(std::initializer_list shape, Format format = FORMAT_NCHW, + DataType data_type = DT_FLOAT) { + GeShape ge_shape{vector(shape)}; + GeTensorDescPtr tensor_desc = std::make_shared(); + tensor_desc->SetShape(ge_shape); + tensor_desc->SetFormat(format); + tensor_desc->SetDataType(data_type); + return tensor_desc; +} + +class NodeBuilder { + public: + NodeBuilder(const std::string &name, const std::string &type) { op_desc_ = std::make_shared(name, type); } + + NodeBuilder &AddInputDesc(std::initializer_list shape = {1, 1, 224, 224}, Format format = FORMAT_NCHW, + DataType data_type = DT_FLOAT) { + op_desc_->AddInputDesc(CreateTensorDesc(shape, format, data_type)->Clone()); + return *this; + } + + NodeBuilder &AddOutputDesc(std::initializer_list shape = {1, 1, 224, 224}, Format format = FORMAT_NCHW, + DataType data_type = DT_FLOAT) { + op_desc_->AddOutputDesc(CreateTensorDesc(shape, format, data_type)->Clone()); + return *this; + } + + NodeBuilder &AddOutputDesc(GeTensorDescPtr tensor_desc) { + op_desc_->AddOutputDesc(tensor_desc->Clone()); + return *this; + } + + NodePtr Build(const ComputeGraphPtr &graph) { + NodePtr node = graph->AddNode(op_desc_); + return node; + } + + private: + OpDescPtr op_desc_; +}; +} // namespace + +class UtestDynamicShapePartition : public testing::Test { + protected: + void SetUp() {} + + void TearDown() {} +}; + +TEST_F(UtestDynamicShapePartition, single_op_scene_success) { + ComputeGraphPtr graph = std::make_shared("default"); + + NodePtr node1 = + NodeBuilder("node1", CONSTANTOP).AddInputDesc({1, 1, 224, 224}).AddOutputDesc({1, 1, 224, 224}).Build(graph); + NodePtr add_n_node = + NodeBuilder("add_n_node", ADDN).AddInputDesc({1, 1, 224, 224}).AddOutputDesc({1, 1, 224, 224}).Build(graph); + NodePtr node2 = + NodeBuilder("node2", RELU).AddInputDesc({1, 1, 224, 224}).AddOutputDesc({1, 1, 224, 224}).Build(graph); + GraphUtils::AddEdge(node1->GetOutDataAnchor(0), add_n_node->GetInDataAnchor(0)); + GraphUtils::AddEdge(add_n_node->GetOutDataAnchor(0), node2->GetInDataAnchor(0)); + + (void)AttrUtils::SetBool(add_n_node->GetOpDesc(), ATTR_SINGLE_OP_SCENE, true); + + DynamicShapePartitioner partitioner(graph); + EXPECT_EQ(partitioner.Partition(), SUCCESS); +} +} // namespace ge \ No newline at end of file diff --git a/tests/ut/ge/graph/passes/base_pass_unittest.cc b/tests/ut/ge/graph/passes/base_pass_unittest.cc index 56a7077a..129c11d8 100644 --- a/tests/ut/ge/graph/passes/base_pass_unittest.cc +++ b/tests/ut/ge/graph/passes/base_pass_unittest.cc @@ -67,6 +67,22 @@ class UtestTestPass : public BaseNodePass { names_to_add_repass_.erase(iter); } } + // simulate infershape pass + if(node->GetType() == WHILE){ + bool need_repass = false; + AttrUtils::GetBool(node->GetOpDesc(),"need_infer_again_", need_repass); + if(!OptionExists(kOptimizeAfterSubGraph)){ + return SUCCESS; + } + if(need_repass){ + AttrUtils::SetBool(node->GetOpDesc(),"need_infer_again_", false); + AddImmediateRePassNode(node); + } + else{ + // clear attr on while + node->GetOpDesc()->DelAttr("need_infer_again_"); + } + } return SUCCESS; } void clear() { iter_nodes_.clear(); } @@ -429,6 +445,7 @@ TEST_F(UTESTGraphPassesBasePass, dead_loop) { EXPECT_EQ(test_pass.GetRunTimes(), 1007); } */ + TEST_F(UTESTGraphPassesBasePass, while_loop) { NamesToPass names_to_pass; auto test_pass = UtestTestPass(true); @@ -438,4 +455,69 @@ TEST_F(UTESTGraphPassesBasePass, while_loop) { auto ge_pass = GEPass(graph); EXPECT_EQ(ge_pass.Run(names_to_pass), SUCCESS); } + +/// data1 const +/// \ / +/// while +/// / \ +/// | | +/// cast1 cast2 +ComputeGraphPtr BuildWhileGraph1() { + // build sub graph + auto builder_sub = ut::GraphBuilder("sub"); + auto data_1 = builder_sub.AddNode("data_1", DATA, 0, 1); + auto data_2 = builder_sub.AddNode("data_2", DATA, 0, 1); + auto add = builder_sub.AddNode("add", ADD, 2, 1); + + builder_sub.AddDataEdge(data_1, 0, add, 0); + builder_sub.AddDataEdge(data_2, 0, add, 1); + auto sub_graph = builder_sub.GetGraph(); + sub_graph->SetName("while_sub"); + // build root graph + auto builder = ut::GraphBuilder("g1"); + auto data = builder.AddNode("data1", DATA, 0, 1); + auto const_op = builder.AddNode("const_op", CONSTANT, 0, 1); + auto c1 = builder.AddNode("cast1", CAST, 1, 1); + auto c2 = builder.AddNode("cast2", CAST, 1, 1); + // add while op + auto tensor_desc = std::make_shared(); + tensor_desc->SetShape(GeShape({1,1,1,1})); + tensor_desc->SetFormat(FORMAT_ND); + tensor_desc->SetDataType(DT_INT32); + + auto op_desc = std::make_shared("while", WHILE); + for (int i = 0; i < 2; ++i) { + op_desc->AddInputDesc(tensor_desc->Clone()); + } + for (int i = 0; i < 2; ++i) { + op_desc->AddOutputDesc(tensor_desc->Clone()); + } + AttrUtils::SetBool(op_desc,"need_infer_again_", true); + op_desc->AddSubgraphName(sub_graph->GetName()); + op_desc->SetSubgraphInstanceName(0,sub_graph->GetName()); + auto root_graph = builder.GetGraph(); + auto while_op = root_graph->AddNode(op_desc); + + builder.AddDataEdge(data, 0, while_op, 0); + builder.AddDataEdge(const_op, 0, while_op, 1); + builder.AddDataEdge(while_op, 0, c1, 0); + builder.AddDataEdge(while_op, 1, c2, 0); + sub_graph->SetParentGraph(root_graph); + sub_graph->SetParentNode(while_op); + root_graph->AddSubgraph(sub_graph); + return root_graph; +} + +TEST_F(UTESTGraphPassesBasePass, while_infershape) { +NamesToPass names_to_pass; +auto test_pass = UtestTestPass(); +names_to_pass.push_back(std::make_pair("test", &test_pass)); + +auto graph = BuildWhileGraph1(); +auto ge_pass = GEPass(graph); +auto while_node = graph->FindNode("while"); +EXPECT_EQ(while_node->GetOpDesc()->GetSubgraphInstanceNames().size(),1); +EXPECT_EQ(ge_pass.Run(names_to_pass), SUCCESS); +} + } // namespace ge diff --git a/tests/ut/ge/graph/passes/link_gen_mask_nodes_pass_unittest.cc b/tests/ut/ge/graph/passes/link_gen_mask_nodes_pass_unittest.cc new file mode 100644 index 00000000..511ddece --- /dev/null +++ b/tests/ut/ge/graph/passes/link_gen_mask_nodes_pass_unittest.cc @@ -0,0 +1,111 @@ +/** + * 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 "graph/passes/link_gen_mask_nodes_pass.h" + + +#include +#include +#include + +#include "graph_builder_utils.h" + +namespace ge { +class UtestLinkGenMaskNodesPass : public testing::Test { + protected: + void SetUp() {} + void TearDown() {} +}; + +namespace { + /* + * do_mask1 do_mask2 do_mask3 do_mask4 do_mask5 do_mask6 + * \| \ / |/ |/ \ / |/ \| \ / |/ + * \ \ / | | \ / | | \ / | + * \ genmask1 | | genmask2 | | genmask3 | + * \ | | | | | | | | | | / + * ----------------------const1 and const2-------------------------- + */ +ut::GraphBuilder Graph1Builder() { + ut::GraphBuilder builder = ut::GraphBuilder("g1"); + auto const1 = builder.AddNode("const1", "Const", 0, 1); + auto const2 = builder.AddNode("const2", "Const", 0, 1); + auto gen_mask1 = builder.AddNode("gen_mask1", "DropOutGenMask", 2, 1); + auto gen_mask2 = builder.AddNode("gen_mask2", "DropOutGenMaskV3", 2, 1); + auto gen_mask3 = builder.AddNode("gen_mask3", "DropOutGenMaskV3D", 2, 1); + auto do_mask1 = builder.AddNode("do_mask1", "DropOutDoMask", 3, 1); + auto do_mask2 = builder.AddNode("do_mask2", "DropOutDoMask", 3, 1); + auto do_mask3 = builder.AddNode("do_mask3", "DropOutDoMask", 3, 1); + auto do_mask4 = builder.AddNode("do_mask4", "DropOutDoMask", 3, 1); + auto do_mask5 = builder.AddNode("do_mask5", "DropOutDoMask", 3, 1); + auto do_mask6 = builder.AddNode("do_mask6", "DropOutDoMask", 3, 1); + gen_mask1->GetOpDesc()->SetOpEngineName("DNN_HCCL"); + gen_mask2->GetOpDesc()->SetOpEngineName("DNN_HCCL"); + gen_mask3->GetOpDesc()->SetOpEngineName("DNN_HCCL"); + + builder.AddDataEdge(const1, 0, gen_mask1, 0); + builder.AddDataEdge(const1, 0, gen_mask2, 0); + builder.AddDataEdge(const1, 0, gen_mask3, 0); + builder.AddDataEdge(const1, 0, do_mask1, 0); + builder.AddDataEdge(const1, 0, do_mask2, 0); + builder.AddDataEdge(const1, 0, do_mask3, 0); + builder.AddDataEdge(const1, 0, do_mask4, 0); + builder.AddDataEdge(const1, 0, do_mask5, 0); + builder.AddDataEdge(const1, 0, do_mask6, 0); + builder.AddDataEdge(gen_mask1, 0, do_mask1, 1); + builder.AddDataEdge(gen_mask1, 0, do_mask2, 1); + builder.AddDataEdge(gen_mask2, 0, do_mask3, 1); + builder.AddDataEdge(gen_mask2, 0, do_mask4, 1); + builder.AddDataEdge(gen_mask3, 0, do_mask5, 1); + builder.AddDataEdge(gen_mask3, 0, do_mask6, 1); + builder.AddDataEdge(const2, 0, gen_mask1, 1); + builder.AddDataEdge(const2, 0, gen_mask2, 1); + builder.AddDataEdge(const2, 0, gen_mask3, 1); + builder.AddDataEdge(const2, 0, do_mask1, 2); + builder.AddDataEdge(const2, 0, do_mask2, 2); + builder.AddDataEdge(const2, 0, do_mask3, 2); + builder.AddDataEdge(const2, 0, do_mask4, 2); + builder.AddDataEdge(const2, 0, do_mask5, 2); + builder.AddDataEdge(const2, 0, do_mask6, 2); + return builder; +} +} // namespace + + +TEST_F(UtestLinkGenMaskNodesPass, link_gen_mask_nodes_pass_success) { + auto builder = Graph1Builder(); + auto graph = builder.GetGraph(); + + std::map stream_max_parallel_num; + stream_max_parallel_num["DNN_HCCL"] = 1; + LinkGenMaskNodesPass link_pass(stream_max_parallel_num); + Status ret = link_pass.Run(graph); + EXPECT_EQ(ret, SUCCESS); + + auto gen_mask2 = graph->FindNode("gen_mask2"); + EXPECT_NE(gen_mask2, nullptr); + + auto in_ctrl_nodes = gen_mask2->GetInControlNodes(); + EXPECT_EQ(in_ctrl_nodes.size(), 1); + auto in_ctrl_node = in_ctrl_nodes.at(0); + EXPECT_EQ(in_ctrl_node->GetName(), "gen_mask3"); + + auto out_ctrl_nodes = gen_mask2->GetOutControlNodes(); + EXPECT_EQ(out_ctrl_nodes.size(), 1); + auto out_ctrl_node = out_ctrl_nodes.at(0); + EXPECT_EQ(out_ctrl_node->GetName(), "gen_mask1"); +} +} // namespace ge diff --git a/tests/ut/ge/graph/passes/parallel_group_pass_unittest.cc b/tests/ut/ge/graph/passes/parallel_group_pass_unittest.cc new file mode 100644 index 00000000..d5b1db41 --- /dev/null +++ b/tests/ut/ge/graph/passes/parallel_group_pass_unittest.cc @@ -0,0 +1,304 @@ +/** + * 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 +#include + +#define private public + +#include "common/ge_inner_error_codes.h" +#include "inc/pass_manager.h" +#include "utils/graph_utils.h" +#include "graph/passes/parallel_group_pass.h" +#undef private + +namespace ge { +namespace { + +class UtestGraphPassesParallelGgroupPass : public testing::Test { + protected: + UtestGraphPassesParallelGgroupPass() { + graph_ = std::make_shared("test"); + sub_graph_ = std::make_shared("test_subgraph"); + vector shape_vec{1, 1, 1, 1}; + GeShape shape = GeShape(shape_vec); + default_tensor_desc_ = std::make_shared(); + default_tensor_desc_->SetShape(shape); + default_tensor_desc_->SetFormat(FORMAT_NCHW); + default_tensor_desc_->SetDataType(DT_FLOAT); + } + + NodePtr NewNode(const std::string &name, const std::string &type, + int input_cnt, int output_cnt, bool isSubgraph = false) { + OpDescPtr op_desc = std::make_shared(name, type); + for (int i = 0; i < input_cnt; ++i) { + op_desc->AddInputDesc(default_tensor_desc_->Clone()); + } + + for (int i = 0; i < output_cnt; ++i) { + op_desc->AddOutputDesc(default_tensor_desc_->Clone()); + } + NodePtr node = nullptr; + if (isSubgraph) { + node = sub_graph_->AddNode(op_desc); + (void)node->SetOwnerComputeGraph(sub_graph_); + } else { + node = graph_->AddNode(op_desc); + (void)node->SetOwnerComputeGraph(graph_); + } + + return node; + } + + void BuildDefaultGraph() { + /// input + /// \ + /// sqrt pred + /// \ / + /// cast + /// / \ + /// switch_t switch_f + /// | | + /// F T + /// | | + /// Merge + /// | + /// relu + /// | + /// sqrt1 + input_node_ = NewNode("input", RELU, 0, 1); + sqrt_node_ = NewNode("sqrt", SQRT, 1, 1); + pred_node_ = NewNode("pred", GREATER, 2, 1); + cast_node_ = NewNode("cast", CAST, 2, 2); + AttrUtils::SetStr(input_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + + switch_node_t = NewNode("switch_t", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node_t->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, true); + switch_node_f = NewNode("switch_f", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node_f->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, false); + output_false_node_ = NewNode("false_output", RELU, 1, 1); + AttrUtils::SetStr(output_false_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + output_true_node_ = NewNode("true_output", RELU, 1, 1); + AttrUtils::SetStr(output_true_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + merge_node_ = NewNode("merge", STREAMMERGE, 2, 1); + relu_node_ = NewNode("relu", RELU, 1, 1); + sqrt_node1_ = NewNode("sqrt1", SQRT, 1, 1); + AttrUtils::SetStr(sqrt_node1_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + + GraphUtils::AddEdge(input_node_->GetOutDataAnchor(0), sqrt_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(pred_node_->GetOutDataAnchor(0), cast_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(sqrt_node_->GetOutDataAnchor(0), cast_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(cast_node_->GetOutDataAnchor(0), switch_node_t->GetInDataAnchor(0)); + GraphUtils::AddEdge(cast_node_->GetOutDataAnchor(1), switch_node_f->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node_f->GetOutDataAnchor(0), output_false_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node_t->GetOutDataAnchor(0), output_true_node_->GetInDataAnchor(0)); + + GraphUtils::AddEdge(output_false_node_->GetOutDataAnchor(0), merge_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(output_true_node_->GetOutDataAnchor(0), merge_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(merge_node_->GetOutDataAnchor(0), relu_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(relu_node_->GetOutDataAnchor(0), sqrt_node1_->GetInDataAnchor(0)); + + output_false_node_->GetOpDesc()->SetIsInputConst({false}); + output_true_node_->GetOpDesc()->SetIsInputConst({false}); + } + + void BuildDefaultGraph1() { + /// input + /// \ + /// sqrt pred + /// \ / + /// Switch + /// | | + /// ----F T---- + /// \ | / \ + /// \ Merge1 Merge2 + /// \_________| + input_node_ = NewNode("input", RELU, 0, 1); + AttrUtils::SetStr(input_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + pred_node_ = NewNode("pred", GREATER, 2, 1); + sqrt_node_ = NewNode("sqrt", SQRT, 1, 1); + cast_node_ = NewNode("cast", CAST, 2, 2); + + switch_node_t = NewNode("switch_t", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node_t->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, true); + switch_node_f = NewNode("switch_f", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node_f->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, false); + output_false_node_ = NewNode("false_output", RELU, 1, 2); + AttrUtils::SetStr(output_false_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + output_true_node_ = NewNode("true_output", RELU, 1, 2); + AttrUtils::SetStr(output_true_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + merge_node_ = NewNode("merge", STREAMMERGE, 2, 1); + merge_node1_ = NewNode("merge1", STREAMMERGE, 2, 1); + + GraphUtils::AddEdge(input_node_->GetOutDataAnchor(0), sqrt_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(pred_node_->GetOutDataAnchor(0), cast_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(sqrt_node_->GetOutDataAnchor(0), cast_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(cast_node_->GetOutDataAnchor(0), switch_node_t->GetInDataAnchor(0)); + GraphUtils::AddEdge(cast_node_->GetOutDataAnchor(1), switch_node_f->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node_f->GetOutDataAnchor(0), output_false_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node_t->GetOutDataAnchor(0), output_true_node_->GetInDataAnchor(0)); + + GraphUtils::AddEdge(output_false_node_->GetOutDataAnchor(0), merge_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(output_true_node_->GetOutDataAnchor(0), merge_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(output_false_node_->GetOutDataAnchor(1), merge_node1_->GetInDataAnchor(0)); + GraphUtils::AddEdge(output_true_node_->GetOutDataAnchor(1), merge_node1_->GetInDataAnchor(1)); + + output_false_node_->GetOpDesc()->SetIsInputConst({false}); + output_true_node_->GetOpDesc()->SetIsInputConst({false}); + } + + + void BuildDefaultGraph2() { + /// input input1 + /// \ \ + /// sqrt pred sqrt1 pred1 + /// \ / \ / + /// Switch Switch1 + /// | | _______| + /// | | / + /// ____F T____ + /// \ | / \ + /// \ Merge1 Merge2 + /// \__________| + input_node_ = NewNode("input", RELU, 0, 2); + input_node1_ = NewNode("input_1", RELU, 0, 2); + sqrt_node_ = NewNode("sqrt", SQRT, 1, 1); + pred_node_ = NewNode("pred", GREATER, 2, 1); + sqrt_node1_ = NewNode("sqrt_1", SQRT, 1, 1); + pred_node1_ = NewNode("pred_1", LESS, 2, 1); + cast_node_ = NewNode("cast", CAST, 2, 2); + cast_node1_ = NewNode("cast_1", CAST, 2, 2); + AttrUtils::SetStr(input_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + AttrUtils::SetStr(input_node1_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "2"); + + switch_node_t = NewNode("switch_t", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node_t->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, true); + switch_node_f = NewNode("switch_f", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node_f->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, false); + switch_node1_t = NewNode("switch1_t", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node1_t->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, true); + switch_node1_f = NewNode("switch1_f", STREAMSWITCH, 1, 1); + AttrUtils::SetBool(switch_node1_f->GetOpDesc(), ATTR_NAME_SWITCH_TRUE_BRANCH_FLAG, false); + output_false_node_ = NewNode("false_output", RELU, 2, 2); + AttrUtils::SetStr(output_false_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + output_true_node_ = NewNode("true_output", RELU, 2, 2); + AttrUtils::SetStr(output_true_node_->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "2"); + merge_node_ = NewNode("merge", STREAMMERGE, 2, 1); + merge_node1_ = NewNode("merge1", STREAMMERGE, 2, 1); + + GraphUtils::AddEdge(input_node_->GetOutDataAnchor(0), sqrt_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(pred_node_->GetOutDataAnchor(0), cast_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(sqrt_node_->GetOutDataAnchor(0), cast_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(cast_node_->GetOutDataAnchor(0), switch_node_t->GetInDataAnchor(0)); + GraphUtils::AddEdge(cast_node_->GetOutDataAnchor(1), switch_node_f->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node_f->GetOutDataAnchor(0), output_false_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node_t->GetOutDataAnchor(0), output_true_node_->GetInDataAnchor(0)); + + GraphUtils::AddEdge(input_node1_->GetOutDataAnchor(0), sqrt_node1_->GetInDataAnchor(0)); + GraphUtils::AddEdge(pred_node1_->GetOutDataAnchor(0), cast_node1_->GetInDataAnchor(0)); + GraphUtils::AddEdge(sqrt_node1_->GetOutDataAnchor(0), cast_node1_->GetInDataAnchor(1)); + GraphUtils::AddEdge(cast_node1_->GetOutDataAnchor(0), switch_node1_t->GetInDataAnchor(0)); + GraphUtils::AddEdge(cast_node1_->GetOutDataAnchor(1), switch_node1_f->GetInDataAnchor(0)); + GraphUtils::AddEdge(switch_node1_f->GetOutDataAnchor(0), output_false_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(switch_node1_t->GetOutDataAnchor(0), output_true_node_->GetInDataAnchor(1)); + + GraphUtils::AddEdge(output_false_node_->GetOutDataAnchor(0), merge_node_->GetInDataAnchor(0)); + GraphUtils::AddEdge(output_true_node_->GetOutDataAnchor(0), merge_node_->GetInDataAnchor(1)); + GraphUtils::AddEdge(output_false_node_->GetOutDataAnchor(1), merge_node1_->GetInDataAnchor(0)); + GraphUtils::AddEdge(output_true_node_->GetOutDataAnchor(1), merge_node1_->GetInDataAnchor(1)); + + output_false_node_->GetOpDesc()->SetIsInputConst({false}); + output_true_node_->GetOpDesc()->SetIsInputConst({false}); + } + + ComputeGraphPtr graph_; + ComputeGraphPtr sub_graph_; + GeTensorDescPtr default_tensor_desc_; + ParallelGroupPass pass_; + NodePtr pred_node_; + NodePtr pred_node1_; + NodePtr cast_node_; + NodePtr cast_node1_; + NodePtr sqrt_node_; + NodePtr sqrt_node1_; + NodePtr input_node_; + NodePtr input_node1_; + NodePtr switch_node_t; + NodePtr switch_node_f; + NodePtr switch_node1_t; + NodePtr switch_node1_f; + NodePtr output_false_node_; + NodePtr output_true_node_; + NodePtr merge_node_; + NodePtr merge_node1_; + NodePtr relu_node_; +}; + +TEST_F(UtestGraphPassesParallelGgroupPass, null_graph) { + ComputeGraphPtr graph = nullptr; + auto ret = pass_.Run(graph); + EXPECT_EQ(ret, PARAM_INVALID); +} + +TEST_F(UtestGraphPassesParallelGgroupPass, normal_graph) { + BuildDefaultGraph(); + auto ret = pass_.Run(graph_); + EXPECT_EQ(ret, GRAPH_SUCCESS); + EXPECT_EQ(true, input_node_->GetOutControlAnchor()->IsLinkedWith(cast_node_->GetInControlAnchor())); + EXPECT_EQ(true, merge_node_->GetOutControlAnchor()->IsLinkedWith(sqrt_node1_->GetInControlAnchor())); + EXPECT_EQ(false, output_false_node_->GetOutControlAnchor()->IsLinkedWith(output_true_node_->GetInControlAnchor())); +} + +TEST_F(UtestGraphPassesParallelGgroupPass, normal_graph1) { + BuildDefaultGraph1(); + auto ret = pass_.Run(graph_); + EXPECT_EQ(ret, GRAPH_SUCCESS); + EXPECT_EQ(true, input_node_->GetOutControlAnchor()->IsLinkedWith(cast_node_->GetInControlAnchor())); +} + +TEST_F(UtestGraphPassesParallelGgroupPass, normal_graph2) { + BuildDefaultGraph2(); + auto ret = pass_.Run(graph_); + EXPECT_EQ(ret, GRAPH_SUCCESS); + EXPECT_EQ(true, input_node_->GetOutControlAnchor()->IsLinkedWith(cast_node_->GetInControlAnchor())); + EXPECT_EQ(true, input_node1_->GetOutControlAnchor()->IsLinkedWith(cast_node1_->GetInControlAnchor())); +} + +TEST_F(UtestGraphPassesParallelGgroupPass, normal_subgraph) { + BuildDefaultGraph1(); + NodePtr input_node1 = NewNode("input1", RELU, 0, 1, true); + NodePtr input_node2 = NewNode("input2", RELU, 0, 1, true); + NodePtr add = NewNode("add", ADD, 2, 1, true); + AttrUtils::SetStr(input_node1->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + AttrUtils::SetStr(input_node2->GetOpDesc(), ATTR_NAME_PARALLEL_GROUP, "1"); + + sub_graph_->SetParentNode(input_node_); + sub_graph_->SetParentGraph(graph_); + auto ret = graph_->AddSubgraph(sub_graph_->GetName(), sub_graph_); + EXPECT_EQ(ret, GRAPH_SUCCESS); + ret = input_node_->GetOpDesc()->AddSubgraphName(sub_graph_->GetName()); + EXPECT_EQ(ret, GRAPH_SUCCESS); + ret = input_node_->GetOpDesc()->SetSubgraphInstanceName(0, sub_graph_->GetName()); + EXPECT_EQ(ret, GRAPH_SUCCESS); + ret = pass_.Run(sub_graph_); + EXPECT_EQ(ret, GRAPH_SUCCESS); + ret = pass_.Run(graph_); + EXPECT_EQ(ret, GRAPH_SUCCESS); +} + +} // namespace +} // namespace ge diff --git a/tests/ut/ge/graph/passes/transpose_transdata_pass_unittest.cc b/tests/ut/ge/graph/passes/transpose_transdata_pass_unittest.cc new file mode 100644 index 00000000..07919dc6 --- /dev/null +++ b/tests/ut/ge/graph/passes/transpose_transdata_pass_unittest.cc @@ -0,0 +1,67 @@ +/** + * 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/passes/transpose_transdata_pass.h" +#include "graph_builder_utils.h" +#undef private +#undef protected + +#include "graph/graph.h" +#include "common/ge_inner_error_codes.h" +#include "common/types.h" +#include "graph/debug/ge_attr_define.h" + +namespace ge { +class UtestGraphPassesTransposeTransdataPass : public testing::Test { + protected: + void SetUp() {} + void TearDown() {} +}; + +static ComputeGraphPtr BuildGraphTransposeD() { + auto builder = ut::GraphBuilder("g1"); + auto transdata1 = builder.AddNode("transdata1", "TransData", 1, 1, FORMAT_NC1HWC0, DT_FLOAT, std::vector({1, 1, 224, 224, 16})); + transdata1->GetOpDesc()->MutableOutputDesc(0)->SetFormat(FORMAT_NHWC); + transdata1->GetOpDesc()->MutableOutputDesc(0)->SetShape(GeShape(std::vector({1, 224, 224, 3}))); + + auto transpose1 = builder.AddNode("transpose1", "TransposeD", 1, 1, FORMAT_NCHW, DT_FLOAT, std::vector({1, 3, 224, 224})); + transpose1->GetOpDesc()->MutableInputDesc(0)->SetFormat(FORMAT_NHWC); + transpose1->GetOpDesc()->MutableInputDesc(0)->SetShape(GeShape(std::vector({1, 224, 224, 3}))); + + auto transdata2 = builder.AddNode("transdata2", "TransData", 1, 1, FORMAT_NCHW, DT_FLOAT, std::vector({1, 3, 224, 224})); + transdata2->GetOpDesc()->MutableOutputDesc(0)->SetFormat(FORMAT_NC1HWC0); + transdata2->GetOpDesc()->MutableOutputDesc(0)->SetShape(GeShape(std::vector({1, 1, 224, 224, 16}))); + + builder.AddDataEdge(transdata1, 0, transpose1, 0); + builder.AddDataEdge(transpose1, 0, transdata2, 0); + + return builder.GetGraph(); +} + +TEST_F(UtestGraphPassesTransposeTransdataPass, test_run) { + auto compute_graph = BuildGraphTransposeD(); + compute_graph->SetSessionID(0); + + auto transpose = compute_graph->FindNode("transpose1"); + TransposeTransDataPass pass; + EXPECT_EQ(pass.Run(transpose), SUCCESS); +} +} // namespace ge diff --git a/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc b/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc index 2f149761..69192631 100644 --- a/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc +++ b/tests/ut/ge/graph/preprocess/graph_preprocess_unittest.cc @@ -74,4 +74,18 @@ TEST_F(UtestGraphPreproces, test_dynamic_input_shape_parse) { EXPECT_EQ(result_shape.GetDim(i), expect_shape.at(i)); } } + +TEST_F(UtestGraphPreproces, test_check_user_input) { + ge::GraphPrepare graph_prepare; + graph_prepare.compute_graph_ = BuildGraph1(); + + vector dim = {2, -3}; + GeTensor tensor; + tensor.SetTensorDesc(GeTensorDesc(GeShape(dim))); + std::vector user_input; + user_input.emplace_back(tensor); + + Status ret = graph_prepare.CheckUserInput(user_input); + EXPECT_EQ(ret, GE_GRAPH_INIT_FAILED); +} } \ No newline at end of file diff --git a/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc b/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc new file mode 100644 index 00000000..dd6b1881 --- /dev/null +++ b/tests/ut/ge/graph_ir/ge_ir_build_unittest.cc @@ -0,0 +1,110 @@ +/** + * 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 "ir_build/atc_ir_common.h" +#include "graph/testcase/ge_graph/graph_builder_utils.h" + +#define protected public +#define private public + +#undef private +#undef protected + +const string DATA = "Data"; +const string AddNYes = "AddNYes"; +const string NETOUTPUT = "NetOutput"; + +using namespace ge; +class UtestIrCommon : public testing::Test { + protected: + void SetUp() {} + + void TearDown() {} +}; + +static ge::OpDescPtr CreateOpDesc(const std::string &name, const std::string &type) { + OpDescPtr op_desc = std::make_shared(name, type); + ge::GeTensorDesc ge_tensor_desc; + op_desc->AddInputDesc("input", ge_tensor_desc); + op_desc->AddOutputDesc("output", ge_tensor_desc); + + return op_desc; +} + +static ComputeGraphPtr BuildComputeGraph() { + auto builder = ut::GraphBuilder("test"); + auto data1 = builder.AddNode("input1", DATA, 1, 1, FORMAT_NCHW, DT_FLOAT, {1, 2, 3}); + auto data2 = builder.AddNode("input2", DATA, 1, 1, FORMAT_NCHW, DT_FLOAT, {4, 10}); + auto addn1 = builder.AddNode("addn1", AddNYes, 2, 1); + auto netoutput = builder.AddNode("netoutput", NETOUTPUT, 1, 0); + + builder.AddDataEdge(data1, 0, addn1, 0); + builder.AddDataEdge(data2, 0, addn1, 1); + builder.AddDataEdge(addn1, 0,netoutput, 0); + + return builder.GetGraph(); +} + +TEST(UtestIrCommon, update_data_op_shape) { + ge::OpDescPtr op_desc = CreateOpDesc("Data", "Data"); + map> shape_map; + shape_map["Data"] = {{1,2}}; + + Status ret = UpdateDataOpShape(op_desc, shape_map); + EXPECT_EQ(ret, ge::SUCCESS); +} + +TEST(UtestIrCommon, update_dynamic_shape_range_success) { + ComputeGraphPtr graph = BuildComputeGraph(); + std::string input_shape_range = "input1:[1, 2~3, -1];input2:[3~5, 10]"; + + Status ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::SUCCESS); +} + +TEST(UtestIrCommon, update_dynamic_shape_range_failed) { + ComputeGraphPtr graph = BuildComputeGraph(); + // 1 + std::string input_shape_range = "input1;[1, 2~3, -1]"; + Status ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::PARAM_INVALID); + + // 2 + input_shape_range = "input1:[1, 2~3, -1)"; + ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::PARAM_INVALID); + + //3 + input_shape_range = "input1:[1, 3~2, -1];input2:[3~5, 10]"; + ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::FAILED); + + //4 + input_shape_range = "input1:[1, 2~-3, -1]"; + ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::PARAM_INVALID); + + //5 + input_shape_range = "input:[1, 2~3, -1]"; + ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::PARAM_INVALID); + + //6 + input_shape_range = "addn1:[1, 2~3, -1]"; + ret = UpdateDynamicInputShapeRange(graph, input_shape_range); + EXPECT_EQ(ret, ge::PARAM_INVALID); +} diff --git a/tests/ut/ge/hybrid/ge_hybrid_unittest.cc b/tests/ut/ge/hybrid/ge_hybrid_unittest.cc index 0b6ca271..3b5d19e6 100644 --- a/tests/ut/ge/hybrid/ge_hybrid_unittest.cc +++ b/tests/ut/ge/hybrid/ge_hybrid_unittest.cc @@ -15,8 +15,8 @@ */ #include +#include #include - #include "runtime/rt.h" #define protected public @@ -25,15 +25,18 @@ #include "hybrid/model/hybrid_model.h" #include "model/ge_model.h" #include "model/ge_root_model.h" - #include "hybrid/node_executor/aicore/aicore_op_task.h" #include "framework/common/taskdown_common.h" #include "framework/common/debug/log.h" #include "graph/ge_context.h" #include "hybrid/executor/hybrid_execution_context.h" +#include "hybrid/executor/hybrid_model_executor.h" #include "hybrid/node_executor/aicore/aicore_task_builder.h" #include "graph/load/model_manager/tbe_handle_store.h" +#include "graph/manager/graph_mem_allocator.h" +#include "hybrid/common/npu_memory_allocator.h" #include "graph/types.h" +#include "graph/utils/tensor_utils.h" #undef private #undef protected @@ -43,6 +46,7 @@ using namespace testing; using namespace ge; using namespace hybrid; + class UtestGeHybrid : public testing::Test { protected: void SetUp() {} @@ -152,6 +156,20 @@ TEST_F(UtestGeHybrid, index_taskdefs_failed) { ASSERT_EQ(hybrid_model_builder.IndexTaskDefs(graph, ge_model), INTERNAL_ERROR); } +TEST_F(UtestGeHybrid, parse_force_infershape_nodes) { + const char *const kForceInfershape = "_force_infershape_when_running"; + auto graph = make_shared("graph"); + OpDescPtr op_desc = CreateOpDesc("Conv2D", "Conv2D"); + ge::AttrUtils::SetBool(op_desc, kForceInfershape, true); + auto node = graph->AddNode(op_desc); + std::unique_ptr new_node; + NodeItem::Create(node, new_node); + GeRootModelPtr ge_root_model = make_shared(graph); + HybridModel hybrid_model(ge_root_model); + HybridModelBuilder hybrid_model_builder(hybrid_model); + ASSERT_EQ(hybrid_model_builder.ParseForceInfershapeNodes(node, *new_node), SUCCESS); +} + TEST_F(UtestGeHybrid, index_taskdefs_success) { // build aicore task domi::ModelTaskDef model_task_def; @@ -190,4 +208,51 @@ TEST_F(UtestGeHybrid, index_taskdefs_success) { HybridModelBuilder hybrid_model_builder(hybrid_model); ASSERT_EQ(hybrid_model_builder.IndexTaskDefs(graph, ge_model), SUCCESS); -} \ No newline at end of file +} + +TEST_F(UtestGeHybrid, init_weight_success) { + NpuMemoryAllocator::allocators_.emplace(make_pair(0, nullptr)); + // make graph with sub_graph + ComputeGraphPtr graph = std::make_shared("root_graph"); + OpDescPtr op_desc = CreateOpDesc("if", IF); + NodePtr node = graph->AddNode(op_desc); + // make sub graph + ComputeGraphPtr sub_graph = std::make_shared("if_sub_graph"); + OpDescPtr const_op_desc = CreateOpDesc("const", CONSTANT); + vector dims_vec_0 = {2, 1, 4, 1, 2}; + vector data_vec_0 = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16}; + GeTensorDesc tensor_desc_0(GeShape(dims_vec_0), FORMAT_NCHW, DT_INT32); + (void)TensorUtils::SetRealDimCnt(tensor_desc_0, dims_vec_0.size()); + ConstGeTensorPtr constTensor_0 = + std::make_shared(tensor_desc_0, (uint8_t *)&data_vec_0[0], data_vec_0.size() * sizeof(int32_t)); + AttrUtils::SetTensor(const_op_desc, ge::ATTR_NAME_WEIGHTS, constTensor_0); + const_op_desc->AddOutputDesc(tensor_desc_0); + NodePtr const_node = sub_graph->AddNode(const_op_desc); + graph->AddSubgraph("sub", sub_graph); + + GeRootModelPtr ge_root_model = make_shared(graph); + GeModelPtr ge_sub_model = make_shared(); + //Buffer weight_buffer = Buffer(128,0); + //ge_sub_model->SetWeight(weight_buffer); + ge_root_model->SetSubgraphInstanceNameToModel("sub",ge_sub_model); + HybridModel hybrid_model(ge_root_model); + HybridModelBuilder hybrid_model_builder(hybrid_model); + auto ret = hybrid_model_builder.InitWeights(); + ASSERT_EQ(ret,SUCCESS); + Buffer weight_buffer = Buffer(128,0); + ge_sub_model->SetWeight(weight_buffer); + ret = hybrid_model_builder.InitWeights(); + ASSERT_EQ(ret,PARAM_INVALID); +} + + TEST_F(UtestGeHybrid, hybrid_model_executor) { + ComputeGraphPtr compute_graph = MakeShared("abc"); + GeRootModelPtr root_model = MakeShared(compute_graph); + HybridModel model(root_model); + HybridModel *model_ptr = &model; + + uint32_t device_id = 0; + rtStream_t stream; + HybridModelExecutor executor(model_ptr, device_id, stream); + executor.Init(); +} 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 eaf4564a..dadabaf6 100644 --- a/tests/ut/ge/single_op/single_op_model_unittest.cc +++ b/tests/ut/ge/single_op/single_op_model_unittest.cc @@ -17,7 +17,6 @@ #include #include -//#include "cce/taskdown_common.hpp" #include "graph/load/model_manager/model_utils.h" #include "graph/utils/graph_utils.h" #include "runtime/rt.h" @@ -196,4 +195,31 @@ TEST_F(UtestSingleOpModel, test_op_task_get_profiler_args) { ASSERT_EQ(model_id, 1); } +TEST_F(UtestSingleOpModel, test_build_dynamic_op) { + string model_data_str = "123456789"; + SingleOpModel model("model", model_data_str.c_str(), model_data_str.size()); + model.netoutput_op_ = make_shared("NetOutput", "NetOutput"); + model.model_helper_.model_ = ge::MakeShared(); + + // make graph + auto compute_graph = make_shared("graph"); + auto data_op = make_shared("Data", DATA); + auto data_node = compute_graph->AddNode(data_op); + auto graph = GraphUtils::CreateGraphFromComputeGraph(compute_graph); + model.model_helper_.model_->SetGraph(graph); + + // set task_def + auto model_task_def = make_shared(); + domi::TaskDef *task_def = model_task_def->add_task(); + task_def->set_type(RT_MODEL_TASK_KERNEL); + domi::KernelDef *kernel_def = task_def->mutable_kernel(); + domi::KernelContext *context = kernel_def->mutable_context(); + context->set_kernel_type(2); // ccKernelType::TE + model.model_helper_.model_->SetModelTaskDef(model_task_def); + + std::mutex stream_mu_; + DynamicSingleOp dynamic_single_op(0, &stream_mu_, nullptr); + StreamResource res((uintptr_t)1); + model.BuildDynamicOp(res, dynamic_single_op); +} diff --git a/third_party/fwkacllib/inc/runtime/rt_model.h b/third_party/fwkacllib/inc/runtime/rt_model.h index 798f63ae..6481f655 100644 --- a/third_party/fwkacllib/inc/runtime/rt_model.h +++ b/third_party/fwkacllib/inc/runtime/rt_model.h @@ -285,10 +285,27 @@ typedef struct tagTaskInfo { } u; } rtTaskInfo_t; +typedef struct tagNodeInfo_t { + uint32_t nodeIdx; + uint32_t reserved[1]; +} rtNodeInfo; + +typedef struct tagHwtsInfo_t { + uint16_t taskId; + uint16_t sqExeHead; + uint16_t streamExeHead; + uint16_t reserved[2]; +} rtHwtsInfo; + typedef struct tagLabelDevInfo_t { uint16_t modelId; uint16_t streamId; uint16_t labelId; + union { + rtNodeInfo nodeInfo; + rtHwtsInfo hwtsInfo; + uint16_t reserved[5]; + }u; }rtLabelDevInfo; typedef rtError_t (*rtTaskGenCallback)(rtModel_t model, rtTaskInfo_t *taskInfo);