[Mlir-commits] [mlir] [mlir][tensor] Add bubble up extract_slice pattern for TilingInterfac… (PR #179967)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Thu Feb 5 08:04:37 PST 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/lib/Dialect/Tensor/Transforms/BubbleUpExtractSliceThroughTilingInterface.cpp mlir/include/mlir/Dialect/Tensor/Transforms/Transforms.h mlir/test/lib/Dialect/Tensor/TestTensorTransforms.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/lib/Dialect/Tensor/Transforms/BubbleUpExtractSliceThroughTilingInterface.cpp b/mlir/lib/Dialect/Tensor/Transforms/BubbleUpExtractSliceThroughTilingInterface.cpp
index 9643d3542..2a72c0a98 100644
--- a/mlir/lib/Dialect/Tensor/Transforms/BubbleUpExtractSliceThroughTilingInterface.cpp
+++ b/mlir/lib/Dialect/Tensor/Transforms/BubbleUpExtractSliceThroughTilingInterface.cpp
@@ -9,7 +9,8 @@
 // This file implements patterns to bubble up `tensor.extract_slice` operations
 // through producers that implement the `TilingInterface`. Unlike the Linalg-
 // specific bubble up pattern, this works with any operation implementing
-// TilingInterface and supports multiple non-overlapping extract_slice consumers.
+// TilingInterface and supports multiple non-overlapping extract_slice
+// consumers.
 //
 // The transformation reduces computation by creating smaller/tiled operations
 // that compute only the slices actually needed by consumers.
@@ -53,9 +54,8 @@ hasOverlappingSlices(MLIRContext *ctx,
         return failure();
       }
       if (*overlapping) {
-        LLVM_DEBUG(llvm::dbgs()
-                   << "Found overlapping slices at indices " << i << " and "
-                   << j << "\n");
+        LLVM_DEBUG(llvm::dbgs() << "Found overlapping slices at indices " << i
+                                << " and " << j << "\n");
         return true;
       }
     }
@@ -69,9 +69,9 @@ hasOverlappingSlices(MLIRContext *ctx,
 /// Matches: TilingInterface op whose output is consumed only by non-overlapping
 /// extract_slice ops.
 ///
-/// Transforms to: tiled operations (via TilingInterface::generateResultTileValue)
-/// that each compute only a specific output slice, with extract_slice operations
-/// applied to the inputs.
+/// Transforms to: tiled operations (via
+/// TilingInterface::generateResultTileValue) that each compute only a specific
+/// output slice, with extract_slice operations applied to the inputs.
 ///
 /// For example:
 ///
@@ -119,8 +119,8 @@ struct BubbleUpExtractSliceThroughTilingInterface
       return rewriter.notifyMatchFailure(producerOp,
                                          "expected ranked tensor result");
 
-    LLVM_DEBUG(llvm::dbgs() << "Checking TilingInterface op: " << *producerOp
-                            << "\n");
+    LLVM_DEBUG(llvm::dbgs()
+               << "Checking TilingInterface op: " << *producerOp << "\n");
 
     // Collect all extract_slice users.
     SmallVector<tensor::ExtractSliceOp> extractSlices;
@@ -135,10 +135,10 @@ struct BubbleUpExtractSliceThroughTilingInterface
     // Sort slices by their position in the block to ensure deterministic
     // processing order. This maintains the correspondence between original
     // extract_slice ops and their replacements.
-    llvm::sort(extractSlices, [](tensor::ExtractSliceOp a,
-                                 tensor::ExtractSliceOp b) {
-      return a->isBeforeInBlock(b);
-    });
+    llvm::sort(extractSlices,
+               [](tensor::ExtractSliceOp a, tensor::ExtractSliceOp b) {
+                 return a->isBeforeInBlock(b);
+               });
 
     if (extractSlices.empty())
       return rewriter.notifyMatchFailure(producerOp,
@@ -172,7 +172,8 @@ struct BubbleUpExtractSliceThroughTilingInterface
     }
 
     // For each extract_slice, create a tiled producer.
-    // Collect all results first before replacing to avoid iterator invalidation.
+    // Collect all results first before replacing to avoid iterator
+    // invalidation.
     SmallVector<std::pair<tensor::ExtractSliceOp, Value>> replacements;
     for (tensor::ExtractSliceOp extractSlice : extractSlices) {
       FailureOr<TilingResult> tilingResult =
@@ -183,8 +184,8 @@ struct BubbleUpExtractSliceThroughTilingInterface
             producerOp, "failed to generate tiled implementation");
 
       if (tilingResult->tiledValues.empty())
-        return rewriter.notifyMatchFailure(
-            producerOp, "tiling produced no values");
+        return rewriter.notifyMatchFailure(producerOp,
+                                           "tiling produced no values");
 
       replacements.emplace_back(extractSlice, tilingResult->tiledValues[0]);
     }

``````````

</details>


https://github.com/llvm/llvm-project/pull/179967


More information about the Mlir-commits mailing list