mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
This reverts commit a9b4989c726a29b4b89c64282e32b9e4fc0b7d68.
Reverted https://github.com/pytorch/pytorch/pull/139132 on behalf of https://github.com/ZainRizvi due to Sorry but this fails on trunk. See inductor/test_mkldnn_pattern_matcher.py::TestPatternMatcher::test_smooth_quant_with_int_mm [GH job link](https://github.com/pytorch/pytorch/actions/runs/11699366379/job/32591132460) [HUD commit link](22e89ea2aa
) ([comment](https://github.com/pytorch/pytorch/pull/139132#issuecomment-2459743145))
26 lines
550 B
C++
26 lines
550 B
C++
#pragma once
|
|
|
|
#include <c10/core/impl/PyInterpreter.h>
|
|
#include <c10/macros/Export.h>
|
|
|
|
namespace c10::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 c10::impl
|