Skip to content

Commit 2564926

Browse files
Federico LebrónMaheshRavishankar
authored andcommitted
Fix pretty printing of linalg GenericOps when there are no inputs.
Differential Revision: https://reviews.llvm.org/D89825
1 parent 2eac8ce commit 2564926

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1453,7 +1453,8 @@ static void printNamedStructuredOpResults(OpAsmPrinter &p,
14531453
template <typename NamedStructuredOpType>
14541454
static void printCommonStructuredOpParts(OpAsmPrinter &p,
14551455
NamedStructuredOpType op) {
1456-
p << " ins(" << op.inputs() << " : " << op.inputs().getTypes() << ")";
1456+
if (!op.inputs().empty())
1457+
p << " ins(" << op.inputs() << " : " << op.inputs().getTypes() << ")";
14571458
if (!op.output_buffers().empty())
14581459
p << " outs(" << op.output_buffers() << " : "
14591460
<< op.output_buffers().getTypes() << ")";

mlir/test/Dialect/Linalg/roundtrip.mlir

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,24 @@ func @generic_with_tensor_input(%arg0: tensor<?x?xvector<3x4xi4>>,
341341

342342
// -----
343343

344+
#map0 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>
345+
func @generic_without_inputs(%arg0 : memref<?x?x?xf32>) {
346+
linalg.generic {indexing_maps = [#map0],
347+
iterator_types = ["parallel", "parallel", "parallel"]}
348+
outs(%arg0 : memref<?x?x?xf32>) {
349+
^bb0(%arg3: f32): // no predecessors
350+
%cst = constant 0.000000e+00 : f32
351+
linalg.yield %cst : f32
352+
}
353+
return
354+
}
355+
356+
// CHECK-LABEL: func @generic_without_inputs
357+
// CHECK: linalg.generic
358+
// CHECK-NOT: ins
359+
360+
// -----
361+
344362
#accesses = [
345363
affine_map<(i, j, k) -> (j, i)>,
346364
affine_map<(i, j, k) -> (i, k, i + j)>,

0 commit comments

Comments
 (0)