Files
pytorch/c10/core/impl/PythonDispatcherTLS.cpp
PyTorch MergeBot 4eaaa08623 Revert "Fix header inclusions in c10 by iwyu (#100304)"
This reverts commit 6037ee8cc914d64a27965a35b20472044416a2a5.

Reverted https://github.com/pytorch/pytorch/pull/100304 on behalf of https://github.com/jeanschmidt due to Breaking meta internal builds and fbgemm builds ([comment](https://github.com/pytorch/pytorch/pull/100304#issuecomment-1543919257))
2023-05-11 12:37:35 +00:00

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