[jit] Initial use RRef in TorchScript (#33190)

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

This enable the initial RRef type to be used inside TorchScript, user
could pass a python RRef into a torchscript function and call to_here
inside. Specifically, this PR:

- Add RRef schema type parsing
- Add python interop for RRef in Python and into JIT
- register to_here op in register_distributed_ops

More support for RRef in TorchScript will be added in future PRs

Test Plan: Imported from OSS

Differential Revision: D19871244

Pulled By: wanchaol

fbshipit-source-id: 7eca6c491a84666b261c70806254b705603bd663
This commit is contained in:
Wanchao Liang
2020-02-13 20:13:10 -08:00
committed by Facebook Github Bot
parent b2c5896432
commit 93179b1c1c
9 changed files with 118 additions and 3 deletions

View File

@ -156,6 +156,13 @@ PyRRef PyRRef::unpickle(const py::tuple& pyTuple) {
return PyRRef(std::move(rref));
}
c10::IValue PyRRef::toIValue() {
// cast to RRefInterface to hold it into IValue
auto rrefPtr = c10::static_intrusive_pointer_cast<c10::RRefInterface>(rref_);
return IValue(rrefPtr);
}
} // namespace rpc
} // namespace distributed
} // namespace torch