This is an archive of the discontinued LLVM Phabricator instance.

[mlir] Fix masked vector transfer ops with broadcasts
ClosedPublic

Authored by springerm on May 3 2021, 12:44 AM.

Details

Summary

Broadcast dimensions of a vector transfer op have no corresponding dimension in the mask vector. E.g., a 2-D TransferReadOp, where one dimension is a broadcast, can have a 1-D mask attribute.

This commit also adds a few additional transfer op integration tests for various combinations of broadcasts, masking, dim transposes, etc.

Diff Detail

Event Timeline

springerm created this revision.May 3 2021, 12:44 AM
springerm requested review of this revision.May 3 2021, 12:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 3 2021, 12:44 AM
springerm updated this revision to Diff 342337.May 3 2021, 2:03 AM

Fix build

aartbik added inline comments.May 5 2021, 11:02 AM
mlir/lib/Conversion/VectorToSCF/ProgressiveVectorToSCF.cpp
608

typo: broadcasted

mlir/lib/Interfaces/VectorInterfaces.cpp
17

I believe, in C++ files we are supposed to use the style rather than adding namespaces around code

mlir::vector::detail::transfermaskType

mlir/test/Integration/Dialect/Vector/CPU/test-transfer-read-1d.mlir
25

Very nitty, here and below, period at end of comment

mlir/include/mlir/Interfaces/VectorInterfaces.td
161

empty vector type usually does it, is there something special about the Optional here ?

mlir/lib/Conversion/VectorToSCF/ProgressiveVectorToSCF.cpp
153–155

Does not return -> Returns null ?

Also, can we enumerate the 3 cases:

  1. X
  2. Y
  3. Z
157–158

maybe is usually associated with optional in my mind, null Value is fine, can we drop the "maybe"?

springerm updated this revision to Diff 343968.May 9 2021, 11:02 PM

address review comments

springerm marked 5 inline comments as done.May 9 2021, 11:08 PM
springerm added inline comments.
mlir/test/Integration/Dialect/Vector/CPU/test-transfer-read-1d.mlir
25

I usually put dots only at the end of sentences, not headlines etc.

aartbik added inline comments.May 10 2021, 12:17 PM
mlir/test/Integration/Dialect/Vector/CPU/test-transfer-read-1d.mlir
25

Yes, but you are part of a larger suite now, and all other files here follow that style.

springerm updated this revision to Diff 344241.May 10 2021, 5:31 PM

address comments

springerm updated this revision to Diff 344249.May 10 2021, 5:42 PM
springerm marked an inline comment as done.

address comments

ThomasRaoux added inline comments.May 11 2021, 9:19 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
2531

Should we add something in verifyTransferOp to check that the mask type is consistent?

springerm added inline comments.May 11 2021, 11:23 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
2531

Yes, I think there should be a check here, because the mask attribute could be modified.

But in general, parser.resolveOperand(maskInfo, maskType, result.operands) already raises an error if a type different from maskType is found during parsing if I remember correctly. Do you know why this is the case? Why does resolveOperand do type checking (maybe in addition to the verifier)?

ThomasRaoux added inline comments.May 11 2021, 11:36 PM
mlir/lib/Dialect/Vector/VectorOps.cpp
2531

Yes the parser will check that the types are consistent. Since the parser infer the mask type it will check that the value has the correct type - the verifier will check that a value is used with the same type as it is defined.

That mean you won't be able to write a simple test for this case but I still think it may be valuable to have the verifier so that when ops are created with the builder there is also a check.

address comments

springerm updated this revision to Diff 344729.May 12 2021, 2:31 AM

masks not supported with vector element type of memref

nicolasvasilache accepted this revision.May 12 2021, 3:36 AM

Same thing as in the previous PR, would be good to have some minimal IR check too.
Approving conditioned on that.

Thanks!

mlir/lib/Conversion/VectorToSCF/ProgressiveVectorToSCF.cpp
82–84

Value maskBuffer = ... ?

91

looks like a good helper to add to vector.transfer ops : isBroadcast(int dim) ?

This revision is now accepted and ready to land.May 12 2021, 3:36 AM
springerm updated this revision to Diff 344999.May 12 2021, 6:37 PM
springerm marked 4 inline comments as done.

address comments

springerm marked an inline comment as done.May 12 2021, 6:43 PM
This revision was landed with ongoing or failed builds.May 12 2021, 7:38 PM
This revision was automatically updated to reflect the committed changes.
springerm reopened this revision.May 12 2021, 7:56 PM
This revision is now accepted and ready to land.May 12 2021, 7:56 PM
springerm updated this revision to Diff 345020.May 12 2021, 7:57 PM

upload newest version

This revision was automatically updated to reflect the committed changes.