diff --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td --- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td +++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td @@ -75,6 +75,24 @@ }]; } +//===----------------------------------------------------------------------===// +// Atan2 +//===----------------------------------------------------------------------===// + +def Atan2Op : ComplexArithmeticOp<"atan2"> { + let summary = "complex 2-argument arctangent"; + let description = [{ + For complex numbers it is expressed using complex logarithm + atan2(y, x) = -i * log((x + i * y) / sqrt(x**2 + y**2)) + + Example: + + ```mlir + %a = complex.atan2 %b, %c : complex + ``` + }]; +} + //===----------------------------------------------------------------------===// // ConstantOp //===----------------------------------------------------------------------===// diff --git a/mlir/test/Dialect/Complex/ops.mlir b/mlir/test/Dialect/Complex/ops.mlir --- a/mlir/test/Dialect/Complex/ops.mlir +++ b/mlir/test/Dialect/Complex/ops.mlir @@ -77,5 +77,8 @@ // CHECK: complex.rsqrt %[[C]] : complex %rsqrt = complex.rsqrt %complex : complex + // CHECK: complex.atan2 %[[C]], %[[C]] : complex + %atan2 = complex.atan2 %complex, %complex : complex + return }