diff options
author | Clement Farabet <clement.farabet@gmail.com> | 2012-09-12 23:55:07 +0400 |
---|---|---|
committer | Clement Farabet <clement.farabet@gmail.com> | 2012-09-12 23:55:07 +0400 |
commit | dc502311ef218b0f89b5074af4dc689154ae7e89 (patch) | |
tree | dfc558081a272d4836d54620dd04cb9590c1e54c /generic | |
parent | 078e179c01af6b0d839dfd9293fe416af16c4d7c (diff) |
Upgrade API (torch)
Diffstat (limited to 'generic')
-rw-r--r-- | generic/DataSetLabelMe.c | 12 | ||||
-rw-r--r-- | generic/DistMarginCriterion.c | 16 | ||||
-rw-r--r-- | generic/SpatialDownSampling.c | 10 | ||||
-rw-r--r-- | generic/SpatialGraph.c | 14 | ||||
-rw-r--r-- | generic/SpatialLinear.c | 22 | ||||
-rw-r--r-- | generic/SpatialMatching.c | 18 | ||||
-rw-r--r-- | generic/SpatialMaxSampling.c | 16 | ||||
-rw-r--r-- | generic/SpatialRadialMatching.c | 18 | ||||
-rw-r--r-- | generic/SpatialReSampling.c | 12 | ||||
-rw-r--r-- | generic/SpatialReSamplingEx.c | 10 | ||||
-rw-r--r-- | generic/SpatialUpSampling.c | 12 | ||||
-rw-r--r-- | generic/Template.c | 2 |
12 files changed, 80 insertions, 82 deletions
diff --git a/generic/DataSetLabelMe.c b/generic/DataSetLabelMe.c index 5b0f34f..eeb52bd 100644 --- a/generic/DataSetLabelMe.c +++ b/generic/DataSetLabelMe.c @@ -4,9 +4,8 @@ static int nn_(DataSetLabelMe_extract)(lua_State *L) { - const void* torch_ShortStorage_id = luaT_checktypename2id(L, "torch.ShortStorage"); int tags = 1; - THTensor *mask = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *mask = luaT_checkudata(L, 2, torch_Tensor); int x_start = lua_tonumber(L, 3); int x_end = lua_tonumber(L, 4); int y_start = lua_tonumber(L, 5); @@ -45,7 +44,7 @@ static int nn_(DataSetLabelMe_extract)(lua_State *L) size = lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "size"); lua_pushnumber(L, size+3); lua_rawset(L, tag); // tag.size = size + 3 lua_pushstring(L, "data"); lua_rawget(L, tag); // data = tag.data - data = luaT_checkudata(L, -1, torch_ShortStorage_id); lua_pop(L, 1); + data = luaT_checkudata(L, -1, "torch_ShortStorage"); lua_pop(L, 1); data->data[size] = x; // data[size+1] = x data->data[size+1] = y; // data[size+1] = y data->data[size+2] = idx; // data[size+1] = idx @@ -61,9 +60,8 @@ static int nn_(DataSetLabelMe_extract)(lua_State *L) static int nn_(DataSetSegmentSampling_extract)(lua_State *L) { - const void* torch_ShortStorage_id = luaT_checktypename2id(L, "torch.ShortStorage"); int tags = 1; - THTensor *mask = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *mask = luaT_checkudata(L, 2, torch_Tensor); int x_start = lua_tonumber(L, 3); int x_end = lua_tonumber(L, 4); int y_start = lua_tonumber(L, 5); @@ -103,7 +101,7 @@ static int nn_(DataSetSegmentSampling_extract)(lua_State *L) size = lua_tonumber(L,-1); lua_pop(L,1); lua_pushstring(L, "size"); lua_pushnumber(L, size+4); lua_rawset(L, tag); // tag.size = size + 4 lua_pushstring(L, "data"); lua_rawget(L, tag); // data = tag.data - data = luaT_checkudata(L, -1, torch_ShortStorage_id); lua_pop(L, 1); + data = luaT_checkudata(L, -1, "torch_ShortStorage"); lua_pop(L, 1); data->data[size] = x; // data[size+1] = x data->data[size+1] = y; // data[size+1] = y data->data[size+2] = idx; // data[size+1] = idx @@ -126,7 +124,7 @@ static const struct luaL_Reg nn_(DataSetLabelMe__) [] = { static void nn_(DataSetLabelMe_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(DataSetLabelMe__), "nn"); lua_pop(L,1); } diff --git a/generic/DistMarginCriterion.c b/generic/DistMarginCriterion.c index bbc6c29..10bbb20 100644 --- a/generic/DistMarginCriterion.c +++ b/generic/DistMarginCriterion.c @@ -4,7 +4,7 @@ static int nn_(DistMarginCriterion_updateOutput)(lua_State *L) { - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int sizeAverage = luaT_getfieldcheckboolean(L, 1, "sizeAverage"); real *input_data, *target_data; long nframe, dim; @@ -18,7 +18,7 @@ static int nn_(DistMarginCriterion_updateOutput)(lua_State *L) if(input->nDimension == 1) { nframe = 1; dim = input->size[0]; - target_ = luaT_checkudata(L, 3, torch_(Tensor_id)); + target_ = luaT_checkudata(L, 3, torch_Tensor); target = THTensor_(new)(); THTensor_(set)(target, target_); THTensor_(resize2d)(target, 1, dim); @@ -26,7 +26,7 @@ static int nn_(DistMarginCriterion_updateOutput)(lua_State *L) else { nframe = input->size[0]; dim = input->size[1]; - target_ = luaT_checkudata(L, 3, torch_(Tensor_id)); + target_ = luaT_checkudata(L, 3, torch_Tensor); THArgCheck((target_->nDimension == 2) && (target_->size[0] == nframe) && (target_->size[1] == dim), 3, "inconsistent target size"); target = THTensor_(newContiguous)(target_); @@ -84,9 +84,9 @@ static int nn_(DistMarginCriterion_updateOutput)(lua_State *L) static int nn_(DistMarginCriterion_updateGradInput)(lua_State *L) { - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int sizeAverage = luaT_getfieldcheckboolean(L, 1, "sizeAverage"); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); real *input_data; real *gradInput_data; real *target_data; @@ -101,7 +101,7 @@ static int nn_(DistMarginCriterion_updateGradInput)(lua_State *L) if(input->nDimension == 1) { nframe = 1; dim = input->size[0]; - target_ = luaT_checkudata(L, 3, torch_(Tensor_id)); + target_ = luaT_checkudata(L, 3, torch_Tensor); target = THTensor_(new)(); THTensor_(set)(target, target_); THTensor_(resize2d)(target, 1, dim); @@ -109,7 +109,7 @@ static int nn_(DistMarginCriterion_updateGradInput)(lua_State *L) else { nframe = input->size[0]; dim = input->size[1]; - target_ = luaT_checkudata(L, 3, torch_(Tensor_id)); + target_ = luaT_checkudata(L, 3, torch_Tensor); THArgCheck((target_->nDimension == 2) && (target_->size[0] == nframe) && (target_->size[1] == dim), 3, "inconsistent target size"); target = THTensor_(newContiguous)(target_); @@ -178,7 +178,7 @@ static const struct luaL_Reg nn_(DistMarginCriterion__) [] = { static void nn_(DistMarginCriterion_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(DistMarginCriterion__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialDownSampling.c b/generic/SpatialDownSampling.c index 0feef5d..e5c3c47 100644 --- a/generic/SpatialDownSampling.c +++ b/generic/SpatialDownSampling.c @@ -4,10 +4,10 @@ static int nn_(SpatialDownSampling_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int rW = luaT_getfieldcheckint(L, 1, "rW"); int rH = luaT_getfieldcheckint(L, 1, "rH"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // dims int iwidth = input->size[2]; @@ -43,8 +43,8 @@ static int nn_(SpatialDownSampling_updateOutput)(lua_State *L) { static int nn_(SpatialDownSampling_updateGradInput)(lua_State *L) { // get all params - THTensor *gradOutput = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); + THTensor *gradOutput = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); int rW = luaT_getfieldcheckint(L, 1, "rW"); int rH = luaT_getfieldcheckint(L, 1, "rH"); @@ -85,7 +85,7 @@ static const struct luaL_Reg nn_(SpatialDownSampling__) [] = { static void nn_(SpatialDownSampling_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialDownSampling__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialGraph.c b/generic/SpatialGraph.c index 7aca380..1ad564c 100644 --- a/generic/SpatialGraph.c +++ b/generic/SpatialGraph.c @@ -10,11 +10,11 @@ static int nn_(SpatialGraph_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int connex = luaT_getfieldcheckint(L, 1, "connex"); int dist = luaT_getfieldcheckint(L, 1, "dist"); int norm = luaT_getfieldcheckint(L, 1, "normalize"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // dims int iwidth = input->size[2]; @@ -112,10 +112,10 @@ static int nn_(SpatialGraph_updateOutput)(lua_State *L) static int nn_(SpatialGraph_updateGradInput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); - THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); + THTensor *gradOutput = luaT_checkudata(L, 3, torch_Tensor); //int connex = luaT_getfieldcheckint(L, 1, "connex"); int dist = luaT_getfieldcheckint(L, 1, "dist"); int norm = luaT_getfieldcheckint(L, 1, "normalize"); @@ -252,7 +252,7 @@ static const struct luaL_Reg nn_(SpatialGraph__) [] = { static void nn_(SpatialGraph_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialGraph__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialLinear.c b/generic/SpatialLinear.c index e3276bc..8a8b756 100644 --- a/generic/SpatialLinear.c +++ b/generic/SpatialLinear.c @@ -5,10 +5,10 @@ static int nn_(SpatialLinear_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *bias = luaT_getfieldcheckudata(L, 1, "bias", torch_(Tensor_id)); - THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_(Tensor_id)); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *bias = luaT_getfieldcheckudata(L, 1, "bias", torch_Tensor); + THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_Tensor); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // dims int ichannels = input->size[0]; @@ -42,12 +42,12 @@ static int nn_(SpatialLinear_updateOutput)(lua_State *L) static int nn_(SpatialLinear_updateGradInput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); - THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_(Tensor_id)); - THTensor *gradWeight = luaT_getfieldcheckudata(L, 1, "gradWeight", torch_(Tensor_id)); - THTensor *gradBias = luaT_getfieldcheckudata(L, 1, "gradBias", torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradOutput = luaT_checkudata(L, 3, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); + THTensor *weight = luaT_getfieldcheckudata(L, 1, "weight", torch_Tensor); + THTensor *gradWeight = luaT_getfieldcheckudata(L, 1, "gradWeight", torch_Tensor); + THTensor *gradBias = luaT_getfieldcheckudata(L, 1, "gradBias", torch_Tensor); int weightDecay = luaT_getfieldcheckint(L, 1, "weightDecay"); // dims @@ -116,7 +116,7 @@ static const struct luaL_Reg nn_(SpatialLinear__) [] = { static void nn_(SpatialLinear_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialLinear__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialMatching.c b/generic/SpatialMatching.c index c64e3d5..f19282e 100644 --- a/generic/SpatialMatching.c +++ b/generic/SpatialMatching.c @@ -9,12 +9,12 @@ static int nn_(SpatialMatching_updateOutput)(lua_State *L) { // get all params - THTensor *input1 = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *input2 = luaT_checkudata(L, 3, torch_(Tensor_id)); + THTensor *input1 = luaT_checkudata(L, 2, torch_Tensor); + THTensor *input2 = luaT_checkudata(L, 3, torch_Tensor); int maxw = luaT_getfieldcheckint(L, 1, "maxw"); int maxh = luaT_getfieldcheckint(L, 1, "maxh"); int full_output = luaT_getfieldcheckboolean(L, 1, "full_output"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // dims int iwidth = input1->size[2]; @@ -113,11 +113,11 @@ static int nn_(SpatialMatching_updateOutput)(lua_State *L) static int nn_(SpatialMatching_updateGradInput)(lua_State *L) { // get all params - THTensor *input1 = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *input2 = luaT_checkudata(L, 3, torch_(Tensor_id)); - THTensor *gradInput1 = luaT_getfieldcheckudata(L, 1, "gradInput1", torch_(Tensor_id)); - THTensor *gradInput2 = luaT_getfieldcheckudata(L, 1, "gradInput2", torch_(Tensor_id)); - THTensor *gradOutput = luaT_checkudata(L, 4, torch_(Tensor_id)); + THTensor *input1 = luaT_checkudata(L, 2, torch_Tensor); + THTensor *input2 = luaT_checkudata(L, 3, torch_Tensor); + THTensor *gradInput1 = luaT_getfieldcheckudata(L, 1, "gradInput1", torch_Tensor); + THTensor *gradInput2 = luaT_getfieldcheckudata(L, 1, "gradInput2", torch_Tensor); + THTensor *gradOutput = luaT_checkudata(L, 4, torch_Tensor); int full_output = luaT_getfieldcheckboolean(L, 1, "full_output"); int maxw = luaT_getfieldcheckint(L, 1, "maxw"); int maxh = luaT_getfieldcheckint(L, 1, "maxh"); @@ -200,7 +200,7 @@ static const struct luaL_Reg nn_(SpatialMatching__) [] = { static void nn_(SpatialMatching_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialMatching__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialMaxSampling.c b/generic/SpatialMaxSampling.c index fcdd54d..1b06b69 100644 --- a/generic/SpatialMaxSampling.c +++ b/generic/SpatialMaxSampling.c @@ -12,11 +12,11 @@ static int nn_(SpatialMaxSampling_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int owidth = luaT_getfieldcheckint(L, 1, "owidth"); int oheight = luaT_getfieldcheckint(L, 1, "oheight"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); - THTensor *indices = luaT_getfieldcheckudata(L, 1, "indices", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); + THTensor *indices = luaT_getfieldcheckudata(L, 1, "indices", torch_Tensor); // check dims luaL_argcheck(L, input->nDimension == 3, 2, "3D tensor expected"); @@ -102,10 +102,10 @@ static int nn_(SpatialMaxSampling_updateOutput)(lua_State *L) static int nn_(SpatialMaxSampling_updateGradInput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); - THTensor *indices = luaT_getfieldcheckudata(L, 1, "indices", torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradOutput = luaT_checkudata(L, 3, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); + THTensor *indices = luaT_getfieldcheckudata(L, 1, "indices", torch_Tensor); int owidth = luaT_getfieldcheckint(L, 1, "owidth"); int oheight = luaT_getfieldcheckint(L, 1, "oheight"); @@ -172,7 +172,7 @@ static const struct luaL_Reg nn_(SpatialMaxSampling__) [] = { static void nn_(SpatialMaxSampling_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialMaxSampling__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialRadialMatching.c b/generic/SpatialRadialMatching.c index 1338dbf..05f38bd 100644 --- a/generic/SpatialRadialMatching.c +++ b/generic/SpatialRadialMatching.c @@ -9,11 +9,11 @@ static int nn_(SpatialRadialMatching_updateOutput)(lua_State *L) { // get all params - THTensor *input1 = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *input2 = luaT_checkudata(L, 3, torch_(Tensor_id)); + THTensor *input1 = luaT_checkudata(L, 2, torch_Tensor); + THTensor *input2 = luaT_checkudata(L, 3, torch_Tensor); //THLongTensor *mask= luaT_checkudata(L, 4, luaT_checktypename2id(L, "torch.LongTensor")); int maxh = luaT_getfieldcheckint(L, 1, "maxh"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // dims int iwidth = input1->size[2]; @@ -57,12 +57,12 @@ static int nn_(SpatialRadialMatching_updateOutput)(lua_State *L) static int nn_(SpatialRadialMatching_updateGradInput)(lua_State *L) { // get all params - THTensor* input1 = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor* input2 = luaT_checkudata(L, 3, torch_(Tensor_id)); - THTensor* gradOutput = luaT_checkudata(L, 4, torch_(Tensor_id)); + THTensor* input1 = luaT_checkudata(L, 2, torch_Tensor); + THTensor* input2 = luaT_checkudata(L, 3, torch_Tensor); + THTensor* gradOutput = luaT_checkudata(L, 4, torch_Tensor); //THLongTensor* mask = luaT_checkudata(L, 5, luaT_checktypename2id(L, "torch.LongTensor")); - THTensor* gradInput1 = luaT_getfieldcheckudata(L, 1, "gradInput1", torch_(Tensor_id)); - THTensor* gradInput2 = luaT_getfieldcheckudata(L, 1, "gradInput2", torch_(Tensor_id)); + THTensor* gradInput1 = luaT_getfieldcheckudata(L, 1, "gradInput1", torch_Tensor); + THTensor* gradInput2 = luaT_getfieldcheckudata(L, 1, "gradInput2", torch_Tensor); int maxh = luaT_getfieldcheckint(L, 1, "maxh"); // dims @@ -117,7 +117,7 @@ static const struct luaL_Reg nn_(SpatialRadialMatching__) [] = { static void nn_(SpatialRadialMatching_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialRadialMatching__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialReSampling.c b/generic/SpatialReSampling.c index 927add2..c8d4bdd 100644 --- a/generic/SpatialReSampling.c +++ b/generic/SpatialReSampling.c @@ -12,10 +12,10 @@ static int nn_(SpatialReSampling_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int owidth = luaT_getfieldcheckint(L, 1, "owidth"); int oheight = luaT_getfieldcheckint(L, 1, "oheight"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // check dims luaL_argcheck(L, input->nDimension == 3, 2, "3D tensor expected"); @@ -88,9 +88,9 @@ static int nn_(SpatialReSampling_updateOutput)(lua_State *L) static int nn_(SpatialReSampling_updateGradInput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradOutput = luaT_checkudata(L, 3, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); // dims int iwidth = input->size[2]; @@ -173,7 +173,7 @@ static const struct luaL_Reg nn_(SpatialReSampling__) [] = { static void nn_(SpatialReSampling_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialReSampling__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialReSamplingEx.c b/generic/SpatialReSamplingEx.c index 2610d0b..1cd71b4 100644 --- a/generic/SpatialReSamplingEx.c +++ b/generic/SpatialReSamplingEx.c @@ -13,8 +13,8 @@ static int nn_(SpatialReSamplingEx_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); int oheight = luaT_getfieldcheckint(L, 1, "oheight"); int owidth = luaT_getfieldcheckint(L, 1, "owidth"); int mode = luaT_getfieldcheckint(L, 1, "mode_c"); @@ -171,8 +171,8 @@ static int nn_(SpatialReSamplingEx_updateGradInput)(lua_State *L) // get all params int iheight = luaT_getfieldcheckint(L, 1, "iheight"); int iwidth = luaT_getfieldcheckint(L, 1, "iwidth"); - THTensor *gradOutput = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); + THTensor *gradOutput = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); int mode = luaT_getfieldcheckint(L, 1, "mode_c"); // dims @@ -329,7 +329,7 @@ static const struct luaL_Reg nn_(SpatialReSamplingEx__) [] = { static void nn_(SpatialReSamplingEx_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialReSamplingEx__), "nn"); lua_pop(L,1); } diff --git a/generic/SpatialUpSampling.c b/generic/SpatialUpSampling.c index be55d8e..3970891 100644 --- a/generic/SpatialUpSampling.c +++ b/generic/SpatialUpSampling.c @@ -5,10 +5,10 @@ static int nn_(SpatialUpSampling_updateOutput)(lua_State *L) { // get all params - THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); + THTensor *input = luaT_checkudata(L, 2, torch_Tensor); int dW = luaT_getfieldcheckint(L, 1, "dW"); int dH = luaT_getfieldcheckint(L, 1, "dH"); - THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_(Tensor_id)); + THTensor *output = luaT_getfieldcheckudata(L, 1, "output", torch_Tensor); // dims int iwidth = input->size[2]; @@ -53,9 +53,9 @@ static int nn_(SpatialUpSampling_updateOutput)(lua_State *L) static int nn_(SpatialUpSampling_updateGradInput)(lua_State *L) { // get all params - //THTensor *input = luaT_checkudata(L, 2, torch_(Tensor_id)); - THTensor *gradOutput = luaT_checkudata(L, 3, torch_(Tensor_id)); - THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_(Tensor_id)); + //THTensor *input = luaT_checkudata(L, 2, torch_Tensor); + THTensor *gradOutput = luaT_checkudata(L, 3, torch_Tensor); + THTensor *gradInput = luaT_getfieldcheckudata(L, 1, "gradInput", torch_Tensor); int dW = luaT_getfieldcheckint(L, 1, "dW"); int dH = luaT_getfieldcheckint(L, 1, "dH"); @@ -109,7 +109,7 @@ static const struct luaL_Reg nn_(SpatialUpSampling__) [] = { static void nn_(SpatialUpSampling_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(SpatialUpSampling__), "nn"); lua_pop(L,1); } diff --git a/generic/Template.c b/generic/Template.c index 6a75b88..48a8307 100644 --- a/generic/Template.c +++ b/generic/Template.c @@ -20,7 +20,7 @@ static const struct luaL_Reg nn_(Template__) [] = { static void nn_(Template_init)(lua_State *L) { - luaT_pushmetaclass(L, torch_(Tensor_id)); + luaT_pushmetatable(L, torch_Tensor); luaT_registeratname(L, nn_(Template__), "nn"); lua_pop(L,1); } |