From eb3926b61ccec43d680467ff4e6067ba0240f46a Mon Sep 17 00:00:00 2001 From: nagadomi Date: Thu, 2 Mar 2017 14:47:49 +0900 Subject: [PATCH] Fix to work on Lua52 web.lua does not work on Lua52 because turbo does not support Lua52 FFI. --- lib/compression.lua | 4 ++-- lib/settings.lua | 5 +++++ tools/benchmark.lua | 5 +++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/lib/compression.lua b/lib/compression.lua index 6593c82..a31e0ed 100644 --- a/lib/compression.lua +++ b/lib/compression.lua @@ -1,5 +1,5 @@ -- snapply compression for ByteTensor -require 'snappy' +local snappy = require 'snappy' local compression = {} compression.compress = function (bt) @@ -9,7 +9,7 @@ end compression.decompress = function(data) local size = data[1] local dec = snappy.decompress(data[2]:string()) - local bt = torch.ByteTensor(unpack(torch.totable(size))) + local bt = torch.ByteTensor(table.unpack(torch.totable(size))) bt:storage():string(dec) return bt end diff --git a/lib/settings.lua b/lib/settings.lua index 1c66cb3..03830e4 100644 --- a/lib/settings.lua +++ b/lib/settings.lua @@ -148,4 +148,9 @@ end settings.images = string.format("%s/images.t7", settings.data_dir) settings.image_list = string.format("%s/image_list.txt", settings.data_dir) +-- patch for lua52 +if not math.log10 then + math.log10 = function(x) return math.log(x, 10) end +end + return settings diff --git a/tools/benchmark.lua b/tools/benchmark.lua index a9aa70f..950f1b1 100644 --- a/tools/benchmark.lua +++ b/tools/benchmark.lua @@ -81,6 +81,11 @@ if opt.output_dir:len() > 0 then dir.makepath(opt.output_dir) end +-- patch for lua52 +if not math.log10 then + math.log10 = function(x) return math.log(x, 10) end +end + local function rgb2y_matlab(x) local y = torch.Tensor(1, x:size(2), x:size(3)):zero() x = iproc.byte2float(x)