[Modes] refactor modes to only use a stack in cpp (#86458)

Refactors the mode code to only have the C++ mode stack and not the "C++ mode" like we originally had. This also simplifies the mode logic in a number of places
Pull Request resolved: https://github.com/pytorch/pytorch/pull/86458
Approved by: https://github.com/zou3519
This commit is contained in:
samdow
2022-10-19 10:36:40 -04:00
committed by PyTorch MergeBot
parent 13cad7e120
commit 169ec120ef
18 changed files with 101 additions and 201 deletions

View File

@ -755,8 +755,7 @@ py::object _get_operation_for_overload_or_packet(
total_arg_num,
false /* throw_error */);
}
if (overloaded_args.size() > 0 ||
at::impl::PythonTorchFunctionTLS::get_mode()) {
if (overloaded_args.size() > 0 || at::impl::torch_function_mode_enabled()) {
py::object ret;
std::string ns = symbol.ns().toUnqualString();
std::string method_name = symbol.toUnqualString();