mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: This is a re-attempt to land the iwyu header changes, by taking the diff from [PR 100304](https://github.com/pytorch/pytorch/pull/100304), and adding the bare minimal changes to make the diff build corectly in the internal builds. X-link: https://github.com/facebookresearch/pytorch3d/pull/1541 X-link: https://github.com/fairinternal/pytorch3d/pull/44 - Re-work D45769819 to fix header inclusions in c10 Test Plan: ``` buck2 build --no-remote-cache mode/dev-nosan //caffe2/c10/... buck2 build --no-remote-cache mode/dev-nosan //deeplearning/fbgemm/fbgemm_gpu/... buck2 build mode/dev-nosan //vision/fair/pytorch3d/pytorch3d:_C ``` Reviewed By: malfet Differential Revision: D45920611 Pull Request resolved: https://github.com/pytorch/pytorch/pull/101846 Approved by: https://github.com/malfet, https://github.com/Skylion007
27 lines
574 B
C++
27 lines
574 B
C++
#pragma once
|
|
|
|
#include <c10/core/impl/PyInterpreter.h>
|
|
#include <c10/macros/Export.h>
|
|
|
|
namespace c10 {
|
|
namespace impl {
|
|
|
|
struct C10_API PythonDispatcherTLS {
|
|
static void set_state(PyInterpreter* state);
|
|
static PyInterpreter* get_state();
|
|
static void reset_state();
|
|
};
|
|
|
|
struct C10_API DisablePythonDispatcher {
|
|
DisablePythonDispatcher() : old_(PythonDispatcherTLS::get_state()) {
|
|
PythonDispatcherTLS::set_state({});
|
|
}
|
|
~DisablePythonDispatcher() {
|
|
PythonDispatcherTLS::set_state(old_);
|
|
}
|
|
PyInterpreter* old_;
|
|
};
|
|
|
|
} // namespace impl
|
|
} // namespace c10
|