diff options
author | Ronan Collobert <ronan@collobert.com> | 2015-10-12 23:05:45 +0300 |
---|---|---|
committer | Ronan Collobert <ronan@collobert.com> | 2015-10-12 23:06:44 +0300 |
commit | a63174c34b6d9aef6f24df1adb3deba5a9196abd (patch) | |
tree | 097e6536e8c0ae84e7753ae091a276ab5338171b | |
parent | 2a3d510907e85d4bb02c97171ea34a8951702eca (diff) |
sharedserialize: added support for tds.Vec
-rw-r--r-- | sharedserialize.lua | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/sharedserialize.lua b/sharedserialize.lua index 43e1714..aba4fb3 100644 --- a/sharedserialize.lua +++ b/sharedserialize.lua @@ -7,24 +7,38 @@ local typenames = {} local _, tds = pcall(require, 'tds') -- for the free/retain functions if tds then local ffi = require 'ffi' - local mt = {} + -- hash + local mt = {} function mt.__factory(f) local self = f:readLong() self = ffi.cast('tds_hash&', self) ffi.gc(self, tds.C.tds_hash_free) return self end - function mt.__write(self, f) f:writeLong(torch.pointer(self)) tds.C.tds_hash_retain(self) end - function mt.__read(self, f) end - typenames['tds.Hash'] = mt + + -- vec + local mt = {} + function mt.__factory(f) + local self = f:readLong() + self = ffi.cast('tds_vec&', self) + ffi.gc(self, tds.C.tds_vec_free) + return self + end + function mt.__write(self, f) + f:writeLong(torch.pointer(self)) + tds.C.tds_vec_retain(self) + end + function mt.__read(self, f) + end + typenames['tds.Vec'] = mt end -- tensor support |