This is an archive of the discontinued LLVM Phabricator instance.

[mlir][vector] Add support for scalable vectors in `trimLeadingOneDims`
ClosedPublic

Authored by awarzynski on Aug 15 2023, 9:16 AM.

Details

Summary

This patch updates one specific hook in "VectorDropLeadUnitDim.cpp" to
make sure that "scalable dims" are handled correctly. While this change
affects multiple patterns, I am only adding one regression tests that
captures one specific case that affects me right now.

I am also adding Vector dialect to the list of dependencies of
-test-vector-to-vector-lowering. Otherwise my test case won't work as
a standalone test.

Diff Detail

Event Timeline

awarzynski created this revision.Aug 15 2023, 9:16 AM
Herald added a project: Restricted Project. · View Herald Transcript
awarzynski requested review of this revision.Aug 15 2023, 9:16 AM
benmxwl-arm added inline comments.Aug 18 2023, 3:46 AM
mlir/lib/Dialect/Vector/Transforms/VectorDropLeadUnitDim.cpp
26–27

This could still incorrectly trim something like vector<[1]x1xi128> to vector<1xi128> as the drop_while() is not checking if the dimension is scalable.

Refine how scalable vectors are treated

awarzynski added inline comments.Aug 19 2023, 8:08 AM
mlir/lib/Dialect/Vector/Transforms/VectorDropLeadUnitDim.cpp
26–27

Great catch, thanks! It's a bit tricky to test this here (many patterns require an update to`tensor.extract` first), but in https://reviews.llvm.org/D158335 I've added a fair tests for cases like this.

benmxwl-arm accepted this revision.Aug 21 2023, 7:51 AM

Very minor nit, otherwise LGTM!

mlir/lib/Dialect/Vector/Transforms/VectorDropLeadUnitDim.cpp
25–32

nit: These are constructed a little inconsistently. Standard assignment should work here :)

This revision is now accepted and ready to land.Aug 21 2023, 7:51 AM

Fix inconsistency - thanks for pointing that out Ben!

dcaballe accepted this revision.Aug 21 2023, 10:31 PM

Thanks!

This revision was landed with ongoing or failed builds.Aug 22 2023, 1:46 AM
This revision was automatically updated to reflect the committed changes.