-
Notifications
You must be signed in to change notification settings - Fork 11k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[mlir][VectorOps] Don't drop scalable dims when lowering transfer_rea…
…ds/writes (in VectorToLLVM) This is a follow-on to D158753, and allows the lowering of a transfer read/write of n-D vectors with a single trailing scalable dimension to primitive vector ops. The final conversion to LLVM depends on D158517 and D158752, without these patches type conversion will fail (or an assert is hit in the LLVM backend) if the final IR contains an array of scalable vectors. This patch adds `transform.apply_patterns.vector.lower_create_mask` which allows the lowering of vector.create_mask/constant_mask to be tested independently of --convert-vector-to-llvm. Reviewed By: c-rhodes, awarzynski, dcaballe Differential Revision: https://reviews.llvm.org/D159482
- Loading branch information
Showing
6 changed files
with
84 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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
40 changes: 40 additions & 0 deletions
40
mlir/test/Dialect/Vector/vector-scalable-create-mask-lowering.mlir
This file contains 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,40 @@ | ||
// RUN: mlir-opt %s --test-transform-dialect-interpreter | FileCheck %s | ||
|
||
// CHECK-LABEL: func.func @create_mask_2d_trailing_scalable( | ||
// CHECK-SAME: %[[arg:.*]]: index) -> vector<3x[4]xi1> { | ||
// CHECK-NEXT: %[[zero_mask_1d:.*]] = arith.constant dense<false> : vector<[4]xi1> | ||
// CHECK-NEXT: %[[zero_mask_2d:.*]] = arith.constant dense<false> : vector<3x[4]xi1> | ||
// CHECK-NEXT: %[[create_mask_1d:.*]] = vector.create_mask %[[arg]] : vector<[4]xi1> | ||
// CHECK-NEXT: %[[res_0:.*]] = vector.insert %[[create_mask_1d]], %[[zero_mask_2d]] [0] : vector<[4]xi1> into vector<3x[4]xi1> | ||
// CHECK-NEXT: %[[res_1:.*]] = vector.insert %[[create_mask_1d]], %[[res_0]] [1] : vector<[4]xi1> into vector<3x[4]xi1> | ||
// CHECK-NEXT: %[[res_2:.*]] = vector.insert %[[zero_mask_1d]], %[[res_1]] [2] : vector<[4]xi1> into vector<3x[4]xi1> | ||
// CHECK-NEXT: return %[[res_2]] : vector<3x[4]xi1> | ||
func.func @create_mask_2d_trailing_scalable(%a: index) -> vector<3x[4]xi1> { | ||
%c2 = arith.constant 2 : index | ||
%mask = vector.create_mask %c2, %a : vector<3x[4]xi1> | ||
return %mask : vector<3x[4]xi1> | ||
} | ||
|
||
// ----- | ||
|
||
/// The following cannot be lowered as the current lowering requires unrolling | ||
/// the leading dim. | ||
|
||
// CHECK-LABEL: func.func @cannot_create_mask_2d_leading_scalable( | ||
// CHECK-SAME: %[[arg:.*]]: index) -> vector<[4]x4xi1> { | ||
// CHECK: %{{.*}} = vector.create_mask %[[arg]], %{{.*}} : vector<[4]x4xi1> | ||
func.func @cannot_create_mask_2d_leading_scalable(%a: index) -> vector<[4]x4xi1> { | ||
%c1 = arith.constant 1 : index | ||
%mask = vector.create_mask %a, %c1 : vector<[4]x4xi1> | ||
return %mask : vector<[4]x4xi1> | ||
} | ||
|
||
transform.sequence failures(suppress) { | ||
^bb1(%module_op: !transform.any_op): | ||
%f = transform.structured.match ops{["func.func"]} in %module_op | ||
: (!transform.any_op) -> !transform.any_op | ||
|
||
transform.apply_patterns to %f { | ||
transform.apply_patterns.vector.lower_create_mask | ||
} : !transform.any_op | ||
} |