Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/cutorch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/init.c
diff options
context:
space:
mode:
authorsoumith <soumith@fb.com>2014-11-12 07:00:18 +0300
committersoumith <soumith@fb.com>2014-11-12 08:15:19 +0300
commit9a72407749e2fec7ba239b0ffb715a7c2a8d37a6 (patch)
treeeef6687d9d2d39d45d0aa64d38a4d505c1d7db23 /init.c
parent497d5c1275f8a9ac5cc25716ce04b0cfd68fd5d1 (diff)
adding getDevice for tensor, manualSeedAll and seedAll
Diffstat (limited to 'init.c')
-rw-r--r--init.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/init.c b/init.c
index 1f21a4c..c83ff0e 100644
--- a/init.c
+++ b/init.c
@@ -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}