aboutsummaryrefslogtreecommitdiff
path: root/nn/param_repo.lua
diff options
context:
space:
mode:
authorcloudygoose <[email protected]>2015-06-03 10:29:41 +0800
committercloudygoose <[email protected]>2015-06-03 10:29:41 +0800
commitbf01fd6cea42def51becb6ea866d4fd335e45842 (patch)
tree09d12e50e3a6156c7e0cd7412b22fa4b61189495 /nn/param_repo.lua
parent6984519cbb659aac0b0b323de93d5a90aa2049b7 (diff)
parentbb56a806e0636a0b20117b1644701d63e2bfaefb (diff)
...
Merge remote-tracking branch 'upstream/master'
Diffstat (limited to 'nn/param_repo.lua')
-rw-r--r--nn/param_repo.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/nn/param_repo.lua b/nn/param_repo.lua
new file mode 100644
index 0000000..3e37c31
--- /dev/null
+++ b/nn/param_repo.lua
@@ -0,0 +1,26 @@
+local ParamRepo = nerv.class("nerv.ParamRepo")
+
+function ParamRepo:__init(param_files)
+ local param_table = {}
+ if type(param_files) ~= "table" then
+ nerv.error("param file table is need")
+ end
+ for i = 1, #param_files do
+ local pf = nerv.ChunkFile(param_files[i], "r")
+ for cid, cspec in pairs(pf.metadata) do
+ if param_table[cid] ~= nil then
+ nerv.error("conflicting chunk id in param files")
+ end
+ param_table[cid] = pf
+ end
+ end
+ self.param_table = param_table
+end
+
+function ParamRepo:get_param(pid, global_conf)
+ local pf = self.param_table[pid]
+ if pf == nil then
+ nerv.error("param with id %s not found", pid)
+ end
+ return pf:read_chunk(pid, global_conf)
+end