-
Notifications
You must be signed in to change notification settings - Fork 125
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
Decide on corner cases for rhs in ShiftXxxOps #1150
Comments
That's a nice catch - thank you for calling this out! This question has also come up on the #stablehlo Discord recently. When writing the initial version of the spec, we've abstracted ourselves away from numerical corner cases, stating that "Error conditions are [...] possible, e.g. through integer overflows, out-of-bounds accesses, etc. Unless explicitly called out, all these errors result in implementation-defined behavior. [However] as an exception to this rule, floating-point exceptions in StableHLO programs have well-defined behavior [...] defined by the IEEE-754 standard". This was convenient for the initial version, but this way we not only deferred figuring out error conditions (desired effect) but also missed some interesting corner cases like this one (undesired effect). Before we release StableHLO v1.0, it would be good to audit the opset and address both items - I opened a ticket to follow up on that: #1157. For this specific ticket, how urgent is it on your side? The easiest way to handle it would be as part of the aforementioned audit sometime later this year. However, if there's a need in faster turnaround, we can also try to find time for that. |
Thanks for the info!
Not urgent at all, I would say. We do not have any existing use cases for these ops; I just ran into this corner case while trying to provide full StableHLO support in our system. |
Here are the constraints for the ShiftLeftOp: ``` (I1) lhs is a tensor of integer type. (I2) rhs is a tensor of integer type. (C1) `lhs`, `rhs`, and `result` have the same type. ``` I1, I2, and C1 are covered by the ODS, so no additional tests are added. Notes: * Corner cases (shift overflow) has not been accounted for: #1150 closes #1112
Here are the constraints for the ShiftRightLogicalOp: ``` (I1) lhs is a tensor of integer type. (I2) rhs is a tensor of integer type. (C1) `lhs`, `rhs`, and `result` have the same type. ``` I1, I2, and C1 are covered by the ODS, so no additional tests are added. Notes: * Corner cases (shift overflow) has not been accounted for: #1150 closes #1114
Here are the constraints for the ShiftRightArithmeticOp: ``` (I1) lhs is a tensor of integer type. (I2) rhs is a tensor of integer type. (C1) `lhs`, `rhs`, and `result` have the same type. ``` I1, I2, and C1 are covered by the ODS, so no additional tests are added. Notes: * Corner cases (shift overflow) has not been accounted for: #1150 closes #1113
Request description
For example, in C++ (and C89),
if the value of the right operand is negative or is greater or equal to the number of bits in the promoted left operand, the behavior is undefined
.Should we specify the same restriction for StableHLO?
The text was updated successfully, but these errors were encountered: