Skip to content

[mlir][transform] Guard parametric loop tiling pass from no option #118254

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 5 commits into from
Dec 4, 2024

Conversation

Lewuathe
Copy link
Member

@Lewuathe Lewuathe commented Dec 2, 2024

test-extract-fixed-outer-loops pass always crash without any test-outer-loop-sizes option. We need to keep the pass from crash by checking the option existence.

Fix #61716, #116360

Copy link

graphite-app bot commented Dec 2, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “FP Bundles” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

@llvmbot
Copy link
Member

llvmbot commented Dec 2, 2024

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-scf

Author: Kai Sasaki (Lewuathe)

Changes

test-extract-fixed-outer-loops pass always crash without any test-outer-loop-sizes option. We need to keep the pass from crash by checking the option existence.

Fix #116360, #116360


Full diff: https://github.com/llvm/llvm-project/pull/118254.diff

2 Files Affected:

  • (added) mlir/test/Transforms/invalid-outer-loop-size.mlir (+19)
  • (modified) mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp (+3)
diff --git a/mlir/test/Transforms/invalid-outer-loop-size.mlir b/mlir/test/Transforms/invalid-outer-loop-size.mlir
new file mode 100644
index 00000000000000..42e5848b9704ed
--- /dev/null
+++ b/mlir/test/Transforms/invalid-outer-loop-size.mlir
@@ -0,0 +1,19 @@
+// RUN: mlir-opt -test-extract-fixed-outer-loops %s | FileCheck %s 
+
+// COMMON-LABEL: @no_crash
+func.func @no_crash(%arg0: memref<?x?xf32>) {
+  // CHECK: %[[c2:.*]] = arith.constant 2 : index
+  %c2 = arith.constant 2 : index
+  // CHECK: %[[c44:.*]] = arith.constant 44 : index
+  %c44 = arith.constant 44 : index
+  // CHECK: %[[c1:.*]] = arith.constant 1 : index  
+  %c1 = arith.constant 1 : index
+  // CHECK: scf.for %[[i:.*]] = %[[c2]] to %[[c44]] step %[[c1]]
+  scf.for %i = %c2 to %c44 step %c1 {
+    // CHECK: scf.for %[[j:.*]] = %[[c1]] to %[[c44]] step %[[c2]]
+    scf.for %j = %c1 to %c44 step %c2 {
+      memref.load %arg0[%i, %j]: memref<?x?xf32>
+    }
+  }
+  return
+}
diff --git a/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp b/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
index 1f33a04b0668a9..f90371a27e7393 100644
--- a/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
+++ b/mlir/test/lib/Dialect/SCF/TestLoopParametricTiling.cpp
@@ -40,6 +40,9 @@ class SimpleParametricLoopTilingPass
   }
 
   void runOnOperation() override {
+    // If no outer loop iteration is given, ignore the pass.
+    if (sizes.empty())
+      return;
     getOperation()->walk([this](scf::ForOp op) {
       // Ignore nested loops.
       if (op->getParentRegion()->getParentOfType<scf::ForOp>())

@Lewuathe Lewuathe requested a review from joker-eph December 4, 2024 01:07
Copy link

github-actions bot commented Dec 4, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

@Lewuathe Lewuathe merged commit caf8942 into llvm:main Dec 4, 2024
8 checks passed
@Lewuathe Lewuathe deleted the guard-no-outer-loop-option branch December 4, 2024 09:56
qiaojbao pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Dec 23, 2024
Local branch amd-gfx 5f484c1 Merged main:68bcba6d7a1c into amd-gfx:fe02a5576f8e
Remote branch main caf8942 [mlir][transform] Guard parametric loop tiling pass from no option (llvm#118254)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants