Skip to content

Commit

Permalink
Relaxe affine
Browse files Browse the repository at this point in the history
  • Loading branch information
josel-amd committed Sep 18, 2024
1 parent ff7d639 commit 276cbea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 5 additions & 3 deletions mlir/lib/Dialect/Affine/IR/AffineOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,13 @@ ParseResult mlir::affine::parseDimAndSymbolList(
template <typename OpTy>
static LogicalResult
verifyDimAndSymbolIdentifiers(OpTy &op, Operation::operand_range operands,
unsigned numDims) {
unsigned numDims,
bool allowNonAffineDimOperands = false) {
unsigned opIt = 0;
for (auto operand : operands) {
if (opIt++ < numDims) {
if (!isValidDim(operand, getAffineScope(op)))
if (!isValidDim(operand, getAffineScope(op)) &&
!(allowNonAffineDimOperands && operand.getType().isIndex()))
return op.emitOpError("operand cannot be used as a dimension id");
} else if (!isValidSymbol(operand, getAffineScope(op))) {
return op.emitOpError("operand cannot be used as a symbol");
Expand Down Expand Up @@ -2804,7 +2806,7 @@ LogicalResult AffineIfOp::verify() {

// Verify that the operands are valid dimension/symbols.
if (failed(verifyDimAndSymbolIdentifiers(*this, getOperands(),
condition.getNumDims())))
condition.getNumDims(), true)))
return failure();

return success();
Expand Down
2 changes: 0 additions & 2 deletions mlir/test/Dialect/Affine/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ func.func @affine_if_invalid_dim(%arg : index) {
affine.for %n0 = 0 to 7 {
%dim = arith.addi %arg, %arg : index

// expected-error@+1 {{operand cannot be used as a dimension id}}
affine.if #set0(%dim)[%n0] {}
}
return
Expand All @@ -109,7 +108,6 @@ func.func @affine_if_invalid_dim(%arg : index) {

func.func @affine_if_invalid_sym() {
affine.for %i0 = 0 to 7 {
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.if #set0(%i0)[%i0] {}
}
return
Expand Down

0 comments on commit 276cbea

Please sign in to comment.