Page MenuHomePhabricator

[mlir][Vector] Add transformation + pattern to split vector.transfer_read into full and partial copies.

Authored by nicolasvasilache on Jul 27 2020, 3:47 AM.



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 = vector.transfer_read %view[...], %pad : memref<A...>, vector<...>
   %3 = vector.type_cast %extra_alloc : memref<...> to
   memref<vector<...>> store %2, %3[] : memref<vector<...>> %4 =
   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 TranscriptJul 27 2020, 3:47 AM

Drop CMake changes.

Fix map capture, $ is now required for globals.

Make alloca default again.

asaadaldien added inline comments.Jul 27 2020, 11:49 AM

duplicate condition, remove ?

aartbik added inline comments.Jul 27 2020, 1:32 PM

lint wants

// namespace scf


The "If ...." sentence seems hanging. Does it belong to anything?

nicolasvasilache marked 3 inline comments as done.

Address review.

Deterministic IR.

aartbik accepted this revision.Jul 29 2020, 11:29 AM

Change LGTM, however, consider adding a bit more comments to make the large blocks a bit more readable.


By adding a bit more comments to the zipResultAndIndexing body, the structure of this call may be a bit more clear


you have a good documenting comment in the header file for matchAndRewrite(). However, this implementation code would benefit if you repeat some of what you are doing here, just to link it back to what you are generating where.

This revision is now accepted and ready to land.Jul 29 2020, 11:29 AM
nicolasvasilache marked 2 inline comments as done.Aug 3 2020, 1:53 AM
nicolasvasilache added inline comments.

Some like to reproduce comments in both the .h and the .cpp
I went ahead and did that.

nicolasvasilache marked an inline comment as done.

Add comments.

This revision was landed with ongoing or failed builds.Aug 3 2020, 1:55 AM
This revision was automatically updated to reflect the committed changes.