Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions mlir/lib/Dialect/MemRef/IR/MemRefOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2917,27 +2917,32 @@ static bool haveCompatibleStrides(MemRefType t1, MemRefType t2,
}

static LogicalResult produceSubViewErrorMsg(SliceVerificationResult result,
Operation *op, Type expectedType) {
SubViewOp op, Type expectedType) {
auto memrefType = llvm::cast<ShapedType>(expectedType);
switch (result) {
case SliceVerificationResult::Success:
return success();
case SliceVerificationResult::RankTooLarge:
return op->emitError("expected result rank to be smaller or equal to ")
<< "the source rank. ";
<< "the source rank, but got " << op.getType();
case SliceVerificationResult::SizeMismatch:
return op->emitError("expected result type to be ")
<< expectedType
<< " or a rank-reduced version. (mismatch of result sizes) ";
<< " or a rank-reduced version. (mismatch of result sizes), but got "
<< op.getType();
case SliceVerificationResult::ElemTypeMismatch:
return op->emitError("expected result element type to be ")
<< memrefType.getElementType();
<< memrefType.getElementType() << ", but got " << op.getType();
case SliceVerificationResult::MemSpaceMismatch:
return op->emitError("expected result and source memory spaces to match.");
return op->emitError(
"expected result and source memory spaces to match, but got ")
<< op.getType();
case SliceVerificationResult::LayoutMismatch:
return op->emitError("expected result type to be ")
<< expectedType
<< " or a rank-reduced version. (mismatch of result layout) ";
<< " or a rank-reduced version. (mismatch of result layout), but "
"got "
<< op.getType();
}
llvm_unreachable("unexpected subview verification result");
}
Expand Down
6 changes: 3 additions & 3 deletions mlir/test/Dialect/MemRef/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ func.func @invalid_subview(%arg0 : index, %arg1 : index, %arg2 : index) {

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

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

Expand Down