torch / cunn

Other
215 stars 174 forks source link

How to implement own c/cuda module in cunn and nn? #485

Open mbcel opened 7 years ago

mbcel commented 7 years ago

I implemented my own module for the nn/cunn package. Therefore I wrote the MyModule_updateOutput() and MyModule_updateGradInput() functions in the .c and .cu files and I call them from MyModule.lua file.

That all works so far but I have problems or don't know in what files I have to include/register this module. Because I get the error

not found: THNN_CudaMyModule_updateGradInput/home/marcel/torch/install/share/lua/5.1/nn/THNN.lua:108: /home/marcel/torch/install/lib/lua/5.1/libTHCUNN.so: undefined symbol: THNN_CudaMyModule_updateGradInput
not found: THNN_CudaMyModule_updateOutput/home/marcel/torch/install/share/lua/5.1/nn/THNN.lua:108: /home/marcel/torch/install/lib/lua/5.1/libTHCUNN.so: undefined symbol: THNN_CudaMyModule_updateOutput
...
.../install/share/lua/5.1/nn/MyModule.lua:24: attempt to index field 'THNN' (a nil value)

which points to the line that the MyModule_updateOutput() .cu cennot be called in the .lua file because input.THNN is nil.

I registered/included the module here:

then I build nn first and cunn second.

am I missing something?