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 @@ -138,6 +138,21 @@ let hasFolder = 1; } +def Shape_ShapeEqOp : Shape_Op<"shape_eq", [Commutative, NoSideEffect]> { + let summary = "Returns whether the input shapes are equal"; + let description = [{ + Takes two shape operands and determines whether they are equal. + If one of the operands is unknown then the result of this equality test is + also unknown. + Error values propagate in the same way. + }]; + + let arguments = (ins Shape_ShapeType:$lhs, Shape_ShapeType:$rhs); + let results = (outs I1:$result); + + let assemblyFormat = "$lhs `,` $rhs attr-dict"; +} + def Shape_FromExtentsOp : Shape_Op<"from_extents", [NoSideEffect]> { let summary = "Creates a shape from extents"; let description = [{ 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 @@ -116,3 +116,8 @@ %rank = shape.rank %shape return %rank : !shape.size } + +func @shape_eq(%a : !shape.shape, %b : !shape.shape) -> i1 { + %result = shape.shape_eq %a, %b + return %result : i1 +}