[Mlir-commits] [mlir] b3c5c22 - [mlir] Add `complex.atan2` operation.
Alexander Belyaev
llvmlistbot at llvm.org
Wed May 25 01:12:03 PDT 2022
Author: Alexander Belyaev
Date: 2022-05-25T10:11:44+02:00
New Revision: b3c5c22c13785570ae2895cc53f407133b602643
URL: https://github.com/llvm/llvm-project/commit/b3c5c22c13785570ae2895cc53f407133b602643
DIFF: https://github.com/llvm/llvm-project/commit/b3c5c22c13785570ae2895cc53f407133b602643.diff
LOG: [mlir] Add `complex.atan2` operation.
Differential Revision: https://reviews.llvm.org/D126357
Added:
Modified:
mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
mlir/test/Dialect/Complex/ops.mlir
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
index 4a7377e7fe643..a8fcf86de3af2 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
@@ -75,6 +75,24 @@ def AddOp : ComplexArithmeticOp<"add"> {
}];
}
+//===----------------------------------------------------------------------===//
+// 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<f32>
+ ```
+ }];
+}
+
//===----------------------------------------------------------------------===//
// ConstantOp
//===----------------------------------------------------------------------===//
diff --git a/mlir/test/Dialect/Complex/ops.mlir b/mlir/test/Dialect/Complex/ops.mlir
index 1b302af74b9c7..f8902bc1b6a45 100644
--- a/mlir/test/Dialect/Complex/ops.mlir
+++ b/mlir/test/Dialect/Complex/ops.mlir
@@ -77,5 +77,8 @@ func.func @ops(%f: f32) {
// CHECK: complex.rsqrt %[[C]] : complex<f32>
%rsqrt = complex.rsqrt %complex : complex<f32>
+ // CHECK: complex.atan2 %[[C]], %[[C]] : complex<f32>
+ %atan2 = complex.atan2 %complex, %complex : complex<f32>
+
return
}
More information about the Mlir-commits
mailing list