11using Test, TestExtras
22using TensorKit
3+ using VectorInterface
34using Enzyme, EnzymeTestUtils
45using Random
56
67spacelist = ad_spacelist (fast_tests)
78eltypes = (Float64, ComplexF64)
89
910is_ci = get (ENV , " CI" , " false" ) == " true"
10- rTs = is_ci ? (Active,) : (Const, Active)
11- fTs = is_ci ? (Duplicated,) : (Const, Duplicated)
1211
1312@timedtestset verbose = true " Enzyme - LinearAlgebra (mul):" begin
1413 @timedtestset " $(TensorKit. type_repr (sectortype (eltype (V)))) ($T )" for V in spacelist, T in eltypes
@@ -23,14 +22,44 @@ fTs = is_ci ? (Duplicated,) : (Const, Duplicated)
2322 end
2423 A = randn (T, codomain (C) ← V[5 ]' ⊗ V[4 ]' )
2524 B = randn (T, domain (A) ← domain (C))
26- α = randn (T)
27- β = randn (T)
25+ zero_αβs = (( Zero (), Zero ()), ( randn (T), Zero ()), ( Zero (), randn (T)) )
26+ αβs = ! is_ci ? vcat (zero_αβs ... , ( randn (T), randn (T))) : (( randn (T), randn (T)), )
2827 for TC in (Duplicated,), TA in (Duplicated,), TB in (Duplicated,)
29- for Tα in rTs, Tβ in rTs
30- EnzymeTestUtils. test_reverse (mul!, TC, (C, TC), (A, TA), (B, TB), (α, Tα), (β, Tβ); atol, rtol, testset_name = " mul! reverse Tα $Tα , Tβ $Tβ " )
31- end
32- for Tα in fTs, Tβ in fTs
33- EnzymeTestUtils. test_forward (mul!, TC, (C, TC), (A, TA), (B, TB), (α, Tα), (β, Tβ); atol, rtol, testset_name = " mul! forward Tα $Tα , Tβ $Tβ " )
28+ for (α, β) in αβs
29+ rTαs = if α === Zero ()
30+ (Const,)
31+ elseif ! is_ci
32+ (Active, Const)
33+ else
34+ (Active,)
35+ end
36+ rTβs = if β === Zero ()
37+ (Const,)
38+ elseif ! is_ci
39+ (Active, Const)
40+ else
41+ (Active,)
42+ end
43+ for Tα in rTαs, Tβ in rTβs
44+ EnzymeTestUtils. test_reverse (mul!, TC, (C, TC), (A, TA), (B, TB), (α, Tα), (β, Tβ); atol, rtol, testset_name = " mul! reverse Tα $Tα , Tβ $Tβ " )
45+ end
46+ fTαs = if α === Zero ()
47+ (Const,)
48+ elseif ! is_ci
49+ (Duplicated, Const)
50+ else
51+ (Duplicated,)
52+ end
53+ fTβs = if β === Zero ()
54+ (Const,)
55+ elseif ! is_ci
56+ (Duplicated, Const)
57+ else
58+ (Duplicated,)
59+ end
60+ for Tα in fTαs, Tβ in fTβs
61+ EnzymeTestUtils. test_forward (mul!, TC, (C, TC), (A, TA), (B, TB), (α, Tα), (β, Tβ); atol, rtol, testset_name = " mul! forward Tα $Tα , Tβ $Tβ " )
62+ end
3463 end
3564 if ! is_ci
3665 EnzymeTestUtils. test_reverse (mul!, TC, (C, TC), (A, TA), (B, TB); atol, rtol, testset_name = " mul! reverse no α no β" )
0 commit comments