Parcourir la source

Fix to work on Lua52

web.lua does not work on Lua52 because turbo does not support Lua52 FFI.
nagadomi il y a 8 ans
Parent
commit
eb3926b61c
3 fichiers modifiés avec 12 ajouts et 2 suppressions
  1. 2 2
      lib/compression.lua
  2. 5 0
      lib/settings.lua
  3. 5 0
      tools/benchmark.lua

+ 2 - 2
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

+ 5 - 0
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

+ 5 - 0
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)