This is an archive of the discontinued LLVM Phabricator instance.

[mlir] [VectorOps] Multi-dim reductions for lowering vector.contract
ClosedPublic

Authored by aartbik on Feb 19 2020, 4:20 PM.

Details

Summary

This implements the last step for lowering vector.contract progressively
to LLVM IR (except for masks). Multi-dimensional reductions that remain
after expanding all parallel dimensions are lowered into into simpler
vector.contract operations until a trivial 1-dim reduction remains.

Diff Detail

Event Timeline

aartbik created this revision.Feb 19 2020, 4:20 PM
andydavis1 accepted this revision.Feb 20 2020, 1:22 PM

Looks good, thanks Aart! One question, is the unrolling here deterministic in that the same op will always produce the same sequence of reductions after unrolling? Context is numerical stability across test runs....

mlir/lib/Dialect/VectorOps/VectorTransforms.cpp
1031

Maybe not in this change, but it would be great if this unrolling code could reuse the unrolling code already in this file: mlir::vector::unrollSingleResultOpMatchingType(

1070

s/idx/id.index() don't see 'idx' used elsewhere.

This revision is now accepted and ready to land.Feb 20 2020, 1:22 PM
aartbik marked 4 inline comments as done.Feb 20 2020, 1:56 PM

The order is always the same of a given mapping and op, but the accumulation may indeed introduce instabilities if an exact order is assumed (i.e. acc feeds into the chain rather than being just added at the end). We can make semantics more strict if needed.

mlir/lib/Dialect/VectorOps/VectorTransforms.cpp
1031

Ack.

1070

This was actually done on purpose to avoid having to cast one to the type of the other (to avoid compiler complaints about sign).
By first assigning it.index() to int64_t this is all done in a much more readable way.

aartbik updated this revision to Diff 245736.Feb 20 2020, 2:02 PM
aartbik marked 2 inline comments as done.

rebase

This revision was automatically updated to reflect the committed changes.
rriddle added inline comments.Feb 20 2020, 2:22 PM
mlir/lib/Dialect/VectorOps/VectorTransforms.cpp
1070

nit: Please remove trivial braces. Also can you just inline the 'idx' variable into its use?