Skip to content

Commit aed8f19

Browse files
authored
[NFC][mlir][memref] refine debug message about memref::SubViewOp. (#145470)
1 parent c3e08c9 commit aed8f19

File tree

2 files changed

+14
-9
lines changed

2 files changed

+14
-9
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2929,27 +2929,32 @@ static bool haveCompatibleStrides(MemRefType t1, MemRefType t2,
29292929
}
29302930

29312931
static LogicalResult produceSubViewErrorMsg(SliceVerificationResult result,
2932-
Operation *op, Type expectedType) {
2932+
SubViewOp op, Type expectedType) {
29332933
auto memrefType = llvm::cast<ShapedType>(expectedType);
29342934
switch (result) {
29352935
case SliceVerificationResult::Success:
29362936
return success();
29372937
case SliceVerificationResult::RankTooLarge:
29382938
return op->emitError("expected result rank to be smaller or equal to ")
2939-
<< "the source rank. ";
2939+
<< "the source rank, but got " << op.getType();
29402940
case SliceVerificationResult::SizeMismatch:
29412941
return op->emitError("expected result type to be ")
29422942
<< expectedType
2943-
<< " or a rank-reduced version. (mismatch of result sizes) ";
2943+
<< " or a rank-reduced version. (mismatch of result sizes), but got "
2944+
<< op.getType();
29442945
case SliceVerificationResult::ElemTypeMismatch:
29452946
return op->emitError("expected result element type to be ")
2946-
<< memrefType.getElementType();
2947+
<< memrefType.getElementType() << ", but got " << op.getType();
29472948
case SliceVerificationResult::MemSpaceMismatch:
2948-
return op->emitError("expected result and source memory spaces to match.");
2949+
return op->emitError(
2950+
"expected result and source memory spaces to match, but got ")
2951+
<< op.getType();
29492952
case SliceVerificationResult::LayoutMismatch:
29502953
return op->emitError("expected result type to be ")
29512954
<< expectedType
2952-
<< " or a rank-reduced version. (mismatch of result layout) ";
2955+
<< " or a rank-reduced version. (mismatch of result layout), but "
2956+
"got "
2957+
<< op.getType();
29532958
}
29542959
llvm_unreachable("unexpected subview verification result");
29552960
}

mlir/test/Dialect/MemRef/invalid.mlir

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -713,7 +713,7 @@ func.func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
713713

714714
func.func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
715715
%0 = memref.alloc() : memref<8x16x4xf32>
716-
// expected-error@+1 {{expected result element type to be 'f32'}}
716+
// expected-error@+1 {{expected result element type to be 'f32', but got 'memref<8x16x4xi32>'}}
717717
%1 = memref.subview %0[0, 0, 0][8, 16, 4][1, 1, 1]
718718
: memref<8x16x4xf32> to
719719
memref<8x16x4xi32>
@@ -724,10 +724,10 @@ func.func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
724724

725725
func.func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {
726726
%0 = memref.alloc() : memref<8x16x4xf32>
727-
// expected-error@+1 {{expected result rank to be smaller or equal to the source rank.}}
727+
// expected-error@+1 {{expected result rank to be smaller or equal to the source rank, but got 'memref<8x16x4x3xf32>'}}
728728
%1 = memref.subview %0[0, 0, 0][8, 16, 4][1, 1, 1]
729729
: memref<8x16x4xf32> to
730-
memref<8x16x4x3xi32>
730+
memref<8x16x4x3xf32>
731731
return
732732
}
733733

0 commit comments

Comments
 (0)