This patch adds constant folder for CosOp which only supports single and double precision floating-point.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
360–376 | I don't think this test should be affected |
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
360–376 | +1 can you please look into this? Is it an issue with the C++ cos function? |
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
360–376 | Yes, I think so. I tried cosf(acosf(-1.0f/2)), the result is not zero too. I think the way cosf and cos caculates might cause some difference. |
I look the constant folder in llvm, it also use cos in libmath to fold llvm.cos. C cos function would cause some inaccuracy than the approximation we had. Any advice for this?
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
358–359 | Can you extra the constant in a function and call it so that folder does not kick in here? |
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
358–359 | It maybe a little odd to have a floating point constant here. In this situation, we need to extra all constant that is integral multiple of PI/2, and we need a new float epsilon to compare our constant input and target number. |
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
360–376 | Good idea. I do not know well about mlir's command line, how to disable |
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
360–376 | Unfortunately, since these are folders, you'll have to "hide" the constants from the op by passing them as function arguments. |
Address comment.
mlir/test/mlir-cpu-runner/math-polynomial-approx.mlir | ||
---|---|---|
360–376 | Thanks, I changed to this form, will this be OK? |
LGTM, but all the other test cases in this file will need to be changed. Since you added folders, they're folding instead of testing the pass. Can you do that in a follow-up?
I've filed https://github.com/llvm/llvm-project/issues/57613. PTAL when you have time
mlir/test/Dialect/Math/canonicalize.mlir | ||
---|---|---|
362 | Note: on Mac I'm getting %cst = arith.constant 0.540302336 : f32 here. |
Note: on Mac I'm getting
%cst = arith.constant 0.540302336 : f32
here.