mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
This work introduces include-what-you-use support for c10 by a CMake option defaulting to off. We also remove some unused header inclusions and fix a trivial inclusion error. Pull Request resolved: https://github.com/pytorch/pytorch/pull/100304 Approved by: https://github.com/ezyang
32 lines
766 B
C++
32 lines
766 B
C++
#include <c10/core/DispatchKey.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
|