提交 1dab0010 authored 作者: Nicolas Ballas's avatar Nicolas Ballas

add storage_map dbg infos in raise_with_op

上级 56aa741b
...@@ -602,13 +602,15 @@ class Function(object): ...@@ -602,13 +602,15 @@ class Function(object):
# For the CVM # For the CVM
gof.link.raise_with_op( gof.link.raise_with_op(
self.fn.nodes[self.fn.position_of_error], self.fn.nodes[self.fn.position_of_error],
self.fn.thunks[self.fn.position_of_error]) self.fn.thunks[self.fn.position_of_error],
storage_map=self.fn.storage_map)
else: else:
# For the c linker We don't have access from # For the c linker We don't have access from
# python to all the temps values So for now, we # python to all the temps values So for now, we
# just don't print the extra shapes/strides info # just don't print the extra shapes/strides info
gof.link.raise_with_op( gof.link.raise_with_op(
self.fn.nodes[self.fn.position_of_error]) self.fn.nodes[self.fn.position_of_error],
storage_map=self.fn.storage_map)
else: else:
# old-style linkers raise their own exceptions # old-style linkers raise their own exceptions
raise raise
......
...@@ -56,7 +56,7 @@ sys.excepthook = thunk_hook ...@@ -56,7 +56,7 @@ sys.excepthook = thunk_hook
# TODO: Make this work with linker defined schedule # TODO: Make this work with linker defined schedule
def raise_with_op(node, thunk=None, exc_info=None, func=None): def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
""" """
Re-raise an exception while annotating the exception object with Re-raise an exception while annotating the exception object with
debug info. debug info.
...@@ -69,6 +69,9 @@ def raise_with_op(node, thunk=None, exc_info=None, func=None): ...@@ -69,6 +69,9 @@ def raise_with_op(node, thunk=None, exc_info=None, func=None):
A tuple containing the exception type, exception object and A tuple containing the exception type, exception object and
associated traceback, as would be returned by a call to associated traceback, as would be returned by a call to
`sys.exc_info()` (which is done if `None` is passed). `sys.exc_info()` (which is done if `None` is passed).
storage_map: dict, optional
storage map of the theano function that resulted in the
raised exception.
Notes Notes
----- -----
...@@ -89,6 +92,7 @@ def raise_with_op(node, thunk=None, exc_info=None, func=None): ...@@ -89,6 +92,7 @@ def raise_with_op(node, thunk=None, exc_info=None, func=None):
""" """
if exc_info is None: if exc_info is None:
exc_info = sys.exc_info() exc_info = sys.exc_info()
print exc_info
exc_type, exc_value, exc_trace = exc_info exc_type, exc_value, exc_trace = exc_info
if exc_type == KeyboardInterrupt: if exc_type == KeyboardInterrupt:
# print a simple traceback from KeyboardInterrupt # print a simple traceback from KeyboardInterrupt
...@@ -171,6 +175,16 @@ def raise_with_op(node, thunk=None, exc_info=None, func=None): ...@@ -171,6 +175,16 @@ def raise_with_op(node, thunk=None, exc_info=None, func=None):
"HINT: Use the Theano flag 'exception_verbosity=high'" "HINT: Use the Theano flag 'exception_verbosity=high'"
" for a debugprint of this apply node.") " for a debugprint of this apply node.")
# Prints output_map
if storage_map is not None:
from sys import getsizeof
detailed_err_msg += "\nStorage Map memory print:\n"
for k in storage_map.keys():
if storage_map[k][0] is not None:
bytes = getsizeof(storage_map[k][0])
detailed_err_msg += str(k) + ": " + str(bytes) + " bytes\n"
exc_value = exc_type(str(exc_value) + detailed_err_msg + exc_value = exc_type(str(exc_value) + detailed_err_msg +
'\n' + '\n'.join(hints)) '\n' + '\n'.join(hints))
raise exc_type, exc_value, exc_trace raise exc_type, exc_value, exc_trace
......
...@@ -416,7 +416,8 @@ class Stack(VM): ...@@ -416,7 +416,8 @@ class Stack(VM):
self.variable_strides[var] = st self.variable_strides[var] = st
except Exception: except Exception:
link.raise_with_op(current_apply, link.raise_with_op(current_apply,
self.thunks[self.node_idx[current_apply]]) self.thunks[self.node_idx[current_apply]],
storage_map)
for o in current_apply.outputs: for o in current_apply.outputs:
compute_map[o][0] = 1 compute_map[o][0] = 1
...@@ -484,7 +485,8 @@ class Stack(VM): ...@@ -484,7 +485,8 @@ class Stack(VM):
except Exception: except Exception:
link.raise_with_op(current_apply, link.raise_with_op(current_apply,
self.thunks[self.node_idx[current_apply]]) self.thunks[self.node_idx[current_apply]],
storage_map)
if requires: if requires:
for r in requires: for r in requires:
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论