diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-06 09:26:18 +0100 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2018-10-06 09:26:18 +0100 |
commit | 9a3b5ef566ad7c57b6509511e53f9dbe58340268 (patch) | |
tree | b3b610c4d7ac1ac0de96fa089977f19225c09934 /lualib | |
parent | dae0ccff831a4a9a2fa536cc4da348bb764a4645 (diff) | |
download | rspamd-9a3b5ef566ad7c57b6509511e53f9dbe58340268.tar.gz rspamd-9a3b5ef566ad7c57b6509511e53f9dbe58340268.zip |
[Minor] Don't load torch unless really needed
Diffstat (limited to 'lualib')
-rw-r--r-- | lualib/lua_nn.lua | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lualib/lua_nn.lua b/lualib/lua_nn.lua index d0d2d5265..d16f0a768 100644 --- a/lualib/lua_nn.lua +++ b/lualib/lua_nn.lua @@ -20,9 +20,13 @@ local exports = {} local lua_nn_models = {} -if rspamd_config:has_torch() then - torch = require "torch" - torch.setnumthreads(1) +local conf_section = rspamd_config:get_all_opt("nn_models") + +if conf_section then + if rspamd_config:has_torch() then + torch = require "torch" + torch.setnumthreads(1) + end end if torch then @@ -43,10 +47,9 @@ if torch then end end end - local section = rspamd_config:get_all_opt("nn_models") - if section and type(section) == 'table' then - for k,v in pairs(section) do + if conf_section and type(conf_section) == 'table' then + for k,v in pairs(conf_section) do if not rspamd_config:add_map(v, "nn map " .. k, gen_process_callback(k)) then rspamd_logger.warnx(rspamd_config, 'cannot load NN map %1', k) end |