Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/tensors/adjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion src/tensors/tensor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
7 changes: 4 additions & 3 deletions test/cuda/tensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down