diff --git a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td --- a/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td +++ b/mlir/include/mlir/Dialect/Shape/IR/ShapeOps.td @@ -267,6 +267,8 @@ let arguments = (ins Shape_SizeType:$lhs, Shape_SizeType:$rhs); let results = (outs Shape_SizeType:$result); + + let assemblyFormat = "attr-dict $lhs `,` $rhs"; } def Shape_NumElementsOp : Shape_Op<"num_elements", [NoSideEffect]> { @@ -274,6 +276,10 @@ let description = [{ Returns the number of elements for a given shape which is the product of its dimensions. + + ```mlir + %product = shape.mul %lhs, %rhs + ``` }]; let arguments = (ins Shape_ShapeType:$shape); diff --git a/mlir/test/Dialect/Shape/ops.mlir b/mlir/test/Dialect/Shape/ops.mlir --- a/mlir/test/Dialect/Shape/ops.mlir +++ b/mlir/test/Dialect/Shape/ops.mlir @@ -1,4 +1,8 @@ // RUN: mlir-opt -split-input-file %s | mlir-opt | FileCheck %s --dump-input-on-failure +// Verify the printed output can be parsed. +// RUN: mlir-opt %s | mlir-opt | FileCheck %s --dump-input-on-failure +// Verify the generic form can be parsed. +// RUN: mlir-opt -mlir-print-op-generic %s | mlir-opt | FileCheck %s --dump-input-on-failure // CHECK-LABEL: shape_num_elements func @shape_num_elements(%shape : !shape.shape) -> !shape.size { @@ -80,3 +84,8 @@ } return } + +func @test_mul(%lhs: !shape.size, %rhs: !shape.size) -> !shape.size { + %product = shape.mul %lhs, %rhs + return %product: !shape.size +}