[dynamo] fix potentially missing _torchdynamo_inline from ScriptFunction (#125447)

Fix https://github.com/pytorch/pytorch/issues/119747

Pull Request resolved: https://github.com/pytorch/pytorch/pull/125447
Approved by: https://github.com/jansel
This commit is contained in:
William Wen 2024-05-03 13:29:27 -07:00 committed by PyTorch MergeBot
parent ad9a27f3e5
commit bdaa7bbd7d
2 changed files with 1 additions and 0 deletions

View file

@ -1391,6 +1391,7 @@ def script(
_check_directly_compile_overloaded(obj)
maybe_already_compiled_fn = _try_get_jit_cached_function(obj)
if maybe_already_compiled_fn:
maybe_already_compiled_fn._torchdynamo_inline = obj # type: ignore[attr-defined]
return maybe_already_compiled_fn
ast = get_jit_def(obj, obj.__name__)
if _rcb is None: