mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-07 00:21:07 +01:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/63117 Test Plan: Imported from OSS Reviewed By: ngimel Differential Revision: D30388097 Pulled By: albanD fbshipit-source-id: f1bc777064645db1ff848bdd64af95bffb530984
22 lines
489 B
C++
22 lines
489 B
C++
#include <c10/core/AutogradState.h>
|
|
|
|
namespace c10 {
|
|
|
|
namespace {
|
|
// By default, grad mode is enabled and inference mode is disabled
|
|
thread_local AutogradState autograd_state_tls = AutogradState(
|
|
/* grad_mode */ true,
|
|
/* inference_mode */ false,
|
|
/* fw_grad_mode */ true);
|
|
} // namespace
|
|
|
|
AutogradState& AutogradState::get_tls_state() {
|
|
return autograd_state_tls;
|
|
}
|
|
|
|
void AutogradState::set_tls_state(AutogradState state) {
|
|
autograd_state_tls = state;
|
|
}
|
|
|
|
} // namespace c10
|