[Mlir-commits] [mlir] d776346 - [mlir][linalg] Avoid emitting errors in block pack matmul (#93170)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Fri May 24 00:29:31 PDT 2024
Author: Adam Siemieniuk
Date: 2024-05-24T09:29:28+02:00
New Revision: d776346afe790e5d51ca6c6e2238a6ba91d130a1
URL: https://github.com/llvm/llvm-project/commit/d776346afe790e5d51ca6c6e2238a6ba91d130a1
DIFF: https://github.com/llvm/llvm-project/commit/d776346afe790e5d51ca6c6e2238a6ba91d130a1.diff
LOG: [mlir][linalg] Avoid emitting errors in block pack matmul (#93170)
Tweaks linalg.generic verification in block pack matmul pass to avoid
using emitting errors which pollute stderr during operation matching.
Added:
Modified:
mlir/lib/Dialect/Linalg/Transforms/BlockPackMatmul.cpp
mlir/test/Dialect/Linalg/block-pack-matmul.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/Transforms/BlockPackMatmul.cpp b/mlir/lib/Dialect/Linalg/Transforms/BlockPackMatmul.cpp
index c07d1387ec753..91d4efa3372b7 100644
--- a/mlir/lib/Dialect/Linalg/Transforms/BlockPackMatmul.cpp
+++ b/mlir/lib/Dialect/Linalg/Transforms/BlockPackMatmul.cpp
@@ -244,8 +244,7 @@ struct BlockPackMatmul<linalg::GenericOp>
LogicalResult matchAndRewrite(linalg::GenericOp linalgOp,
PatternRewriter &rewriter) const override {
// Match suitable generics.
- if (failed(linalg::detail::verifyContractionInterface(
- linalgOp.getOperation()))) {
+ if (!linalg::isaContractionOpInterface(linalgOp)) {
return rewriter.notifyMatchFailure(linalgOp, "not a contraction");
}
diff --git a/mlir/test/Dialect/Linalg/block-pack-matmul.mlir b/mlir/test/Dialect/Linalg/block-pack-matmul.mlir
index cc9af913ca15a..8a82608177692 100644
--- a/mlir/test/Dialect/Linalg/block-pack-matmul.mlir
+++ b/mlir/test/Dialect/Linalg/block-pack-matmul.mlir
@@ -476,3 +476,32 @@ func.func @block_generic_matmul_transpose_b(
// CHECK-SAME: inner_dims_pos = [0, 1] inner_tiles = [32, 16]
// CHECK-SAME: into %[[C]] : tensor<2x4x32x16xf32> -> tensor<64x64xf32>
// CHECK: return %[[RES_UNPACKED]] : tensor<64x64xf32>
+
+// -----
+
+#map = affine_map<(d0, d1) -> (d0, d1)>
+
+func.func @non_contraction_generic(
+ %A: tensor<64x128xf32>) -> tensor<64x128xf32> {
+ %c0 = arith.constant 0.000000e+00 : f32
+ %0 = linalg.generic {indexing_maps = [#map], iterator_types = ["parallel", "parallel"]}
+ outs(%A : tensor<64x128xf32>) {
+ ^bb0(%out: f32):
+ %1 = arith.maximumf %out, %c0 : f32
+ linalg.yield %1 : f32
+ } -> tensor<64x128xf32>
+ return %0 : tensor<64x128xf32>
+}
+
+// CHECK-DAG: #[[$MAP:.+]] = affine_map<(d0, d1) -> (d0, d1)>
+
+// CHECK-LABEL: func @non_contraction_generic(
+// CHECK-SAME: %[[A:[0-9a-z]+]]: tensor<64x128xf32>
+// CHECK-DAG: %[[C0:.+]] = arith.constant 0.000000e+00 : f32
+// CHECK-NOT: tensor.pack
+// CHECK: %[[GENERIC:.+]] = linalg.generic
+// CHECK-SAME: indexing_maps = [#[[$MAP]]]
+// CHECK-SAME: iterator_types = ["parallel", "parallel"]
+// CHECK-SAME: outs(%[[A]] : tensor<64x128xf32>)
+// CHECK-NOT: tensor.unpack
+// CHECK: return %[[GENERIC]] : tensor<64x128xf32>
More information about the Mlir-commits
mailing list