introducing new modules to torch

424 views
Skip to first unread message

David Belanger

unread,
Mar 27, 2015, 3:59:33 PM3/27/15
to tor...@googlegroups.com
I've implemented a new torch nn criterion. I've done all the necessary steps for integrating this into torch (writing a .c file in nn/generic, adding lines to nn/init.c and nn/init.lua, etc.). However, I'm having issues building torch using my new stuff. 

Here's what I did:

1) fork torch/nn on github
2) remove my local torch/nn directory, which is a clone of mainline github torch/nn
3) git clone my personal nn fork so that the torch/nn path now contains my clone.
4) add my new code to this clone. 
5) cd .. and run install.sh

It's not working, however, because the build uses "git submodule update" to switch to the  remotes/origin/getParamsByDevice branch of nn (which doesn't exist in my fork). 

I'm sure other people have had a similar issue, where they've developed new modules that include c code in generic/ and want to use it locally (e.g. for testing) before making a torch pull request. How shouId I do it?

Thanks,
David

David Belanger

unread,
Mar 30, 2015, 3:23:35 PM3/30/15
to tor...@googlegroups.com
Ok. I figured it out. All you need to do is not use the install.sh script for torch and all of its subprojects, but just build the relevant package (in my case, nn) specifically. From the extra/nn directory, I run

luarocks make rocks/nn-scm-1.rockspec

and then, there's one final command:
cp ../../install/lib/lua/5.1/nn_scm_1-libnn.so ../../install/lib/lua/5.1/libnn.so

soumith

unread,
Mar 30, 2015, 5:16:39 PM3/30/15
to torch7 on behalf of David Belanger
Hey, I meant to reply, but I forgot to.

You can just keep your custom nn fork in a separate folder, make your changes, and then in the folder do:
luarocks make rocks/nn-scm-1.rockspec

That will automatically install your new fork.

Example:
cd mynn
# modify nn as you please
luarocks make rocks/nn-scm-1.rockspec

--
S

--
You received this message because you are subscribed to the Google Groups "torch7" group.
To unsubscribe from this group and stop receiving emails from it, send an email to torch7+un...@googlegroups.com.
To post to this group, send email to tor...@googlegroups.com.
Visit this group at http://groups.google.com/group/torch7.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages