|
| 1 | +using Test |
| 2 | +using Strided |
| 3 | +using CUDA: CuMatrix |
| 4 | +using CUDA.Adapt: adapt |
| 5 | + |
1 | 6 | for T in (Float32, Float64, Complex{Float32}, Complex{Float64}) |
2 | 7 | @testset "Copy with CuStridedView: $T, $f1, $f2" for f2 in (identity, conj, adjoint, transpose), f1 in (identity, conj, transpose, adjoint) |
3 | 8 | for m1 in (0, 16, 32), m2 in (0, 16, 32) |
4 | | - A1 = CUDA.randn(T, (m1, m2)) |
5 | | - A2 = similar(A1) |
6 | | - zA1 = CuMatrix(f1(zeros(T, (m1, m2)))) |
7 | | - zA2 = CuMatrix(f2(zeros(T, (m1, m2)))) |
8 | | - A1c = copy(A1) |
9 | | - A2c = copy(A2) |
10 | | - B1 = f1(StridedView(A1c)) |
11 | | - B2 = f2(StridedView(A2c)) |
| 9 | + A1 = randn(T, (m1, m2)) |
| 10 | + A2 = randn(T, (m1, m2)) |
12 | 11 | axes(f1(A1)) == axes(f2(A2)) || continue |
13 | | - @test collect(CuMatrix(copy!(f2(A2), f1(A1)))) == CUDA.Adapt.adapt(Vector{T}, copy!(B2, B1)) |
14 | | - @test copy!(zA1, f1(A1)) == copy!(zA2, B1) |
15 | | - A3 = CuArray(randn(T, (m1, m2))) |
16 | | - A3c = copy(A3) |
17 | | - B3 = f1(StridedView(A3c)) |
18 | | - @. B1 = 2 * B1 - B3 / 3 # test copyto! of Broadcasted |
19 | | - @. A1 = 2 * A1 - A3 / 3 # test copyto! of Broadcasted |
20 | | - @test CUDA.Adapt.adapt(Vector{T}, f1(A1)) == CUDA.Adapt.adapt(Vector{T}, B1) |
21 | | - x = rand(T) |
22 | | - @test f1(StridedView(CUDA.Adapt.adapt(Vector{T}, fill!(A1c, x)))) == CUDA.Adapt.adapt(Vector{T}, fill!(B1, x)) |
| 12 | + |
| 13 | + cuA1 = CuMatrix(A1) |
| 14 | + cuA2 = CuMatrix(A2) |
| 15 | + |
| 16 | + B1 = f1(StridedView(A1)) |
| 17 | + B2 = f2(StridedView(A2)) |
| 18 | + cuB1 = f1(StridedView(cuA1)) |
| 19 | + cuB2 = f2(StridedView(cuA2)) |
| 20 | + |
| 21 | + @test copy!(B1, B2) == adapt(Vector{T}, copy!(cuB1, cuB2)) |
23 | 22 | end |
24 | 23 | end |
25 | 24 | end |
0 commit comments