-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[mlir] [vector] Add linearization pattern for vector.create_mask #138214
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
Changes from 11 commits
3a83e2d
203ec82
24b0739
2b8a653
8e8de7a
528f913
c2c1a22
c5b2e81
8fca9c1
2b7e06e
db484c9
7b714ce
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -345,3 +345,31 @@ func.func @linearize_scalable_vector_splat(%arg0: i32) -> vector<4x[2]xi32> { | |
%0 = vector.splat %arg0 : vector<4x[2]xi32> | ||
return %0 : vector<4x[2]xi32> | ||
} | ||
|
||
// ----- | ||
|
||
// CHECK-LABEL: linearize_create_mask | ||
// CHECK-SAME: (%[[ARG0:.*]]: index, %[[ARG1:.*]]: index) -> vector<1x16xi1> | ||
func.func @linearize_create_mask(%arg0 : index, %arg1 : index) -> vector<1x16xi1> { | ||
|
||
// CHECK: %[[C0:.*]] = arith.constant 0 : index | ||
// CHECK: %[[CMP:.*]] = arith.cmpi sgt, %[[ARG0]], %[[C0]] : index | ||
// CHECK: %[[INDEXCAST:.*]] = arith.index_cast %[[CMP]] : i1 to index | ||
// CHECK: %[[MULI:.*]] = arith.andi %[[INDEXCAST]], %[[ARG1]] : index | ||
// CHECK: %[[MASK_1D:.*]] = vector.create_mask %[[MULI]] : vector<16xi1> | ||
// CHECK: %[[CAST:.*]] = vector.shape_cast %[[MASK_1D]] : vector<16xi1> to vector<1x16xi1> | ||
// CHECK: return %[[CAST]] : vector<1x16xi1> | ||
%0 = vector.create_mask %arg0, %arg1 : vector<1x16xi1> | ||
return %0 : vector<1x16xi1> | ||
} | ||
|
||
// ----- | ||
// CHECK-LABEL: linearize_scalable_create_mask | ||
// CHECK-SAME: (%[[ARG0:.*]]: index, %[[ARG1:.*]]: index) -> vector<1x[16]xi1> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: I think it is better to not capture arguments (ARG0 and and ARG1) if they are not subsequently used. Thanks for reducing the size of this test! In fact I think it could reduced even further to // This test is the same as |
||
func.func @linearize_scalable_create_mask(%arg0 : index, %arg1 : index) -> vector<1x[16]xi1> { | ||
|
||
// CHECK: %[[MASK_1D:.*]] = vector.create_mask {{%.*}} : vector<[16]xi1> | ||
// CHECK: %[[CAST:.*]] = vector.shape_cast %[[MASK_1D]] : vector<[16]xi1> to vector<1x[16]xi1> | ||
%0 = vector.create_mask %arg0, %arg1 : vector<1x[16]xi1> | ||
return %0 : vector<1x[16]xi1> | ||
} |
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.
Consider adding
// FIXME: add support for any vector with at most 1 non-unit dimension (like vector<1x4x1xi1>)
here