Skip to content

Commit

Permalink
Fix to work on Lua52
Browse files Browse the repository at this point in the history
web.lua does not work on Lua52 because turbo does not support Lua52 FFI.
  • Loading branch information
nagadomi committed Mar 2, 2017
1 parent 780e22c commit eb3926b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/compression.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- snapply compression for ByteTensor
require 'snappy'
local snappy = require 'snappy'

local compression = {}
compression.compress = function (bt)
Expand All @@ -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
Expand Down
5 changes: 5 additions & 0 deletions lib/settings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions tools/benchmark.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb3926b

Please sign in to comment.