Skip to content

Commit

Permalink
[mlir] Fix printing when linalg.map has no inputs.
Browse files Browse the repository at this point in the history
Differential Revision: https://reviews.llvm.org/D136836
  • Loading branch information
pifon2a committed Oct 27, 2022
1 parent 38f44cc commit 30ceb74
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
10 changes: 6 additions & 4 deletions mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 19 additions & 0 deletions mlir/test/Dialect/Linalg/roundtrip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 30ceb74

Please sign in to comment.