[mlir] Add `complex.atan2` operation.

Differential Revision: https://reviews.llvm.org/D126357
This commit is contained in:
Alexander Belyaev 2022-05-25 09:58:00 +02:00
parent 8a6698b523
commit b3c5c22c13
2 changed files with 21 additions and 0 deletions

View File

@ -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
//===----------------------------------------------------------------------===//

View File

@ -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
}