[Mlir-commits] [mlir] Allow empty dimension arrays in `linalg::inferContractionDims` (PR #69496)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 19 08:35:33 PDT 2023
https://github.com/bjacob updated https://github.com/llvm/llvm-project/pull/69496
>From 835049da083d930b436a7624349aec01c6af2c9a Mon Sep 17 00:00:00 2001
From: Benoit Jacob <jacob.benoit.1 at gmail.com>
Date: Wed, 18 Oct 2023 14:36:14 -0400
Subject: [PATCH 1/2] allow-empty
---
mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp | 3 ---
1 file changed, 3 deletions(-)
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
index ea50e1232a4c74a..5fde8d71cac3e75 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgInterfaces.cpp
@@ -227,9 +227,6 @@ mlir::linalg::inferContractionDims(LinalgOp linalgOp) {
linalgOp, linalgOp.getDpsInputOperand(1), red);
llvm::set_intersect(ra, rb);
- if (ac.empty() || bc.empty() || ra.empty())
- return failure();
-
// Return each set in sorted order.
ContractionDimensions dimensions{
SmallVector<unsigned, 2>(batches.begin(), batches.end()),
>From 2a016ef53be8f65aa787edc1a97eaef5d99a09a8 Mon Sep 17 00:00:00 2001
From: Benoit Jacob <jacob.benoit.1 at gmail.com>
Date: Thu, 19 Oct 2023 11:33:22 -0400
Subject: [PATCH 2/2] add test
---
mlir/test/Dialect/Linalg/match-ops-interpreter.mlir | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
index bad6893eaa99e1e..1da092ab42ad779 100644
--- a/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
+++ b/mlir/test/Dialect/Linalg/match-ops-interpreter.mlir
@@ -910,6 +910,19 @@ module attributes { transform.target_tag = "start_here" } {
return %result : tensor<10x15xf64>
}
+ func.func @vecmat_simple(%lhs: tensor<20xf32>, %rhs: tensor<20x15xf32>) -> tensor<15xf64> {
+ %cst = arith.constant 0.0 : f64
+ %empty = tensor.empty() : tensor<15xf64>
+ %fill = linalg.fill ins(%cst : f64) outs(%empty : tensor<15xf64>) -> tensor<15xf64>
+ // expected-remark @below {{contraction}}
+ // expected-remark @below {{batch dims}}
+ // expected-remark @below {{m dims}}
+ // expected-remark @below {{n dims 0}}
+ // expected-remark @below {{k dims 1}}
+ %result = linalg.vecmat ins(%lhs, %rhs: tensor<20xf32>, tensor<20x15xf32>) outs(%fill: tensor<15xf64>) -> tensor<15xf64>
+ return %result : tensor<15xf64>
+ }
+
func.func @double_batch(%lhs: tensor<40x10x50x20xf32>, %rhs: tensor<40x20x50x15xf32>) -> tensor<40x10x50x15xf32> {
%cst = arith.constant 0.0 : f32
%empty = tensor.empty() : tensor<40x10x50x15xf32>
More information about the Mlir-commits
mailing list