@@ -23,11 +23,10 @@ function test_enzyme_svd_compact(
2323 alg = MatrixAlgebraKit. select_algorithm (svd_compact, A)
2424 USVᴴ, ΔUSVᴴ = ad_svd_compact_setup (A)
2525 test_reverse (svd_compact, RT, (A, TA), (alg, Const); atol, rtol, output_tangent = ΔUSVᴴ, fdm)
26- test_reverse (call_and_zero!, RT, (svd_compact!, Const), (A , TA), (alg, Const); atol, rtol, output_tangent = ΔUSVᴴ, fdm)
26+ test_reverse (call_and_zero!, RT, (svd_compact!, Const), (copy (A) , TA), (alg, Const); atol, rtol, output_tangent = ΔUSVᴴ, fdm)
2727 if eltype (T) <: Real
28- A = instantiate_matrix (T, sz)
2928 test_forward (svd_compact, RT, (A, TA), (alg, Const); atol, rtol, fdm)
30- test_forward (call_and_zero!, RT, (svd_compact!, Const), (A , TA), (alg, Const); atol, rtol, fdm)
29+ test_forward (call_and_zero!, RT, (svd_compact!, Const), (copy (A) , TA), (alg, Const); atol, rtol, fdm)
3130 end
3231 end
3332end
@@ -48,11 +47,10 @@ function test_enzyme_svd_full(
4847 alg = MatrixAlgebraKit. select_algorithm (svd_full, A)
4948 USVᴴ, ΔUSVᴴ = ad_svd_full_setup (A)
5049 test_reverse (svd_full, RT, (A, TA), (alg, Const); atol, rtol, output_tangent = ΔUSVᴴ, fdm)
51- test_reverse (call_and_zero!, RT, (svd_full!, Const), (A , TA), (alg, Const); atol, rtol, output_tangent = ΔUSVᴴ, fdm)
50+ test_reverse (call_and_zero!, RT, (svd_full!, Const), (copy (A) , TA), (alg, Const); atol, rtol, output_tangent = ΔUSVᴴ, fdm)
5251 if eltype (T) <: Real
53- A = instantiate_matrix (T, sz)
5452 test_forward (svd_full, RT, (A, TA), (alg, Const); atol, rtol, fdm)
55- test_forward (call_and_zero!, RT, (svd_full!, Const), (A , TA), (alg, Const); atol, rtol, fdm)
53+ test_forward (call_and_zero!, RT, (svd_full!, Const), (copy (A) , TA), (alg, Const); atol, rtol, fdm)
5654 end
5755 end
5856end
@@ -72,10 +70,9 @@ function test_enzyme_svd_vals(
7270 alg = MatrixAlgebraKit. select_algorithm (svd_vals, A)
7371 S, ΔS = ad_svd_vals_setup (A)
7472 test_reverse (svd_vals, RT, (A, TA), (alg, Const); atol, rtol, output_tangent = ΔS, fdm)
75- test_reverse (call_and_zero!, RT, (svd_vals!, Const), (A, TA), (alg, Const); atol, rtol, output_tangent = ΔS, fdm)
76- A = instantiate_matrix (T, sz)
73+ test_reverse (call_and_zero!, RT, (svd_vals!, Const), (copy (A), TA), (alg, Const); atol, rtol, output_tangent = ΔS, fdm)
7774 test_forward (svd_vals, RT, (A, TA), (alg, Const); atol, rtol, fdm)
78- test_forward (call_and_zero!, RT, (svd_vals!, Const), (A , TA), (alg, Const); atol, rtol, fdm)
75+ test_forward (call_and_zero!, RT, (svd_vals!, Const), (copy (A) , TA), (alg, Const); atol, rtol, fdm)
7976 end
8077end
8178
@@ -99,15 +96,15 @@ function test_enzyme_svd_trunc(
9996 trunc = truncrank (r)
10097 truncalg = TruncatedAlgorithm (alg, trunc)
10198 USVᴴ, _, ΔUSVᴴ, ΔUSVᴴtrunc = ad_svd_trunc_setup (A, truncalg)
102- test_reverse (svd_trunc_no_error, RT, (A , TA), (truncalg, Const); atol, rtol, output_tangent = ΔUSVᴴtrunc, fdm)
99+ test_reverse (svd_trunc_no_error, RT, (copy (A) , TA), (truncalg, Const); atol, rtol, output_tangent = ΔUSVᴴtrunc, fdm)
103100 test_reverse (call_and_zero!, RT, (svd_trunc_no_error!, Const), (copy (A), TA), (truncalg, Const); atol, rtol, output_tangent = ΔUSVᴴtrunc, fdm)
104101 end
105102 @testset " trunctol" begin
106103 S = svd_vals (A, alg)
107104 trunc = trunctol (atol = maximum (S) / 2 )
108105 truncalg = TruncatedAlgorithm (alg, trunc)
109106 USVᴴ, _, ΔUSVᴴ, ΔUSVᴴtrunc = ad_svd_trunc_setup (A, truncalg)
110- test_reverse (svd_trunc_no_error, RT, (A , TA), (truncalg, Const); atol, rtol, output_tangent = ΔUSVᴴtrunc, fdm)
107+ test_reverse (svd_trunc_no_error, RT, (copy (A) , TA), (truncalg, Const); atol, rtol, output_tangent = ΔUSVᴴtrunc, fdm)
111108 test_reverse (call_and_zero!, RT, (svd_trunc_no_error!, Const), (copy (A), TA), (truncalg, Const); atol, rtol, output_tangent = ΔUSVᴴtrunc, fdm)
112109 end
113110 end
0 commit comments