mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
This reverts commit39ec5fa722. Reverted https://github.com/pytorch/pytorch/pull/100304 on behalf of https://github.com/huydhn due to Sorry for reverting your PR, it is almost there but fails on Windows39ec5fa722, which is in unstable mode after https://github.com/pytorch/pytorch/pull/100548 ([comment](https://github.com/pytorch/pytorch/pull/100304#issuecomment-1542975714))
33 lines
804 B
C++
33 lines
804 B
C++
#include <c10/core/DispatchKeySet.h>
|
|
#include <c10/core/SafePyObject.h>
|
|
#include <c10/core/impl/LocalDispatchKeySet.h>
|
|
#include <c10/core/impl/PythonDispatcherTLS.h>
|
|
|
|
namespace c10 {
|
|
namespace impl {
|
|
|
|
thread_local PyInterpreter* pythonDispatcherState;
|
|
|
|
void PythonDispatcherTLS::set_state(PyInterpreter* state) {
|
|
if (state) {
|
|
c10::impl::tls_set_dispatch_key_included(
|
|
DispatchKey::PythonDispatcher, true);
|
|
} else {
|
|
PythonDispatcherTLS::reset_state();
|
|
}
|
|
pythonDispatcherState = state;
|
|
}
|
|
|
|
PyInterpreter* PythonDispatcherTLS::get_state() {
|
|
return pythonDispatcherState;
|
|
}
|
|
|
|
void PythonDispatcherTLS::reset_state() {
|
|
pythonDispatcherState = nullptr;
|
|
c10::impl::tls_set_dispatch_key_included(
|
|
DispatchKey::PythonDispatcher, false);
|
|
}
|
|
|
|
} // namespace impl
|
|
} // namespace c10
|