提交 21471c14 authored 作者: Pascal Lamblin's avatar Pascal Lamblin

Merge pull request #3077 from julianser/new_stacktrace_fix

Further work on issue #3018.
......@@ -331,15 +331,17 @@ class FunctionGraph(utils.object2):
# if there is no path then r isn't really a graph input so we shouldn't be running error
# handler code in the first place
assert path is not None
tr = getattr(r.tag, 'trace', None)
tr = getattr(r.tag, 'trace', [])
detailed_err_msg = ""
if tr:
sio = StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
if len(tr) > 0:
detailed_err_msg += "\nBacktrace when the variable is created:\n"
detailed_err_msg += str(tr)
# Print separate message for each element in
# the list of batcktraces
sio = StringIO()
for subtr in tr:
traceback.print_list(subtr, sio)
detailed_err_msg += str(sio.getvalue())
raise MissingInputError(
'A variable that is an input to the graph was '
'neither provided as an input to the function '
......
......@@ -156,14 +156,16 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
"HINT: Use another linker then the c linker to"
" have the inputs shapes and strides printed.")
# Print node backtrace
tr = getattr(node.outputs[0].tag, 'trace', None)
if tr:
sio = StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
# Print node backtraces
tr = getattr(node.outputs[0].tag, 'trace', [])
if len(tr) > 0:
detailed_err_msg += "\nBacktrace when the node is created:\n"
detailed_err_msg += str(tr)
# Print separate message for each element in the list of batcktraces
sio = StringIO()
for subtr in tr:
traceback.print_list(subtr, sio)
detailed_err_msg += str(sio.getvalue())
else:
hints.append(
"HINT: Re-running with most Theano optimization disabled could"
......
......@@ -458,14 +458,17 @@ class PureOp(object):
detailed_err_msg = (
"For compute_test_value, one input test value does not"
" have the requested type.\n")
tr = getattr(v.tag, 'trace', None)
if tr:
sio = StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
tr = getattr(v.tag, 'trace', [])
if len(tr) > 0:
detailed_err_msg += (
" \nBacktrace when that variable is created:\n")
detailed_err_msg += str(tr)
# Print separate message for each element in the list
# of batcktraces
sio = StringIO()
for subtr in tr:
traceback.print_list(subtr, sio)
detailed_err_msg += str(sio.getvalue())
detailed_err_msg += (
"\nThe error when converting the test value to that"
" variable type:")
......
......@@ -94,7 +94,7 @@ def add_tag_trace(thing, user_line=1):
# The order is from the oldest to the newest
if len(tr) > user_line:
tr = tr[-user_line:]
thing.tag.trace = tr
thing.tag.trace = [tr]
return thing
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论