|
@@ -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) { |
|
@@ -70,8 +71,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, "[Check][JobId]Failed," |
|
|
|
|
|
"the job_id [%s] string length: %zu > max string length: %d", |
|
|
|
|
|
|
|
|
GELOGE(PARAM_INVALID, "[Check][JobId]Failed, the job_id [%s] string length: %zu > max string length: %d", |
|
|
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); |
|
|
job_id_iter->second.c_str(), job_id_iter->second.length(), kMaxStrLen); |
|
|
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id", "length"}), |
|
|
REPORT_INPUT_ERROR("E10051", std::vector<std::string>({"id", "length"}), |
|
|
std::vector<std::string>({job_id_iter->second, |
|
|
std::vector<std::string>({job_id_iter->second, |
|
@@ -95,8 +95,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, |
|
|
|
|
|
"[Init][PathBase]Init failed when pass param path_base:%s", path_base.c_str()); |
|
|
|
|
|
|
|
|
GELOGE(GE_CLI_INIT_FAILED, "[Init][PathBase]Init failed when pass param path_base:%s", path_base.c_str()); |
|
|
REPORT_CALL_ERROR("E19999", "Init failed when pass param path_base:%s", path_base.c_str()); |
|
|
REPORT_CALL_ERROR("E19999", "Init failed when pass param path_base:%s", path_base.c_str()); |
|
|
return ret; |
|
|
return ret; |
|
|
} |
|
|
} |
|
@@ -117,11 +116,9 @@ 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, |
|
|
|
|
|
"[Init][OpsProtoPath]Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid.", |
|
|
|
|
|
|
|
|
GELOGE(GE_CLI_INIT_FAILED, "[Init][OpsProtoPath]Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid.", |
|
|
opsproto_path.c_str()); |
|
|
opsproto_path.c_str()); |
|
|
REPORT_CALL_ERROR("E19999", "Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid", |
|
|
|
|
|
opsproto_path.c_str()); |
|
|
|
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Loading OpsProto lib plugin failed, OpsProtoPath:%s invalid", opsproto_path.c_str()); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -148,6 +145,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 |
|
@@ -173,8 +186,7 @@ Status GEInitialize(const std::map<AscendString, AscendString> &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, "[Check][Param]Options invalid, first or second option 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."); |
|
|
|
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Check parameter's options invalid, the first or second option is nullptr."); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
std::string key = option.first.GetString(); |
|
|
std::string key = option.first.GetString(); |
|
@@ -217,6 +229,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; |
|
@@ -251,28 +269,18 @@ std::string GEGetWarningMsg() { |
|
|
Session::Session(const std::map<string, string> &options) { |
|
|
Session::Session(const std::map<string, string> &options) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Start to construct session."); |
|
|
GELOGT(TRACE_INIT, "Start to construct session."); |
|
|
|
|
|
|
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
// check init status |
|
|
// check init status |
|
|
sessionId_ = 0; |
|
|
sessionId_ = 0; |
|
|
if (!g_ge_initialized) { |
|
|
if (!g_ge_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<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Construct][Session]Failed, GELib instance is nullptr or it is not InitFlag"); |
|
|
|
|
|
|
|
|
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; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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 |
|
@@ -288,32 +296,21 @@ Session::Session(const std::map<string, string> &options) { |
|
|
Session::Session(const std::map<AscendString, AscendString> &options) { |
|
|
Session::Session(const std::map<AscendString, AscendString> &options) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kInitialize, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Session Constructor start"); |
|
|
GELOGT(TRACE_INIT, "Session Constructor start"); |
|
|
|
|
|
|
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
// check init status |
|
|
// check init status |
|
|
sessionId_ = 0; |
|
|
sessionId_ = 0; |
|
|
if (!g_ge_initialized) { |
|
|
if (!g_ge_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."); |
|
|
|
|
|
|
|
|
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; |
|
|
return; |
|
|
} |
|
|
} |
|
|
// call Initialize |
|
|
// call Initialize |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Construct][Session]Failed, the GELib instance is nullptr or is not InitFlag"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
GELOGT(TRACE_RUNNING, "Creating session"); |
|
|
GELOGT(TRACE_RUNNING, "Creating 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, "[Construct][Session]Failed, the first or second option 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."); |
|
|
|
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Creating session's options invalid, the first or second option is nullptr."); |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
std::string key = option.first.GetString(); |
|
|
std::string key = option.first.GetString(); |
|
@@ -321,7 +318,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 |
|
@@ -350,19 +347,12 @@ Session::~Session() { |
|
|
try { |
|
|
try { |
|
|
uint64_t session_id = sessionId_; |
|
|
uint64_t session_id = sessionId_; |
|
|
// call DestroySession |
|
|
// call DestroySession |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGW("GE is not yet initialized or is finalized."); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); |
|
|
GELOGT(TRACE_RUNNING, "Session id is %lu", session_id); |
|
|
|
|
|
|
|
|
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 " |
|
|
|
|
|
"because get fatalException."); |
|
|
|
|
|
|
|
|
GELOGE(GE_CLI_SESS_DESTROY_FAILED, "[Destruct][Session]Failed because get fatalException."); |
|
|
REPORT_CALL_ERROR("E19999", "Destruct session failed, get fatal exception"); |
|
|
REPORT_CALL_ERROR("E19999", "Destruct session failed, get fatal exception"); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -377,9 +367,7 @@ Session::~Session() { |
|
|
|
|
|
|
|
|
// Add Graph |
|
|
// 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(error_message::kModelCompile, error_message::kOther); |
|
|
|
|
|
std::map<std::string, std::string> options; |
|
|
std::map<std::string, std::string> options; |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
|
|
|
return AddGraph(graph_id, graph, options); |
|
|
return AddGraph(graph_id, graph, options); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -388,20 +376,16 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<s |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); |
|
|
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
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."); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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, |
|
|
|
|
|
"[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
GELOGD("AddGraph finished in Session."); |
|
|
GELOGD("AddGraph finished in Session."); |
|
@@ -409,37 +393,31 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<s |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//Add Graph |
|
|
//Add Graph |
|
|
Status Session::AddGraph(uint32_t graph_id, const Graph &graph, |
|
|
|
|
|
const std::map<AscendString, AscendString> &options) { |
|
|
|
|
|
|
|
|
Status Session::AddGraph(uint32_t graph_id, const Graph &graph, const std::map<AscendString, AscendString> &options) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); |
|
|
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
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."); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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, "[Add][Graph]Failed, the first or second option 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."); |
|
|
|
|
|
|
|
|
REPORT_INNER_ERROR("E19999", "Add Graph Failed, the first or second option is nullptr."); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
std::string key = option.first.GetString(); |
|
|
std::string key = option.first.GetString(); |
|
|
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, |
|
|
|
|
|
"[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
GELOGD("AddGraph finished in Session."); |
|
|
GELOGD("AddGraph finished in Session."); |
|
@@ -447,8 +425,6 @@ Status Session::AddGraph(uint32_t graph_id, const Graph &graph, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { |
|
|
Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
|
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
|
|
|
std::map<AscendString, AscendString> options; |
|
|
std::map<AscendString, AscendString> options; |
|
|
return AddGraphWithCopy(graph_id, graph, options); |
|
|
return AddGraphWithCopy(graph_id, graph, options); |
|
|
} |
|
|
} |
|
@@ -459,24 +435,20 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); |
|
|
GELOGT(TRACE_INIT, "Start to add graph in Session. graph_id: %u, session_id: %lu.", graph_id, sessionId_); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
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."); |
|
|
|
|
|
|
|
|
if (!g_ge_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 FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
std::map<std::string, std::string> str_options; |
|
|
std::map<std::string, std::string> str_options; |
|
|
for (auto it = options.begin(); it != options.end(); ++it) { |
|
|
for (auto it = options.begin(); it != options.end(); ++it) { |
|
|
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, |
|
|
|
|
|
"[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Add][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
GELOGD("AddGraph finished in Session."); |
|
|
GELOGD("AddGraph finished in Session."); |
|
@@ -487,29 +459,21 @@ Status Session::AddGraphWithCopy(uint32_t graph_id, const Graph &graph, |
|
|
Status Session::RemoveGraph(uint32_t graph_id) { |
|
|
Status Session::RemoveGraph(uint32_t graph_id) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Session RemoveGraph start"); |
|
|
GELOGT(TRACE_INIT, "Session RemoveGraph start"); |
|
|
|
|
|
|
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
// call RemoveGraph |
|
|
// call RemoveGraph |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (!instance_ptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Remove][Graph]Failed, GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"RemoveGraph Failed, GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
|
|
|
if (!g_ge_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 FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
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, |
|
|
|
|
|
"[Remove][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Remove graph failed, error code:%u, " |
|
|
|
|
|
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Remove][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Remove graph failed, error code:%u, session_id:%lu, graph_id:%u", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
GELOGT(TRACE_STOP, "Session RemoveGraph finished"); |
|
|
GELOGT(TRACE_STOP, "Session RemoveGraph finished"); |
|
@@ -568,29 +532,21 @@ void PrintOutputResult(std::vector<Tensor> &outputs) { |
|
|
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(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Session RunGraph start"); |
|
|
GELOGT(TRACE_INIT, "Session RunGraph start"); |
|
|
|
|
|
|
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::vector<Tensor> graph_inputs = inputs; |
|
|
|
|
|
// call RunGraph |
|
|
|
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Run][Graph]Failed, GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"RunGraph Failed, GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
|
|
|
if (!g_ge_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 FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// call RunGraph |
|
|
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, inputs, outputs); |
|
|
// check return status |
|
|
// check return status |
|
|
if (ret != SUCCESS) { |
|
|
if (ret != SUCCESS) { |
|
|
GELOGE(ret, |
|
|
|
|
|
"[Run][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Remove graph failed, error code:%u, " |
|
|
|
|
|
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Run][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Remove graph failed, error code:%u, session_id:%lu, graph_id:%u", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -609,30 +565,15 @@ Status Session::RunGraphWithStreamAsync(uint32_t graph_id, void *stream, const s |
|
|
std::vector<Tensor> &outputs) { |
|
|
std::vector<Tensor> &outputs) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
GELOGT(TRACE_INIT, "Start to run graph with stream async."); |
|
|
GELOGT(TRACE_INIT, "Start to run graph with stream async."); |
|
|
|
|
|
|
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Run][Graph]Run graph with stream async failed, the GELib instance is nullptr," |
|
|
|
|
|
"session id = %lu, graph id = %u, stream = %p.", sessionId_, graph_id, stream); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"Run graph with stream async failed, the GELib instance is nullptr" |
|
|
|
|
|
"session id = %lu, graph id = %u, stream = %p.", sessionId_, graph_id, stream); |
|
|
|
|
|
return FAILED; |
|
|
|
|
|
} |
|
|
|
|
|
if (!instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Run][Graph]Run graph with stream asyn failed, the GELib instance is not init," |
|
|
|
|
|
"session id = %lu, graph id = %u, stream = %p.", sessionId_, graph_id, stream); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"Run graph with stream asyn failed, the GELib instance is not init," |
|
|
|
|
|
"session id = %lu, graph id = %u, stream = %p.", sessionId_, graph_id, stream); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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, |
|
|
|
|
|
outputs); |
|
|
|
|
|
|
|
|
Status ret = g_session_manager->RunGraphWithStreamAsync(sessionId_, graph_id, stream, inputs, 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," |
|
|
"error code = %u, session id = %lu, graph id = %u, stream = %p.", ret, sessionId_, graph_id, stream); |
|
|
"error code = %u, session id = %lu, graph id = %u, stream = %p.", ret, sessionId_, graph_id, stream); |
|
@@ -648,40 +589,46 @@ 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); |
|
|
|
|
|
|
|
|
if (!g_ge_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 FAILED; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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) { |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
|
|
|
if (!g_ge_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 FAILED; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
std::string str_key; |
|
|
std::string str_key; |
|
|
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 |
|
|
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(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Build][Graph]Failed, the GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"Build graph failed, the GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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, |
|
|
|
|
|
"[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Build graph failed , error code:%u, " |
|
|
|
|
|
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Build graph failed , error code:%u, session_id:%lu, graph_id:%u", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
@@ -691,24 +638,18 @@ Status Session::BuildGraph(uint32_t graph_id, const std::vector<InputTensorInfo> |
|
|
Status Session::BuildGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inputs) { |
|
|
Status Session::BuildGraph(uint32_t graph_id, const std::vector<ge::Tensor> &inputs) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelCompile, error_message::kOther); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Build][Graph]Failed, the GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"Build graph failed, the GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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, |
|
|
|
|
|
"[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Build graph failed , error code:%u, " |
|
|
|
|
|
"session_id:%lu, graph_id:%u", ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
GELOGE(ret, "[Build][Graph]Failed, error code:%u, session_id:%lu, graph_id:%u.", ret, sessionId_, graph_id); |
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Build graph failed , error code:%u, session_id:%lu, graph_id:%u", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
@@ -719,26 +660,22 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<ge::Tensor> & |
|
|
RunAsyncCallback callback) { |
|
|
RunAsyncCallback callback) { |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelExecute, error_message::kModelExecute); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelExecute, error_message::kModelExecute); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdBySessionGraph(sessionId_, graph_id); |
|
|
std::shared_ptr<GELib> instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
GELOGE(GE_CLI_GE_NOT_INITIALIZED, |
|
|
|
|
|
"[Run][Graph]RunGraphAsyncFailed, the GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
REPORT_INNER_ERROR("E19999", |
|
|
|
|
|
"RunGraphAsync Failed, the GELib instance is nullptr or is not InitFlag, " |
|
|
|
|
|
"session_id %lu, graph_id %u", sessionId_, graph_id); |
|
|
|
|
|
|
|
|
if (!g_ge_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 FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); |
|
|
GELOGT(TRACE_RUNNING, "Run Graph Asynchronously"); |
|
|
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); |
|
|
REPORT_CALL_ERROR("E19999", "RunGraphAsync Failed, error code:%u, session_id:%lu, " |
|
|
|
|
|
"graph_id:%u", ret, sessionId_, graph_id); |
|
|
|
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "RunGraphAsync Failed, error code:%u, session_id:%lu, graph_id:%u", |
|
|
|
|
|
ret, sessionId_, graph_id); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
@@ -748,16 +685,14 @@ Status Session::RunGraphAsync(uint32_t graph_id, const std::vector<ge::Tensor> & |
|
|
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(error_message::kModelExecute, error_message::kModelExecute); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelExecute, error_message::kModelExecute); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
auto instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
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."); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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; |
|
@@ -769,14 +704,12 @@ Status Session::GetVariables(const std::vector<std::string> &var_names, std::vec |
|
|
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(error_message::kModelExecute, error_message::kModelExecute); |
|
|
ErrorManager::GetInstance().SetStage(error_message::kModelExecute, error_message::kModelExecute); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
ErrorManager::GetInstance().GenWorkStreamIdDefault(); |
|
|
auto instance_ptr = ge::GELib::GetInstance(); |
|
|
|
|
|
if (instance_ptr == nullptr || !instance_ptr->InitFlag()) { |
|
|
|
|
|
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."); |
|
|
|
|
|
|
|
|
if (!g_ge_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 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) { |
|
@@ -787,17 +720,22 @@ 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.", |
|
|
|
|
|
ret, sessionId_); |
|
|
|
|
|
|
|
|
REPORT_CALL_ERROR("E19999", "Get variables failed, error code:%u, session_id:%lu.", ret, sessionId_); |
|
|
return FAILED; |
|
|
return FAILED; |
|
|
} |
|
|
} |
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
bool Session::IsGraphNeedRebuild(uint32_t graph_id) { |
|
|
bool Session::IsGraphNeedRebuild(uint32_t graph_id) { |
|
|
return ge::GELib::GetInstance()->SessionManagerObj().IsGraphNeedRebuild(sessionId_, graph_id); |
|
|
|
|
|
|
|
|
if (!g_ge_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 false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return g_session_manager->IsGraphNeedRebuild(sessionId_, graph_id); |
|
|
} |
|
|
} |
|
|
} // namespace ge |
|
|
} // namespace ge |