This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Add more vector.contract -> outerproduct lowerings and fix vector.contract type inference.
ClosedPublic

Authored by nicolasvasilache on May 21 2020, 11:14 AM.

Details

Summary

This revision expands the types of vector contractions that can be lowered to vector.outerproduct.
All 8 permutation cases are support.
The idiomatic manipulation of AffineMap written declaratively makes this straightforward.

In the process a bug with the vector.contract verifier was uncovered.
The vector shape verification part of the contract op is rewritten to use AffineMap composition.
One bug in the vector ops.mlir test is fixed and a new case not yet captured is added
to the vector`invalid.mlir` test.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptMay 21 2020, 11:14 AM
aartbik added inline comments.May 21 2020, 12:46 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
300

Nit: one would expect 'expected' to only be set when the method returns true; likewise, for the scalar case, the parameter is not set (obviously since it is a vector); since it is a local method it is okay to have a very specific interface, but since you both test the return value and expected contents with !, as well as print the expected contents on failure, the API feels a bit convoluted

mlir/test/Dialect/Vector/vector-contract-transforms.mlir
3

why did the threading flag get into play here?

nicolasvasilache marked 4 inline comments as done.

Address review.

mlir/lib/Dialect/Vector/VectorOps.cpp
300

makes sense, updated the API

mlir/test/Dialect/Vector/vector-contract-transforms.mlir
3

debugging leftover, thanks!

ftynse accepted this revision.May 26 2020, 9:36 AM
ftynse added inline comments.
mlir/lib/Dialect/Vector/VectorOps.cpp
275

No need to reserve after constructing with a size

285

Nit: assert(... && "textual explanation") would be helpful here

292

Nit: same as above

mlir/lib/Dialect/Vector/VectorTransforms.cpp
1532

This looks unused.

1569

The code permutes the Lhs, while the comment claims its Rhs.

1587

Same as above

This revision is now accepted and ready to land.May 26 2020, 9:36 AM
ftynse added inline comments.May 26 2020, 9:37 AM
mlir/test/Dialect/Vector/vector-contract-transforms.mlir
3

Still see it in the code, forgot to upload?

nicolasvasilache marked 7 inline comments as done.May 26 2020, 12:35 PM

Address reviews.

This revision was automatically updated to reflect the committed changes.

@jpienaar sent a hotfix in ae903f0313e481520eff8a13044070aca4d0b75d, it is weird that neither our internal or OSS clang-9.0.1 caught this ..