[Mlir-commits] [mlir] [mlir][linalg] Guard pack tensor semantics (PR #206011)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri Jun 26 02:17:57 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
Author: mygitljf
<details>
<summary>Changes</summary>
Added a guard so the structured pack transform reports a normal tiling failure when the target has already been bufferized, instead of reaching a tensor-only path and asserting.
Fixes #<!-- -->205744
---
Full diff: https://github.com/llvm/llvm-project/pull/206011.diff
2 Files Affected:
- (modified) mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp (+4)
- (added) mlir/test/Dialect/Linalg/transform-op-pack-bufferized.mlir (+17)
``````````diff
diff --git a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
index f2d491ac442e6..0b6d067d13a16 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/Transforms.cpp
@@ -484,6 +484,10 @@ FailureOr<PackResult> linalg::pack(RewriterBase &rewriter,
return rewriter.notifyMatchFailure(linalgOp,
"incorrect number of pack sizes");
}
+ if (!linalgOp.hasPureTensorSemantics()) {
+ return rewriter.notifyMatchFailure(
+ linalgOp, "expects LinalgOp with pure tensor semantics");
+ }
Location loc = linalgOp->getLoc();
SmallVector<AffineMap> indexingMaps = linalgOp.getIndexingMapsArray();
diff --git a/mlir/test/Dialect/Linalg/transform-op-pack-bufferized.mlir b/mlir/test/Dialect/Linalg/transform-op-pack-bufferized.mlir
new file mode 100644
index 0000000000000..071ae8f35f97f
--- /dev/null
+++ b/mlir/test/Dialect/Linalg/transform-op-pack-bufferized.mlir
@@ -0,0 +1,17 @@
+// RUN: mlir-opt -sparsification-and-bufferization -transform-interpreter -split-input-file -verify-diagnostics -allow-unregistered-dialect %s
+
+module attributes {gpu.data_layout = "chunked", impl.libfunc.name = "test.matmul"} {
+ func.func @matmul(%arg0: tensor<?x?xf32>, %arg1: tensor<?x?xf32>, %arg2: tensor<?x?xf32>) -> tensor<?x?xf32> {
+ %0 = linalg.matmul ins(%arg0, %arg1 : tensor<?x?xf32>, tensor<?x?xf32>) outs(%arg2 : tensor<?x?xf32>) -> tensor<?x?xf32>
+ return %0 : tensor<?x?xf32>
+ }
+
+ module attributes {transform.with_named_sequence} {
+ transform.named_sequence @__transform_main(%arg0: !transform.any_op {transform.readonly}) {
+ %0 = transform.structured.match ops{["linalg.matmul"]} in %arg0 : (!transform.any_op) -> !transform.any_op
+ // expected-error @below {{data tiling failed}}
+ %1 = transform.structured.pack %0 packed_sizes = [2, 3, 4] : (!transform.any_op) -> !transform.op<"linalg.generic">
+ transform.yield
+ }
+ }
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/206011
More information about the Mlir-commits
mailing list