Revert "[dynamo][executorch] Do not trace into exeuctorch LoweredBackendModule (#165126)"

This reverts commit 41936f4cf6ff93b70d81f6a23811d43a0647f1e1.

Reverted https://github.com/pytorch/pytorch/pull/165126 on behalf of https://github.com/anijain2305 due to https://github.com/pytorch/pytorch/pull/165172 is the right way ([comment](https://github.com/pytorch/pytorch/pull/165126#issuecomment-3391975498))
This commit is contained in:
PyTorch MergeBot
2025-10-10 19:21:41 +00:00
parent 8f78999d77
commit d16627f4d0

View File

@ -117,21 +117,6 @@ def is_dynamic_nn_module(obj: Any, is_export: bool) -> bool:
return True return True
if hasattr(obj, "torchdynamo_force_dynamic"): if hasattr(obj, "torchdynamo_force_dynamic"):
return obj.torchdynamo_force_dynamic return obj.torchdynamo_force_dynamic
# TODO - Executorch uses a delegate mechanism to lower nn.Module to a
# backend. This today requires Dynamo to not look inside the
# LoweredBackendModule. We should perhaps revisit this to understand
# why Dynamo is tracing this module.
if isinstance(obj, torch.nn.Module):
try:
cls = type(obj)
if cls.__module__.startswith("executorch") and cls.__name__.endswith(
"LoweredBackendModule"
):
return False
except Exception:
pass
if ( if (
isinstance(obj, torch.nn.Module) isinstance(obj, torch.nn.Module)
and config.inline_inbuilt_nn_modules and config.inline_inbuilt_nn_modules