| @@ -69,7 +69,7 @@ Status CheckOptionsValid(const std::map<string, string> &options) { | |||||
| auto job_id_iter = options.find(OPTION_EXEC_JOB_ID); | auto job_id_iter = options.find(OPTION_EXEC_JOB_ID); | ||||
| if (job_id_iter != options.end()) { | if (job_id_iter != options.end()) { | ||||
| if (job_id_iter->second.length() > kMaxStrLen) { | if (job_id_iter->second.length() > kMaxStrLen) { | ||||
| GELOGE(PARAM_INVALID, "CheckOptionsValid job_id failed, string len > %d", kMaxStrLen); | |||||
| GELOGE(PARAM_INVALID, "[Check][Job_id]Before execution, check job_id failed,the job_id string length:%d > max string length:%d", kMaxStrLen, job_id_iter); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| } | } | ||||
| @@ -84,7 +84,7 @@ Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
| std::string path_base = ge::GELib::GetPath(); | std::string path_base = ge::GELib::GetPath(); | ||||
| auto ret = ErrorManager::GetInstance().Init(path_base); | auto ret = ErrorManager::GetInstance().Init(path_base); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(GE_CLI_INIT_FAILED, "ErrorManager init fail"); | |||||
| GELOGE(GE_CLI_INIT_FAILED, "[Check][Path_base]GELib init fail because GELib path_base:%s is invalid", path_base); | |||||
| return ret; | return ret; | ||||
| } | } | ||||
| @@ -104,7 +104,7 @@ Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
| bool is_proto_init = manager->Initialize(option_tmp); | bool is_proto_init = manager->Initialize(option_tmp); | ||||
| GE_TIMESTAMP_END(GEInitialize, "GEInitialize::ManagerInitialize"); | GE_TIMESTAMP_END(GEInitialize, "GEInitialize::ManagerInitialize"); | ||||
| if (!is_proto_init) { | if (!is_proto_init) { | ||||
| GELOGE(GE_CLI_INIT_FAILED, "geInitialize failed, ops proto path is invalid."); | |||||
| GELOGE(GE_CLI_INIT_FAILED, "[LoadOpsProtoLibPlugin][OpsProtoPath]Loading OpsProto lib plugin failed because ops proto path:%s is invalid.", opsproto_path); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -127,7 +127,7 @@ Status GEInitializeImpl(const std::map<string, string> &options) { | |||||
| ret = ge::GELib::Initialize(options); | ret = ge::GELib::Initialize(options); | ||||
| GE_TIMESTAMP_END(GELibInitialize, "GEInitialize::GELibInitialize"); | GE_TIMESTAMP_END(GELibInitialize, "GEInitialize::GELibInitialize"); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(GE_CLI_INIT_FAILED, "geInitialize failed, error code = %u", ret); | |||||
| GELOGE(GE_CLI_INIT_FAILED, "[GELibInit][GELib]GELib init failed because the options are invalid, error code = %u", ret); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -155,7 +155,7 @@ Status GEInitialize(const std::map<AscendString, AscendString> &options) { | |||||
| std::map<std::string, std::string> str_options; | std::map<std::string, std::string> str_options; | ||||
| for (auto &option : options) { | for (auto &option : options) { | ||||
| if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | ||||
| GELOGE(FAILED, "GEInitialize options is nullptr."); | |||||
| GELOGE(FAILED, "[GELibInit][GELib]GELib init failed because the options are nullptr, first option and second option are both nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| std::string key = option.first.GetString(); | std::string key = option.first.GetString(); | ||||
| @@ -237,13 +237,13 @@ Session::Session(const std::map<string, string> &options) { | |||||
| // check init status | // check init status | ||||
| sessionId_ = 0; | sessionId_ = 0; | ||||
| if (!g_ge_initialized) { | if (!g_ge_initialized) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[SessionConstruct][Session]GE session constructor init failed because the init status(g_ge_initialized) is false."); | |||||
| return; | return; | ||||
| } | } | ||||
| // call Initialize | // call Initialize | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[SessionConstruct][Session]GE session constructor init failed because instance_ptr is nullptr"); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -256,7 +256,7 @@ Session::Session(const std::map<string, string> &options) { | |||||
| if (ret == SUCCESS) { | if (ret == SUCCESS) { | ||||
| sessionId_ = session_id; | sessionId_ = session_id; | ||||
| } else { | } else { | ||||
| GELOGE(ret, "Session constructor failed, session Id not initialized"); | |||||
| GELOGE(ret, "[SessionConstruct][Session]GE session constructor init failed because return status is failed."); | |||||
| return; | return; | ||||
| } | } | ||||
| GELOGT(TRACE_STOP, "Session Constructor finished"); | GELOGT(TRACE_STOP, "Session Constructor finished"); | ||||
| @@ -270,13 +270,13 @@ Session::Session(const std::map<AscendString, AscendString> &options) { | |||||
| // check init status | // check init status | ||||
| sessionId_ = 0; | sessionId_ = 0; | ||||
| if (!g_ge_initialized) { | if (!g_ge_initialized) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "GE is not initialized."); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[SessionConstruct][Session]GE session constructor init failed because the init status(g_ge_initialized) is false."); | |||||
| return; | return; | ||||
| } | } | ||||
| // call Initialize | // call Initialize | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session Constructor failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[SessionConstruct][Session]GE session constructor init failed because the instance_ptr is nullptr"); | |||||
| return; | return; | ||||
| } | } | ||||
| @@ -284,7 +284,7 @@ Session::Session(const std::map<AscendString, AscendString> &options) { | |||||
| std::map<std::string, std::string> str_options; | std::map<std::string, std::string> str_options; | ||||
| for (auto &option : options) { | for (auto &option : options) { | ||||
| if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | ||||
| GELOGE(FAILED, "Session options is nullptr."); | |||||
| GELOGE(FAILED, "[SessionConstruct][Session]Creating GE session failed because the options are nullptr."); | |||||
| return; | return; | ||||
| } | } | ||||
| std::string key = option.first.GetString(); | std::string key = option.first.GetString(); | ||||
| @@ -299,7 +299,7 @@ Session::Session(const std::map<AscendString, AscendString> &options) { | |||||
| if (ret == SUCCESS) { | if (ret == SUCCESS) { | ||||
| sessionId_ = session_id; | sessionId_ = session_id; | ||||
| } else { | } else { | ||||
| GELOGE(ret, "Session constructor failed, session Id not initialized"); | |||||
| GELOGE(ret, "[SessionConstruct][Session]GE session constructor init failed because return status is failed."); | |||||
| return; | return; | ||||
| } | } | ||||
| GELOGT(TRACE_STOP, "Session Constructor finished"); | GELOGT(TRACE_STOP, "Session Constructor finished"); | ||||
| @@ -331,17 +331,18 @@ Session::~Session() { | |||||
| ret = instance_ptr->SessionManagerObj().DestroySession(session_id); | ret = instance_ptr->SessionManagerObj().DestroySession(session_id); | ||||
| } catch (google::protobuf::FatalException &e) { | } catch (google::protobuf::FatalException &e) { | ||||
| GELOGE(GE_CLI_SESS_DESTROY_FAILED, "SessionDestructor throws FatalException"); | |||||
| GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[SessionDestruct][Session]GE session destructor throws FatalException"); | |||||
| } | } | ||||
| // check return status, return, update session id if success | // check return status, return, update session id if success | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "Session Destructor failed"); | |||||
| GELOGE(ret, "[SessionDestruct][Session]GE session destructor init failed because the return status is failed."); | |||||
| } | } | ||||
| GELOGT(TRACE_STOP, "Session Destructor finished"); | GELOGT(TRACE_STOP, "Session Destructor finished"); | ||||
| } | } | ||||
| //Add Graph | |||||
| Status Session::AddGraph(uint32_t graph_id, const Graph &graph) { | Status Session::AddGraph(uint32_t graph_id, const Graph &graph) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ||||
| std::map<std::string, std::string> options; | std::map<std::string, std::string> options; | ||||
| @@ -355,19 +356,20 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<s | |||||
| ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[AddGraph][Graph]AddGraph to session failed because instance_ptr is nullptr."); | |||||
| 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 = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, options); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "AddGraph failed in Session."); | |||||
| GELOGE(ret, "[AddGraph][Graph]AddGraph to session failed because graph info(session_id, graph_id, graph, options) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGD("AddGraph finished in Session."); | GELOGD("AddGraph finished in Session."); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| //Add Graph | |||||
| Status Session::AddGraph(uint32_t graph_id, const Graph &graph, | Status Session::AddGraph(uint32_t graph_id, const Graph &graph, | ||||
| const std::map<AscendString, AscendString> &options) { | const std::map<AscendString, AscendString> &options) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ||||
| @@ -375,14 +377,14 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, | |||||
| ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[AddGraph][Graph]AddGraph to session failed because instance_ptr is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGD("Adding graph to session"); | GELOGD("Adding graph to session"); | ||||
| std::map<std::string, std::string> str_options; | std::map<std::string, std::string> str_options; | ||||
| for (auto &option : options) { | for (auto &option : options) { | ||||
| if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | if (option.first.GetString() == nullptr || option.second.GetString() == nullptr) { | ||||
| GELOGE(FAILED, "AddGraph options is nullptr."); | |||||
| GELOGE(FAILED, "[AddGraph][Graph]AddGraph to session failed because the options is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| std::string key = option.first.GetString(); | std::string key = option.first.GetString(); | ||||
| @@ -391,13 +393,14 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, | |||||
| } | } | ||||
| Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); | Status ret = instance_ptr->SessionManagerObj().AddGraph(sessionId_, graph_id, graph, str_options); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "AddGraph failed in Session."); | |||||
| GELOGE(ret, "[Check][AddGraphObj]AddGraph to session failed because graph info(session_id, graph_id, graph, str_options) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGD("AddGraph finished in Session."); | GELOGD("AddGraph finished in Session."); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| //Add Graph With Copy | |||||
| Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { | Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ||||
| ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
| @@ -412,7 +415,7 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, | |||||
| ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "AddGraph failed in Session."); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[AddGraphWithCopy][Graph]AddGraph to session failed because the instance_ptr is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| std::map<std::string, std::string> str_options; | std::map<std::string, std::string> str_options; | ||||
| @@ -422,13 +425,14 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, | |||||
| GELOGD("Adding graph to session"); | GELOGD("Adding graph to session"); | ||||
| Status ret = instance_ptr->SessionManagerObj().AddGraphWithCopy(sessionId_, graph_id, graph, str_options); | Status ret = instance_ptr->SessionManagerObj().AddGraphWithCopy(sessionId_, graph_id, graph, str_options); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "AddGraph failed in Session."); | |||||
| GELOGE(ret, "[AddGraphWithCopy][Graph]AddGraph to session failed because graph info(session_id, graph_id, graph, str_options) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGD("AddGraph finished in Session."); | GELOGD("AddGraph finished in Session."); | ||||
| return ret; | return ret; | ||||
| } | } | ||||
| //Remove Graph | |||||
| Status Session::RemoveGraph(uint32_t graph_id) { | Status Session::RemoveGraph(uint32_t graph_id) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ||||
| GELOGT(TRACE_INIT, "Session RemoveGraph start"); | GELOGT(TRACE_INIT, "Session RemoveGraph start"); | ||||
| @@ -437,7 +441,7 @@ Status Session::RemoveGraph(uint32_t graph_id) { | |||||
| // call RemoveGraph | // call RemoveGraph | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (!instance_ptr || !instance_ptr->InitFlag()) { | if (!instance_ptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session RemoveGraph failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[RemoveGraph][Graph]RemoveGraph out of session failed because instance_ptr is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -445,7 +449,7 @@ Status Session::RemoveGraph(uint32_t graph_id) { | |||||
| Status ret = instance_ptr->SessionManagerObj().RemoveGraph(sessionId_, graph_id); | Status ret = instance_ptr->SessionManagerObj().RemoveGraph(sessionId_, graph_id); | ||||
| // check return status, return | // check return status, return | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "session RemoveGraph failed"); | |||||
| GELOGE(ret, "[RemoveGraph][Graph]RemoveGraph out of session failed because remove graph info(session_id, graph_id) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_STOP, "Session RemoveGraph finished"); | GELOGT(TRACE_STOP, "Session RemoveGraph finished"); | ||||
| @@ -499,6 +503,7 @@ void PrintOutputResult(std::vector<Tensor> &outputs) { | |||||
| } | } | ||||
| } | } | ||||
| //Run Graph | |||||
| Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, std::vector<Tensor> &outputs) { | Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, std::vector<Tensor> &outputs) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ||||
| GELOGT(TRACE_INIT, "Session RunGraph start"); | GELOGT(TRACE_INIT, "Session RunGraph start"); | ||||
| @@ -508,14 +513,14 @@ Status Session::RunGraph(uint32_t graph_id, const std::vector<Tensor> &inputs, s | |||||
| // call RunGraph | // call RunGraph | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "Session RunGraph failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[RunGraph][Graph]Session RunGraph failed because the instance_ptr is nullptr."); | |||||
| 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 = instance_ptr->SessionManagerObj().RunGraph(sessionId_, graph_id, graph_inputs, outputs); | ||||
| // check return status | // check return status | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "Session RunGraph failed"); | |||||
| GELOGE(ret, "[RunGraph][Graph]Session RunGraph failed because run graph info(session_id, graph_id, graph_inputs, outputs) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| @@ -543,30 +548,32 @@ Status Session::RegisterCallBackFunc(const char *key, const session::pCallBackFu | |||||
| return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); | return ge::GELib::GetInstance()->SessionManagerObj().RegisterCallBackFunc(sessionId_, str_key, callback); | ||||
| } | } | ||||
| //Build Graph | |||||
| Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> &inputs) { | Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> &inputs) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelCompile, ErrorMessage::kOther); | ||||
| ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[BuildGraph][Graph]Session BuildGraph failed because the instance_ptr is nullptr."); | |||||
| 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 = instance_ptr->SessionManagerObj().BuildGraph(sessionId_, graph_id, inputs); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "Session BuildGraph failed"); | |||||
| GELOGE(ret, "[BuildGraph][Graph]Session BuildGraph failed because build graph info(session_id, graph_id, inputs) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| //Run Graph Asynchronously | |||||
| Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorInfo> &inputs, | Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorInfo> &inputs, | ||||
| RunAsyncCallback callback) { | RunAsyncCallback callback) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); | ||||
| ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); | ||||
| std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[RunGraphAsync][Graph]Session RunGraphAsync failed because the instance_ptr is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); | ||||
| @@ -575,49 +582,51 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<InputTensorIn | |||||
| Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); | Status ret = ge::GELib::GetInstance()->SessionManagerObj().RunGraphAsync(sessionId_, graph_id, inputs, callback); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "SessionManager RunGraphAsync failed"); | |||||
| GELOGE(ret, "[RunGraphAsync][Graph]Session RunGraphAsync failed beccause asnchronously running graph info(session_id, graph_id, inputs, callback) is invalid, session_id:%lu, graph_id:%lu." sessionId_, graph_id); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| //Get Variables | |||||
| Status Session::GetVariables(const std::vector<std::string> &var_names, std::vector<Tensor> &var_values) { | Status Session::GetVariables(const std::vector<std::string> &var_names, std::vector<Tensor> &var_values) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); | ||||
| ErrorManager::GetInstance().GenWorkStreamIdDefault(); | ErrorManager::GetInstance().GenWorkStreamIdDefault(); | ||||
| auto instance_ptr = ge::GELib::GetInstance(); | auto instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[GetVariables][Variables]Session GetVariables failed because the instance_ptr is nullptr."); | |||||
| 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 = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, var_names, var_values); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "SessionManager RunGraphAsync failed"); | |||||
| GELOGE(ret, "[GetVariables][Variables]Session GetVariables failed because getting variables info(session_id, var_names, var_values) is invalid, session_id:%lu." sessionId_); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||
| } | } | ||||
| //Get Variables | |||||
| Status Session::GetVariables(const std::vector<AscendString> &var_names, std::vector<Tensor> &var_values) { | Status Session::GetVariables(const std::vector<AscendString> &var_names, std::vector<Tensor> &var_values) { | ||||
| ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); | ErrorManager::GetInstance().SetStage(ErrorMessage::kModelExecute, ErrorMessage::kModelExecute); | ||||
| ErrorManager::GetInstance().GenWorkStreamIdDefault(); | ErrorManager::GetInstance().GenWorkStreamIdDefault(); | ||||
| auto instance_ptr = ge::GELib::GetInstance(); | auto instance_ptr = ge::GELib::GetInstance(); | ||||
| if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { | ||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "SessionConstructor failed"); | |||||
| GELOGE(GE_CLI_GE_NOT_INITIALIZED, "[GetVariables][Variables]Session GetVariables failed because the instance_ptr is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| GELOGT(TRACE_RUNNING, "Get Variables"); | GELOGT(TRACE_RUNNING, "Get Variables"); | ||||
| std::vector<ge::string> str_var_names; | std::vector<ge::string> str_var_names; | ||||
| for (auto &var_name : var_names) { | for (auto &var_name : var_names) { | ||||
| if (var_name.GetString() == nullptr) { | if (var_name.GetString() == nullptr) { | ||||
| GELOGE(FAILED, "GetVariables name is nullptr."); | |||||
| GELOGE(FAILED, "[GetVariablesName][VariablesName]GetVariables name(var_name) is nullptr."); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| 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 = ge::GELib::GetInstance()->SessionManagerObj().GetVariables(sessionId_, str_var_names, var_values); | ||||
| if (ret != SUCCESS) { | if (ret != SUCCESS) { | ||||
| GELOGE(ret, "SessionManager RunGraphAsync failed"); | |||||
| GELOGE(ret, "[GetVariables][Variables]Session GetVariables failed because getting variables info(session_id, str_var_names, var_values) is invalid, session_id:%lu." sessionId_); | |||||
| return FAILED; | return FAILED; | ||||
| } | } | ||||
| return SUCCESS; | return SUCCESS; | ||||