Merge pull request #428 from tejank10/rnn-fixes

[WIP] Fixes for RNN tests
This commit is contained in:
Mike J Innes 2018-10-10 16:58:44 +01:00 committed by GitHub
commit ab0763fd41
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 3 deletions

View File

@ -46,10 +46,10 @@ const RNN_ALGO_PERSIST_DYNAMIC = 2
# LSTM: [weight, bias] × [input, hidden] × [input, forget, newmem, output]
function params(w::CuVector, input, hidden, n = 1)
slice(offset, shape) = reshape(w[offset.+(1:prod(shape))], shape)
slice(offset, shape) = reshape(view(w, offset.+(1:prod(shape))), shape)
wx = slice(0, (input, hidden*n))
wh = slice(length(wx), (hidden, hidden*n))
bias = w[length(wx)+length(wh) .+ (1:hidden*n)]
bias = view(w, length(wx)+length(wh) .+ (1:hidden*n))
(wx, wh), bias
end
@ -91,7 +91,7 @@ function RNNDesc{T}(mode::Int, input::Int, hidden::Int; layers = 1) where T
rd = RNNDesc{T}(mode, input, hidden, w, params(w, input, hidden, ngates(mode))..., d[])
finalizer(rd) do x
@check ccall((:cudnnDestroyRNNDescriptor,libcudnn),cudnnStatus_t,(Ptr{Nothing},),x)
end
end
return rd
end