Skip to content

Commit

Permalink
Update on "group constraints by arg"
Browse files Browse the repository at this point in the history
Before, we would emit a soup of specializations / constraints without any obvious order to guide readability.

With this diff, we group such results by arg, and add comments preceding each group. Empirically, the results read much better.

Differential Revision: [D45995199](https://our.internmc.facebook.com/intern/diff/D45995199/)

cc voznesenskym penguinwu anijain2305 EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx desertfire

[ghstack-poisoned]
  • Loading branch information
avikchaudhuri committed May 20, 2023
2 parents 81be6af + 479dd12 commit c68ebbe
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions torch/fx/experimental/symbolic_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1778,7 +1778,6 @@ def remove_default_lower_bound(dc):
for i, arg in enumerate(signature.parameters.keys()):
args_index[arg] = (i, arg)

buf = ""
def print_results(grouped, indent, result_fn):
nonlocal buf

Expand All @@ -1792,6 +1791,7 @@ def print_results(grouped, indent, result_fn):
for result in results:
buf += f"\n{indent}{result_fn(result)}"

buf = ""
indent = 4 * " "
if self._static_results:
grouped_static_results = group(self._static_results, args_index)
Expand All @@ -1811,7 +1811,7 @@ def print_results(grouped, indent, result_fn):
buf += f"\n{indent}return ["
print_results(
grouped_dynamic_results,
indent*2,
indent * 2,
lambda result: f"{remove_default_lower_bound(result)},",
)
buf += f"\n{indent}]\n```\n"
Expand Down

0 comments on commit c68ebbe

Please sign in to comment.