@@ -11,46 +11,44 @@ eltypes = (Float64, ComplexF64)
1111@timedtestset " Enzyme - PlanarOperations (planarcontract): $(TensorKit. type_repr (sectortype (eltype (V)))) ($T )" for V in spacelist, T in eltypes
1212 atol = default_tol (T)
1313 rtol = default_tol (T)
14- for _ in 1 : 5
15- d = 0
16- local V1, V2, V3, k1, k2, k3
17- # retry a couple times to make sure there are at least some nonzero elements
18- for _ in 1 : 10
19- k1 = rand (0 : 3 )
20- k2 = rand (0 : 2 )
21- k3 = rand (0 : 2 )
22- V1 = prod (v -> rand (Bool) ? v' : v, rand (V, k1); init = one (V[1 ]))
23- V2 = prod (v -> rand (Bool) ? v' : v, rand (V, k2); init = one (V[1 ]))
24- V3 = prod (v -> rand (Bool) ? v' : v, rand (V, k3); init = one (V[1 ]))
25- d = min (dim (V1 ← V2), dim (V1' ← V2), dim (V2 ← V3), dim (V2' ← V3))
26- d > 1 && break
27- end
28- k′ = rand (0 : (k1 + k2))
29- pA = randcircshift (k′, k1 + k2 - k′, k1)
30- ipA = _repartition (invperm (linearize (pA)), k′)
31- k′ = rand (0 : (k2 + k3))
32- pB = randcircshift (k′, k2 + k3 - k′, k2)
33- ipB = _repartition (invperm (linearize (pB)), k′)
34- # TODO : primal value already is broken for this?
35- # pAB = randcircshift(k1, k3)
36- pAB = _repartition (tuple ((1 : (k1 + k3)). .. ), k1)
14+ d = 0
15+ local V1, V2, V3, k1, k2, k3
16+ # retry a couple times to make sure there are at least some nonzero elements
17+ for _ in 1 : 10
18+ k1 = rand (0 : 3 )
19+ k2 = rand (0 : 2 )
20+ k3 = rand (0 : 2 )
21+ V1 = prod (v -> rand (Bool) ? v' : v, rand (V, k1); init = one (V[1 ]))
22+ V2 = prod (v -> rand (Bool) ? v' : v, rand (V, k2); init = one (V[1 ]))
23+ V3 = prod (v -> rand (Bool) ? v' : v, rand (V, k3); init = one (V[1 ]))
24+ d = min (dim (V1 ← V2), dim (V1' ← V2), dim (V2 ← V3), dim (V2' ← V3))
25+ d > 1 && break
26+ end
27+ k′ = rand (0 : (k1 + k2))
28+ pA = randcircshift (k′, k1 + k2 - k′, k1)
29+ ipA = _repartition (invperm (linearize (pA)), k′)
30+ k′ = rand (0 : (k2 + k3))
31+ pB = randcircshift (k′, k2 + k3 - k′, k2)
32+ ipB = _repartition (invperm (linearize (pB)), k′)
33+ # TODO : primal value already is broken for this?
34+ # pAB = randcircshift(k1, k3)
35+ pAB = _repartition (tuple ((1 : (k1 + k3)). .. ), k1)
3736
38- α = randn (T)
39- β = randn (T)
37+ α = randn (T)
38+ β = randn (T)
4039
41- A = randn (T, permute (V1 ← V2, ipA))
42- B = randn (T, permute (V2 ← V3, ipB))
43- C = randn! (
44- TensorOperations. tensoralloc_contract (
45- T, A, pA, false , B, pB, false , pAB, Val (false )
46- )
40+ A = randn (T, permute (V1 ← V2, ipA))
41+ B = randn (T, permute (V2 ← V3, ipB))
42+ C = randn! (
43+ TensorOperations. tensoralloc_contract (
44+ T, A, pA, false , B, pB, false , pAB, Val (false )
4745 )
48- for TC in (Duplicated,), TA in (Duplicated,), TB in (Duplicated, )
49- EnzymeTestUtils . test_reverse (TensorKit . planarcontract!, TC, (C, TC ), (A, TA), (pA, Const ), (B, TB), (pB, Const), (pAB, Const), ( One (), Const), ( Zero (), Const); atol, rtol )
50- EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α , Const), (β , Const); atol, rtol)
51- EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Const), (β, Active ); atol, rtol)
52- EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Active ), (β, Const ); atol, rtol)
53- EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Active), (β, Active ); atol, rtol)
54- end
46+ )
47+ for TC in (Duplicated, ), TA in (Duplicated, ), TB in (Duplicated, )
48+ EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (One () , Const), (Zero () , Const); atol, rtol)
49+ EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Const), (β, Const ); atol, rtol)
50+ EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Const ), (β, Active ); atol, rtol)
51+ EnzymeTestUtils. test_reverse (TensorKit. planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Active), (β, Const ); atol, rtol)
52+ EnzymeTestUtils . test_reverse (TensorKit . planarcontract!, TC, (C, TC), (A, TA), (pA, Const), (B, TB), (pB, Const), (pAB, Const), (α, Active), (β, Active); atol, rtol)
5553 end
5654end
0 commit comments