-
Notifications
You must be signed in to change notification settings - Fork 15k
[MLIR] Make 1-D memref flattening a prerequisite for vector narrow type emulation #157771
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
686a25b
First updates.
lialan b061ab9
Forgot to push
lialan f523d84
Adding new tests
lialan 6edd712
Fix according to comments.
lialan 2e850c3
Fix according to comments.
lialan 7c2a464
Merge branch 'main' into one_d_emulation
lialan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
mlir/test/Dialect/Vector/flatten-memref-and-emulate-narrow-types.mlir
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| // RUN: mlir-opt --test-memref-flatten-and-vector-narrow-type-emulation --split-input-file %s | FileCheck %s | ||
|
|
||
| // This test verifies that narrow-type-emulation works correctly for | ||
| // rank > 1 memrefs by combining memref flattening with vector narrow type | ||
| // emulation patterns. | ||
| // | ||
| // The patterns tested here demonstrate the composition of two transformations, | ||
| // memref flattening for vector ops and vector op narrow type emulation. | ||
| // | ||
| // TODO: Support `vector.transfer_write` operation. | ||
|
|
||
| func.func @vector_load_2d_i4(%arg0: index, %arg1: index) -> vector<8xi4> { | ||
lialan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| %0 = memref.alloc() : memref<4x8xi4> | ||
| %1 = vector.load %0[%arg0, %arg1] : memref<4x8xi4>, vector<8xi4> | ||
| return %1 : vector<8xi4> | ||
| } | ||
| // CHECK: func @vector_load_2d_i4 | ||
lialan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // CHECK: vector.load {{.*}} memref<16xi8> | ||
|
|
||
| // ----- | ||
|
|
||
| func.func @vector_maskedload_2d_i4(%arg0: index, %arg1: index, %passthru: vector<8xi4>) -> vector<8xi4> { | ||
| %0 = memref.alloc() : memref<4x8xi4> | ||
| %mask = vector.constant_mask [6] : vector<8xi1> | ||
| %1 = vector.maskedload %0[%arg0, %arg1], %mask, %passthru : | ||
| memref<4x8xi4>, vector<8xi1>, vector<8xi4> into vector<8xi4> | ||
| return %1 : vector<8xi4> | ||
| } | ||
| // CHECK: func @vector_maskedload_2d_i4( | ||
| // CHECK: vector.maskedload {{.*}} memref<16xi8> | ||
|
|
||
| // ----- | ||
|
|
||
| func.func @vector_maskedstore_2d_i4(%arg0: index, %arg1: index, %value: vector<8xi4>) { | ||
| %0 = memref.alloc() : memref<4x8xi4> | ||
| %mask = vector.constant_mask [5] : vector<8xi1> | ||
| vector.maskedstore %0[%arg0, %arg1], %mask, %value : | ||
| memref<4x8xi4>, vector<8xi1>, vector<8xi4> | ||
| return | ||
| } | ||
| // CHECK: func @vector_maskedstore_2d_i4( | ||
| // CHECK: vector.maskedstore {{.*}} memref<16xi8> | ||
|
|
||
| // ----- | ||
|
|
||
| func.func @vector_store_2d_i4(%arg0: index, %arg1: index, %value: vector<8xi4>) { | ||
| %0 = memref.alloc() : memref<4x8xi4> | ||
| vector.store %value, %0[%arg0, %arg1] : memref<4x8xi4>, vector<8xi4> | ||
| return | ||
| } | ||
| // CHECK: func @vector_store_2d_i4( | ||
| // CHECK: vector.store {{.*}} memref<16xi8> | ||
|
|
||
| // ----- | ||
|
|
||
| func.func @vector_transfer_read_2d_i4(%arg0: index, %arg1: index, %padding: i4) -> vector<8xi4> { | ||
| %0 = memref.alloc() : memref<4x8xi4> | ||
| %1 = vector.transfer_read %0[%arg0, %arg1], %padding {in_bounds = [true]} : memref<4x8xi4>, vector<8xi4> | ||
| return %1 : vector<8xi4> | ||
| } | ||
| // CHECK: func @vector_transfer_read_2d_i4( | ||
| // CHECK-SAME: %{{.*}}: index, %{{.*}}: index, %[[PADDING_I4:.*]]: i4) | ||
| // CHECK: %[[PADDING_I8:.*]] = arith.extui %[[PADDING_I4]] : i4 to i8 | ||
| // CHECK: vector.transfer_read {{.*}}, %[[PADDING_I8]] : memref<16xi8>, vector<4xi8> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
populateFlattenVectorMemrefPatternsincludes patterns forvector.store,vector.transfer_readandvector.transfer_write. Can you remind me - are these supported? If not, could you add a TODO here?Also, could you add a high-level comment specifying what combination of patterns is tested and that we are merely verifying that narrow-type-emulation works for rank > 1 memrefs? Otherwise the lack of more thorough test lines feels a bit ad-hoc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added new tests except
vector.transfer_write, added a TODO there.Also updated comments as well.