@@ -32,6 +32,19 @@ function test_enzyme_left_polar(
3232 A = instantiate_matrix (T, sz)
3333 test_forward (left_polar, RT, (A, TA), (alg, Const); atol, rtol)
3434 test_forward (call_and_zero!, RT, (left_polar!, Const), (A, TA), (alg, Const); atol, rtol)
35+
36+ A = instantiate_rank_deficient_matrix (T, sz)
37+ test_reverse (polar_P_wrapper, RT, (left_polar, Const), (A, TA), (alg, Const); atol, rtol, fdm = rank_deficient_fdm)
38+ test_forward (polar_P_wrapper, RT, (left_polar, Const), (A, TA), (alg, Const); atol, rtol, fdm = rank_deficient_fdm)
39+ # TODO : Enzyme can't diff through complex BLAS gemm
40+ if eltype (T) <: Real
41+ L, R = rank_deficient_factors (T, sz)
42+ for wrapper in (left_polar_rank_deficient_wrapper, left_polar!_rank_deficient_wrapper)
43+ f = wrapper === left_polar_rank_deficient_wrapper ? left_polar : left_polar!
44+ test_reverse (wrapper, RT, (f, Const), (L, TA), (R, TA), (alg, Const); atol, rtol)
45+ test_forward (wrapper, RT, (f, Const), (L, TA), (R, TA), (alg, Const); atol, rtol)
46+ end
47+ end
3548 end
3649 end
3750end
@@ -57,6 +70,19 @@ function test_enzyme_right_polar(
5770 A = instantiate_matrix (T, sz)
5871 test_forward (right_polar, RT, (A, TA), (alg, Const); atol, rtol)
5972 test_forward (call_and_zero!, RT, (right_polar!, Const), (A, TA), (alg, Const); atol, rtol)
73+
74+ A = instantiate_rank_deficient_matrix (T, sz)
75+ test_reverse (polar_P_wrapper, RT, (right_polar, Const), (A, TA), (alg, Const); atol, rtol, fdm = rank_deficient_fdm)
76+ test_forward (polar_P_wrapper, RT, (right_polar, Const), (A, TA), (alg, Const); atol, rtol, fdm = rank_deficient_fdm)
77+ # TODO : Enzyme can't diff through complex BLAS gemm
78+ if eltype (T) <: Real
79+ L, R = rank_deficient_factors (T, sz)
80+ for wrapper in (right_polar_rank_deficient_wrapper, right_polar!_rank_deficient_wrapper)
81+ f = wrapper === right_polar_rank_deficient_wrapper ? right_polar : right_polar!
82+ test_reverse (wrapper, RT, (f, Const), (L, TA), (R, TA), (alg, Const); atol, rtol)
83+ test_forward (wrapper, RT, (f, Const), (L, TA), (R, TA), (alg, Const); atol, rtol)
84+ end
85+ end
6086 end
6187 end
6288end
0 commit comments