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
4 changes: 4 additions & 0 deletions ext/TensorKitCUDAExt/cutensormap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ function Base.promote_rule(
return CuTensorMap{T, S, N₁, N₂}
end

TensorKit.promote_storage_rule(::Type{CuArray{T, N}}, ::Type{<:CuArray{T, N}}) where {T, N} =
CuArray{T, N, CUDA.default_memory}


# CuTensorMap exponentation:
function TensorKit.exp!(t::CuTensorMap)
domain(t) == codomain(t) ||
Expand Down
8 changes: 8 additions & 0 deletions test/cuda/tensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,14 @@ for V in spacelist
@test domain(t) == one(W)
@test typeof(t) == TensorMap{Float64, spacetype(t), 5, 0, CuVector{Float64, CUDA.DeviceMemory}}
end
for f in (Base.ones, Base.zeros)
t = @constinferred f(CuVector{Float64, CUDA.DeviceMemory}, W)
@test scalartype(t) == Float64
@test codomain(t) == W
@test space(t) == (W ← one(W))
@test domain(t) == one(W)
@test typeof(t) == TensorMap{Float64, spacetype(t), 5, 0, CuVector{Float64, CUDA.DeviceMemory}}
end
for f in (rand, randn)
t = @constinferred f(CuVector{Float64, CUDA.DeviceMemory}, W)
@test scalartype(t) == Float64
Expand Down
9 changes: 9 additions & 0 deletions test/tensors/tensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,15 @@ for V in spacelist
@test space(t) == (W ← one(W))
@test domain(t) == one(W)
@test typeof(t) == TensorMap{T, spacetype(t), 5, 0, Vector{T}}
# Array type input
t = @constinferred zeros(Vector{T}, W)
@test @constinferred(hash(t)) == hash(deepcopy(t))
@test scalartype(t) == T
@test norm(t) == 0
@test codomain(t) == W
@test space(t) == (W ← one(W))
@test domain(t) == one(W)
@test typeof(t) == TensorMap{T, spacetype(t), 5, 0, Vector{T}}
# blocks
bs = @constinferred blocks(t)
if !isempty(blocksectors(t)) # multifusion space ending on module gives empty data
Expand Down