Skip to content

Commit

Permalink
Trace through nn.Module dunder methods for UnspecializedNNModule (#12…
Browse files Browse the repository at this point in the history
…6578)

Summary:
Tracing through `__init__`  is important because it initializes (calls STORE_ATTR) on members. By doing that, we kick in the mutation tracking for these objects. So, things like mutating `_modules` etc is tracked automatically.

Fixes pytorch/pytorch#111837

X-link: pytorch/pytorch#126578
Approved by: https://github.com/jansel

Reviewed By: clee2000

Differential Revision: D58451174

Pulled By: anijain2305

fbshipit-source-id: a9dca5754b57247ed6c3bf97dc6ec0f00670c477
  • Loading branch information
anijain2305 authored and facebook-github-bot committed Jun 12, 2024
1 parent c4b0ffc commit c13df57
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2019,12 +2019,12 @@ def object_has_getattribute(value: Any):
return False


def get_custom_getattr(value: Any):
def get_custom_getattr(value: Any, ignore_nn_module_getattr: bool = False):
try:
getattr_fn = inspect.getattr_static(type(value), "__getattr__")
except AttributeError:
getattr_fn = None
if getattr_fn is torch.nn.Module.__getattr__:
if ignore_nn_module_getattr and getattr_fn is torch.nn.Module.__getattr__:
# ignore this case of getattr
getattr_fn = None
return getattr_fn
Expand Down

0 comments on commit c13df57

Please sign in to comment.