diff --git a/extend.lua b/extend.lua new file mode 100644 index 0000000..9e8de8c --- /dev/null +++ b/extend.lua @@ -0,0 +1,10 @@ + + +function torchx.extend(types, funcs, alias) + for _,type in ipairs(types) do + local metatable = torch.getmetatable(alias and ('torch.' .. type .. 'Tensor') or type) + for funcname, func in pairs(funcs) do + rawset(metatable, funcname, func) + end + end +end