[Mlir-commits] [mlir] a3a85fe - [mlir] Add RSqrt tp ComplexOps.td.

Alexander Belyaev llvmlistbot at llvm.org
Mon May 23 07:12:20 PDT 2022


Author: Alexander Belyaev
Date: 2022-05-23T16:12:05+02:00
New Revision: a3a85fe59f489b7531e2852c1c573a26b18703b9

URL: https://github.com/llvm/llvm-project/commit/a3a85fe59f489b7531e2852c1c573a26b18703b9
DIFF: https://github.com/llvm/llvm-project/commit/a3a85fe59f489b7531e2852c1c573a26b18703b9.diff

LOG: [mlir] Add RSqrt tp ComplexOps.td.

Differential Revision: https://reviews.llvm.org/D126202

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 a87af6f4fabf..3073d4e08866 100644
--- a/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
+++ b/mlir/include/mlir/Dialect/Complex/IR/ComplexOps.td
@@ -387,6 +387,25 @@ def ReOp : ComplexUnaryOp<"re",
   let hasFolder = 1;
 }
 
+//===----------------------------------------------------------------------===//
+// RsqrtOp
+//===----------------------------------------------------------------------===//
+
+def RsqrtOp : ComplexUnaryOp<"rsqrt", [SameOperandsAndResultType]> {
+  let summary = "complex reciprocal of square root";
+  let description = [{
+    The `rsqrt` operation computes reciprocal of square root.
+
+    Example:
+
+    ```mlir
+    %a = complex.rsqrt %b : complex<f32>
+    ```
+  }];
+
+  let results = (outs Complex<AnyFloat>:$result);
+}
+
 //===----------------------------------------------------------------------===//
 // SignOp
 //===----------------------------------------------------------------------===//

diff  --git a/mlir/test/Dialect/Complex/ops.mlir b/mlir/test/Dialect/Complex/ops.mlir
index 6c2ed8bc9dfe..f0f80e080297 100644
--- a/mlir/test/Dialect/Complex/ops.mlir
+++ b/mlir/test/Dialect/Complex/ops.mlir
@@ -61,5 +61,18 @@ func.func @ops(%f: f32) {
 
   // CHECK: complex.sub %[[C]], %[[C]] : complex<f32>
   %
diff  = complex.sub %complex, %complex : complex<f32>
+
+  // CHECK: complex.tanh %[[C]] : complex<f32>
+  %tanh = complex.tanh %complex : complex<f32>
+
+  // CHECK: complex.pow %[[C]], %[[C]] : complex<f32>
+  %pow = complex.pow %complex, %complex : complex<f32>
+
+  // CHECK: complex.sqrt %[[C]] : complex<f32>
+  %sqrt = complex.sqrt %complex : complex<f32>
+
+  // CHECK: complex.rsqrt %[[C]] : complex<f32>
+  %rsqrt = complex.rsqrt %complex : complex<f32>
+
   return
 }


        


More information about the Mlir-commits mailing list