This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Modernize default lowering of vector transpose
ClosedPublic

Authored by dcaballe on Mar 9 2022, 11:48 AM.

Details

Summary

This patch removes an old recursive implementation to lower vector.transpose to extract/insert operations
and replaces it with a iterative approach that leverages newer linearization/delinearization utilities.
The patch should be NFC except by the order in which the extract/insert ops are generated.

Diff Detail

Event Timeline

dcaballe created this revision.Mar 9 2022, 11:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2022, 11:48 AM
dcaballe requested review of this revision.Mar 9 2022, 11:48 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 9 2022, 11:48 AM
nicolasvasilache accepted this revision.Mar 9 2022, 11:54 AM
nicolasvasilache added inline comments.
mlir/lib/Dialect/Utils/IndexingUtils.cpp
33 ↗(On Diff #414176)

actually, now that I see this, I remember we have:

void applyPermutationToVector(SmallVector<T, N> &inVec,
                              ArrayRef<int64_t> permutation)

in LinalgUtils.h; mind refactoring a bit more so that one uses the other / we end with only 1 version ?

mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
421

can we use/add a builder that would take ArrayRef and avoid the need for users to materialize the Attr ?

This revision is now accepted and ready to land.Mar 9 2022, 11:54 AM
dcaballe updated this revision to Diff 414260.Mar 9 2022, 6:22 PM
dcaballe marked an inline comment as done.

Addressed feedback.

I'll commit it tomorrow if no more comments. Thanks!

mlir/lib/Dialect/Utils/IndexingUtils.cpp
33 ↗(On Diff #414176)

I moved applyPermutationToVector to this file, since it's more generic and can be reused across dialects.

mlir/lib/Dialect/Vector/Transforms/VectorTransforms.cpp
421

Much better, thanks!