Skip to content

Commit b82fbbf

Browse files
authored
Consolidate Enzyme index manipulation tests a bit and try running on 1.10 again (#496)
* Consolidate some of the indexmanip tests * Try running again on Windows and/or 1.10
1 parent e852e6a commit b82fbbf

9 files changed

Lines changed: 124 additions & 132 deletions

File tree

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using Test, TestExtras
2+
using TensorKit
3+
using TensorOperations
4+
using Enzyme, EnzymeTestUtils
5+
using Random
6+
7+
spacelist = ad_spacelist(fast_tests)
8+
eltypes = (Float64, ComplexF64)
9+
10+
is_ci = get(ENV, "CI", "false") == "true"
11+
Tαs = is_ci ? (Active,) : (Active, Const)
12+
Tβs = is_ci ? (Active,) : (Active, Const)
13+
14+
@timedtestset "Enzyme - Index Manipulations (braid!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T) Tα $Tα Tβ $Tβ" for V in spacelist, T in eltypes, Tα in Tαs, Tβ in Tβs
15+
atol = default_tol(T)
16+
rtol = default_tol(T)
17+
Vstr = TensorKit.type_repr(sectortype(eltype(V)))
18+
has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding
19+
if has_braiding
20+
A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])')
21+
α = randn(T)
22+
β = randn(T)
23+
p = randcircshift(numout(A), numin(A))
24+
levels = Tuple(randperm(numind(A)))
25+
C = randn!(transpose(A, p))
26+
EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (α, Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ")
27+
if !(T <: Real) && !is_ci
28+
EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (real(A), Duplicated), (p, Const), (levels, Const), (α, Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ")
29+
EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (real(α), Tα), (β, Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ")
30+
EnzymeTestUtils.test_reverse(TensorKit.braid!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (levels, Const), (real(α), Tα), (real(β), Tβ); atol, rtol, testset_name = "braid! V $Vstr Tα $Tα Tβ $Tβ")
31+
end
32+
end
33+
end

test/enzyme-indexmanipulations-flip-twist/flip.jl renamed to test/enzyme-indexmanipulations-flip-twist-transform/flip.jl

File renamed without changes.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Test, TestExtras
2+
using TensorKit
3+
using TensorOperations
4+
using Enzyme, EnzymeTestUtils
5+
using Random
6+
7+
spacelist = ad_spacelist(fast_tests)
8+
eltypes = (Float64, ComplexF64)
9+
10+
is_ci = get(ENV, "CI", "false") == "true"
11+
Tαs = is_ci ? (Active,) : (Active, Const)
12+
Tβs = is_ci ? (Active,) : (Active, Const)
13+
14+
@timedtestset "Enzyme - Index Manipulations (permute!): $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
15+
println(TensorKit.type_repr(sectortype(eltype(V))))
16+
atol = default_tol(T)
17+
rtol = default_tol(T)
18+
symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding
19+
20+
symmetricbraiding && @timedtestset "permute! Tα $Tα, Tβ $Tβ" for Tα in Tαs, Tβ in Tβs
21+
A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])')
22+
α = randn(T)
23+
β = randn(T)
24+
p = randindextuple(numind(A))
25+
C = randn!(permute(A, p))
26+
EnzymeTestUtils.test_reverse(TensorKit.permute!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol)
27+
end
28+
end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
using Test, TestExtras
2+
using TensorKit
3+
using TensorOperations
4+
using VectorInterface: Zero, One
5+
using Enzyme, EnzymeTestUtils
6+
using Random
7+
8+
spacelist = ad_spacelist(fast_tests)
9+
eltypes = (Float64, ComplexF64)
10+
11+
is_ci = get(ENV, "CI", "false") == "true"
12+
13+
Tαs = is_ci ? (Active,) : (Active, Const)
14+
Tβs = is_ci ? (Active,) : (Active, Const)
15+
16+
@timedtestset "Enzyme - Index Manipulations (transpose!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes
17+
atol = default_tol(T)
18+
rtol = default_tol(T)
19+
A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])')
20+
α = randn(T)
21+
β = randn(T)
22+
23+
# repeat a couple times to get some distribution of arrows
24+
p = randcircshift(numout(A), numin(A))
25+
C = randn!(transpose(A, p))
26+
!is_ci && EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (One(), Const), (Zero(), Const); atol, rtol)
27+
@testset for Tα in Tαs, Tβ in Tβs
28+
EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol)
29+
if !(T <: Real) && !is_ci
30+
EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol)
31+
EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol)
32+
EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol)
33+
end
34+
end
35+
end
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using Test, TestExtras
2+
using TensorKit
3+
using TensorOperations
4+
using VectorInterface: Zero, One
5+
using Enzyme, EnzymeTestUtils
6+
using Random
7+
8+
spacelist = ad_spacelist(fast_tests)
9+
eltypes = (Float64, ComplexF64)
10+
11+
@timedtestset "Enzyme - Index Manipulations (twist):" begin
12+
@timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,)
13+
atol = default_tol(T)
14+
rtol = default_tol(T)
15+
A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])')
16+
has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding
17+
if has_braiding && !(T <: Real && !(sectorscalartype(sectortype(A)) <: Real))
18+
EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,))
19+
EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,))
20+
EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol)
21+
EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol)
22+
EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,))
23+
EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,))
24+
EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), (1, Const); atol, rtol)
25+
EnzymeTestUtils.test_forward(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol)
26+
end
27+
end
28+
end

‎test/enzyme-indexmanipulations-flip-twist/twist.jl‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎test/enzyme-indexmanipulations-transform/braid.jl‎

Lines changed: 0 additions & 35 deletions
This file was deleted.

‎test/enzyme-indexmanipulations-transform/permute.jl‎

Lines changed: 0 additions & 30 deletions
This file was deleted.

‎test/enzyme-indexmanipulations-transform/transpose.jl‎

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)