Skip to content

Commit d716bbb

Browse files
committed
Review feedback
1 parent 2f14c0f commit d716bbb

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

mlir/include/mlir/Dialect/Vector/IR/VectorOps.td

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2485,10 +2485,9 @@ def Vector_MaskOp : Vector_Op<"mask", [
24852485
terminator yields all results from the maskable operation to the result of
24862486
this operation. No other values are allowed to be yielded.
24872487

2488-
An empty `vector.mask` operation is considered ill-formed but legal to
2489-
facilitate optimizations across the `vector.mask` operation. It is considered
2490-
a no-op regardless of its returned values and will be removed by the
2491-
canonicalizer.
2488+
An empty `vector.mask` operation is legal to facilitate optimizations across
2489+
the `vector.mask` operation. However, it is considered a no-op regardless of
2490+
its returned values and will be removed by the canonicalizer.
24922491

24932492
The vector mask argument holds a bit for each vector lane and determines
24942493
which vector lanes should execute the maskable operation and which ones

mlir/lib/Dialect/Vector/IR/VectorOps.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6550,18 +6550,20 @@ void mlir::vector::MaskOp::print(OpAsmPrinter &p) {
65506550
}
65516551

65526552
void MaskOp::ensureTerminator(Region &region, Builder &builder, Location loc) {
6553-
// Create default terminator if there are no ops to mask.
6553+
// 1. For an empty `vector.mask`, create a default terminator.
65546554
if (region.empty() || region.front().empty()) {
65556555
OpTrait::SingleBlockImplicitTerminator<vector::YieldOp>::Impl<
65566556
MaskOp>::ensureTerminator(region, builder, loc);
65576557
return;
65586558
}
65596559

6560-
// If region has an explicit terminator, we don't modify it.
6560+
// 2. For a non-empty `vector.mask` with an explicit terminator, do nothing.
65616561
Block &block = region.front();
65626562
if (isa<vector::YieldOp>(block.back()))
65636563
return;
65646564

6565+
// 3. For a non-empty `vector.mask` without an explicit terminator:
6566+
65656567
// Create default terminator if the number of masked operations is not
65666568
// one. This case will trigger a verification failure.
65676569
if (block.getOperations().size() != 1) {
@@ -6610,9 +6612,8 @@ LogicalResult MaskOp::verify() {
66106612
"number of results");
66116613

66126614
if (!llvm::equal(maskableOp->getResults(), terminator.getOperands()))
6613-
return emitOpError(
6614-
"expects all the results from the MaskableOpInterface to "
6615-
"be returned by the terminator");
6615+
return emitOpError("expects all the results from the MaskableOpInterface "
6616+
"to match all the values returned by the terminator");
66166617

66176618
if (!llvm::equal(maskableOp->getResultTypes(), getResultTypes()))
66186619
return emitOpError(

mlir/test/Dialect/Vector/invalid.mlir

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1756,12 +1756,12 @@ func.func @vector_mask_empty_passthru_no_return_type(%mask : vector<8xi1>,
17561756

17571757
// -----
17581758

1759-
func.func @vector_mask_non_empty_external_return(%t0: tensor<?xf32>, %idx: index,
1760-
%m0: vector<16xi1>, %ext: vector<16xf32>) -> vector<16xf32> {
1759+
func.func @vector_mask_non_empty_external_return(%t: tensor<?xf32>, %idx: index,
1760+
%m: vector<16xi1>, %ext: vector<16xf32>) -> vector<16xf32> {
17611761
%ft0 = arith.constant 0.0 : f32
1762-
// expected-error@+1 {{'vector.mask' op expects all the results from the MaskableOpInterface to be returned by the terminator}}
1763-
%0 = vector.mask %m0 {
1764-
%1 =vector.transfer_read %t0[%idx], %ft0 : tensor<?xf32>, vector<16xf32>
1762+
// expected-error@+1 {{'vector.mask' op expects all the results from the MaskableOpInterface to match all the values returned by the terminator}}
1763+
%0 = vector.mask %m {
1764+
%1 =vector.transfer_read %t[%idx], %ft0 : tensor<?xf32>, vector<16xf32>
17651765
vector.yield %ext : vector<16xf32>
17661766
} : vector<16xi1> -> vector<16xf32>
17671767

@@ -1779,12 +1779,12 @@ func.func @vector_mask_empty_passthru_empty_return_type(%mask : vector<8xi1>,
17791779

17801780
// -----
17811781

1782-
func.func @vector_mask_non_empty_mixed_return(%t0: tensor<?xf32>, %idx: index,
1783-
%m0: vector<16xi1>, %ext: vector<16xf32>) -> (vector<16xf32>, vector<16xf32>) {
1782+
func.func @vector_mask_non_empty_mixed_return(%t: tensor<?xf32>, %idx: index,
1783+
%m: vector<16xi1>, %ext: vector<16xf32>) -> (vector<16xf32>, vector<16xf32>) {
17841784
%ft0 = arith.constant 0.0 : f32
17851785
// expected-error@+1 {{'vector.mask' op expects number of results to match maskable operation number of results}}
1786-
%0:2 = vector.mask %m0 {
1787-
%1 =vector.transfer_read %t0[%idx], %ft0 : tensor<?xf32>, vector<16xf32>
1786+
%0:2 = vector.mask %m {
1787+
%1 =vector.transfer_read %t[%idx], %ft0 : tensor<?xf32>, vector<16xf32>
17881788
vector.yield %1, %ext : vector<16xf32>, vector<16xf32>
17891789
} : vector<16xi1> -> (vector<16xf32>, vector<16xf32>)
17901790

0 commit comments

Comments
 (0)