This is an archive of the discontinued LLVM Phabricator instance.

[mlir][Vector] Extend xfer drop unit dim patterns
ClosedPublic

Authored by dcaballe on May 19 2023, 4:23 PM.

Details

Summary

This patch extends the transfer drop unit dim patterns to support cases where the vector shape should also be reduced
(e.g., transfer_read(memref<1x4x1xf32>, vector<1x4x1xf32>) -> transfer_read(memref<4xf32>, vector<4xf32>).

Diff Detail

Event Timeline

dcaballe created this revision.May 19 2023, 4:23 PM
Herald added a project: Restricted Project. · View Herald Transcript
dcaballe requested review of this revision.May 19 2023, 4:23 PM
dcaballe edited the summary of this revision. (Show Details)May 19 2023, 4:25 PM
dcaballe added reviewers: hanchung, ThomasRaoux, pzread.
hanchung accepted this revision.May 22 2023, 11:01 AM

Overall looks good to me, thanks! Just few nits.

mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
287

I know that this is wrapped within anonymous namespace, so we don't need the static keyword. The style guide points out that we should use static keyword even if they are within anonymous namespace.

They reduce locality of reference: if you see a random function definition in a C++ file, it is easy to see if it is marked static, but seeing if it is in an anonymous namespace requires scanning a big chunk of the file.

https://llvm.org/docs/CodingStandards.html#anonymous-namespaces

292–297

ditto, add a static keyword.

346–347

style nit: use auto. Because ::get method already spells the type.

https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable

This revision is now accepted and ready to land.May 22 2023, 11:01 AM
pzread added inline comments.May 22 2023, 11:27 AM
mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
296

Can you add a test to check when we have the vector shape <1x1x1xf32>? I ran into a problem in that case since the pass reduces them into zero-dim vectors.

dcaballe updated this revision to Diff 524409.May 22 2023, 11:37 AM
dcaballe marked 3 inline comments as done.

Address feedback

Landing. Thanks!

mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
287

I think the doc means that we should move these cases out of the anonymous namespace and use static instead but not using both at the same time. Fixed!

dcaballe added inline comments.May 22 2023, 11:39 AM
mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
296

Sure, let me try

hanchung added inline comments.May 22 2023, 2:22 PM
mlir/lib/Dialect/Vector/Transforms/VectorTransferOpTransforms.cpp
287

Good point.. You're right! (My point was echoing the "scanning a big chunk of the file" point. And yes, it's not saying that we should use it at the same time.)

dcaballe updated this revision to Diff 524840.May 23 2023, 12:15 PM

Support and test 0-d

pzread accepted this revision.May 23 2023, 1:23 PM
This revision was automatically updated to reflect the committed changes.