This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Fix re-oredring of floating point adds during lower of `vector.contract`.
ClosedPublic

Authored by mravishankar on Jun 27 2022, 11:44 AM.

Details

Summary

Adding the accumulator value after the vector.contract changes the
precision of the operation. This makes sure the accumulator is carried
through to vector.reduce (and down to LLVM).

Diff Detail

Event Timeline

mravishankar created this revision.Jun 27 2022, 11:44 AM
mravishankar requested review of this revision.Jun 27 2022, 11:44 AM
ThomasRaoux requested changes to this revision.Jun 27 2022, 11:51 AM
ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
411–412

We need to change the op description as well as the lowering to LLVM as this case was explicitly not allowed.

This revision now requires changes to proceed.Jun 27 2022, 11:51 AM
mravishankar added inline comments.Jun 27 2022, 12:16 PM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
411–412

Could you give me pointers to that. No tests fail, so not sure where to look.

ThomasRaoux added inline comments.Jun 27 2022, 12:39 PM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
411–412

I think we need to update at least those spots:
https://github.com/llvm/llvm-project/blob/ef5510d81b64fa64a75b9c9c024d7c0f6cb8e241/mlir/include/mlir/Dialect/Vector/IR/VectorOps.td#L283
https://github.com/llvm/llvm-project/blob/ef5510d81b64fa64a75b9c9c024d7c0f6cb8e241/mlir/lib/Conversion/VectorToLLVM/ConvertVectorToLLVM.cpp#L381

The lowering to LLVM for int assumes no acc. I'm guessing no test fails because this IR wasn't allowed and there is no tests going from MultiDimReduction to LLVM.

Rebase and adderss comments.

mravishankar added inline comments.Jun 27 2022, 4:18 PM
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
411–412

Added lowering for integer version of vector.reduction <..> with accumulator. PTAL.

ThomasRaoux accepted this revision.Jun 27 2022, 6:47 PM
ThomasRaoux added inline comments.
mlir/include/mlir/Dialect/Vector/IR/VectorOps.td
283 ↗(On Diff #440427)

nit: All reductions now allow for the optional accumulator. (remove the "Some"?)

This revision is now accepted and ready to land.Jun 27 2022, 6:47 PM