Skip to content

Commit a62f73f

Browse files
committed
fix error message
1 parent 1423741 commit a62f73f

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1894,8 +1894,10 @@ LogicalResult ReinterpretCastOp::verify() {
18941894
llvm::enumerate(resultType.getShape(), getStaticSizes())) {
18951895
if (!ShapedType::isDynamic(resultSize) && resultSize != expectedSize)
18961896
return emitError("expected result type with size = ")
1897-
<< expectedSize << " instead of " << resultSize
1898-
<< " in dim = " << idx;
1897+
<< (ShapedType::isDynamic(expectedSize)
1898+
? std::string("dynamic")
1899+
: std::to_string(expectedSize))
1900+
<< " instead of " << resultSize << " in dim = " << idx;
18991901
}
19001902

19011903
// Match offset and strides in static_offset and static_strides attributes. If
@@ -1911,15 +1913,20 @@ LogicalResult ReinterpretCastOp::verify() {
19111913
int64_t expectedOffset = getStaticOffsets().front();
19121914
if (!ShapedType::isDynamic(resultOffset) && resultOffset != expectedOffset)
19131915
return emitError("expected result type with offset = ")
1914-
<< expectedOffset << " instead of " << resultOffset;
1916+
<< (ShapedType::isDynamic(expectedOffset)
1917+
? std::string("dynamic")
1918+
: std::to_string(expectedOffset))
1919+
<< " instead of " << resultOffset;
19151920

19161921
// Match strides in result memref type and in static_strides attribute.
19171922
for (auto [idx, resultStride, expectedStride] :
19181923
llvm::enumerate(resultStrides, getStaticStrides())) {
19191924
if (!ShapedType::isDynamic(resultStride) && resultStride != expectedStride)
19201925
return emitError("expected result type with stride = ")
1921-
<< expectedStride << " instead of " << resultStride
1922-
<< " in dim = " << idx;
1926+
<< (ShapedType::isDynamic(expectedStride)
1927+
? std::string("dynamic")
1928+
: std::to_string(expectedStride))
1929+
<< " instead of " << resultStride << " in dim = " << idx;
19231930
}
19241931

19251932
return success();

mlir/test/Dialect/MemRef/invalid.mlir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ func.func @memref_reinterpret_cast_no_map_but_offset(%in: memref<?xf32>) {
218218
// -----
219219

220220
func.func @memref_reinterpret_cast_offset_mismatch_dynamic(%in: memref<?xf32>, %offset : index) {
221-
// expected-error @+1 {{expected result type with offset = -9223372036854775808 instead of 0}}
221+
// expected-error @+1 {{expected result type with offset = dynamic instead of 0}}
222222
%out = memref.reinterpret_cast %in to offset: [%offset], sizes: [10], strides: [1]
223223
: memref<?xf32> to memref<10xf32>
224224
return

0 commit comments

Comments
 (0)