Skip to content

Commit

Permalink
Update on "[user errors] compulsory case names, allow multiple"
Browse files Browse the repository at this point in the history
We want to get to a point where most UserErrors link to exportdb examples. This PR makes passing case names non-optional to make this intent clearer and encourage developers who raise UserErrors to make or point to examples that make fixing such errors more obvious for users.

In addition, sometimes there are multiple examples that are relevant to an error. Thus this PR also enables passing multiple case names.

Retry of #110733 which was reverted due to a landrace.

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

cc voznesenskym penguinwu EikanWang jgong5 Guobing-Chen XiaobingSuper zhuhaozhe blzheng Xia-Weiwen wenzhe-nrv jiayisunx chenyang78 aakhundov kadeng gmagogsfm zhxchen17 tugsbayasgalan

[ghstack-poisoned]
  • Loading branch information
avikchaudhuri committed Oct 9, 2023
1 parent 750eace commit 171ee55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions torch/_dynamo/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

from .utils import counters


def exportdb_error_message(case_names):
case_names_str = ", ".join(
"https://pytorch.org/docs/main/generated/exportdb/index.html#"
Expand Down
4 changes: 3 additions & 1 deletion torch/_dynamo/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,9 @@ def visit(n: torch.fx.Node):
case_names=["constrain_as_value_example", "constrain_as_size_example"],
)
elif isinstance(cause, torch.utils._sympy.value_ranges.ValueRangeError):
raise UserError(UserErrorType.CONSTRAINT_VIOLATION, e.args[0], case_names=[]) from e
raise UserError(
UserErrorType.CONSTRAINT_VIOLATION, e.args[0], case_names=[]
) from e
raise TorchRuntimeError(str(e)).with_traceback(e.__traceback__) from None


Expand Down

0 comments on commit 171ee55

Please sign in to comment.