mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
This reverts commit 6037ee8cc9.
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))
28 lines
599 B
C++
28 lines
599 B
C++
#pragma once
|
|
|
|
#include <c10/core/SafePyObject.h>
|
|
#include <c10/macros/Macros.h>
|
|
#include <c10/util/Optional.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
|