This is an archive of the discontinued LLVM Phabricator instance.

[mlir][linalg] Add isPermutation helper (NFC).
ClosedPublic

Authored by gysit on Sep 21 2021, 1:33 AM.

Details

Summary

Add a helper method to check if an index vector contains a permutation of its indices. Additionally, refactor applyPermutationToVector to take int64_t.

Diff Detail

Event Timeline

gysit created this revision.Sep 21 2021, 1:33 AM
gysit requested review of this revision.Sep 21 2021, 1:33 AM
gysit added inline comments.Sep 21 2021, 1:38 AM
mlir/include/mlir/Dialect/Linalg/Utils/Utils.h
34

AFAIK the context is needed to create an AffineMap. Optionally, we may also add an assertion inside of applyPermutationToVector, but this would also require adding context to the argument list.

nicolasvasilache accepted this revision.Sep 21 2021, 6:23 AM
This revision is now accepted and ready to land.Sep 21 2021, 6:23 AM

you could also just traverse by recording the min, max and unique counts to avoid creating the AffineMap in the first place.

This works too.

gysit updated this revision to Diff 373923.Sep 21 2021, 7:27 AM

Verify permutation without using AffineMap.

gysit updated this revision to Diff 373935.Sep 21 2021, 7:52 AM

Add unsigned to signed casts.

This revision was landed with ongoing or failed builds.Sep 21 2021, 8:08 AM
This revision was automatically updated to reflect the committed changes.