Skip to content

Commit 60c9d29

Browse files
committed
[mlir][vector] Refine diagnostic messages
Clarify a few diagnostics so that they are more consistent with the corresponding condition. For example: ``` if (positionAttr.size() > static_cast<unsigned>(getSourceVectorType().getRank())) ``` should lead to ("no greater than"): ``` return emitOpError( "expected position attribute of rank no greater than vector rank"); ``` as opposed to ("smaller"): ``` return emitOpError( "expected position attribute of rank smaller than vector rank"); ``` Differential Revision: https://reviews.llvm.org/D154998
1 parent 7b7d3c8 commit 60c9d29

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ LogicalResult vector::ExtractOp::verify() {
11881188
if (positionAttr.size() >
11891189
static_cast<unsigned>(getSourceVectorType().getRank()))
11901190
return emitOpError(
1191-
"expected position attribute of rank smaller than vector rank");
1191+
"expected position attribute of rank no greater than vector rank");
11921192
for (const auto &en : llvm::enumerate(positionAttr)) {
11931193
auto attr = llvm::dyn_cast<IntegerAttr>(en.value());
11941194
if (!attr || attr.getInt() < 0 ||
@@ -2488,7 +2488,7 @@ static LogicalResult isIntegerArrayAttrSmallerThanShape(OpType op,
24882488
StringRef attrName) {
24892489
if (arrayAttr.size() > shape.size())
24902490
return op.emitOpError("expected ")
2491-
<< attrName << " attribute of rank smaller than vector rank";
2491+
<< attrName << " attribute of rank no greater than vector rank";
24922492
return success();
24932493
}
24942494

@@ -2579,7 +2579,7 @@ LogicalResult InsertStridedSliceOp::verify() {
25792579
return emitOpError("expected strides of same size as source vector rank");
25802580
if (sourceVectorType.getRank() > destVectorType.getRank())
25812581
return emitOpError(
2582-
"expected source rank to be smaller than destination rank");
2582+
"expected source rank to be no greater than destination rank");
25832583

25842584
auto sourceShape = sourceVectorType.getShape();
25852585
auto destShape = destVectorType.getShape();

mlir/test/Dialect/Vector/invalid.mlir

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,14 @@ func.func @extract_vector_type(%arg0: index) {
125125
// -----
126126

127127
func.func @extract_position_rank_overflow(%arg0: vector<4x8x16xf32>) {
128-
// expected-error@+1 {{expected position attribute of rank smaller than vector}}
128+
// expected-error@+1 {{expected position attribute of rank no greater than vector rank}}
129129
%1 = vector.extract %arg0[0, 0, 0, 0] : vector<4x8x16xf32>
130130
}
131131

132132
// -----
133133

134134
func.func @extract_position_rank_overflow_generic(%arg0: vector<4x8x16xf32>) {
135-
// expected-error@+1 {{expected position attribute of rank smaller than vector}}
135+
// expected-error@+1 {{expected position attribute of rank no greater than vector rank}}
136136
%1 = "vector.extract" (%arg0) { position = [0, 0, 0, 0] } : (vector<4x8x16xf32>) -> (vector<16xf32>)
137137
}
138138

@@ -153,7 +153,7 @@ func.func @extract_precise_position_overflow(%arg0: vector<4x8x16xf32>) {
153153
// -----
154154

155155
func.func @extract_0d(%arg0: vector<f32>) {
156-
// expected-error@+1 {{expected position attribute of rank smaller than vector rank}}
156+
// expected-error@+1 {{expected position attribute of rank no greater than vector rank}}
157157
%1 = vector.extract %arg0[0] : vector<f32>
158158
}
159159

@@ -587,7 +587,7 @@ func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
587587
// -----
588588

589589
func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
590-
// expected-error@+1 {{expected source rank to be smaller than destination rank}}
590+
// expected-error@+1 {{expected source rank to be no greater than destination rank}}
591591
%1 = vector.insert_strided_slice %b, %a {offsets = [2, 2], strides = [1, 1, 1]} : vector<4x8x16xf32> into vector<4x4xf32>
592592
}
593593

@@ -622,14 +622,14 @@ func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
622622
// -----
623623

624624
func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
625-
// expected-error@+1 {{expected offsets attribute of rank smaller than vector rank}}
625+
// expected-error@+1 {{expected offsets attribute of rank no greater than vector rank}}
626626
%1 = vector.extract_strided_slice %arg0 {offsets = [2, 2, 2, 2], sizes = [2, 2, 2, 2], strides = [1, 1, 1, 1]} : vector<4x8x16xf32> to vector<2x2x16xf32>
627627
}
628628

629629
// -----
630630

631631
func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
632-
// expected-error@+1 {{expected offsets attribute of rank smaller than vector rank}}
632+
// expected-error@+1 {{expected offsets attribute of rank no greater than vector rank}}
633633
%1 = vector.extract_strided_slice %arg0 {offsets = [2, 2, 2, 2], sizes = [2, 2, 2, 2], strides = [1, 1, 1, 1]} : vector<4x8x16xf32> to vector<2x2x16xf32>
634634
}
635635

0 commit comments

Comments
 (0)