Skip to content

Commit

Permalink
Support NNModules as dict keys (#116723)
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#116723
Approved by: https://github.com/lezcano

Reviewed By: osalpekar

Differential Revision: D52648982

Pulled By: voznesenskym

fbshipit-source-id: 55c94bbda1e16e3ed20ce61e15c184e0a90bcea4
  • Loading branch information
voznesenskym authored and facebook-github-bot committed Jan 10, 2024
1 parent 8125608 commit e7b3e2b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions userbenchmark/dynamo/dynamobench/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1059,8 +1059,11 @@ def iter_contains(items, search, tx, check_tensor_identity=False):
return found


def tensor_to_id(value):
return [id(k) if isinstance(k, torch.Tensor) else k for k in value.keys()]
def tensor_or_module_to_id(value):
return [
id(k) if isinstance(k, (torch.Tensor, torch.nn.Module)) else k
for k in value.keys()
]


def const_repr(x, *, local) -> str:
Expand Down

0 comments on commit e7b3e2b

Please sign in to comment.