Reland torch.ops API change machinery with the core functionality disabled (#71785)

Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/71785

see https://github.com/pytorch/pytorch/pull/67254
ghstack-source-id: 147648699

Test Plan: github CI

Reviewed By: albanD

Differential Revision: D33777229

fbshipit-source-id: 517b36be9743025eb40d708d380dae62e3663184
(cherry picked from commit a637e695694d3fd615dbe821394bfe53d41b6901)
This commit is contained in:
Anjali Chourdia
2022-02-02 07:55:12 -08:00
committed by PyTorch MergeBot
parent 1fdbe9aa76
commit a1383a9cfa
10 changed files with 284 additions and 36 deletions

View File

@ -1104,6 +1104,13 @@ std::shared_ptr<SugaredValue> toSugaredValue(
}
}
auto opoverloadpacket_type =
py::module::import("torch").attr("_ops").attr("OpOverloadPacket");
py::bool_ is_overloadpacket = py::isinstance(obj, opoverloadpacket_type);
if (is_overloadpacket) {
obj = py::getattr(obj, "op");
}
bool isRpcAvailable = py::cast<bool>(
py::module::import("torch.distributed.rpc").attr("is_available")());