-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from timharley/thgenerator
Make random number generator state a TH type
- Loading branch information
Showing
12 changed files
with
284 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#include <general.h> | ||
|
||
static const struct luaL_Reg torch_Generator_table_ [] = { | ||
{NULL, NULL} | ||
}; | ||
|
||
int torch_Generator_new(lua_State *L) | ||
{ | ||
THGenerator *gen = THGenerator_new(); | ||
luaT_pushudata(L, gen, torch_Generator); | ||
return 1; | ||
} | ||
|
||
int torch_Generator_free(lua_State *L) | ||
{ | ||
THGenerator *gen= luaT_checkudata(L, 1, torch_Generator); | ||
THGenerator_free(gen); | ||
return 0; | ||
} | ||
|
||
#define torch_Generator_factory torch_Generator_new | ||
|
||
void torch_Generator_init(lua_State *L) | ||
{ | ||
luaT_newmetatable(L, torch_Generator, NULL, | ||
torch_Generator_new, torch_Generator_free, torch_Generator_factory); | ||
luaL_register(L, NULL, torch_Generator_table_); | ||
lua_pop(L, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this commit change the Lua signature of all the random functions?
I'm getting segfaults (OSX) after that commit. I still can't pinpoint the exact reason though.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Himm, I just ran torch.test and nn.test on mac with this change and did not get anything. This changes the Lua side signatures, but there is a default generator that is passed, so it is backward compatible in Lua. However, it is not backward compatible in C. Maybe you had a package that used the old C THRandom interface?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, on OSX, before this commit, everything's fine, after, this segfaults for me:
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't. Are you sure you do not have some old TH include files lying around?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, same thing :-(.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let me check on my OSX.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely dont see it on linux.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also using the latest LuaJIT from https://github.com/torch/luajit-rocks .
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i did a fresh local ezinstall, dont see it. I'm on Mavericks.
uname -a
Darwin a812s3pp1.local 13.1.0 Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 x86_64
th> a=torch.rand(10)
th> =a
0.2603
0.5489
0.6255
0.2807
0.5866
0.3169
0.6153
0.7909
0.6049
0.2710
[torch.DoubleTensor of dimension 10]
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which compiler are you using?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same thing, I'm on Mavericks, using Clang 5.1.0 .
Damn, no idea why this is happening.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok just tried with clang 5.1.0 as well (was using gcc), not the issue.
Are you loading any other packages, or just luajit -ltorch ?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, maybe weird DYLD_* variables?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did a fresh install, with clang 5.1.0 (so no openmp), then:
luajit -ltorch
torch is the head of the current master, and luajit is the head from luajit-rocks.
What else could interfere?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No DYLD_* defined ...
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
beats me. how's the stack looking, did you look at the coredump?
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
015eee4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I checked the otool and it points to the right libTH : @executable_path/../lib/libluaT.dylib.
Ok thanks a lot for your help, I'm going keep digging, at least I know it must be an install problem on my side.