This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Allow a 0-d for for vector transfer ops.
ClosedPublic

Authored by nicolasvasilache on Oct 11 2021, 10:15 AM.

Details

Summary

This revision updates the op semantics, printer, parser and verifier to allow 0-d transfers.
Until 0-d vectors are available, such transfers have a special form that transits through vector<1xt>.
This is a stepping stone towards the longer term work of adding 0-d vectors and will help significantly reduce corner cases in vectorization.

Transformations and lowerings do not yet support this form, extensions will follow.

Diff Detail

Event Timeline

nicolasvasilache requested review of this revision.Oct 11 2021, 10:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 11 2021, 10:15 AM

Just a quick comment for now... Before moving forward with this, would it make sense to send a small RFC to describe what a 0-d vector is, motivation, how it's different from a scalar or a vector<1xtype>. It seems like a significant addition to me and I think we have to make sure it aligns and composes well with tensors and memrefs.

0-d vectors were discussed here: https://llvm.discourse.group/t/should-we-have-0-d-vectors/3097
There was quick consensus that the addition makes sense.

Note: vector::LoadOp and vector::StoreOp will also need to be updated. The LLVM lowering goes through these two ops. (There are also masked versions of those, but I think these can remain unchanged.)

mlir/include/mlir/Dialect/Vector/VectorOps.td
1281

There could be some ambiguity with broadcasts, which are also encoded with zeros.

Maybe an affine map with no result would make more sense, since we actually have no dimension in the 0D case:

affine_map<()->()> or affine_map<()->(0)>

Not sure if this valid though...

mlir/lib/Dialect/Vector/VectorUtils.cpp
246–247

This affine map has no results.

ThomasRaoux added inline comments.Oct 11 2021, 5:09 PM
mlir/include/mlir/Dialect/Vector/VectorOps.td
1281

+1, it sounds I believe affine_map<()->(0)> would be the most aligned with what we have now since the vector has a rank of 1 so we have 1 result and tensor has a rank of 0 so we should have 0 input dim.

nicolasvasilache marked 3 inline comments as done.

Address review.

mlir/include/mlir/Dialect/Vector/VectorOps.td
1281

you're both right, thanks for catching this.

Note: vector::LoadOp and vector::StoreOp will also need to be updated. The LLVM lowering goes through these two ops. (There are also masked versions of those, but I think these can remain unchanged.)

yes that will come in the followup

gysit accepted this revision.Oct 12 2021, 4:59 AM
This revision is now accepted and ready to land.Oct 12 2021, 4:59 AM
springerm accepted this revision.Oct 12 2021, 5:01 AM