diff --git a/src/tensors/adjoint.jl b/src/tensors/adjoint.jl index ca484e77b..dfc1a4471 100644 --- a/src/tensors/adjoint.jl +++ b/src/tensors/adjoint.jl @@ -50,6 +50,8 @@ Base.@propagate_inbounds function subblock(t::AdjointTensorMap, (f₁, f₂)::Tu return permutedims(conj(data), (domainind(tp)..., codomainind(tp)...)) end +to_cpu(t::AdjointTensorMap) = adjoint(to_cpu(adjoint(t))) + # Show #------ function Base.showarg(io::IO, t::AdjointTensorMap, toplevel::Bool) diff --git a/src/tensors/tensor.jl b/src/tensors/tensor.jl index 300654632..526f4e489 100644 --- a/src/tensors/tensor.jl +++ b/src/tensors/tensor.jl @@ -532,7 +532,8 @@ end #--------------------------- Base.convert(::Type{TensorMap}, t::TensorMap) = t function Base.convert(::Type{TensorMap}, t::AbstractTensorMap) - return copy!(TensorMap{scalartype(t)}(undef, space(t)), t) + A = storagetype(t) + return copy!(TensorMapWithStorage{scalartype(A), A}(undef, space(t)), t) end function Base.convert(::Type{TensorMapWithStorage{T, A}}, t::TensorMap) where {T, A} diff --git a/test/cuda/tensors.jl b/test/cuda/tensors.jl index e495eef08..a31015a4a 100644 --- a/test/cuda/tensors.jl +++ b/test/cuda/tensors.jl @@ -258,14 +258,15 @@ 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 CUDA.randn(W ← W) - #@test typeof(convert(TensorMap, t')) == typeof(t) # TODO Adjoint not supported yet + @test typeof(convert(typeof(t), t')) == typeof(t) + @test typeof(TensorKit.to_cpu(t')) == typeof(TensorKit.to_cpu(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