This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Merge accumulator/result transpose into contract
ClosedPublic

Authored by antiagainst on Oct 7 2022, 3:43 PM.

Details

Summary

This commit adds a pattern to merge accumulator and result
vector.transpose ops into vector.contract. This kind of
pattern can be generated for NCHW convolution vectorization,
where we use transposes to convert the 1-D NCW convolution
into NWC during vectorization. Merging the transpose would
mean we can avoid materialize vector extract/insert for
transposes and it makes further vector level transformations
easier.

Diff Detail

Event Timeline

antiagainst created this revision.Oct 7 2022, 3:43 PM
Herald added a project: Restricted Project. · View Herald Transcript
antiagainst requested review of this revision.Oct 7 2022, 3:43 PM
ThomasRaoux added inline comments.Oct 7 2022, 3:51 PM
mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
1107

I wonder if we want to fail in case the contractOp has multiple users as it would duplicate the contraction op?

ThomasRaoux accepted this revision.Oct 7 2022, 4:01 PM
ThomasRaoux added inline comments.
mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
1133

nit: the code could be simplified a bit by checking inversePermutation(accTMap) != resTMap

This revision is now accepted and ready to land.Oct 7 2022, 4:01 PM

Address comments

antiagainst marked an inline comment as done.Oct 7 2022, 4:09 PM
antiagainst added inline comments.
mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
1107

Good point. Done.

antiagainst marked 2 inline comments as done.Oct 7 2022, 4:10 PM