[Mlir-commits] [mlir] [mlir][SCF] Allow using a custom operation to generate loops with `mlir::tileUsingSCF`. (PR #159660)
Quinn Dawkins
llvmlistbot at llvm.org
Fri Sep 19 13:31:02 PDT 2025
================
@@ -491,27 +459,108 @@ static LogicalResult generateLoopNestUsingForOp(
cast<scf::ForOp>(outerLoop.getOperation()).getBody());
scf::YieldOp::create(rewriter, outerLoop.getLoc(), innerLoop->getResults());
}
- return success();
+ return loops;
+}
+
+/// Compute the `OpFoldResult`s that represents the multi-dimensional
+/// `offset`s and `size`s of the tile of the iteration space that the
+/// innermost loop body of the generated tiled loops corresponds to
+/// when tiling using `forall` op. This is handle separately dut to
+/// the special case handling needed for when the tiling is done by
+/// specifying number of threads.
+static std::tuple<SmallVector<OpFoldResult>, SmallVector<OpFoldResult>>
+getTileOffsetAndSizesWithForAllOp(RewriterBase &rewriter, Location loc,
+ ValueRange ivs,
+ ArrayRef<Range> iterationDomain,
+ ArrayRef<OpFoldResult> givenTileSizes,
+ ArrayRef<OpFoldResult> numThreads) {
+ if (numThreads.empty()) {
+ return getTileOffsetAndSizes(rewriter, loc, ivs, iterationDomain,
+ givenTileSizes);
+ }
+
+ SmallVector<OpFoldResult> offsets, sizes;
+ int materializedLoopNum = 0;
+
+ AffineExpr d0, d1, s0, s1;
----------------
qedawkins wrote:
I see that this code was just moved and isn't new, but why mixed dims vs symbols? I never know when to use which.
https://github.com/llvm/llvm-project/pull/159660
More information about the Mlir-commits
mailing list