Files
pytorch/c10/core/InferenceMode.cpp
cyy fa65ae8f56 cleanup unused include (#93359)
Using `include-what-you-use` tool to find out and remove some unused includes
Pull Request resolved: https://github.com/pytorch/pytorch/pull/93359
Approved by: https://github.com/malfet
2023-02-04 02:15:50 +00:00

13 lines
429 B
C++

#include <c10/core/InferenceMode.h>
namespace c10 {
// Invariant:
// is_enabled() ==
// !c10::impl::tls_is_dispatch_key_included(DispatchKey::ADInplaceOrView);
// InferenceMode::is_enabled() is in perf critical path (TensorImpl constructor)
// so it worths a separate TLS to skip the DispatchKeySet check.
bool InferenceMode::is_enabled() {
return AutogradState::get_tls_state().get_inference_mode();
}
} // namespace c10