Skip to content

Commit

Permalink
[mlir][complex] Correctness check for complex.conj
Browse files Browse the repository at this point in the history
Add correctness check for complex.conj operation

Reviewed By: pifon2a

Differential Revision: https://reviews.llvm.org/D127377
  • Loading branch information
Lewuathe authored and pifon2a committed Jun 9, 2022
1 parent 447c411 commit fff27d1
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions mlir/test/Integration/Dialect/Complex/CPU/correctness.mlir
Expand Up @@ -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>) {
Expand Down Expand Up @@ -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
}

0 comments on commit fff27d1

Please sign in to comment.