-
Notifications
You must be signed in to change notification settings - Fork 2
fix: remove sign check from PowOp
#61
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
Conversation
Comment has an error and did not reflect actual structure of code logic and so was fixed
Note that `ToMemref` has been changed to `ToBuffer` LLVM commit used contains the PRs - llvm/llvm-project#144636 - llvm/llvm-project#144638 which were committed in order to apply changes from `ConstantOp` to `ConstantIntOp`
Patch done to llvm-project: - Switches int/type ordering of `ConstantIntOp`to standardize with `ConstantOp` argument ordering - Adds constructor for `APInt` types Note that a `TypedAttr` input still requires `ConstantOp` to be used
patches/ is not a real folder and our patch files are all included in third-party/llvm-project/
Without this move, pre-commit may need to be run twice
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.
Summary of Changes
Hello @quanxi1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request resolves a probabilistic test failure in the scalar power operation by refining how exponents are handled. Previously, the power operation incorrectly rejected valid unsigned integer exponents due to a misinterpretation of their sign. The solution involves renaming the operation to PowUIOp to explicitly signify that it expects unsigned integer exponents, thereby removing the ambiguous sign check and aligning the operation with MLIR's established conventions for integer semantics. This ensures correct behavior for power calculations and enhances the robustness of the system.
Highlights
- Operation Renaming: The core power operation, previously named
PowOp, has been renamed toPowUIOpto clearly indicate that it expects an unsigned integer as its exponent. - Removal of Erroneous Sign Check: The problematic sign check that incorrectly interpreted unsigned integers with the most significant bit (MSB) set as negative values has been removed from the power operation's conversion logic.
- MLIR Design Alignment: The changes align the power operation's exponent handling with MLIR's established design principles for integer signedness semantics, promoting consistency and predictability.
- Probabilistic Test Fix: This fix addresses a probabilistic test failure in the scalar power operation unit test, improving the stability and reliability of the test suite.
Using Gemini Code Assist
The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.
Invoking Gemini
You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.
| Feature | Command | Description |
|---|---|---|
| Code Review | /gemini review |
Performs a code review for the current pull request in its current state. |
| Pull Request Summary | /gemini summary |
Provides a summary of the current pull request in its current state. |
| Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in issue comments and review comments. |
| Help | /gemini help |
Displays a list of available commands. |
Customization
To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.
Limitations & Feedback
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.
You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.
Footnotes
-
Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩
|
/gemini summary |
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.
Code Review
This pull request correctly addresses a bug in PowOp where large unsigned exponents were incorrectly treated as negative. By renaming the operation to PowUIOp and removing the sign check, the code now clearly communicates its intent to use an unsigned integer for the exponent, aligning with MLIR's design principles. The changes are consistently applied across the operation definition, conversion logic, and tests. The fix is well-reasoned and the implementation is clean.
6206e20 to
bd8a7dc
Compare
e8ea60d to
6e14d69
Compare
|
Could you add more context to the commit body of fix(field): remove negative exponent assertion from PowOp? Alternatively, you could squash it with refac(field): rename PowOp to PowUIOp, since the removal of the negative exponent assertion ties directly to the rename—this would help readers connect the reasoning. You might also consider copying the PR description into the commit body, because it already contains a clear and detailed explanation. |
519e2e2 to
a35ad9e
Compare
340b12a to
c19023e
Compare
bd8a7dc to
2464719
Compare
2a246d9 to
a598ee9
Compare
a598ee9 to
e71eef0
Compare
…nent The original PowOp was designed to reject negative exponents since negative powers require inverse operations. However, it incorrectly rejected unsigned integer exponents with the MSB set to 1, interpreting them as negative values. Following the MLIR's design choice of builtin operations, instead of imposing the signedness constraints on operand types or checking the MSB of input, we explicitly indicate the intention in the operation name that the operation interprets the exponent input as an unsigned integer by renaming PowOp to PowUIOp.
2464719 to
dcf049d
Compare
|
/gemini review |
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.
Code Review
This pull request correctly refactors PowOp to PowUIOp to clarify that it handles unsigned integer exponents, and removes the now-unnecessary sign check. The changes are consistent across the test files, conversion passes, and operation definitions. I have one suggestion to improve the documentation for the new operation.
chokobole
left a comment
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.
LGTM
batzor
left a comment
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.
LGTM
ashjeong
left a comment
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.
LGTM
This PR fixes a probabilistic test failure in the scalar power operation unit test in ZKX.
The original
PowOpwas designed to reject negative exponents since negative powers require inverse operations. However, it incorrectly rejected unsigned integer exponents with the MSB set to 1, interpreting them as negative values.Following the MLIR's design choice of builtin operations, instead of imposing the signedness constraints on operand types or checking the MSB of input, we explicitly indicate the intention in the operation name that the operation interprets the exponent input as an unsigned integer by renaming
PowOptoPowUIOp.See MLIR Integer Signedness Semantics Rationale.