diff --git a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp index 47552c31007f69..cd471d5b16489d 100644 --- a/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp +++ b/mlir/lib/Dialect/Linalg/IR/LinalgOps.cpp @@ -1453,7 +1453,8 @@ static void printNamedStructuredOpResults(OpAsmPrinter &p, template static void printCommonStructuredOpParts(OpAsmPrinter &p, NamedStructuredOpType op) { - p << " ins(" << op.inputs() << " : " << op.inputs().getTypes() << ")"; + if (!op.inputs().empty()) + p << " ins(" << op.inputs() << " : " << op.inputs().getTypes() << ")"; if (!op.output_buffers().empty()) p << " outs(" << op.output_buffers() << " : " << op.output_buffers().getTypes() << ")"; diff --git a/mlir/test/Dialect/Linalg/roundtrip.mlir b/mlir/test/Dialect/Linalg/roundtrip.mlir index b4347ca8988779..b63c26f215830f 100644 --- a/mlir/test/Dialect/Linalg/roundtrip.mlir +++ b/mlir/test/Dialect/Linalg/roundtrip.mlir @@ -341,6 +341,24 @@ func @generic_with_tensor_input(%arg0: tensor>, // ----- +#map0 = affine_map<(d0, d1, d2) -> (d0, d1, d2)> +func @generic_without_inputs(%arg0 : memref) { + linalg.generic {indexing_maps = [#map0], + iterator_types = ["parallel", "parallel", "parallel"]} + outs(%arg0 : memref) { + ^bb0(%arg3: f32): // no predecessors + %cst = constant 0.000000e+00 : f32 + linalg.yield %cst : f32 + } + return +} + +// CHECK-LABEL: func @generic_without_inputs +// CHECK: linalg.generic +// CHECK-NOT: ins + +// ----- + #accesses = [ affine_map<(i, j, k) -> (j, i)>, affine_map<(i, j, k) -> (i, k, i + j)>,