Add non-eager registration to dispatch autogen (#74557)

Summary:
Previously, the torchscript backend would be (partially) initialized at startup.
- the dispatcher registrations would be registered,
- but other backend components would not be initialized until explicitly calling
  the backend init function

With this change, the torchscript backend is not initialized until its explicit
initialization function is called.

This enables external backends to register their own backend instead of the torchscript
backend to the same (Lazy) key.

Lands a change contributed by antoniojkim via lazy_tensor_staging branch (https://github.com/pytorch/pytorch/issues/73973)

Pull Request resolved: https://github.com/pytorch/pytorch/pull/74557

Reviewed By: bdhirsh

Differential Revision: D35051464

Pulled By: wconstab

fbshipit-source-id: 5a8b0851293e394f49427d1416ee571a8881fe9f
(cherry picked from commit ef745a4a2c8d1d7f9510541a20f1f40625ce29de)
This commit is contained in:
Will Constable
2022-03-31 20:37:50 -07:00
committed by PyTorch MergeBot
parent c5023ea1d5
commit b9e535a64a
9 changed files with 121 additions and 33 deletions

View File

@ -199,6 +199,7 @@ def main() -> None:
from tools.codegen.gen_lazy_tensor import run_gen_lazy_tensor
run_gen_lazy_tensor(aten_path=aten_path,
source_yaml=ts_backend_yaml,
backend_name="TorchScript",
output_dir=lazy_install_dir,
dry_run=False,
impl_path=ts_native_functions,