Unverified Commit 1204cf0a authored by Dimitrios Bariamis's avatar Dimitrios Bariamis Committed by GitHub
Browse files

[Bugfix] Fix mock.patch resolution failure for...


[Bugfix] Fix mock.patch resolution failure for standalone_compile.FakeTensorMode on Python <= 3.10 (#37158)
Signed-off-by: default avatarDimitrios Bariamis <12195802+dbari@users.noreply.github.com>
Co-authored-by: default avatarDimitrios Bariamis <12195802+dbari@users.noreply.github.com>
parent b36adfa3
...@@ -373,8 +373,15 @@ class InductorStandaloneAdaptor(CompilerInterface): ...@@ -373,8 +373,15 @@ class InductorStandaloneAdaptor(CompilerInterface):
break break
if input_fake_mode is not None: if input_fake_mode is not None:
fake_mode_ctx: Any = patch( # Use patch.object on the actual module from sys.modules
"torch._inductor.standalone_compile.FakeTensorMode", # because in Python <=3.10 the string-based patch() resolves
# torch._inductor.standalone_compile to the wrapper function
# (defined in __init__.py) instead of the module.
import sys
fake_mode_ctx: Any = patch.object(
sys.modules["torch._inductor.standalone_compile"],
"FakeTensorMode",
lambda *a, **kw: input_fake_mode, lambda *a, **kw: input_fake_mode,
) )
else: else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment