From 592a1d79016a1a631e1cc0dd615a984b8b72052d Mon Sep 17 00:00:00 2001 From: Katharine Hyatt Date: Wed, 1 Jul 2026 21:09:24 +0200 Subject: [PATCH] Fix Enzyme index manipulation spaces to match Mooncake --- .../flip.jl | 24 +++++++++++++ .../twist.jl | 26 ++++++++++++++ .../braid.jl | 35 +++++++++++++++++++ .../permute.jl | 7 ++-- .../transpose.jl | 16 ++++----- .../insertunit.jl | 26 ++++++++++++++ .../removeunit.jl | 22 ++++++++++++ test/enzyme-indexmanipulations/braid.jl | 32 ----------------- test/enzyme-indexmanipulations/flip.jl | 19 ---------- test/enzyme-indexmanipulations/insertunit.jl | 24 ------------- test/enzyme-indexmanipulations/removeunit.jl | 20 ----------- test/enzyme-indexmanipulations/twist.jl | 23 ------------ 12 files changed, 145 insertions(+), 129 deletions(-) create mode 100644 test/enzyme-indexmanipulations-flip-twist/flip.jl create mode 100644 test/enzyme-indexmanipulations-flip-twist/twist.jl create mode 100644 test/enzyme-indexmanipulations-transform/braid.jl rename test/{enzyme-indexmanipulations => enzyme-indexmanipulations-transform}/permute.jl (72%) rename test/{enzyme-indexmanipulations => enzyme-indexmanipulations-transform}/transpose.jl (54%) create mode 100644 test/enzyme-indexmanipulations-unit/insertunit.jl create mode 100644 test/enzyme-indexmanipulations-unit/removeunit.jl delete mode 100644 test/enzyme-indexmanipulations/braid.jl delete mode 100644 test/enzyme-indexmanipulations/flip.jl delete mode 100644 test/enzyme-indexmanipulations/insertunit.jl delete mode 100644 test/enzyme-indexmanipulations/removeunit.jl delete mode 100644 test/enzyme-indexmanipulations/twist.jl diff --git a/test/enzyme-indexmanipulations-flip-twist/flip.jl b/test/enzyme-indexmanipulations-flip-twist/flip.jl new file mode 100644 index 000000000..d410673e4 --- /dev/null +++ b/test/enzyme-indexmanipulations-flip-twist/flip.jl @@ -0,0 +1,24 @@ +using Test, TestExtras +using TensorKit +using Enzyme, EnzymeTestUtils +using Random + +spacelist = ad_spacelist(fast_tests) +eltypes = (Float64, ComplexF64) + +if !Sys.iswindows() && VERSION > v"1.11.0-rc" + @timedtestset "Enzyme - Index Manipulations (flip):" begin + @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T) TA ($TA)" for V in spacelist, T in eltypes, TA in (Duplicated,) + atol = default_tol(T) + rtol = default_tol(T) + has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding + if has_braiding + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + EnzymeTestUtils.test_reverse(flip, TA, (A, TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) + EnzymeTestUtils.test_reverse(flip, TA, (A, TA), [1, 3]; atol, rtol, fkwargs = (inv = true,)) + EnzymeTestUtils.test_reverse(flip, TA, (A, TA), (1, Const); atol, rtol) + EnzymeTestUtils.test_reverse(flip, TA, (A, TA), ([1, 3], Const); atol, rtol) + end + end + end +end diff --git a/test/enzyme-indexmanipulations-flip-twist/twist.jl b/test/enzyme-indexmanipulations-flip-twist/twist.jl new file mode 100644 index 000000000..6dedcdd5a --- /dev/null +++ b/test/enzyme-indexmanipulations-flip-twist/twist.jl @@ -0,0 +1,26 @@ +using Test, TestExtras +using TensorKit +using TensorOperations +using VectorInterface: Zero, One +using Enzyme, EnzymeTestUtils +using Random + +spacelist = ad_spacelist(fast_tests) +eltypes = (Float64, ComplexF64) + +if !Sys.iswindows() && VERSION > v"1.11.0-rc" + @timedtestset "Enzyme - Index Manipulations (twist):" begin + @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,) + atol = default_tol(T) + rtol = default_tol(T) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding + if has_braiding && !(T <: Real && !(sectorscalartype(sectortype(A)) <: Real)) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,)) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), (1, Const); atol, rtol) + EnzymeTestUtils.test_reverse(twist!, TA, (copy(A), TA), ([1, 3], Const); atol, rtol) + end + end + end +end diff --git a/test/enzyme-indexmanipulations-transform/braid.jl b/test/enzyme-indexmanipulations-transform/braid.jl new file mode 100644 index 000000000..0d4099d13 --- /dev/null +++ b/test/enzyme-indexmanipulations-transform/braid.jl @@ -0,0 +1,35 @@ +using Test, TestExtras +using TensorKit +using TensorOperations +using Enzyme, EnzymeTestUtils +using Random + +spacelist = ad_spacelist(fast_tests) +eltypes = (Float64, ComplexF64) + +is_ci = get(ENV, "CI", "false") == "true" +Tαs = is_ci ? (Active,) : (Active, Const) +Tβs = is_ci ? (Active,) : (Active, Const) + +if !Sys.iswindows() && VERSION > v"1.11.0-rc" + @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 + atol = default_tol(T) + rtol = default_tol(T) + Vstr = TensorKit.type_repr(sectortype(eltype(V))) + has_braiding = BraidingStyle(sectortype(eltype(V))) isa HasBraiding + if has_braiding + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + α = randn(T) + β = randn(T) + p = randcircshift(numout(A), numin(A)) + levels = Tuple(randperm(numind(A))) + C = randn!(transpose(A, p)) + 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β") + if !(T <: Real) && !is_ci + 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β") + 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β") + 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β") + end + end + end +end diff --git a/test/enzyme-indexmanipulations/permute.jl b/test/enzyme-indexmanipulations-transform/permute.jl similarity index 72% rename from test/enzyme-indexmanipulations/permute.jl rename to test/enzyme-indexmanipulations-transform/permute.jl index a7f6126d6..d78ec1e41 100644 --- a/test/enzyme-indexmanipulations/permute.jl +++ b/test/enzyme-indexmanipulations-transform/permute.jl @@ -11,14 +11,15 @@ is_ci = get(ENV, "CI", "false") == "true" Tαs = is_ci ? (Active,) : (Active, Const) Tβs = is_ci ? (Active,) : (Active, Const) -@timedtestset "Enzyme - Index Manipulations (permute!):" begin - @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes +if VERSION >= v"1.11.0-rc" # segfault issues on 1.10 + @timedtestset "Enzyme - Index Manipulations (permute!): $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes + println(TensorKit.type_repr(sectortype(eltype(V)))) atol = default_tol(T) rtol = default_tol(T) symmetricbraiding = BraidingStyle(sectortype(eltype(V))) isa SymmetricBraiding symmetricbraiding && @timedtestset "permute! Tα $Tα, Tβ $Tβ" for Tα in Tαs, Tβ in Tβs - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') α = randn(T) β = randn(T) p = randindextuple(numind(A)) diff --git a/test/enzyme-indexmanipulations/transpose.jl b/test/enzyme-indexmanipulations-transform/transpose.jl similarity index 54% rename from test/enzyme-indexmanipulations/transpose.jl rename to test/enzyme-indexmanipulations-transform/transpose.jl index bff2cb379..7ba3e2d42 100644 --- a/test/enzyme-indexmanipulations/transpose.jl +++ b/test/enzyme-indexmanipulations-transform/transpose.jl @@ -13,24 +13,24 @@ is_ci = get(ENV, "CI", "false") == "true" Tαs = is_ci ? (Active,) : (Active, Const) Tβs = is_ci ? (Active,) : (Active, Const) -@timedtestset "Enzyme - Index Manipulations (transpose!):" begin - @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes +if VERSION > v"1.11.0-rc" # https://github.com/QuantumKitHub/TensorKit.jl/issues/457 + @timedtestset "Enzyme - Index Manipulations (transpose!) $(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes atol = default_tol(T) rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') α = randn(T) β = randn(T) # repeat a couple times to get some distribution of arrows p = randcircshift(numout(A), numin(A)) C = randn!(transpose(A, p)) - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (One(), Const), (Zero(), Const); atol, rtol) + !is_ci && EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (One(), Const), (Zero(), Const); atol, rtol) @testset for Tα in Tαs, Tβ in Tβs - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) if !(T <: Real) && !is_ci - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (C, Duplicated), (real(A), Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (C, Duplicated), (A, Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) - EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (C, Duplicated), (real(A), Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (α, Tα), (β, Tβ); atol, rtol) + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (A, Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) + EnzymeTestUtils.test_reverse(TensorKit.transpose!, Duplicated, (copy(C), Duplicated), (real(A), Duplicated), (p, Const), (real(α), Tα), (β, Tβ); atol, rtol) end end end diff --git a/test/enzyme-indexmanipulations-unit/insertunit.jl b/test/enzyme-indexmanipulations-unit/insertunit.jl new file mode 100644 index 000000000..9513d5ee7 --- /dev/null +++ b/test/enzyme-indexmanipulations-unit/insertunit.jl @@ -0,0 +1,26 @@ +using Test, TestExtras +using TensorKit +using Enzyme, EnzymeTestUtils +using Random + +spacelist = ad_spacelist(fast_tests) +eltypes = (Float64, ComplexF64) + +if VERSION > v"1.11.0-rc" # https://github.com/QuantumKitHub/TensorKit.jl/issues/457 + @timedtestset verbose = true "Enzyme - Index Manipulations (insertunit):" begin + @timedtestset verbose = true "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,) + atol = default_tol(T) + rtol = default_tol(T) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + @testset for insertunit in (insertleftunit, insertrightunit) + EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(1), Const); atol, rtol) + EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(4), Const); atol, rtol) + EnzymeTestUtils.test_reverse(insertunit, TA, (A', TA), (Val(2), Const); atol, rtol) + EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(1), Const); atol, rtol, fkwargs = (copy = false,)) + EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(2), Const); atol, rtol, fkwargs = (copy = true,)) + EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(3), Const); atol, rtol, fkwargs = (copy = false, dual = true, conj = true)) + EnzymeTestUtils.test_reverse(insertunit, TA, (A', TA), (Val(3), Const); atol, rtol, fkwargs = (copy = false, dual = true, conj = true)) + end + end + end +end diff --git a/test/enzyme-indexmanipulations-unit/removeunit.jl b/test/enzyme-indexmanipulations-unit/removeunit.jl new file mode 100644 index 000000000..2cd632a90 --- /dev/null +++ b/test/enzyme-indexmanipulations-unit/removeunit.jl @@ -0,0 +1,22 @@ +using Test, TestExtras +using TensorKit +using Enzyme, EnzymeTestUtils +using Random + +spacelist = ad_spacelist(fast_tests) +eltypes = (Float64, ComplexF64) + +if VERSION > v"1.11.0-rc" # https://github.com/QuantumKitHub/TensorKit.jl/issues/457 + @timedtestset verbose = true "Enzyme - Index Manipulations (removeunit):" begin + @timedtestset verbose = true "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TB in (Duplicated,) + atol = default_tol(T) + rtol = default_tol(T) + A = randn(T, V[1] ⊗ V[2] ← (V[3] ⊗ V[4] ⊗ V[5])') + for i in 1:2 + B = insertleftunit(A, i; dual = rand(Bool)) + EnzymeTestUtils.test_reverse(removeunit, TB, (B, TB), (Val(i), Const); atol, rtol, fkwargs = (copy = false,)) + EnzymeTestUtils.test_reverse(removeunit, TB, (B, TB), (Val(i), Const); atol, rtol, fkwargs = (copy = true,)) + end + end + end +end diff --git a/test/enzyme-indexmanipulations/braid.jl b/test/enzyme-indexmanipulations/braid.jl deleted file mode 100644 index 28d1e52ba..000000000 --- a/test/enzyme-indexmanipulations/braid.jl +++ /dev/null @@ -1,32 +0,0 @@ -using Test, TestExtras -using TensorKit -using TensorOperations -using Enzyme, EnzymeTestUtils -using Random - -spacelist = ad_spacelist(fast_tests) -eltypes = (Float64, ComplexF64) - -is_ci = get(ENV, "CI", "false") == "true" -Tαs = is_ci ? (Active,) : (Active, Const) -Tβs = is_ci ? (Active,) : (Active, Const) - -@timedtestset "Enzyme - Index Manipulations (braid!):" begin - @timedtestset "$(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 - atol = default_tol(T) - rtol = default_tol(T) - Vstr = TensorKit.type_repr(sectortype(eltype(V))) - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) - α = randn(T) - β = randn(T) - p = randcircshift(numout(A), numin(A)) - levels = Tuple(randperm(numind(A))) - C = randn!(transpose(A, p)) - 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β") - if !(T <: Real) && !is_ci - 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β") - 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β") - 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β") - end - end -end diff --git a/test/enzyme-indexmanipulations/flip.jl b/test/enzyme-indexmanipulations/flip.jl deleted file mode 100644 index 8afe4e914..000000000 --- a/test/enzyme-indexmanipulations/flip.jl +++ /dev/null @@ -1,19 +0,0 @@ -using Test, TestExtras -using TensorKit -using Enzyme, EnzymeTestUtils -using Random - -spacelist = ad_spacelist(fast_tests) -eltypes = (Float64, ComplexF64) - -@timedtestset "Enzyme - Index Manipulations (flip):" begin - @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T) TA ($TA)" for V in spacelist, T in eltypes, TA in (Duplicated,) - atol = default_tol(T) - rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) - EnzymeTestUtils.test_reverse(flip, TA, (A, TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) - EnzymeTestUtils.test_reverse(flip, TA, (A, TA), [1, 3]; atol, rtol, fkwargs = (inv = true,)) - EnzymeTestUtils.test_reverse(flip, TA, (A, TA), (1, Const); atol, rtol) - EnzymeTestUtils.test_reverse(flip, TA, (A, TA), ([1, 3], Const); atol, rtol) - end -end diff --git a/test/enzyme-indexmanipulations/insertunit.jl b/test/enzyme-indexmanipulations/insertunit.jl deleted file mode 100644 index 15e02d22c..000000000 --- a/test/enzyme-indexmanipulations/insertunit.jl +++ /dev/null @@ -1,24 +0,0 @@ -using Test, TestExtras -using TensorKit -using Enzyme, EnzymeTestUtils -using Random - -spacelist = ad_spacelist(fast_tests) -eltypes = (Float64, ComplexF64) - -@timedtestset verbose = true "Enzyme - Index Manipulations (insertunit):" begin - @timedtestset verbose = true "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,) - atol = default_tol(T) - rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) - @testset for insertunit in (insertleftunit, insertrightunit) - EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(1), Const); atol, rtol) - EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(4), Const); atol, rtol) - EnzymeTestUtils.test_reverse(insertunit, TA, (A', TA), (Val(2), Const); atol, rtol) - EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(1), Const); atol, rtol, fkwargs = (copy = false,)) - EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(2), Const); atol, rtol, fkwargs = (copy = true,)) - EnzymeTestUtils.test_reverse(insertunit, TA, (A, TA), (Val(3), Const); atol, rtol, fkwargs = (copy = false, dual = true, conj = true)) - EnzymeTestUtils.test_reverse(insertunit, TA, (A', TA), (Val(3), Const); atol, rtol, fkwargs = (copy = false, dual = true, conj = true)) - end - end -end diff --git a/test/enzyme-indexmanipulations/removeunit.jl b/test/enzyme-indexmanipulations/removeunit.jl deleted file mode 100644 index 2249483be..000000000 --- a/test/enzyme-indexmanipulations/removeunit.jl +++ /dev/null @@ -1,20 +0,0 @@ -using Test, TestExtras -using TensorKit -using Enzyme, EnzymeTestUtils -using Random - -spacelist = ad_spacelist(fast_tests) -eltypes = (Float64, ComplexF64) - -@timedtestset verbose = true "Enzyme - Index Manipulations (removeunit):" begin - @timedtestset verbose = true "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TB in (Duplicated,) - atol = default_tol(T) - rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) - for i in 1:2 - B = insertleftunit(A, i; dual = rand(Bool)) - EnzymeTestUtils.test_reverse(removeunit, TB, (B, TB), (Val(i), Const); atol, rtol, fkwargs = (copy = false,)) - EnzymeTestUtils.test_reverse(removeunit, TB, (B, TB), (Val(i), Const); atol, rtol, fkwargs = (copy = true,)) - end - end -end diff --git a/test/enzyme-indexmanipulations/twist.jl b/test/enzyme-indexmanipulations/twist.jl deleted file mode 100644 index c939c76d2..000000000 --- a/test/enzyme-indexmanipulations/twist.jl +++ /dev/null @@ -1,23 +0,0 @@ -using Test, TestExtras -using TensorKit -using TensorOperations -using VectorInterface: Zero, One -using Enzyme, EnzymeTestUtils -using Random - -spacelist = ad_spacelist(fast_tests) -eltypes = (Float64, ComplexF64) - -@timedtestset "Enzyme - Index Manipulations (twist):" begin - @timedtestset "$(TensorKit.type_repr(sectortype(eltype(V)))) ($T)" for V in spacelist, T in eltypes, TA in (Duplicated,) - atol = default_tol(T) - rtol = default_tol(T) - A = randn(T, V[1] ⊗ V[2] ← V[4] ⊗ V[5]) - if !(T <: Real && !(sectorscalartype(sectortype(A)) <: Real)) - EnzymeTestUtils.test_reverse(twist!, TA, (A, TA), (1, Const); atol, rtol, fkwargs = (inv = false,)) - EnzymeTestUtils.test_reverse(twist!, TA, (A, TA), ([1, 3], Const); atol, rtol, fkwargs = (inv = true,)) - EnzymeTestUtils.test_reverse(twist!, TA, (A, TA), (1, Const); atol, rtol) - EnzymeTestUtils.test_reverse(twist!, TA, (A, TA), ([1, 3], Const); atol, rtol) - end - end -end