Page MenuHomePhabricator

[mlir][Vector] Add linalg.copy-based pattern for splitting vector.transfer_read into full and partial copies.
ClosedPublic

Authored by nicolasvasilache on Tue, Jul 28, 10:17 AM.

Details

Summary

This revision adds a transformation and a pattern that rewrites a "maybe masked" vector.transfer_read %view[...], %pad into a pattern resembling:

%1:3 = scf.if (%inBounds) {
   scf.yield %view : memref<A...>, index, index
 } else {
   %2 = linalg.fill(%extra_alloc, %pad)
   %3 = subview %view [...][...][...]
   linalg.copy(%3, %alloc)
   memref_cast %extra_alloc: memref<B...> to memref<A...>
   scf.yield %4 : memref<A...>, index, index
}
%res= vector.transfer_read %1#0[%1#1, %1#2] {masked = [false ... false]}

where extra_alloc is a top of the function alloca'ed buffer of one vector.

This rewrite makes it possible to realize the "always full tile" abstraction where vector.transfer_read operations are guaranteed to read from a padded full buffer.
The extra work only occurs on the boundary tiles.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptTue, Jul 28, 10:17 AM
nicolasvasilache requested review of this revision.Tue, Jul 28, 10:17 AM
bondhugula added inline comments.
mlir/lib/Dialect/Vector/VectorTransforms.cpp
2060–2069

Doc comment please.

2121

Avoid auto here.

2131

Missing doc comment.

2167

Missing doc comment.

2172–2201

This would need comments for the major blocks/logic.

nicolasvasilache marked 5 inline comments as done.

Comments.

ftynse accepted this revision.Mon, Aug 3, 3:37 AM
ftynse added inline comments.
mlir/include/mlir/Dialect/Vector/VectorOps.h
68

Typo: splut

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

Multiple typos here

2067

Typos: andor, dimenisons

This revision is now accepted and ready to land.Mon, Aug 3, 3:37 AM
aartbik accepted this revision.Mon, Aug 3, 12:46 PM
aartbik added inline comments.
mlir/include/mlir/Dialect/Vector/VectorTransforms.h
127–133

maybe add a

fastpath, direct cast.

comment to be symmetric with the slowpath comment

mlir/lib/Dialect/Vector/VectorTransforms.cpp
2255–2261

same

nicolasvasilache marked 5 inline comments as done.Tue, Aug 4, 5:38 AM