Skip to content

[MLIR][Affine] Add missing check in affine data copy nest generation #127809

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 20, 2025
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
9 changes: 8 additions & 1 deletion mlir/lib/Dialect/Affine/Utils/LoopUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2001,8 +2001,15 @@ static LogicalResult generateCopy(
}

SmallVector<AffineMap, 4> lbMaps(rank), ubMaps(rank);
for (unsigned i = 0; i < rank; ++i)
for (unsigned i = 0; i < rank; ++i) {
region.getLowerAndUpperBound(i, lbMaps[i], ubMaps[i]);
if (lbMaps[i].getNumResults() == 0 || ubMaps[i].getNumResults() == 0) {
LLVM_DEBUG(llvm::dbgs()
<< "Missing lower or upper bound for region along dimension: "
<< i << '\n');
return failure();
}
}

const FlatAffineValueConstraints *cst = region.getConstraints();
// 'regionSymbols' hold values that this memory region is symbolic/parametric
Expand Down
11 changes: 6 additions & 5 deletions mlir/test/Dialect/Affine/affine-data-copy.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -300,14 +300,15 @@ func.func @affine_parallel(%85:memref<2x5x4x2xi64>) {
}
}
}
// CHECK: affine.for
// CHECK-NEXT: affine.for %{{.*}} = 0 to 5
// CHECK-NEXT: affine.for %{{.*}} = 0 to 4
// CHECK-NEXT: affine.for %{{.*}} = 0 to 2

// Lower and upper bounds for the region can't be determined for the outermost
// dimension. No fast buffer generation.
// CHECK: affine.for
// CHECK-NEXT: affine.parallel
// CHECK-NEXT: affine.parallel
// CHECK-NEXT: affine.for
// CHECK-NOT: affine.for


return
}

Expand Down