[Bugfix] Fix mock.patch resolution failure for standalone_compile.FakeTensorMode on Python <= 3.10 (#37158)
Signed-off-by: Dimitrios Bariamis <12195802+dbari@users.noreply.github.com> Co-authored-by: Dimitrios Bariamis <12195802+dbari@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
b36adfa349
commit
1204cf0a9d
@@ -373,8 +373,15 @@ class InductorStandaloneAdaptor(CompilerInterface):
|
||||
break
|
||||
|
||||
if input_fake_mode is not None:
|
||||
fake_mode_ctx: Any = patch(
|
||||
"torch._inductor.standalone_compile.FakeTensorMode",
|
||||
# Use patch.object on the actual module from sys.modules
|
||||
# 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,
|
||||
)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user