Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 13 additions & 0 deletions mlir/test/Dialect/Affine/invalid-reify-bound-dim.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// RUN: mlir-opt %s -pass-pipeline='builtin.module(func.func(test-affine-reify-value-bounds))' -verify-diagnostics

// -----

func.func @test_invalid_reify_dim(%size: index) -> (index) {
%zero = arith.constant 0 : index
%tensor_val = tensor.empty(%size) : tensor<?xf32>

// expected-error@+1 {{'test.reify_bound' op invalid dim for shaped type}}
%dim = "test.reify_bound"(%tensor_val) {dim = 1 : i64} : (tensor<?xf32>) -> index

return %dim: index
}
7 changes: 7 additions & 0 deletions mlir/test/lib/Dialect/Affine/TestReifyValueBounds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ static LogicalResult testReifyValueBounds(FunctionOpInterface funcOp,
auto boundType = op.getBoundType();
Value value = op.getVar();
std::optional<int64_t> dim = op.getDim();
auto shapedType = dyn_cast<ShapedType>(value.getType());
if (shapedType && shapedType.hasRank() && dim.has_value() &&
dim.value() >= shapedType.getRank()) {
op->emitOpError("invalid dim for shaped type");
return WalkResult::interrupt();
}

bool constant = op.getConstant();
bool scalable = op.getScalable();

Expand Down
Loading