Skip to content

Commit

Permalink
Merge pull request #353 from Xilinx/jose-relax-affine-if
Browse files Browse the repository at this point in the history
Relax affine
  • Loading branch information
josel-amd authored Sep 19, 2024
2 parents b46c5b7 + c391a49 commit 9054950
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 6 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,8 @@ LogicalResult AffineIfOp::verify() {

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

return success();
Expand Down
4 changes: 2 additions & 2 deletions mlir/test/Dialect/Affine/invalid.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ func.func @affine_for_upper_bound_invalid_sym() {
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}}
// Non-affine operand %dim has been made legal as input to affine.if.
// expected-error@+1 {{operand cannot be used as a symbol}}
affine.if #set0(%dim)[%n0] {}
}
return
Expand Down

0 comments on commit 9054950

Please sign in to comment.