提交 f3e696a5 authored 作者: Nicolas Ballas's avatar Nicolas Ballas

Fix test crash and update output format

上级 d2684b00
"""WRITEME""" """WRITEME"""
from copy import copy, deepcopy from copy import copy, deepcopy
from sys import getsizeof
import StringIO import StringIO
import sys import sys
import traceback import traceback
...@@ -164,21 +165,15 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None): ...@@ -164,21 +165,15 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
" Theano optimizations can be disabled with 'optimizer=None'.") " Theano optimizations can be disabled with 'optimizer=None'.")
if theano.config.exception_verbosity == 'high': if theano.config.exception_verbosity == 'high':
f = StringIO.StringIO() f = StringIO.StringIO()
theano.printing.debugprint(node, file=f, stop_on_name=True, theano.printing.debugprint(node, file=f, stop_on_name=True,
print_type=True) print_type=True)
detailed_err_msg += "\nDebugprint of the apply node: \n" detailed_err_msg += "\nDebugprint of the apply node: \n"
detailed_err_msg += f.getvalue() detailed_err_msg += f.getvalue()
else:
hints.append(
"HINT: Use the Theano flag 'exception_verbosity=high'"
" for a debugprint of this apply node.")
# Prints output_map # Prints output_map
if storage_map is not None: if storage_map is not None:
from sys import getsizeof
detailed_err_msg += "\nStorage map footprint:\n" detailed_err_msg += "\nStorage map footprint:\n"
for k in storage_map.keys(): for k in storage_map.keys():
if storage_map[k][0] is not None: if storage_map[k][0] is not None:
...@@ -190,13 +185,20 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None): ...@@ -190,13 +185,20 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
if hasattr(storage_map[k][0], 'dtype'): if hasattr(storage_map[k][0], 'dtype'):
dtype = storage_map[k][0].dtype dtype = storage_map[k][0].dtype
if shapeinfo is None: if shapeinfo is None:
detailed_err_msg += "size: %s\n" % numpy.dtype(dtype).itemsize detailed_err_msg += "size: %s Byte(s)\n" % numpy.dtype(dtype).itemsize
else: else:
detailed_err_msg += "size: %s\n" % (numpy.dtype(dtype).itemsize * detailed_err_msg += "size: %s Byte(s)\n" % (numpy.dtype(dtype).itemsize * numpy.prod(shapeinfo))
numpy.prod(shapeinfo))
else: else:
bytes = getsizeof(storage_map[k][0]) bytes = getsizeof(storage_map[k][0])
detailed_err_msg += "size: %s\n" % str(bytes) detailed_err_msg += "elementsize: %s Byte(s)\n" % str(bytes)
else:
hints.append(
"HINT: Use the Theano flag 'exception_verbosity=high'"
" for a debugprint and storage map footprint of this apply node.")
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))
......
...@@ -417,7 +417,7 @@ class Stack(VM): ...@@ -417,7 +417,7 @@ 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) storage_map=storage_map)
for o in current_apply.outputs: for o in current_apply.outputs:
compute_map[o][0] = 1 compute_map[o][0] = 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论