Element-Research / rnn

Recurrent Neural Network library for Torch7's nn
BSD 3-Clause "New" or "Revised" License
941 stars 313 forks source link

Maskzero breaks with cuda #313

Closed RicherMans closed 8 years ago

RicherMans commented 8 years ago

Hey there, I recently updated my torch and rnn( including dpnn, torchx ) and after updating the maskzero layer does not seem to work. The following code demonstrates the problem:

require 'rnn'
require 'nn'

cuda = arg[1]

mdl = nn.Sequential()

mdl:add(nn.MaskZero(nn.Linear(10,20),1))
mdl:add(nn.ReLU())
mdl:add(nn.LogSoftMax())
inp = torch.rand(10,10)
if cuda == "cuda" then
    require 'cunn'
    mdl = mdl:cuda()
    inp = inp:cuda()
end
print(mdl:forward(inp))

When I run this script on the cpu, it works without any problem, but if I use it on the GPU, it crashes with:

MaskZero.lua:49: invalid arguments: CudaTensor CudaTensor number 
expected arguments: *CudaTensor* CudaByteTensor float
nicholas-leonard commented 8 years ago

@RicherMans Good catch. Apparently, this cutorch commit https://github.com/torch/cutorch/commit/20001aca5b7e49c414011938a2d79637924f2888 breaks backwards compatibility. I am looking into it.

nicholas-leonard commented 8 years ago

fixed by #319