|
1 | 1 | @test Flux.AMDGPU_LOADED[]
|
2 | 2 |
|
3 |
| -@testset "Basic GPU movement" begin |
4 |
| - @test Flux.amd(rand(Float64, 16)) isa ROCArray{Float32, 1} |
5 |
| - @test Flux.amd(rand(Float64, 16, 16)) isa ROCArray{Float32, 2} |
6 |
| - @test Flux.amd(rand(Float32, 16, 16)) isa ROCArray{Float32, 2} |
7 |
| - @test Flux.amd(rand(Float16, 16, 16, 16)) isa ROCArray{Float16, 3} |
| 3 | +# @testset "Basic GPU movement" begin |
| 4 | +# @test Flux.amd(rand(Float64, 16)) isa ROCArray{Float32, 1} |
| 5 | +# @test Flux.amd(rand(Float64, 16, 16)) isa ROCArray{Float32, 2} |
| 6 | +# @test Flux.amd(rand(Float32, 16, 16)) isa ROCArray{Float32, 2} |
| 7 | +# @test Flux.amd(rand(Float16, 16, 16, 16)) isa ROCArray{Float16, 3} |
8 | 8 |
|
9 |
| - @test gradient(x -> sum(Flux.amd(x)), rand(Float32, 4, 4)) isa Tuple |
10 |
| - @test gradient(x -> sum(cpu(x)), AMDGPU.rand(Float32, 4, 4)) isa Tuple |
11 |
| -end |
| 9 | +# @test gradient(x -> sum(Flux.amd(x)), rand(Float32, 4, 4)) isa Tuple |
| 10 | +# @test gradient(x -> sum(cpu(x)), AMDGPU.rand(Float32, 4, 4)) isa Tuple |
| 11 | +# end |
12 | 12 |
|
13 |
| -@testset "Dense no bias" begin |
14 |
| - m = Dense(3 => 4; bias=false) |> Flux.amd |
15 |
| - x = zeros(Float32, 3, 4) |> Flux.amd |
16 |
| - @test sum(m(x)) ≈ 0f0 |
17 |
| - gs = gradient(m -> sum(m(x)), m) |
18 |
| - @test isnothing(gs[1].bias) |
19 |
| -end |
| 13 | +# @testset "Dense no bias" begin |
| 14 | +# m = Dense(3 => 4; bias=false) |> Flux.amd |
| 15 | +# x = zeros(Float32, 3, 4) |> Flux.amd |
| 16 | +# @test sum(m(x)) ≈ 0f0 |
| 17 | +# gs = gradient(m -> sum(m(x)), m) |
| 18 | +# @test isnothing(gs[1].bias) |
| 19 | +# end |
20 | 20 |
|
21 |
| -@testset "Chain of Dense layers" begin |
22 |
| - m = Chain(Dense(10, 5, tanh), Dense(5, 2), softmax) |> f32 |
23 |
| - x = rand(Float32, 10, 10) |
24 |
| - amdgputest(m, x) |
25 |
| -end |
| 21 | +# @testset "Chain of Dense layers" begin |
| 22 | +# m = Chain(Dense(10, 5, tanh), Dense(5, 2), softmax) |> f32 |
| 23 | +# x = rand(Float32, 10, 10) |
| 24 | +# amdgputest(m, x) |
| 25 | +# end |
26 | 26 |
|
27 |
| -@testset "Cross-correlation" begin |
28 |
| - m = CrossCor((2, 2), 3 => 4) |> f32 |
29 |
| - x = rand(Float32, 10, 10, 3, 2) |
30 |
| - amdgputest(m, x; atol=1f-3) |
| 27 | +@testset "Convolution" begin |
| 28 | + m = Conv((2, 2), 1 => 1) |> f32 |
| 29 | + x = rand(Float32, 4, 4, 1, 1) |
| 30 | + amdgputest(m, x; atol=1f-3, checkgrad=false) |
| 31 | + |
| 32 | + # Gradients are flipped as well. |
| 33 | + md, xd = Flux.amd.((m, x)) |
| 34 | + gs = gradient(m -> sum(m(x)), m) |
| 35 | + gsd = gradient(m -> sum(m(xd)), md) |
| 36 | + @test gs[1].weight[end:-1:1, end:-1:1, :, :] ≈ Array(gsd[1].weight) atol=1f-3 |
31 | 37 | end
|
32 | 38 |
|
33 |
| -@testset "Restructure" begin |
34 |
| - m = Dense(1, 1) |> Flux.amd |
35 |
| - θ, m̂ = Flux.destructure(m) |
36 |
| - foo(x) = sum(re(p)(x)) |
| 39 | +# @testset "Cross-correlation" begin |
| 40 | +# m = CrossCor((2, 2), 3 => 4) |> f32 |
| 41 | +# x = rand(Float32, 10, 10, 3, 2) |
| 42 | +# amdgputest(m, x; atol=1f-3) |
| 43 | +# end |
37 | 44 |
|
38 |
| - x = Flux.amd(rand(Float32, 1)) |
39 |
| - @test gradient(x -> sum(m̂(θ)(x)), x)[1] isa ROCArray{Float32} |
40 |
| -end |
| 45 | +# @testset "Restructure" begin |
| 46 | +# m = Dense(1, 1) |> Flux.amd |
| 47 | +# θ, m̂ = Flux.destructure(m) |
| 48 | +# foo(x) = sum(re(p)(x)) |
41 | 49 |
|
42 |
| -@testset "Flux.amd(x) on structured arrays" begin |
43 |
| - g1 = Zygote.OneElement(1, (2, 3), axes(ones(4, 5))) |
44 |
| - @test Flux.amd(g1) isa ROCMatrix{Int64} |
45 |
| - g2 = Zygote.Fill(1f0, 2) |
46 |
| - @test Flux.amd(g2) isa ROCArray{Float32, 1} |
47 |
| - g3 = transpose(Float32[1 2; 3 4]) |
48 |
| - @test parent(Flux.amd(g3)) isa ROCMatrix{Float32} |
49 |
| -end |
| 50 | +# x = Flux.amd(rand(Float32, 1)) |
| 51 | +# @test gradient(x -> sum(m̂(θ)(x)), x)[1] isa ROCArray{Float32} |
| 52 | +# end |
50 | 53 |
|
51 |
| -@testset "Flux.onecold gpu" begin |
52 |
| - y = Flux.onehotbatch(ones(3), 1:10) |> Flux.amd |
53 |
| - l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] |
54 |
| - @test Flux.onecold(y) isa ROCArray |
55 |
| - @test y[3, :] isa ROCArray |
56 |
| - @test Flux.onecold(y, l) == ['a', 'a', 'a'] |
57 |
| -end |
| 54 | +# @testset "Flux.amd(x) on structured arrays" begin |
| 55 | +# g1 = Zygote.OneElement(1, (2, 3), axes(ones(4, 5))) |
| 56 | +# @test Flux.amd(g1) isa ROCMatrix{Int64} |
| 57 | +# g2 = Zygote.Fill(1f0, 2) |
| 58 | +# @test Flux.amd(g2) isa ROCArray{Float32, 1} |
| 59 | +# g3 = transpose(Float32[1 2; 3 4]) |
| 60 | +# @test parent(Flux.amd(g3)) isa ROCMatrix{Float32} |
| 61 | +# end |
| 62 | + |
| 63 | +# @testset "Flux.onecold gpu" begin |
| 64 | +# y = Flux.onehotbatch(ones(3), 1:10) |> Flux.amd |
| 65 | +# l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] |
| 66 | +# @test Flux.onecold(y) isa ROCArray |
| 67 | +# @test y[3, :] isa ROCArray |
| 68 | +# @test Flux.onecold(y, l) == ['a', 'a', 'a'] |
| 69 | +# end |
58 | 70 |
|
59 | 71 | # FIXME scalar indexing. Needs NNlib.scatter?
|
60 | 72 | # @testset "Flux.onehot gpu" begin
|
|
0 commit comments