提交 6919127f 编写于 作者: M Megvii Engine Team

fix(mge): fix event pool destructor order issue and do full sync at python exit

GitOrigin-RevId: b9fa1f45b151295e5ae988419440819fe2d95f78
上级 60459bd7
......@@ -71,7 +71,9 @@ if sys.platform == "win32":
kernel32.SetErrorMode(old_error_mode)
from .core._imperative_rt.core2 import release_trace_apply_func, sync, full_sync
from .core._imperative_rt.core2 import full_sync as _full_sync
from .core._imperative_rt.core2 import release_trace_apply_func
from .core._imperative_rt.core2 import sync as _sync
from .core._imperative_rt.utils import _set_fork_exec_path_for_timed_func
from .device import *
from .logger import enable_debug_log, get_logger, set_log_file, set_log_level
......@@ -89,10 +91,9 @@ _set_fork_exec_path_for_timed_func(
_persistent_cache_impl_ins = persistent_cache.PersistentCacheOnServer()
_persistent_cache_impl_ins.reg()
atexit.register(sync)
atexit.register(_full_sync)
atexit.register(release_trace_apply_func)
del sync
del release_trace_apply_func
del _set_fork_exec_path_for_timed_func
del _persistent_cache_impl_ins
......
......@@ -24,6 +24,7 @@ std::unique_ptr<Interpreter::Channel> InterpreterImpl::create_channel() {
}
Interpreter& Interpreter::inst() {
Tensor::_static_init();
static InterpreterImpl inst_;
return inst_;
}
......
......@@ -56,6 +56,10 @@ protected:
return {};
}
AsyncReleaser() {
EventPool::without_timer();
}
public:
static AsyncReleaser* inst() {
static AsyncReleaser releaser;
......@@ -367,6 +371,10 @@ CompNode::Event* Tensor::get_or_create_event() {
return e;
}
void Tensor::_static_init() {
EventPool::without_timer();
}
} // namespace imperative
} // namespace mgb
......
......@@ -130,6 +130,12 @@ public:
void add_release_callback(CompNode cn);
CompNode::Event* get_or_create_event();
// Make sure all static objects required to destruct a tensor has completed
// construction. All static storage duration object that holds tensors must
// call this method before their constructors completes.
static void _static_init();
private:
TensorLayout m_layout;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册