diff options
author | Ronan Collobert <ronan@collobert.com> | 2015-04-19 05:49:11 +0300 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2015-04-19 05:49:11 +0300 |
commit | bbec9fc2c96b31eab780764e8f98961cc14d4def (patch) | |
tree | 79729470eb71c46de7e8489d3cc6eda725ce64c8 /generic | |
parent | 3d8a93cee81e84407efc5b57aa1a73f581687375 (diff) |
expose storage and tensor retain() and free() methods into Lua
Diffstat (limited to 'generic')
-rw-r--r-- | generic/Storage.c | 9 | ||||
-rw-r--r-- | generic/Tensor.c | 9 |
2 files changed, 18 insertions, 0 deletions
diff --git a/generic/Storage.c b/generic/Storage.c index 66ff742..9dc3ba2 100644 --- a/generic/Storage.c +++ b/generic/Storage.c @@ -45,6 +45,13 @@ static int torch_Storage_(new)(lua_State *L) return 1; } +static int torch_Storage_(retain)(lua_State *L) +{ + THStorage *storage = luaT_checkudata(L, 1, torch_Storage); + THStorage_(retain)(storage); + return 0; +} + static int torch_Storage_(free)(lua_State *L) { THStorage *storage = luaT_checkudata(L, 1, torch_Storage); @@ -201,6 +208,8 @@ static int torch_Storage_(read)(lua_State *L) } static const struct luaL_Reg torch_Storage_(_) [] = { + {"retain", torch_Storage_(retain)}, + {"free", torch_Storage_(free)}, {"size", torch_Storage_(__len__)}, {"__len__", torch_Storage_(__len__)}, {"__newindex__", torch_Storage_(__newindex__)}, diff --git a/generic/Tensor.c b/generic/Tensor.c index 730d4a9..c8f84d2 100644 --- a/generic/Tensor.c +++ b/generic/Tensor.c @@ -956,6 +956,13 @@ static int torch_Tensor_(__index__)(lua_State *L) } } +static int torch_Tensor_(retain)(lua_State *L) +{ + THTensor *tensor = luaT_checkudata(L, 1, torch_Tensor); + THTensor_(retain)(tensor); + return 0; +} + static int torch_Tensor_(free)(lua_State *L) { THTensor *tensor = luaT_checkudata(L, 1, torch_Tensor); @@ -1217,6 +1224,8 @@ static int torch_Tensor_(read)(lua_State *L) } static const struct luaL_Reg torch_Tensor_(_) [] = { + {"retain", torch_Tensor_(retain)}, + {"free", torch_Tensor_(free)}, {"contiguous", torch_Tensor_(contiguous)}, {"size", torch_Tensor_(size)}, {"__len__", torch_Tensor_(size)}, |