提交 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): ...@@ -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 # 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 # handler code in the first place
assert path is not None assert path is not None
tr = getattr(r.tag, 'trace', None) tr = getattr(r.tag, 'trace', [])
detailed_err_msg = "" detailed_err_msg = ""
if tr: if len(tr) > 0:
sio = StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
detailed_err_msg += "\nBacktrace when the variable is created:\n" 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( raise MissingInputError(
'A variable that is an input to the graph was ' 'A variable that is an input to the graph was '
'neither provided as an input to the function ' '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): ...@@ -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" "HINT: Use another linker then the c linker to"
" have the inputs shapes and strides printed.") " have the inputs shapes and strides printed.")
# Print node backtrace # Print node backtraces
tr = getattr(node.outputs[0].tag, 'trace', None) tr = getattr(node.outputs[0].tag, 'trace', [])
if tr: if len(tr) > 0:
sio = StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
detailed_err_msg += "\nBacktrace when the node is created:\n" 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: else:
hints.append( hints.append(
"HINT: Re-running with most Theano optimization disabled could" "HINT: Re-running with most Theano optimization disabled could"
......
...@@ -458,14 +458,17 @@ class PureOp(object): ...@@ -458,14 +458,17 @@ class PureOp(object):
detailed_err_msg = ( detailed_err_msg = (
"For compute_test_value, one input test value does not" "For compute_test_value, one input test value does not"
" have the requested type.\n") " have the requested type.\n")
tr = getattr(v.tag, 'trace', None) tr = getattr(v.tag, 'trace', [])
if tr: if len(tr) > 0:
sio = StringIO()
traceback.print_list(tr, sio)
tr = sio.getvalue()
detailed_err_msg += ( detailed_err_msg += (
" \nBacktrace when that variable is created:\n") " \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 += ( detailed_err_msg += (
"\nThe error when converting the test value to that" "\nThe error when converting the test value to that"
" variable type:") " variable type:")
......
...@@ -94,7 +94,7 @@ def add_tag_trace(thing, user_line=1): ...@@ -94,7 +94,7 @@ def add_tag_trace(thing, user_line=1):
# The order is from the oldest to the newest # The order is from the oldest to the newest
if len(tr) > user_line: if len(tr) > user_line:
tr = tr[-user_line:] tr = tr[-user_line:]
thing.tag.trace = tr thing.tag.trace = [tr]
return thing return thing
......
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论