PT2/TorchScript interoperability fix (#94678)

Allows torch.compile() to inline into ScriptFunction

Pull Request resolved: https://github.com/pytorch/pytorch/pull/94678
Approved by: https://github.com/ezyang
This commit is contained in:
Jason Ansel
2023-02-14 19:06:50 +00:00
committed by PyTorch MergeBot
parent b6443fca86
commit ae57bd6630
10 changed files with 61 additions and 3 deletions

View File

@ -1343,6 +1343,8 @@ def script(obj, optimize=None, _frames_up=0, _rcb=None,
)
# Forward docstrings
fn.__doc__ = obj.__doc__
# Allow torch.compile() to inline
fn._torchdynamo_inline = obj # type: ignore[attr-defined]
_set_jit_function_cache(obj, fn)
return fn
else: