Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 278bc98

Browse filesBrowse files
SherlockNoMadbearzx
authored andcommitted
[report_exportability] Avoid re-exporting duplicated modules (#133930)
Summary: Skip re-exporting modules with the duplicated types to speed up the exportability tests. In real models, there are many duplicated modules, and mostly have the same export issues. Test Plan: Existing CI Differential Revision: D61504630 Pull Request resolved: #133930 Approved by: https://github.com/angelayi Co-authored-by: bearzx <bearzx@fb.com>
1 parent 333890b commit 278bc98
Copy full SHA for 278bc98

File tree

Expand file treeCollapse file tree

2 files changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+7
-2
lines changed

‎torch/_export/tools.py

Copy file name to clipboardExpand all lines: torch/_export/tools.py
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,15 @@ def report_exportability(
9191
all_submod_names = [name for name, _ in mod.named_modules() if name != ""]
9292
submod_inputs = _generate_inputs_for_submodules(mod, all_submod_names, args, kwargs)
9393

94+
tried_module_types = set()
9495
report: Dict[str, Optional[Exception]] = {}
9596

9697
def try_export(module, module_name, args, kwargs):
97-
nonlocal submod_inputs, report, strict, pre_dispatch
98+
nonlocal submod_inputs, report, strict, pre_dispatch, tried_module_types
99+
100+
if type(module) in tried_module_types:
101+
return
102+
tried_module_types.add(type(module))
98103

99104
if args is not None or kwargs is not None:
100105
try:

‎torch/export/_trace.py

Copy file name to clipboardExpand all lines: torch/export/_trace.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ def make_argument_spec(i, node) -> ArgumentSpec:
694694
if isinstance(node, (int, bool, float, type(None), str)):
695695
# For const outputs we just directly return this
696696
return ConstantArgument(name="", value=node)
697-
697+
698698
assert (
699699
"val" in node.meta
700700
), f"{node} is not a constant or a node with a 'val' metadata field"

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.