[Mlir-commits] [mlir] [mlir][linalg] fix segmentation fault in isContractionBody function (PR #108703)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Wed Sep 18 01:03:51 PDT 2024
https://github.com/BRUCE11111 updated https://github.com/llvm/llvm-project/pull/108703
>From 18e8c0fdb0f615bb5cf2227f34cbda141ac96dd0 Mon Sep 17 00:00:00 2001
From: "Xu, Xiaohui1" <xiaohui1.xu at intel.com>
Date: Sat, 14 Sep 2024 23:01:11 +0800
Subject: [PATCH 1/2] [mlir][linalg] fix segmentation fault in
isContractionBody function
---
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
index 0c48a5aeb26a26..0b5191664a9e2f 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
@@ -222,7 +222,7 @@ bool mlir::linalg::detail::isContractionBody(
Value contributed = getSourceSkipUnary(
isa<BlockArgument>(reductionLHS) ? reductionRHS : reductionLHS);
Operation *elementwiseOp = contributed.getDefiningOp();
- if (elementwiseOp->getNumResults() != 1 ||
+ if (!elementwiseOp || elementwiseOp->getNumResults() != 1 ||
elementwiseOp->getNumOperands() != 2) {
errs << "expected elementwise op to be binary";
return false;
>From 0b61073429a857204d53a92dddb63bb40501d817 Mon Sep 17 00:00:00 2001
From: "Xu, Xiaohui1" <xiaohui1.xu at intel.com>
Date: Wed, 18 Sep 2024 15:59:56 +0800
Subject: [PATCH 2/2] [mlir][linalg] add a simple test
---
.../Dialect/Linalg/match-ops-interpreter.mlir | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index 4bfed475d44f60..bfe7a07cb38a50 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -996,6 +996,21 @@ module attributes { transform.target_tag = "start_here" } {
} -> tensor<40x10x50x15xf32>
return %result : tensor<40x10x50x15xf32>
}
+
+ func.func @generic_min(%arg0: tensor<1x7x4xf32>, %arg1: tensor<4xf32>, %arg2: tensor<1x1x4xf32>) {
+ linalg.generic {
+ indexing_maps = [affine_map<(d0, d1, d2, d3) -> (d0, d1 * 2 + d3 * 2, d2)>,
+ affine_map<(d0, d1, d2, d3) -> (d3)>,
+ affine_map<(d0, d1, d2, d3) -> (d0, d1, d2)>],
+ iterator_types = ["parallel", "parallel", "parallel", "reduction"]}
+ ins(%arg0, %arg1 : tensor<1x7x4xf32>, tensor<4xf32>)
+ outs(%arg2 : tensor<1x1x4xf32>) {
+ ^bb0(%in: f32, %in_1: f32, %out: f32):
+ %5 = arith.minimumf %out, %in : f32
+ linalg.yield %5 : f32
+ } -> tensor<1x1x4xf32>
+ return
+ }
}
// -----
More information about the Mlir-commits
mailing list