Vous avez re莽u un message "Your GitLab account has been locked ..." ? Pas d'inqui茅tude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit d287790a authored by Alexis Brenon's avatar Alexis Brenon
Browse files

馃殤 Fix memory error

Building a too long string results in a memory error. Using a table to
concat afterward fix this.
parent 5bece76e
......@@ -71,9 +71,9 @@ end
-- Special case, don't print big Tensors (more than 25 elements), just their size
local ndepth = 6
function module.pretty_repr(...)
local result = ""
local result = {}
local function rawprint(o)
result = result .. tostring(o or '') .. '\n'
table.insert(result, tostring(o or '') .. '\n')
end
local function printtensor(obj)
local size = ""
......@@ -87,7 +87,7 @@ function module.pretty_repr(...)
local function printrecursive(obj,depth)
local depth = depth or 0
local tab = depth*4
local line = function(s) for i=1,tab do result = result .. ' ' end rawprint(s) end
local line = function(s) for i=1,tab do table.insert(result, ' ') end rawprint(s) end
if next(obj) then
line('{')
tab = tab+2
......@@ -125,7 +125,7 @@ function module.pretty_repr(...)
elseif type(obj) == 'userdata' or type(obj) == 'cdata' then
rawprint(obj)
else
result = result .. obj .. '\t'
table.insert(result, obj .. '\t')
if i == select('#',...) then
rawprint()
end
......@@ -136,7 +136,7 @@ function module.pretty_repr(...)
printrecursive(obj)
end
end
return result
return table.concat(result)
end
return module
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment