forked from pytorch/pytorch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPythonTorchFunctionTLS.cpp
38 lines (28 loc) · 1.01 KB
/
PythonTorchFunctionTLS.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <ATen/PythonTorchFunctionTLS.h>
#include <c10/core/TensorImpl.h>
namespace at {
namespace impl {
static thread_local PythonTorchFunctionTLS pythonTorchFunctionState;
void PythonTorchFunctionTLS::set_mode(std::shared_ptr<c10::SafePyObject> mode) {
pythonTorchFunctionState.mode_ = std::move(mode);
}
const std::shared_ptr<c10::SafePyObject>& PythonTorchFunctionTLS::get_mode() {
return pythonTorchFunctionState.mode_;
}
void PythonTorchFunctionTLS::swap_mode(std::shared_ptr<c10::SafePyObject>& mode) {
pythonTorchFunctionState.mode_.swap(mode);
}
void PythonTorchFunctionTLS::set_disabled(bool disabled) {
pythonTorchFunctionState.disabled_ = disabled;
}
bool PythonTorchFunctionTLS::is_disabled() {
return pythonTorchFunctionState.disabled_;
}
void PythonTorchFunctionTLS::set_state(const PythonTorchFunctionTLS& state) {
pythonTorchFunctionState = state;
}
const PythonTorchFunctionTLS& PythonTorchFunctionTLS::get_state() {
return pythonTorchFunctionState;
}
} // namespace impl
} // namespace at