-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ONNX] clarifies error message for upsample interpolation mode #3940
base: main
Are you sure you want to change the base?
[ONNX] clarifies error message for upsample interpolation mode #3940
Conversation
- easier to find - cleaner diffs when modified
ba53bcd
to
13bbe6b
Compare
binder.op, "unsupported interpolation mode other than nearest, " | ||
"linear"); | ||
binder.op, | ||
"Expected valid interpolation mode: “nearest” | “linear”"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd remove the quotes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was on the fence about that, too!
I encountered two contending DX considerations:
- Maintaining string "greppability"
- tough when escaping straight double quotes like
"\""
- tough when escaping straight double quotes like
- Conveying (in an intuitive way) that the input is a string literal, even in an error message
- using curved opening/closing double quotes somewhat solves this problem, but might add more cognitive load than it's worth.
Solution could be a raw string literal.
R"(Expected valid interpolation mode: "nearest" | "linear")"
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be best to remove the quotes. These match failure messages should be short and easy to search for, that way people can find the source of the match failure in the code easily.
They don't need to be fully descriptive, but the change in tone from "unsupported" to "unexpected" is helpful.
We likely created the linked issue because someone was skimming for match failures on attribute checks and saw the word "unsupported".
- prior error message felt more like an implementation stub than an assertion failure
- prior error message did not communicate input type - grepping the neighboring literals wouldn't also grep these instances
13bbe6b
to
803c266
Compare
@@ -3332,7 +3332,7 @@ void mlir::torch::onnx_c::populateDefaultDomainQtoZ( | |||
if (mode != "nearest" && mode != "linear") | |||
return rewriter.notifyMatchFailure( | |||
binder.op, | |||
"Expected valid interpolation mode: nearest | linear"); | |||
R"(Expected valid interpolation mode: "nearest" | "linear")"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zjgarvey I split the commit into two to narrow the scope of the convo!
Earlier, you had said:
These match failure messages should be short and easy to search for, that way people can find the source of the match failure in the code easily.
Let's quantify the change:
- number of characters added to code for message: 8
- number of characters added to message: 4
Zach's Criteria:
- short: I agree! Luckily, this only adds 4 characters to the length of the message itself
- easily searchable: I agree! And devs will still be able to copy the message as is and find the instance
Expected valid interpolation mode: "nearest" | "linear"
Jacob's Criteria
- communicate type where possible: looks more like string literal
- inherently connected to the literals they describe:
- searching "nearest" with the quotes and all will pull up the usage and the documentation-via-error-message!
I think these are compatible sets of criteria 😎
You had also mentioned:
[Match failure messages] don't need to be fully descriptive
Situations where a fully descriptive error message might be undesirable:
- Security Concerns: exposing sensitive information
- Users Experience: For end-users who may not have technical expertise
- Performance: could be impacted by massive message
- Redundancy: the error is common and well-documented
- Context: Additional details might be unnecessary when the errors are self-explanatory
Our Situation
- No sensitive info
- No technical content added
- 4-character diff likely has negligible performance impact
- I didn't see any similar instances; it's a big code base haha
- My guess is that, because you have a ton of context already, it feels self-explanatory, yeah?
In general, things I've found useful to ask myself:
- "What tiny tweak (on its own) would have made this issue easier to fix or entirely avoidable?"
- "What set of first principles were forgotten or violated that made this tougher than it coulda been?"
And those questions lead me to "oh, we could just add some quotes around the words that correspond to the string literals!"
Thanks for reading all that haha. What do you think, does any of that track?
@zjgarvey How's it look?