diff options
author | soumith <soumith@fb.com> | 2014-11-12 07:00:18 +0300 |
---|---|---|
committer | soumith <soumith@fb.com> | 2014-11-12 08:15:19 +0300 |
commit | 9a72407749e2fec7ba239b0ffb715a7c2a8d37a6 (patch) | |
tree | eef6687d9d2d39d45d0aa64d38a4d505c1d7db23 /init.c | |
parent | 497d5c1275f8a9ac5cc25716ce04b0cfd68fd5d1 (diff) |
adding getDevice for tensor, manualSeedAll and seedAll
Diffstat (limited to 'init.c')
-rw-r--r-- | init.c | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -104,6 +104,13 @@ static int cutorch_seed(lua_State *L) return 1; } +static int cutorch_seedAll(lua_State *L) +{ + unsigned long seed = THCRandom_seedAll(getState(L)->rngState); + lua_pushnumber(L, seed); + return 1; +} + static int cutorch_initialSeed(lua_State *L) { unsigned long seed = THCRandom_initialSeed(getState(L)->rngState); @@ -118,6 +125,13 @@ static int cutorch_manualSeed(lua_State *L) return 0; } +static int cutorch_manualSeedAll(lua_State* L) +{ + unsigned long seed = luaL_checknumber(L, 1); + THCRandom_manualSeedAll(getState(L)->rngState, seed); + return 0; +} + static int cutorch_getRNGState(lua_State *L) { THByteTensor* t = THByteTensor_new(); @@ -141,8 +155,10 @@ static const struct luaL_Reg cutorch_stuff__ [] = { {"getDeviceProperties", cutorch_getDeviceProperties}, {"setDevice", cutorch_setDevice}, {"seed", cutorch_seed}, + {"seedAll", cutorch_seedAll}, {"initialSeed", cutorch_initialSeed}, {"manualSeed", cutorch_manualSeed}, + {"manualSeedAll", cutorch_manualSeedAll}, {"getRNGState", cutorch_getRNGState}, {"setRNGState", cutorch_setRNGState}, {NULL, NULL} |