mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 12:21:27 +01:00
See strategy at PythonOpRegistrationTrampoline.cpp for the big picture. Along the way, I made OperatorHandle support == and hashing, and slightly changed the low level python_dispatch impl API to disallow empty strings for dispatch key, which had the knock on effect of requiring us to explicitly make sure we pass in CompositeImplicitAutograd if we would have passed in "" (I didn't apply this to the rest of the file because I'm lazy.) Test strategy is we delete the logic for preventing Python op registrations in torch from being skipped in a torchdeploy context and show CI still works. Signed-off-by: Edward Z. Yang <ezyang@fb.com> Pull Request resolved: https://github.com/pytorch/pytorch/pull/87162 Approved by: https://github.com/anjali411, https://github.com/bdhirsh
24 lines
472 B
C++
24 lines
472 B
C++
#include <c10/core/impl/HermeticPyObjectTLS.h>
|
|
|
|
namespace c10 {
|
|
namespace impl {
|
|
|
|
thread_local std::atomic<bool> hermeticPyObjectState{false};
|
|
|
|
std::atomic<bool> HermeticPyObjectTLS::haveState_{false};
|
|
|
|
void HermeticPyObjectTLS::set_state(bool state) {
|
|
hermeticPyObjectState = state;
|
|
}
|
|
|
|
bool HermeticPyObjectTLS::get_tls_state() {
|
|
return hermeticPyObjectState;
|
|
}
|
|
|
|
void HermeticPyObjectTLS::init_state() {
|
|
haveState_ = true;
|
|
}
|
|
|
|
} // namespace impl
|
|
} // namespace c10
|