Skip to content

Commit bc4ec1a

Browse files
committed
add Adapt tests
1 parent 1cbc7ed commit bc4ec1a

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

test/cuda/tensors.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ for V in spacelist
115115
@test domain(t2) == one(W)
116116
end
117117
end
118+
@timedtestset "Adapt" begin
119+
W = V1 V2 V3 V4 V5
120+
t = rand(Float64, W)
121+
t_gpu = @constinferred adapt(CuArray, t)
122+
@test storagetype(t_gpu) <: CuArray
123+
@test scalartype(t_gpu) === scalartype(t)
124+
@test collect(t_gpu.data) == t.data
125+
126+
t_cpu = @constinferred adapt(Array, t_cpu)
127+
@test t_cpu == t
128+
@test storagetype(t_cpu) isa Array
129+
end
118130
@timedtestset "Tensor Dict conversion" begin
119131
W = V1 V2 V3 V4 V5
120132
for T in (Int, Float32, ComplexF64)

0 commit comments

Comments
 (0)