[Mlir-commits] [mlir] fff27d1 - [mlir][complex] Correctness check for complex.conj

Alexander Belyaev llvmlistbot at llvm.org
Thu Jun 9 02:12:13 PDT 2022


Author: lewuathe
Date: 2022-06-09T11:11:56+02:00
New Revision: fff27d181c0ca09ed3a944e10a030d494c824fb9

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

LOG: [mlir][complex] Correctness check for complex.conj

Add correctness check for complex.conj operation

Reviewed By: pifon2a

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

Added: 
    

Modified: 
    mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir

Removed: 
    


################################################################################
diff  --git a/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir b/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
index 00ab3ed76e278..5f7940b9da28b 100644
--- a/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
+++ b/mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
@@ -43,6 +43,11 @@ func.func @rsqrt(%arg: complex<f32>) -> complex<f32> {
   func.return %sqrt : complex<f32>
 }
 
+func.func @conj(%arg: complex<f32>) -> complex<f32> {
+  %conj = complex.conj %arg : complex<f32>
+  func.return %conj : complex<f32>
+}
+
 // %input contains pairs of lhs, rhs, i.e. [lhs_0, rhs_0, lhs_1, rhs_1,...]
 func.func @test_binary(%input: tensor<?xcomplex<f32>>,
                        %func: (complex<f32>, complex<f32>) -> complex<f32>) {
@@ -216,5 +221,36 @@ func.func @entry() {
   call @test_unary(%rsqrt_test_cast, %rsqrt_func)
     : (tensor<?xcomplex<f32>>, (complex<f32>) -> complex<f32>) -> ()
 
+  // complex.conj test
+  %conj_test = arith.constant dense<[
+    (-1.0, -1.0),
+    // CHECK:      -1.0
+    // CHECK-NEXT: 1.0
+    (-1.0, 1.0),
+    // CHECK-NEXT:  -1.0
+    // CHECK-NEXT:  -1.0
+    (0.0, 0.0),
+    // CHECK-NEXT:  0
+    // CHECK-NEXT:  0
+    (0.0, 1.0),
+    // CHECK-NEXT:  0
+    // CHECK-NEXT:  -1.0
+    (1.0, -1.0),
+    // CHECK-NEXT:  1.0
+    // CHECK-NEXT:  -1.0
+    (1.0, 0.0),
+    // CHECK-NEXT:  1.0
+    // CHECK-NEXT:  0
+    (1.0, 1.0)
+    // CHECK-NEXT:  1.0
+    // CHECK-NEXT:  -1.0
+  ]> : tensor<7xcomplex<f32>>
+  %conj_test_cast = tensor.cast %conj_test
+    :  tensor<7xcomplex<f32>> to tensor<?xcomplex<f32>>
+
+  %conj_func = func.constant @conj : (complex<f32>) -> complex<f32>
+  call @test_unary(%conj_test_cast, %conj_func)
+    : (tensor<?xcomplex<f32>>, (complex<f32>) -> complex<f32>) -> ()
+    
   func.return
 }


        


More information about the Mlir-commits mailing list