Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
A few additional comments. Otherwise looks good to me after updating the test.
mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp | ||
---|---|---|
318 | nit: add period to the end of comment. | |
319 | I think it would make more sense to just convert to i32 because we don't know whether something like f16 -> int16 will be supported (@antiagainst to confirm). | |
320 | nit: unused variable | |
338–349 | It is probably cleaner to get the Attribute inside the if and then create the constant based on that attribute. |
Thanks for the fix! A few comments in addition to the missing test.
mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp | ||
---|---|---|
308 | Nit: // Get the scalar float type. | |
309 | Nit: Name this as scalarFloatType to be consistent with scalarIntType. | |
318 | Nit: // Get int type of the same bitwidth and shape as the float type. | |
319 | Nit: Type intType = scalarIntType to avoid duplication . | |
334 | Could you add a TODO here to mention that "The following just forcefully casts y into an integer value in order to properly propagate the sign, assuming integer y cases. It doesn't cover other cases and should be fixed." | |
339 | Can we repurpose getScalarOrVectorI32Constant to handle more bitwidths and use it here? | |
351 | In Vulkan, "For the OpSRem and OpSMod instructions, if either operand is negative the result is undefined." https://registry.khronos.org/vulkan/specs/1.3-extensions/html/chap50.html Also, mod is an expensive operation. Here we just want to check whether it's odd or even. You can do bit operation to bitwise and 1 == 1. |
mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp | ||
---|---|---|
319 | yup good point. we can always convert to i32 for capability reasons. (the exact value doesn't matter that much given we only care about the odd/even part.) |
mlir/lib/Conversion/MathToSPIRV/MathToSPIRV.cpp | ||
---|---|---|
339 | Remaining debugging dump(). :) I'll remove these before landing. |
Nit: // Get the scalar float type.