| @@ -474,9 +474,6 @@ set(INFER_SRC_LIST | |||||
| "common/ge/plugin_manager.cc" | "common/ge/plugin_manager.cc" | ||||
| "common/ge/op_tiling_manager.cc" | "common/ge/op_tiling_manager.cc" | ||||
| "init/gelib.cc" | "init/gelib.cc" | ||||
| "session/inner_session.cc" | |||||
| "session/session_manager.cc" | |||||
| "graph/execute/model_executor.cc" | |||||
| "engine_manager/dnnengine_manager.cc" | "engine_manager/dnnengine_manager.cc" | ||||
| "opskernel_manager/ops_kernel_manager.cc" | "opskernel_manager/ops_kernel_manager.cc" | ||||
| "opskernel_manager/ops_kernel_builder_manager.cc" | "opskernel_manager/ops_kernel_builder_manager.cc" | ||||
| @@ -721,6 +718,12 @@ set(INFER_SRC_LIST | |||||
| "ge_opt_info/ge_opt_info.cc" | "ge_opt_info/ge_opt_info.cc" | ||||
| ) | ) | ||||
| set(RUNNER_SRC_LIST | |||||
| "client/ge_api.cc" | |||||
| "session/inner_session.cc" | |||||
| "session/session_manager.cc" | |||||
| ) | |||||
| if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | if (NOT ENABLE_D AND NOT ENABLE_ACL AND NOT ENABLE_MS_TESTCASES) | ||||
| message("CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}") | message("CMAKE_CXX_COMPILER_VERSION = ${CMAKE_CXX_COMPILER_VERSION}") | ||||
| ############ libge_runner.so ############ | ############ libge_runner.so ############ | ||||
| @@ -47,6 +47,7 @@ const int32_t kMaxStrLen = 128; | |||||
| static bool g_ge_initialized = false; | static bool g_ge_initialized = false; | ||||
| static std::mutex g_ge_release_mutex; // GEFinalize and ~Session use | static std::mutex g_ge_release_mutex; // GEFinalize and ~Session use | ||||
| static std::shared_ptr<ge::SessionManager> g_session_manager; | |||||
| namespace ge { | namespace ge { | ||||
| void GetOpsProtoPath(std::string &opsproto_path) { | void GetOpsProtoPath(std::string &opsproto_path) { | ||||
| @@ -148,6 +149,22 @@ Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther); | |||||
| GELOGI("sessionManager initial."); | |||||
| GE_TIMESTAMP_START(SessionManagerInitialize); | |||||
| g_session_manager = MakeShared<ge::SessionManager>(); | |||||
| if (g_session_manager == nullptr) { | |||||
| GELOGE(GE_CLI_INIT_FAILED, "[Init][Create]SessionManager failed"); | |||||
| return FAILED; | |||||
| } | |||||
| ret = g_session_manager->Initialize(options); | |||||
| GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize"); | |||||
| if (ret != SUCCESS) { | |||||
| GELOGE(ret, "[Init][SessionManager] GE session manager initial failed."); | |||||
| REPORT_CALL_ERROR("E19999", "SessionManager initialize failed."); | |||||
| return ret; | |||||
| } | |||||
| // 7.check return status, return | // 7.check return status, return | ||||
| if (!g_ge_initialized) { | if (!g_ge_initialized) { | ||||
| // Initialize success, first time calling initialize | // Initialize success, first time calling initialize | ||||
| @@ -217,6 +234,12 @@ Status GEFinalize() { | |||||
| ret = middle_ret; | ret = middle_ret; | ||||
| } | } | ||||
| } | } | ||||
| GELOGI("SessionManager finalization."); | |||||
| if (g_session_manager != nullptr) { | |||||
| (void)g_session_manager->Finalize(); // always success. | |||||
| } | |||||
| middle_ret = TBEPluginManager::Instance().Finalize(); | middle_ret = TBEPluginManager::Instance().Finalize(); | ||||
| if (middle_ret != SUCCESS) { | if (middle_ret != SUCCESS) { | ||||
| ret = middle_ret; | ret = middle_ret; | ||||
| @@ -272,7 +295,7 @@ Session::Session(const std::map<string, string> &options) { | |||||
| GELOGT(TRACE_RUNNING, "Creating session"); | GELOGT(TRACE_RUNNING, "Creating session"); | ||||
| uint64_t session_id = 0; | uint64_t session_id = 0; | ||||
| Status ret = instance_ptr->SessionManagerObj().CreateSession(options, session_id); | |||||
| Status ret = g_session_manager->CreateSession(options, session_id); | |||||
| GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); | GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); | ||||
| // check return status, return, update session id if success | // check return status, return, update session id if success | ||||
| @@ -321,7 +344,7 @@ Session::Session(const std::map<AscendString, AscendString> &options) { | |||||
| str_options[key] = val; | str_options[key] = val; | ||||
| } | } | ||||
| uint64_t session_id = 0; | uint64_t session_id = 0; | ||||
| Status ret = instance_ptr->SessionManagerObj().CreateSession(str_options, session_id); | |||||
| Status ret = g_session_manager->CreateSession(str_options, session_id); | |||||
| GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); | GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); | ||||
| // check return status, return, update session id if success | // check return status, return, update session id if success | ||||
| @@ -359,7 +382,7 @@ Session::~Session() { | |||||
| GELOGT(TRACE_RUNNING, "Destroying session"); | GELOGT(TRACE_RUNNING, "Destroying session"); | ||||
| ret = instance_ptr->SessionManagerObj().DestroySession(session_id); | |||||
| ret = g_session_manager->DestroySession(session_id); | |||||
| } catch (google::protobuf::FatalException &e) { | } catch (google::protobuf::FatalException &e) { | ||||
| GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destruct][Session]Failed " | GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destruct][Session]Failed " | ||||
| "because get fatalException."); | "because get fatalException."); | ||||
| @@ -397,7 +420,7 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<s | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGD("Adding graph to session"); | GELOGD("Adding graph to session"); | ||||
| Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, options); | |||||
| Status ret = g_session_manager->AddGraph(sessionId_, graph_id, graph, options); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
| @@ -435,7 +458,7 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, | |||||
| std::string val = option.second.GetString(); | std::string val = option.second.GetString(); | ||||
| str_options[key] = val; | str_options[key] = val; | ||||
| } | } | ||||
| Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); | |||||
| Status ret = g_session_manager->AddGraph(sessionId_, graph_id, graph, str_options); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
| @@ -472,7 +495,7 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, | |||||
| str_options.insert({it->first.GetString(), it->second.GetString()}); | str_options.insert({it->first.GetString(), it->second.GetString()}); | ||||
| } | } | ||||
| GELOGD("Adding graph to session"); | GELOGD("Adding graph to session"); | ||||
| Status ret = instance_ptr->SessionManagerObj().AddGraphWithCopy(sessionId_, graph_id, graph, str_options); | |||||
| Status ret = g_session_manager->AddGraphWithCopy(sessionId_, graph_id, graph, str_options); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
| @@ -502,7 +525,7 @@ Status Session::RemoveGraph(uint32_t graph_id) { | |||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Removing Graph from session"); | GELOGT(TRACE_RUNNING, "Removing Graph from session"); | ||||
| Status ret = instance_ptr->SessionManagerObj().RemoveGraph(sessionId_, graph_id); | |||||
| Status ret = g_session_manager->RemoveGraph(sessionId_, graph_id); | |||||
| // check return status, return | // check return status, return | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| @@ -583,7 +606,7 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Running Graph"); | GELOGT(TRACE_RUNNING, "Running Graph"); | ||||
| Status ret = instance_ptr->SessionManagerObj().RunGraph(sessionId_, graph_id, graph_inputs, outputs); | |||||
| Status ret = g_session_manager->RunGraph(sessionId_, graph_id, graph_inputs, outputs); | |||||
| // check return status | // check return status | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| @@ -631,7 +654,7 @@ Status Session::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const s | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Run Graph Run graph with stream asyn."); | GELOGT(TRACE_RUNNING, "Run Graph Run graph with stream asyn."); | ||||
| Status ret = instance_ptr->SessionManagerObj().RunGraphWithStreamAsync(sessionId_, graph_id, stream, inputs, | |||||
| Status ret = g_session_manager->RunGraphWithStreamAsync(sessionId_, graph_id, stream, inputs, | |||||
| outputs); | outputs); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "[Run][Graph]Run graph with stream asyn Failed," | GELOGE(ret, "[Run][Graph]Run graph with stream asyn Failed," | ||||
| @@ -648,7 +671,7 @@ Status Session::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const s | |||||
| // Register Call Back | // Register Call Back | ||||
| Status Session::RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback) { | Status Session::RegisterCallBackFunc(const std::string &key, const pCallBackFunc &callback) { | ||||
| ErrorManager::GetInstance().GenWorkStreamIdDefault(); | ErrorManager::GetInstance().GenWorkStreamIdDefault(); | ||||
| return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, key, callback); | |||||
| return g_session_manager->RegisterCallBackFunc(sessionId_, key, callback); | |||||
| } | } | ||||
| Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback) { | Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFunc &callback) { | ||||
| @@ -657,7 +680,7 @@ Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFu | |||||
| if (key != nullptr) { | if (key != nullptr) { | ||||
| str_key = key; | str_key = key; | ||||
| } | } | ||||
| return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); | |||||
| return g_session_manager->RegisterCallBackFunc(sessionId_, str_key, callback); | |||||
| } | } | ||||
| // Build Graph | // Build Graph | ||||
| @@ -675,7 +698,7 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Building Graph"); | GELOGT(TRACE_RUNNING, "Building Graph"); | ||||
| Status ret = instance_ptr->SessionManagerObj().BuildGraph(sessionId_, graph_id, inputs); | |||||
| Status ret = g_session_manager->BuildGraph(sessionId_, graph_id, inputs); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
| @@ -702,7 +725,7 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inp | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Building Graph"); | GELOGT(TRACE_RUNNING, "Building Graph"); | ||||
| Status ret = instance_ptr->SessionManagerObj().BuildGraph(sessionId_, graph_id, inputs); | |||||
| Status ret = g_session_manager->BuildGraph(sessionId_, graph_id, inputs); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, | GELOGE(ret, | ||||
| "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
| @@ -733,7 +756,7 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<ge::Tensor> & | |||||
| GELOGW( | GELOGW( | ||||
| "The callback function will not be checked. Please ensure that the implementation of the function is trusted."); | "The callback function will not be checked. Please ensure that the implementation of the function is trusted."); | ||||
| Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); | |||||
| Status ret = g_session_manager->RunGraphAsync(sessionId_, graph_id, inputs, callback); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "[Run][Graph]RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u.", | GELOGE(ret, "[Run][Graph]RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u.", | ||||
| ret, sessionId_, graph_id); | ret, sessionId_, graph_id); | ||||
| @@ -757,7 +780,7 @@ Status Session::GetVariables(const std::vector<std::string> &var_names, std::vec | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Get Variables"); | GELOGT(TRACE_RUNNING, "Get Variables"); | ||||
| Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, var_names, var_values); | |||||
| Status ret = g_session_manager->GetVariables(sessionId_, var_names, var_values); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); | GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); | ||||
| return FAILED; | return FAILED; | ||||
| @@ -787,7 +810,7 @@ Status Session::GetVariables(const std::vector<AscendString> &var_names, std::ve | |||||
| } | } | ||||
| str_var_names.emplace_back(var_name.GetString()); | str_var_names.emplace_back(var_name.GetString()); | ||||
| } | } | ||||
| Status ret = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); | |||||
| Status ret = g_session_manager->GetVariables(sessionId_, str_var_names, var_values); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); | GELOGE(ret, "[Get][Variables]Failed, error code:%u, session_id:%lu.", ret, sessionId_); | ||||
| REPORT_CALL_ERROR("E19999", "Get variables failed, error code:%u, session_id:%lu.", | REPORT_CALL_ERROR("E19999", "Get variables failed, error code:%u, session_id:%lu.", | ||||
| @@ -798,6 +821,6 @@ Status Session::GetVariables(const std::vector<AscendString> &var_names, std::ve | |||||
| } | } | ||||
| bool Session::IsGraphNeedRebuild(uint32_t graph_id) { | bool Session::IsGraphNeedRebuild(uint32_t graph_id) { | ||||
| return ge::GELib::GetInstance()->SessionManagerObj().IsGraphNeedRebuild(sessionId_, graph_id); | |||||
| return g_session_manager->IsGraphNeedRebuild(sessionId_, graph_id); | |||||
| } | } | ||||
| } // namespace ge | } // namespace ge | ||||
| @@ -23,6 +23,7 @@ | |||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| #include "graph/utils/tensor_adapter.h" | #include "graph/utils/tensor_adapter.h" | ||||
| #include "graph/load/graph_loader.h" | #include "graph/load/graph_loader.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | |||||
| #include "common/math/math_util.h" | #include "common/math/math_util.h" | ||||
| #include "common/formats/utils/formats_trans_utils.h" | #include "common/formats/utils/formats_trans_utils.h" | ||||
| @@ -38,7 +39,7 @@ namespace ge { | |||||
| /// @param [in] options user config params | /// @param [in] options user config params | ||||
| /// @return Status result of function | /// @return Status result of function | ||||
| /// | /// | ||||
| Status ModelExecutor::Initialize(const map<string, string> &options) { | |||||
| Status ModelExecutor::Initialize(const map<string, string> &options, uint64_t session_id) { | |||||
| graph_run_listener_ = MakeShared<GraphModelListener>(sync_run_mutex_, condition_); | graph_run_listener_ = MakeShared<GraphModelListener>(sync_run_mutex_, condition_); | ||||
| if (graph_run_listener_ == nullptr) { | if (graph_run_listener_ == nullptr) { | ||||
| REPORT_CALL_ERROR("E19999", "New GraphModelListener fail"); | REPORT_CALL_ERROR("E19999", "New GraphModelListener fail"); | ||||
| @@ -46,6 +47,14 @@ Status ModelExecutor::Initialize(const map<string, string> &options) { | |||||
| return MEMALLOC_FAILED; | return MEMALLOC_FAILED; | ||||
| } | } | ||||
| auto model_manager = ModelManager::GetInstance(); | |||||
| GE_CHECK_NOTNULL(model_manager); | |||||
| GE_IF_BOOL_EXEC(model_manager->EnableExceptionDump(options) != SUCCESS, | |||||
| REPORT_CALL_ERROR("E19999", "ModelManager EnableExceptionDump failed."); | |||||
| GELOGE(FAILED, "[Enable][ExceptionDump] failed."); | |||||
| return FAILED); | |||||
| session_id_ = session_id; | |||||
| train_graph_flag_ = ParseTrainGraphFlag(); | train_graph_flag_ = ParseTrainGraphFlag(); | ||||
| thread_run_flag_.store(true); | thread_run_flag_.store(true); | ||||
| run_thread_ = std::thread(&ModelExecutor::RunThread, this); | run_thread_ = std::thread(&ModelExecutor::RunThread, this); | ||||
| @@ -74,6 +83,7 @@ Status ModelExecutor::Finalize() { | |||||
| GELOGW("Graph executor FreeExecuteMemory failed, resources may not be released correctly."); | GELOGW("Graph executor FreeExecuteMemory failed, resources may not be released correctly."); | ||||
| } | } | ||||
| ModelManager::GetInstance()->DestroyAicpuSession(session_id_); | |||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| @@ -30,7 +30,7 @@ class ModelExecutor : public Executor { | |||||
| /// @param [in] options user config params | /// @param [in] options user config params | ||||
| /// @return Status result of function | /// @return Status result of function | ||||
| /// | /// | ||||
| Status Initialize(const map<string, string> &options); | |||||
| Status Initialize(const map<string, string> &options, uint64_t session_id); | |||||
| /// | /// | ||||
| /// @ingroup ge | /// @ingroup ge | ||||
| @@ -120,6 +120,7 @@ class ModelExecutor : public Executor { | |||||
| bool init_flag_{false}; | bool init_flag_{false}; | ||||
| bool train_graph_flag_{false}; | bool train_graph_flag_{false}; | ||||
| uint64_t session_id_{0}; | |||||
| GraphExecutor graph_executor_; | GraphExecutor graph_executor_; | ||||
| std::mutex mutex_; | std::mutex mutex_; | ||||
| @@ -38,7 +38,6 @@ | |||||
| #include "graph/common/ge_call_wrapper.h" | #include "graph/common/ge_call_wrapper.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/ge_global_options.h" | #include "graph/ge_global_options.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | |||||
| #include "graph/manager/graph_mem_manager.h" | #include "graph/manager/graph_mem_manager.h" | ||||
| #include "graph/manager/host_mem_manager.h" | #include "graph/manager/host_mem_manager.h" | ||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| @@ -160,18 +159,6 @@ Status GELib::InnerInitialize(const map<string, string> &options) { | |||||
| return initOpsBuilderStatus; | return initOpsBuilderStatus; | ||||
| } | } | ||||
| ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther); | |||||
| GELOGI("sessionManager initial."); | |||||
| GE_TIMESTAMP_START(SessionManagerInitialize); | |||||
| Status initSmStatus = sessionManager_.Initialize(options); | |||||
| GE_TIMESTAMP_END(SessionManagerInitialize, "InnerInitialize::SessionManagerInitialize"); | |||||
| if (initSmStatus != SUCCESS) { | |||||
| GELOGE(initSmStatus, "[Init][SessionManager] GE session manager initial failed."); | |||||
| REPORT_CALL_ERROR("E19999", "SessionManager initialize failed."); | |||||
| RollbackInit(); | |||||
| return initSmStatus; | |||||
| } | |||||
| GELOGI("Start to initialize HostCpuEngine"); | GELOGI("Start to initialize HostCpuEngine"); | ||||
| GE_TIMESTAMP_START(HostCpuEngineInitialize); | GE_TIMESTAMP_START(HostCpuEngineInitialize); | ||||
| Status initHostCpuEngineStatus = HostCpuEngine::GetInstance().Initialize(); | Status initHostCpuEngineStatus = HostCpuEngine::GetInstance().Initialize(); | ||||
| @@ -209,12 +196,6 @@ Status GELib::SystemInitialize(const map<string, string> &options) { | |||||
| // In train and infer, profiling is always needed. | // In train and infer, profiling is always needed. | ||||
| InitProfiling(this->options_); | InitProfiling(this->options_); | ||||
| auto model_manager = ModelManager::GetInstance(); | |||||
| GE_CHECK_NOTNULL(model_manager); | |||||
| GE_IF_BOOL_EXEC(model_manager->EnableExceptionDump(options) != SUCCESS, | |||||
| REPORT_CALL_ERROR("E19999", "ModelManager EnableExceptionDump failed."); | |||||
| GELOGE(FAILED, "[Enable][ExceptionDump] failed."); | |||||
| return FAILED); | |||||
| // 1.`is_train_mode_` means case: train | // 1.`is_train_mode_` means case: train | ||||
| // 2.`(!is_train_mode_) && (options_.device_id != kDefaultDeviceIdForInfer)` means case: online infer | // 2.`(!is_train_mode_) && (options_.device_id != kDefaultDeviceIdForInfer)` means case: online infer | ||||
| // these two case with logical device id | // these two case with logical device id | ||||
| @@ -454,12 +435,6 @@ Status GELib::Finalize() { | |||||
| GELOGW("engineManager finalize failed"); | GELOGW("engineManager finalize failed"); | ||||
| final_state = mid_state; | final_state = mid_state; | ||||
| } | } | ||||
| GELOGI("sessionManager finalization."); | |||||
| mid_state = sessionManager_.Finalize(); | |||||
| if (mid_state != SUCCESS) { | |||||
| GELOGW("sessionManager finalize failed"); | |||||
| final_state = mid_state; | |||||
| } | |||||
| GELOGI("opsBuilderManager finalization."); | GELOGI("opsBuilderManager finalization."); | ||||
| mid_state = OpsKernelBuilderManager::Instance().Finalize(); | mid_state = OpsKernelBuilderManager::Instance().Finalize(); | ||||
| @@ -539,9 +514,6 @@ void GELib::RollbackInit() { | |||||
| if (opsManager_.init_flag_) { | if (opsManager_.init_flag_) { | ||||
| (void)opsManager_.Finalize(); | (void)opsManager_.Finalize(); | ||||
| } | } | ||||
| if (sessionManager_.init_flag_) { | |||||
| (void)sessionManager_.Finalize(); | |||||
| } | |||||
| MemManager::Instance().Finalize(); | MemManager::Instance().Finalize(); | ||||
| HostMemManager::Instance().Finalize(); | HostMemManager::Instance().Finalize(); | ||||
| VarManagerPool::Instance().Destory(); | VarManagerPool::Instance().Destory(); | ||||
| @@ -22,7 +22,13 @@ | |||||
| #include <vector> | #include <vector> | ||||
| #include "engine_manager/dnnengine_manager.h" | #include "engine_manager/dnnengine_manager.h" | ||||
| #include "opskernel_manager/ops_kernel_manager.h" | #include "opskernel_manager/ops_kernel_manager.h" | ||||
| #include "session/session_manager.h" | |||||
| #include "graph/tuning_utils.h" | |||||
| #include "graph/operator_factory.h" | |||||
| #include "graph/ge_local_context.h" | |||||
| #include "graph/debug/ge_attr_define.h" | |||||
| #include "graph/utils/graph_utils.h" | |||||
| #include "graph/utils/anchor_utils.h" | |||||
| #include "graph/manager/graph_var_manager.h" | |||||
| #include "framework/common/ge_inner_error_codes.h" | #include "framework/common/ge_inner_error_codes.h" | ||||
| #include "framework/common/ge_types.h" | #include "framework/common/ge_types.h" | ||||
| @@ -53,9 +59,6 @@ class GE_FUNC_VISIBILITY GELib { | |||||
| // get OpsKernelManager object | // get OpsKernelManager object | ||||
| OpsKernelManager &OpsKernelManagerObj() { return opsManager_; } | OpsKernelManager &OpsKernelManagerObj() { return opsManager_; } | ||||
| // get SessionManager object | |||||
| SessionManager &SessionManagerObj() { return sessionManager_; } | |||||
| // get Initial flag | // get Initial flag | ||||
| bool InitFlag() const { return init_flag_; } | bool InitFlag() const { return init_flag_; } | ||||
| @@ -90,7 +93,6 @@ class GE_FUNC_VISIBILITY GELib { | |||||
| DNNEngineManager engineManager_; | DNNEngineManager engineManager_; | ||||
| OpsKernelManager opsManager_; | OpsKernelManager opsManager_; | ||||
| SessionManager sessionManager_; | |||||
| std::mutex status_mutex_; | std::mutex status_mutex_; | ||||
| bool init_flag_ = false; | bool init_flag_ = false; | ||||
| Options options_; | Options options_; | ||||
| @@ -30,7 +30,6 @@ | |||||
| #include "graph/ge_global_options.h" | #include "graph/ge_global_options.h" | ||||
| #include "graph/ge_local_context.h" | #include "graph/ge_local_context.h" | ||||
| #include "graph/common/local_context.h" | #include "graph/common/local_context.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | |||||
| #include "graph/manager/graph_var_manager.h" | #include "graph/manager/graph_var_manager.h" | ||||
| #include "graph/manager/graph_mem_manager.h" | #include "graph/manager/graph_mem_manager.h" | ||||
| #include "graph/utils/tensor_adapter.h" | #include "graph/utils/tensor_adapter.h" | ||||
| @@ -169,7 +168,6 @@ Status InnerSession::Finalize() { | |||||
| REPORT_CALL_ERROR("E19999", "GraphManager Finalize failed, InnerSession:%lu.", session_id_); | REPORT_CALL_ERROR("E19999", "GraphManager Finalize failed, InnerSession:%lu.", session_id_); | ||||
| } | } | ||||
| ModelManager::GetInstance()->DestroyAicpuSession(session_id_); | |||||
| init_flag_ = false; | init_flag_ = false; | ||||
| // release var memory | // release var memory | ||||
| GELOGI("VarManager free var memory."); | GELOGI("VarManager free var memory."); | ||||
| @@ -189,7 +187,7 @@ Status InnerSession::Finalize() { | |||||
| } | } | ||||
| Status InnerSession::InnerInitialize() { | Status InnerSession::InnerInitialize() { | ||||
| Status ret = model_executor_.Initialize(options_); | |||||
| Status ret = model_executor_.Initialize(options_, session_id_); | |||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "[Init][GraphExecutor] failed, InnerSession:%lu.", session_id_); | GELOGE(ret, "[Init][GraphExecutor] failed, InnerSession:%lu.", session_id_); | ||||
| REPORT_CALL_ERROR("E19999", "GraphExecutor initialize failed, InnerSession:%lu.", session_id_); | REPORT_CALL_ERROR("E19999", "GraphExecutor initialize failed, InnerSession:%lu.", session_id_); | ||||
| @@ -20,7 +20,6 @@ | |||||
| #include "common/ge/ge_util.h" | #include "common/ge/ge_util.h" | ||||
| #include "framework/common/debug/ge_log.h" | #include "framework/common/debug/ge_log.h" | ||||
| #include "graph/ge_context.h" | #include "graph/ge_context.h" | ||||
| #include "graph/load/model_manager/model_manager.h" | |||||
| #include "graph/manager/util/rt_context_util.h" | #include "graph/manager/util/rt_context_util.h" | ||||
| using std::map; | using std::map; | ||||
| @@ -105,10 +104,6 @@ Status SessionManager::DestroySession(SessionId session_id) { | |||||
| return GE_SESSION_NOT_EXIST; | return GE_SESSION_NOT_EXIST; | ||||
| } | } | ||||
| if (ModelManager::GetInstance() != nullptr) { | |||||
| ModelManager::GetInstance()->DestroyAicpuSession(session_id); | |||||
| } | |||||
| // Unified destruct rt_context | // Unified destruct rt_context | ||||
| RtContextUtil::GetInstance().DestroyRtContexts(session_id); | RtContextUtil::GetInstance().DestroyRtContexts(session_id); | ||||
| @@ -31,9 +31,26 @@ namespace ge { | |||||
| using SessionPtr = std::shared_ptr<InnerSession>; | using SessionPtr = std::shared_ptr<InnerSession>; | ||||
| class SessionManager { | class SessionManager { | ||||
| friend class GELib; | |||||
| public: | public: | ||||
| SessionManager() = default; | |||||
| ~SessionManager() = default; | |||||
| /// | |||||
| /// @ingroup ge_session | |||||
| /// @brief initialize session manager | |||||
| /// @param [in] options session manager config options | |||||
| /// @return Status result of function | |||||
| /// | |||||
| Status Initialize(const std::map<std::string, std::string> &options); | |||||
| /// | |||||
| /// @ingroup ge_session | |||||
| /// @brief finalize session manager | |||||
| /// @return Status result of function | |||||
| /// | |||||
| Status Finalize(); | |||||
| /// | /// | ||||
| /// @ingroup ge_session | /// @ingroup ge_session | ||||
| /// @brief create session | /// @brief create session | ||||
| @@ -181,25 +198,6 @@ class SessionManager { | |||||
| bool IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id); | bool IsGraphNeedRebuild(SessionId session_id, uint32_t graph_id); | ||||
| private: | private: | ||||
| SessionManager() = default; | |||||
| ~SessionManager() = default; | |||||
| /// | |||||
| /// @ingroup ge_session | |||||
| /// @brief initialize session manager | |||||
| /// @param [in] options session manager config options | |||||
| /// @return Status result of function | |||||
| /// | |||||
| Status Initialize(const std::map<std::string, std::string> &options); | |||||
| /// | |||||
| /// @ingroup ge_session | |||||
| /// @brief finalize session manager | |||||
| /// @return Status result of function | |||||
| /// | |||||
| Status Finalize(); | |||||
| bool HasSession(SessionId session_id); | bool HasSession(SessionId session_id); | ||||
| Status GetNextSessionId(SessionId &next_session_id); | Status GetNextSessionId(SessionId &next_session_id); | ||||