!45885 fix double free at exit
Merge pull request !45885 from zhoufeng/xiu-ba-ge-4
This commit is contained in:
commit
6881b8d34f
|
@ -40,6 +40,8 @@ std::map<std::string, MsBackendPolicy> kPolicyMap = {{"ge", kMsBackendGePrior},
|
|||
std::atomic<bool> thread_1_must_end(false);
|
||||
|
||||
MsContext::DeviceSeter MsContext::seter_ = nullptr;
|
||||
MsContext::LoadPluginError MsContext::load_plugin_error_ = nullptr;
|
||||
std::shared_ptr<MsContext> MsContext::inst_context_ = nullptr;
|
||||
|
||||
MsContext::MsContext(const std::string &policy, const std::string &target) {
|
||||
#ifndef ENABLE_SECURITY
|
||||
|
@ -124,6 +126,7 @@ MsContext::MsContext(const std::string &policy, const std::string &target) {
|
|||
}
|
||||
|
||||
std::shared_ptr<MsContext> MsContext::GetInstance() {
|
||||
static std::once_flag inst_context_init_flag_ = {};
|
||||
std::call_once(inst_context_init_flag_, [&]() {
|
||||
if (inst_context_ == nullptr) {
|
||||
MS_LOG(DEBUG) << "Create new mindspore context";
|
||||
|
|
|
@ -201,9 +201,8 @@ class MS_CORE_API MsContext {
|
|||
|
||||
private:
|
||||
static DeviceSeter seter_;
|
||||
inline static std::once_flag inst_context_init_flag_ = {};
|
||||
inline static std::shared_ptr<MsContext> inst_context_ = nullptr;
|
||||
inline static LoadPluginError load_plugin_error_ = nullptr;
|
||||
static std::shared_ptr<MsContext> inst_context_;
|
||||
static LoadPluginError load_plugin_error_;
|
||||
|
||||
bool bool_params_[MsCtxParam::NUM_BOOL_PARAMS];
|
||||
int int_params_[MsCtxParam::NUM_INT_PARAMS];
|
||||
|
|
Loading…
Reference in New Issue