Flux.jl/test/cuarrays.jl
2018-01-24 13:12:26 +00:00

24 lines
520 B
Julia
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Flux, Flux.Tracker, CuArrays, Base.Test
info("Testing Flux/GPU")
@testset "CuArrays" begin
CuArrays.allowscalar(false)
x = param(randn(5, 5))
cx = cu(x)
@test cx isa TrackedArray && cx.data isa CuArray
x = Flux.onehotbatch([1, 2, 3], 1:3)
cx = cu(x)
@test cx isa Flux.OneHotMatrix && cx.data isa CuArray
m = Chain(Dense(10, 5, σ), Dense(5, 2))
cm = cu(m)
@test all(p isa TrackedArray && p.data isa CuArray for p in params(cm))
@test cm(cu(rand(10, 10))) isa TrackedArray{Float32,2,CuArray{Float32,2}}
end