pytorch/c10/core/GradMode.cpp
albanD 04108592a3 New TLS to disable forward mode AD (#63117)
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
2021-08-27 11:59:24 -07:00

15 lines
282 B
C++

#include <c10/core/GradMode.h>
#include <stdexcept>
namespace c10 {
bool GradMode::is_enabled() {
return AutogradState::get_tls_state().get_grad_mode();
}
void GradMode::set_enabled(bool enabled) {
AutogradState::get_tls_state().set_grad_mode(enabled);
}
} // namespace c10