Skip to content

Commit dbc903a

Browse files
malaybagpytorchmergebot
authored andcommitted
[APS IR] Minfor fix - use GetAttrKey in get_keystr to match with flat args path in unflatten (pytorch#161453)
Summary: While passing path info to [_check_input_constraints_for_graph](https://www.internalfb.com/code/fbsource/[6b5b2dc35902a26ce265e3c0ae5189a3faba1d38]/fbcode/caffe2/torch/export/unflatten.py?lines=594), GetAttrKey is used to specify path str. To match with that get_keystr should also use GetAttrKey. Test Plan: Existing tests ``` buck run mode/opt caffe2/test:test_export -- -r unflatten ``` ``` Ran 413 tests in 204.533s OK (skipped=1, expected failures=13) ``` Rollback Plan: Differential Revision: D80984083 Pull Request resolved: pytorch#161453 Approved by: https://github.com/tugsbayasgalan
1 parent 1b34e04 commit dbc903a

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

torch/_export/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def get_keystr(key_path: KeyPath) -> str:
331331
return f"*args{keystr(key_path[1:])}"
332332
else:
333333
kwarg_key = key_path[1]
334-
assert isinstance(kwarg_key, MappingKey)
334+
assert isinstance(kwarg_key, GetAttrKey)
335335
name = str(kwarg_key)[1:-1] # get rid of the enclosed []
336336
return f"{name}{keystr(key_path[2:])}"
337337

torch/export/unflatten.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,11 @@ class _SubmoduleBase:
134134
_ty: Optional[str]
135135

136136
def type_name(self) -> Optional[str]:
137+
"""
138+
Subclass of this class - InterpreterModule, InterpreterModuleDispatcher, represents
139+
corresponding model in eager model. To get this type information for those modules
140+
in eager model we need to use this method.
141+
"""
137142
return self._ty
138143

139144

0 commit comments

Comments
 (0)