[Mlir-commits] [mlir] 30ceb74 - [mlir] Fix printing when linalg.map has no inputs.
Alexander Belyaev
llvmlistbot at llvm.org
Thu Oct 27 04:55:31 PDT 2022
Author: Alexander Belyaev
Date: 2022-10-27T13:55:16+02:00
New Revision: 30ceb749c565aaa11a3e630743705c27038adbfa
URL: https://github.com/llvm/llvm-project/commit/30ceb749c565aaa11a3e630743705c27038adbfa
DIFF: https://github.com/llvm/llvm-project/commit/30ceb749c565aaa11a3e630743705c27038adbfa.diff
LOG: [mlir] Fix printing when linalg.map has no inputs.
Differential Revision: https://reviews.llvm.org/D136836
Added:
Modified:
mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
mlir/test/Dialect/Linalg/roundtrip.mlir
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
index a7e1938e2418a..03a959acfb2c7 100644
--- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
+++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
@@ -176,12 +176,14 @@ static void printCommonStructuredOpParts(OpAsmPrinter &p, ValueRange inputs,
static void printCommonStructuredOpPartsWithNewLine(OpAsmPrinter &p,
ValueRange inputs,
ValueRange outputs) {
- p.printNewline();
- if (!inputs.empty())
+ if (!inputs.empty()) {
+ p.printNewline();
p << "ins(" << inputs << " : " << inputs.getTypes() << ")";
- p.printNewline();
- if (!outputs.empty())
+ }
+ if (!outputs.empty()) {
+ p.printNewline();
p << "outs(" << outputs << " : " << outputs.getTypes() << ")";
+ }
}
//===----------------------------------------------------------------------===//
// Specific parsing and printing for named structured ops created by ods-gen.
diff --git a/mlir/test/Dialect/Linalg/roundtrip.mlir b/mlir/test/Dialect/Linalg/roundtrip.mlir
index 6e1c26634c417..fc0e3e057d9a8 100644
--- a/mlir/test/Dialect/Linalg/roundtrip.mlir
+++ b/mlir/test/Dialect/Linalg/roundtrip.mlir
@@ -326,6 +326,25 @@ func.func @mixed_parallel_reduced_results(%arg0 : tensor<?x?x?xf32>,
// -----
+func.func @map_no_inputs(%init: tensor<64xf32>) -> tensor<64xf32> {
+ %add = linalg.map
+ outs(%init:tensor<64xf32>)
+ () {
+ %0 = arith.constant 0.0: f32
+ linalg.yield %0: f32
+ }
+ func.return %add : tensor<64xf32>
+}
+// CHECK-LABEL: func @map_no_inputs
+// CHECK: linalg.map
+// CHECK-NEXT: outs
+// CHECK-NEXT: () {
+// CHECK-NEXT: arith.constant
+// CHECK-NEXT: linalg.yield
+// CHECK-NEXT: }
+
+// -----
+
func.func @map_binary(%lhs: tensor<64xf32>, %rhs: tensor<64xf32>,
%init: tensor<64xf32>) -> tensor<64xf32> {
%add = linalg.map
More information about the Mlir-commits
mailing list