This is an archive of the discontinued LLVM Phabricator instance.

[mlir] [VectorOps] Framework for progressive lowering of vector.contract
ClosedPublic

Authored by aartbik on Feb 18 2020, 2:42 PM.

Details

Summary

Lowers all free/batch dimensions in a vector.contract progressively
into simpler vector.contract operations until a direct vector.reduction
operation is reached. Then lowers 1-D reductions into vector.reduce.

Still TBD:
multi-dimensional contractions that remain after removing all the parallel dims

Diff Detail

Event Timeline

aartbik created this revision.Feb 18 2020, 2:42 PM
aartbik edited the summary of this revision. (Show Details)Feb 18 2020, 2:45 PM
aartbik added reviewers: andydavis1, rriddle.
andydavis1 added inline comments.Feb 18 2020, 2:50 PM
mlir/lib/Dialect/VectorOps/VectorTransforms.cpp
980

Remove debug code.

rriddle added inline comments.Feb 18 2020, 3:40 PM
mlir/lib/Dialect/VectorOps/VectorTransforms.cpp
926

Can we add /*...=*/ parameter comments to these constant -1s?

972

Can you add messages to these asserts?

993

Drop the mlir:: here.

1037

nit: Use Optional<int64_t> instead.

1070

nit: Don't use trailing comments.

aartbik updated this revision to Diff 245304.Feb 18 2020, 4:45 PM
aartbik marked 5 inline comments as done.

addressed comments

andydavis1 accepted this revision.Feb 19 2020, 11:06 AM

Thanks Aart!

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

As discussed in person, let's add a TODO to separate the transpose cases out into a separate vector transpose operation.

954

Add a TODO to consider using the existing vector ContractionOp unrolling in VectorTransforms.cpp mlir::vector::unrollSingleResultOpMatchingType(...).
That transform takes a target vector size and supports any iteration order during unrolling: (i, j, k), (i, k, j), etc...

1078

Please add a TODO to see if you can use the vector ReshapeOp for these reshapes in the future. You could emit a ReshapeOp here, then have a separate pattern for lowering the ReshapeOps.

This revision is now accepted and ready to land.Feb 19 2020, 11:06 AM
aartbik updated this revision to Diff 245479.Feb 19 2020, 11:30 AM
aartbik marked 2 inline comments as done.

added TODOs as requested

aartbik marked an inline comment as done.Feb 19 2020, 11:32 AM
This revision was automatically updated to reflect the committed changes.

Thanks for adding this Aart!
Made a quick pass as I am catching up.
I am wondering whether the impl could be simplified or whether some of the complexity is a fundamental property of the problem at hand?

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

typo Contraction

881

+1, thanks Andy!