This is an archive of the discontinued LLVM Phabricator instance.

Generalize the vector transfer flattening patterns (dyn shapes).
ClosedPublic

Authored by Benoit on Jul 21 2022, 9:16 AM.

Details

Summary

This generalizes this pattern to support dynamic shapes, and the source memref is no longer flattened all the way to 1D. Only a sufficient number of innermost dimensions are collapsed, to match the number of elements of the vectorType (which is still being flattened to 1D).

Not flattening the outer dimensions of the memrefType is key to simple, correct handling of the indices for these outer dims: we can just keep those as-is, whereas if we kept the flattening of all those outer dims, we would have to generate arithmetic to compute the correct flattened index.

This pattern was also conflating another thing into it: a helper was calling rankReducingSubviewDroppingUnitDims, which was duplicating the work of the other patterns Transfer{Read,Write}DropUnitDimsPattern. This is dropped. That didn't seem to break anything, possibly because whichever places needed that were also adding those patterns anyway. The reason why I specifically needed to drop that now was that conflating that was making the logic here really messy.

Diff Detail

Event Timeline

Benoit created this revision.Jul 21 2022, 9:16 AM
Benoit requested review of this revision.Jul 21 2022, 9:16 AM
Benoit edited the summary of this revision. (Show Details)Jul 21 2022, 9:19 AM
Benoit added a reviewer: ThomasRaoux.
Benoit updated this revision to Diff 446535.Jul 21 2022, 9:21 AM

fix comment.

Benoit updated this revision to Diff 446536.Jul 21 2022, 9:22 AM

actually return 0 for out-of-bounds case.

Benoit updated this revision to Diff 446622.Jul 21 2022, 1:42 PM

Fixes issues found in IREE integration; limit generality: not handling nonzero indices after all.

Benoit updated this revision to Diff 446624.Jul 21 2022, 1:43 PM

clang-format

Benoit edited the summary of this revision. (Show Details)Jul 21 2022, 1:45 PM
Benoit retitled this revision from Generalize the vector transfer flattening patterns (dyn shapes). to (DO NOT REVIEW YET) Generalize the vector transfer flattening patterns (dyn shapes)..Jul 21 2022, 1:48 PM
Benoit edited the summary of this revision. (Show Details)
Benoit updated this revision to Diff 447029.Jul 22 2022, 7:36 PM

correct handling of outer indices. No longer flattening the outer dims.

Benoit retitled this revision from (DO NOT REVIEW YET) Generalize the vector transfer flattening patterns (dyn shapes). to Generalize the vector transfer flattening patterns (dyn shapes)..Jul 22 2022, 7:42 PM
Benoit edited the summary of this revision. (Show Details)
Benoit added a reviewer: antiagainst.
Benoit updated this revision to Diff 447031.Jul 22 2022, 7:45 PM
Benoit edited the summary of this revision. (Show Details)

drop no-longer-needed hunk

Benoit updated this revision to Diff 447032.Jul 22 2022, 7:48 PM

comments

ThomasRaoux accepted this revision.Jul 24 2022, 7:42 PM

LGTM once the last minor comments are addressed

mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
382

Nit: remove braces

507

Should be cast<> if you don’t expect null result (and don’t check for it)

This revision is now accepted and ready to land.Jul 24 2022, 7:42 PM
Benoit updated this revision to Diff 447351.Jul 25 2022, 8:23 AM

review comments

Benoit marked 2 inline comments as done.Jul 25 2022, 8:24 AM