[Mlir-commits] [mlir] 60c9d29 - [mlir][vector] Refine diagnostic messages
Andrzej Warzynski
llvmlistbot at llvm.org
Tue Jul 11 23:42:54 PDT 2023
Author: Andrzej Warzynski
Date: 2023-07-12T07:42:46+01:00
New Revision: 60c9d2993bbf1594e89e1e6f72e1472eb1aeb8ef
URL: https://github.com/llvm/llvm-project/commit/60c9d2993bbf1594e89e1e6f72e1472eb1aeb8ef
DIFF: https://github.com/llvm/llvm-project/commit/60c9d2993bbf1594e89e1e6f72e1472eb1aeb8ef.diff
LOG: [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
Added:
Modified:
mlir/lib/Dialect/Vector/IR/VectorOps.cpp
mlir/test/Dialect/Vector/invalid.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index dcb3d2fbb0c790..b54ea90642e9e7 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -1188,7 +1188,7 @@ LogicalResult vector::ExtractOp::verify() {
if (positionAttr.size() >
static_cast<unsigned>(getSourceVectorType().getRank()))
return emitOpError(
- "expected position attribute of rank smaller than vector rank");
+ "expected position attribute of rank no greater than vector rank");
for (const auto &en : llvm::enumerate(positionAttr)) {
auto attr = llvm::dyn_cast<IntegerAttr>(en.value());
if (!attr || attr.getInt() < 0 ||
@@ -2488,7 +2488,7 @@ static LogicalResult isIntegerArrayAttrSmallerThanShape(OpType op,
StringRef attrName) {
if (arrayAttr.size() > shape.size())
return op.emitOpError("expected ")
- << attrName << " attribute of rank smaller than vector rank";
+ << attrName << " attribute of rank no greater than vector rank";
return success();
}
@@ -2579,7 +2579,7 @@ LogicalResult InsertStridedSliceOp::verify() {
return emitOpError("expected strides of same size as source vector rank");
if (sourceVectorType.getRank() > destVectorType.getRank())
return emitOpError(
- "expected source rank to be smaller than destination rank");
+ "expected source rank to be no greater than destination rank");
auto sourceShape = sourceVectorType.getShape();
auto destShape = destVectorType.getShape();
diff --git a/mlir/test/Dialect/Vector/invalid.mlir b/mlir/test/Dialect/Vector/invalid.mlir
index 225a20fd3c4ccd..242b0728e9953b 100644
--- a/mlir/test/Dialect/Vector/invalid.mlir
+++ b/mlir/test/Dialect/Vector/invalid.mlir
@@ -125,14 +125,14 @@ func.func @extract_vector_type(%arg0: index) {
// -----
func.func @extract_position_rank_overflow(%arg0: vector<4x8x16xf32>) {
- // expected-error at +1 {{expected position attribute of rank smaller than vector}}
+ // expected-error at +1 {{expected position attribute of rank no greater than vector rank}}
%1 = vector.extract %arg0[0, 0, 0, 0] : vector<4x8x16xf32>
}
// -----
func.func @extract_position_rank_overflow_generic(%arg0: vector<4x8x16xf32>) {
- // expected-error at +1 {{expected position attribute of rank smaller than vector}}
+ // expected-error at +1 {{expected position attribute of rank no greater than vector rank}}
%1 = "vector.extract" (%arg0) { position = [0, 0, 0, 0] } : (vector<4x8x16xf32>) -> (vector<16xf32>)
}
@@ -153,7 +153,7 @@ func.func @extract_precise_position_overflow(%arg0: vector<4x8x16xf32>) {
// -----
func.func @extract_0d(%arg0: vector<f32>) {
- // expected-error at +1 {{expected position attribute of rank smaller than vector rank}}
+ // expected-error at +1 {{expected position attribute of rank no greater than vector rank}}
%1 = vector.extract %arg0[0] : vector<f32>
}
@@ -587,7 +587,7 @@ func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
// -----
func.func @insert_strided_slice(%a: vector<4x4xf32>, %b: vector<4x8x16xf32>) {
- // expected-error at +1 {{expected source rank to be smaller than destination rank}}
+ // expected-error at +1 {{expected source rank to be no greater than destination rank}}
%1 = vector.insert_strided_slice %b, %a {offsets = [2, 2], strides = [1, 1, 1]} : vector<4x8x16xf32> into vector<4x4xf32>
}
@@ -622,14 +622,14 @@ func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
// -----
func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
- // expected-error at +1 {{expected offsets attribute of rank smaller than vector rank}}
+ // expected-error at +1 {{expected offsets attribute of rank no greater than vector rank}}
%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>
}
// -----
func.func @extract_strided_slice(%arg0: vector<4x8x16xf32>) {
- // expected-error at +1 {{expected offsets attribute of rank smaller than vector rank}}
+ // expected-error at +1 {{expected offsets attribute of rank no greater than vector rank}}
%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>
}
More information about the Mlir-commits
mailing list