[Mlir-commits] [mlir] Add worklist comparator to tile and fuse options (PR #211523)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Jul 23 04:10:25 PDT 2026
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp mlir/test/lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp --diff_from_common_commit
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h b/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
index 125ff0edb..034bfbec5 100644
--- a/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
+++ b/mlir/include/mlir/Dialect/SCF/Transforms/TileUsingInterface.h
@@ -312,20 +312,19 @@ struct SCFTileAndFuseOptions {
return *this;
}
- /// Comparator used to select the next `tensor.extract_slice` to process from
- /// the fusion worklist. Returns true if `lhs` should be processed before
- /// `rhs`. This allows callers to enforce a desired tiling order. For example,
- /// to process producers in topological order, a producer that is an ancestor
- /// of another producer in the defining-op chain can be ordered before it.
- /// By default, the worklist is processed in FIFO order.
- using TileOrderControlFnTy =
- std::function<bool(tensor::ExtractSliceOp lhs,
- tensor::ExtractSliceOp rhs)>;
- TileOrderControlFnTy tileOrderControlFn = nullptr;
- SCFTileAndFuseOptions &setTileOrderControlFn(TileOrderControlFnTy controlFn) {
- tileOrderControlFn = std::move(controlFn);
- return *this;
- }
+ /// Comparator used to select the next `tensor.extract_slice` to process from
+ /// the fusion worklist. Returns true if `lhs` should be processed before
+ /// `rhs`. This allows callers to enforce a desired tiling order. For example,
+ /// to process producers in topological order, a producer that is an ancestor
+ /// of another producer in the defining-op chain can be ordered before it.
+ /// By default, the worklist is processed in FIFO order.
+ using TileOrderControlFnTy = std::function<bool(tensor::ExtractSliceOp lhs,
+ tensor::ExtractSliceOp rhs)>;
+ TileOrderControlFnTy tileOrderControlFn = nullptr;
+ SCFTileAndFuseOptions &setTileOrderControlFn(TileOrderControlFnTy controlFn) {
+ tileOrderControlFn = std::move(controlFn);
+ return *this;
+ }
/// An optional set of rewrite patterns to apply to the results of tiling
/// before fusion. This will track deleted and newly inserted
diff --git a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
index 00a27b4dc..b856174b7 100644
--- a/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
+++ b/mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp
@@ -1645,9 +1645,9 @@ public:
/// `tileOrderControlFn` is set, returns the preferred slice according to the
/// callback. Otherwise pops from the front (FIFO). The worklist must be
/// non-empty.
- tensor::ExtractSliceOp popNext(
- const scf::SCFTileAndFuseOptions::TileOrderControlFnTy
- &tileOrderControlFn);
+ tensor::ExtractSliceOp
+ popNext(const scf::SCFTileAndFuseOptions::TileOrderControlFnTy
+ &tileOrderControlFn);
/// The worklist for this transformation keeps track of the slices to visit
/// next for fusion.
@@ -1716,22 +1716,22 @@ void SliceTrackingListener::notifyOperationReplaced(Operation *op,
}
tensor::ExtractSliceOp SliceTrackingListener::popNext(
- const scf::SCFTileAndFuseOptions::TileOrderControlFnTy
- &tileOrderControlFn) {
-assert(!worklist.empty() && "expected non-empty worklist");
-if (!tileOrderControlFn) {
- auto slice = worklist.front();
- worklist.pop_front();
+ const scf::SCFTileAndFuseOptions::TileOrderControlFnTy
+ &tileOrderControlFn) {
+ assert(!worklist.empty() && "expected non-empty worklist");
+ if (!tileOrderControlFn) {
+ auto slice = worklist.front();
+ worklist.pop_front();
+ return slice;
+ }
+ auto it = llvm::min_element(
+ worklist, [&](tensor::ExtractSliceOp lhs, tensor::ExtractSliceOp rhs) {
+ return tileOrderControlFn(lhs, rhs);
+ });
+ auto slice = *it;
+ worklist.erase(it);
return slice;
}
-auto it = llvm::min_element(worklist, [&](tensor::ExtractSliceOp lhs,
- tensor::ExtractSliceOp rhs) {
- return tileOrderControlFn(lhs, rhs);
-});
-auto slice = *it;
-worklist.erase(it);
-return slice;
-}
//===----------------------------------------------------------------------===//
// ReplacementListener
diff --git a/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp b/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp
index d891e576b..42139c110 100644
--- a/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp
+++ b/mlir/test/lib/Interfaces/TilingInterface/TestTilingInterfaceTransformOps.cpp
@@ -60,13 +60,12 @@ static llvm::SmallDenseSet<Operation *> collectTiledAndFusedOps(Operation *op) {
/// Apply a tile and fuse transformation to all payload ops and store both the
/// tiled operation as well as the created tile loops.
template <typename Range>
-static LogicalResult
-applyTileAndFuseToAll(RewriterBase &rewriter, Operation *transformOp,
- Range &&payloadOps, unsigned numLoops,
- scf::SCFTilingOptions tilingOptions,
- TransformResults &transformResults,
- scf::SCFTileAndFuseOptions::TileOrderControlFnTy
- tileOrderControlFn = nullptr) {
+static LogicalResult applyTileAndFuseToAll(
+ RewriterBase &rewriter, Operation *transformOp, Range &&payloadOps,
+ unsigned numLoops, scf::SCFTilingOptions tilingOptions,
+ TransformResults &transformResults,
+ scf::SCFTileAndFuseOptions::TileOrderControlFnTy tileOrderControlFn =
+ nullptr) {
SmallVector<Operation *> tiledOps;
SmallVector<SmallVector<Operation *>> loopOps(numLoops);
``````````
</details>
https://github.com/llvm/llvm-project/pull/211523
More information about the Mlir-commits
mailing list