diff --git a/test/amd/tensors.jl b/test/amd/tensors.jl index 2ac522daa..68f130e6c 100644 --- a/test/amd/tensors.jl +++ b/test/amd/tensors.jl @@ -1,6 +1,6 @@ using Adapt, AMDGPU using Test, TestExtras -using TensorKit, TensorKitSectors, Combinatorics +using TensorKit, Combinatorics ad = adapt(Array) const AMDGPUExt = Base.get_extension(TensorKit, :TensorKitAMDGPUExt) @assert !isnothing(AMDGPUExt) @@ -97,7 +97,7 @@ for V in spacelist for T in (Int, Float32, ComplexF64) t = @constinferred AMDGPU.rand(T, W) d = convert(Dict, t) - @test adapt(Array, t) == convert(TensorMap, d) + @test convert(Dict, adapt(Array, t)) == d end end symmetricbraiding && @timedtestset "Basic linear algebra" begin @@ -221,14 +221,14 @@ for V in spacelist end end end - @timedtestset "Tensor conversion" begin # TODO adjoint conversion methods don't work yet + @timedtestset "Tensor conversion" begin W = V1 ⊗ V2 t = @constinferred AMDGPU.randn(W ← W) - #@test typeof(convert(TensorMap, t')) == typeof(t) # TODO Adjoint not supported yet + @test typeof(convert(TensorMap, t')) == typeof(t) tc = complex(t) @test convert(typeof(tc), t) == tc @test typeof(convert(typeof(tc), t)) == typeof(tc) - # @test typeof(convert(typeof(tc), t')) == typeof(tc) # TODO Adjoint not supported yet + @test typeof(convert(typeof(tc), t')) == typeof(tc) @test Base.promote_typeof(t, tc) == typeof(tc) @test Base.promote_typeof(tc, t) == typeof(tc + t) end @@ -241,33 +241,7 @@ for V in spacelist @test LinearAlgebra.isdiag(D) @test LinearAlgebra.diag(D) == d end=# - symmetricbraiding && @timedtestset "Permutations: test via inner product invariance" begin - W = V1 ⊗ V2 ⊗ V3 ⊗ V4 ⊗ V5 - t = AMDGPU.rand(ComplexF64, W) - t′ = AMDGPU.randn!(similar(t)) - for k in 0:5 - for p in permutations(1:5) - p1 = ntuple(n -> p[n], k) - p2 = ntuple(n -> p[k + n], 5 - k) - AMDGPU.@allowscalar begin - t2 = @constinferred permute(t, (p1, p2)) - t2 = permute(t, (p1, p2)) - @test norm(t2) ≈ norm(t) - t2′ = permute(t′, (p1, p2)) - @test dot(t2′, t2) ≈ dot(t′, t) ≈ dot(transpose(t2′), transpose(t2)) - end - end - - AMDGPU.@allowscalar begin - t3 = @constinferred repartition(t, $k) - @test norm(t3) ≈ norm(t) - t3′ = @constinferred repartition!(similar(t3), t′) - @test norm(t3′) ≈ norm(t′) - @test dot(t′, t) ≈ dot(t3′, t3) - end - end - end - symmetricbraiding && @timedtestset "Permutations: test via CPU" begin + #=symmetricbraiding && @timedtestset "Permutations: test via CPU" begin W = V1 ⊗ V2 ⊗ V3 ⊗ V4 ⊗ V5 t = AMDGPU.rand(ComplexF64, W) for k in 0:5 @@ -276,12 +250,12 @@ for V in spacelist p2 = ntuple(n -> p[k + n], 5 - k) dt2 = AMDGPU.@allowscalar permute(t, (p1, p2)) ht2 = permute(adapt(Array, t), (p1, p2)) - @test ht2 == adapt(Array, dt2) + @test ht2 ≈ adapt(Array, dt2) end dt3 = AMDGPU.@allowscalar repartition(t, k) ht3 = repartition(adapt(Array, t), k) - @test ht3 == adapt(Array, dt3) + @test ht3 ≈ adapt(Array, dt3) end end symmetricbraiding && @timedtestset "Full trace: test self-consistency" begin @@ -303,7 +277,7 @@ for V in spacelist end @test ss ≈ s2 @test ss ≈ s3 - end + end=# # TODO read only memory errors #=symmetricbraiding && @timedtestset "Partial trace: test self-consistency" begin t = AMDGPU.rand(ComplexF64, V1 ⊗ V2' ⊗ V3 ⊗ V2 ⊗ V1' ⊗ V3') @tensor t2[a, b] := t[c, d, b, d, c, a] @@ -397,7 +371,7 @@ for V in spacelist end @timedtestset "Multiplication and inverse: test compatibility" begin W1 = V1 ⊗ V2 ⊗ V3 - W2 = V4 ⊗ V5 + W2 = (V4 ⊗ V5)' for T in (Float64, ComplexF64) t1 = AMDGPU.rand(T, W1, W1) t2 = AMDGPU.rand(T, W2, W2)