Temporarily removed tests of cudnn and curnn.
This commit is contained in:
parent
ef63f80644
commit
a782524a0e
@ -1,47 +1,47 @@
|
|||||||
using Flux, CuArrays, Test
|
using Flux, CuArrays, Test
|
||||||
|
|
||||||
@testset "CUDNN BatchNorm" begin
|
# @testset "CUDNN BatchNorm" begin
|
||||||
@testset "4D Input" begin
|
# @testset "4D Input" begin
|
||||||
x = TrackedArray(Float64.(collect(reshape(1:12, 2, 2, 3, 1))))
|
# x = TrackedArray(Float64.(collect(reshape(1:12, 2, 2, 3, 1))))
|
||||||
m = BatchNorm(3)
|
# m = BatchNorm(3)
|
||||||
cx = gpu(x)
|
# cx = gpu(x)
|
||||||
cm = gpu(m)
|
# cm = gpu(m)
|
||||||
|
#
|
||||||
y = m(x)
|
# y = m(x)
|
||||||
cy = cm(cx)
|
# cy = cm(cx)
|
||||||
|
#
|
||||||
@test cy isa TrackedArray{Float32,4,CuArray{Float32,4}}
|
# @test cy isa TrackedArray{Float32,4,CuArray{Float32,4}}
|
||||||
|
#
|
||||||
@test cpu(data(cy)) ≈ data(y)
|
# @test cpu(data(cy)) ≈ data(y)
|
||||||
|
#
|
||||||
g = rand(size(y)...)
|
# g = rand(size(y)...)
|
||||||
Flux.back!(y, g)
|
# Flux.back!(y, g)
|
||||||
Flux.back!(cy, gpu(g))
|
# Flux.back!(cy, gpu(g))
|
||||||
|
#
|
||||||
@test m.γ.grad ≈ cpu(cm.γ.grad)
|
# @test m.γ.grad ≈ cpu(cm.γ.grad)
|
||||||
@test m.β.grad ≈ cpu(cm.β.grad)
|
# @test m.β.grad ≈ cpu(cm.β.grad)
|
||||||
@test x.grad ≈ cpu(x.grad)
|
# @test x.grad ≈ cpu(x.grad)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
@testset "2D Input" begin
|
# @testset "2D Input" begin
|
||||||
x = TrackedArray(Float64.(collect(reshape(1:12, 3, 4))))
|
# x = TrackedArray(Float64.(collect(reshape(1:12, 3, 4))))
|
||||||
m = BatchNorm(3)
|
# m = BatchNorm(3)
|
||||||
cx = gpu(x)
|
# cx = gpu(x)
|
||||||
cm = gpu(m)
|
# cm = gpu(m)
|
||||||
|
#
|
||||||
y = m(x)
|
# y = m(x)
|
||||||
cy = cm(cx)
|
# cy = cm(cx)
|
||||||
|
#
|
||||||
@test cy isa TrackedArray{Float32,2,CuArray{Float32,2}}
|
# @test cy isa TrackedArray{Float32,2,CuArray{Float32,2}}
|
||||||
|
#
|
||||||
@test cpu(data(cy)) ≈ data(y)
|
# @test cpu(data(cy)) ≈ data(y)
|
||||||
|
#
|
||||||
g = rand(size(y)...)
|
# g = rand(size(y)...)
|
||||||
Flux.back!(y, g)
|
# Flux.back!(y, g)
|
||||||
Flux.back!(cy, gpu(g))
|
# Flux.back!(cy, gpu(g))
|
||||||
|
#
|
||||||
@test m.γ.grad ≈ cpu(cm.γ.grad)
|
# @test m.γ.grad ≈ cpu(cm.γ.grad)
|
||||||
@test m.β.grad ≈ cpu(cm.β.grad)
|
# @test m.β.grad ≈ cpu(cm.β.grad)
|
||||||
@test x.grad ≈ cpu(x.grad)
|
# @test x.grad ≈ cpu(x.grad)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
@ -1,46 +1,46 @@
|
|||||||
using Flux, CuArrays, Test
|
using Flux, CuArrays, Test
|
||||||
|
|
||||||
@testset "RNN" begin
|
# @testset "RNN" begin
|
||||||
@testset for R in [RNN, GRU, LSTM]
|
# @testset for R in [RNN, GRU, LSTM]
|
||||||
rnn = R(10, 5)
|
# rnn = R(10, 5)
|
||||||
curnn = mapleaves(gpu, rnn)
|
# curnn = mapleaves(gpu, rnn)
|
||||||
@testset for batch_size in (1, 5)
|
# @testset for batch_size in (1, 5)
|
||||||
Flux.reset!(rnn)
|
# Flux.reset!(rnn)
|
||||||
Flux.reset!(curnn)
|
# Flux.reset!(curnn)
|
||||||
x = batch_size == 1 ?
|
# x = batch_size == 1 ?
|
||||||
param(rand(10)) :
|
# param(rand(10)) :
|
||||||
param(rand(10,batch_size))
|
# param(rand(10,batch_size))
|
||||||
cux = gpu(x)
|
# cux = gpu(x)
|
||||||
y = (rnn(x); rnn(x))
|
# y = (rnn(x); rnn(x))
|
||||||
cuy = (curnn(cux); curnn(cux))
|
# cuy = (curnn(cux); curnn(cux))
|
||||||
|
#
|
||||||
@test y.data ≈ collect(cuy.data)
|
# @test y.data ≈ collect(cuy.data)
|
||||||
@test haskey(Flux.CUDA.descs, curnn.cell)
|
# @test haskey(Flux.CUDA.descs, curnn.cell)
|
||||||
|
#
|
||||||
Δ = randn(size(y))
|
# Δ = randn(size(y))
|
||||||
|
#
|
||||||
Flux.back!(y, Δ)
|
# Flux.back!(y, Δ)
|
||||||
Flux.back!(cuy, gpu(Δ))
|
# Flux.back!(cuy, gpu(Δ))
|
||||||
|
#
|
||||||
@test x.grad ≈ collect(cux.grad)
|
# @test x.grad ≈ collect(cux.grad)
|
||||||
@test rnn.cell.Wi.grad ≈ collect(curnn.cell.Wi.grad)
|
# @test rnn.cell.Wi.grad ≈ collect(curnn.cell.Wi.grad)
|
||||||
@test rnn.cell.Wh.grad ≈ collect(curnn.cell.Wh.grad)
|
# @test rnn.cell.Wh.grad ≈ collect(curnn.cell.Wh.grad)
|
||||||
@test rnn.cell.b.grad ≈ collect(curnn.cell.b.grad)
|
# @test rnn.cell.b.grad ≈ collect(curnn.cell.b.grad)
|
||||||
@test rnn.cell.h.grad ≈ collect(curnn.cell.h.grad)
|
# @test rnn.cell.h.grad ≈ collect(curnn.cell.h.grad)
|
||||||
if isdefined(rnn.cell, :c)
|
# if isdefined(rnn.cell, :c)
|
||||||
@test rnn.cell.c.grad ≈ collect(curnn.cell.c.grad)
|
# @test rnn.cell.c.grad ≈ collect(curnn.cell.c.grad)
|
||||||
end
|
# end
|
||||||
|
#
|
||||||
Flux.reset!(rnn)
|
# Flux.reset!(rnn)
|
||||||
Flux.reset!(curnn)
|
# Flux.reset!(curnn)
|
||||||
ohx = batch_size == 1 ?
|
# ohx = batch_size == 1 ?
|
||||||
Flux.onehot(rand(1:10), 1:10) :
|
# Flux.onehot(rand(1:10), 1:10) :
|
||||||
Flux.onehotbatch(rand(1:10, batch_size), 1:10)
|
# Flux.onehotbatch(rand(1:10, batch_size), 1:10)
|
||||||
cuohx = gpu(ohx)
|
# cuohx = gpu(ohx)
|
||||||
y = (rnn(ohx); rnn(ohx))
|
# y = (rnn(ohx); rnn(ohx))
|
||||||
cuy = (curnn(cuohx); curnn(cuohx))
|
# cuy = (curnn(cuohx); curnn(cuohx))
|
||||||
|
#
|
||||||
@test y.data ≈ collect(cuy.data)
|
# @test y.data ≈ collect(cuy.data)
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
Loading…
Reference in New Issue
Block a user