-
Notifications
You must be signed in to change notification settings - Fork 14.6k
[mlir][spirv][webgpu] Add lowering of IAddCarry to IAdd #68495
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
@kuhar @antiagainst I will ping you here for a request to review for a SPIR-V related change. No rush, I understand you are both busy, just before I forget to do so :) |
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.
Thanks for taking a stab at this! I think we can simplify the code, but do let me know if I missed something there.
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.
Nice, thanks for the changes.
Could you also add a runtime integration test under https://github.com/llvm/llvm-project/tree/main/mlir/test/mlir-vulkan-runner to make sure we are getting the expected results?
WebGPU does not currently support extended arithmetic, this is an issue when we want to lower from SPIR-V. This commit adds a pattern to transform and emulate spirv.IAddCarry with spirv.IAdd operations Fixes llvm#65154
- inline the lowerAddCarry function to make it clearer that we check that each integer is of i32 - switch the computation of the carry to reduce instructions and simplify
- clarify description comment - add integration test for the vulkan runner
eeccf0a
to
9ed4b59
Compare
Rebased and force pushed to hopefully remedy the code_formatter error. |
You need to set these two in cmake:
|
The runner test fails with:
|
@inbelic I made the test type check and compile but it doesn't give the expected output: kuhar@d20f576 I changed the i8 memrefs to i32 because the type of both iadd_carry results will be the same on the spir-v side anyway, and it doesn't require spir-v capabilities for i8 types. This extends out test coverage to vulkan implementations that don't expose these, e.g., swiftshader. |
@kuhar Awesome thanks. Have got the runner test locally and also get the wrong behaviour when using the negative minimum integers for the input. I believe this is because the However, imo it should be that the negative number is interpreted as an unsigned integer and then we unfortunately will need to use a different solution. |
@inbelic Signed and unsigned integer addition is the same operation, that's why there's a single Therefore, |
- use int32 to reduce required capabilities of testing environments - updated test values with the expected behaviour
Resolved my confusion. Updated the test cases with your suggested changes and updated the expected values and inputs. |
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. I ran the integration tests on my machine and everything passed. Thanks!
@inbelic I went ahead and merged the code |
WebGPU does not currently support extended arithmetic, this is an issue when we want to lower from SPIR-V. This commit adds a pattern to transform and emulate spirv.IAddCarry with spirv.IAdd operations
Fixes #65154