changed the THEANO_DEBUGMODE_CHECK_STRIDES env variable, 0 no check, 1 warn, 2

err.
上级 985e62a0
...@@ -463,7 +463,12 @@ def _is_function_output(node): ...@@ -463,7 +463,12 @@ def _is_function_output(node):
def _is_used_in_graph(node): def _is_used_in_graph(node):
return not(_is_function_output(node) or node.clients==[]) return not(_is_function_output(node) or node.clients==[])
def _check_strides_match(a, b, raise_on_err, op): def _check_strides_match(a, b, warn_err, op):
"""
param: warn_err: if 0, no warning, if 1 warning, if 2 error
"""
if warn_err==0: return
try: try:
strides_eq = a.strides == b.strides strides_eq = a.strides == b.strides
except: except:
...@@ -471,7 +476,7 @@ def _check_strides_match(a, b, raise_on_err, op): ...@@ -471,7 +476,7 @@ def _check_strides_match(a, b, raise_on_err, op):
if not strides_eq: if not strides_eq:
e = TypeError('Stride mismatch', (a.shape, b.shape, a.strides, b.strides, str(op))) e = TypeError('Stride mismatch', (a.shape, b.shape, a.strides, b.strides, str(op)))
if raise_on_err: if warn_err==2:
raise e raise e
else: else:
print >> sys.stderr, 'WARNING:', e print >> sys.stderr, 'WARNING:', e
...@@ -1372,10 +1377,10 @@ class DebugMode(Mode): ...@@ -1372,10 +1377,10 @@ class DebugMode(Mode):
Should we check for (and complain about) NaN/Inf ndarray elements? Should we check for (and complain about) NaN/Inf ndarray elements?
""" """
require_matching_strides = bool(int(os.getenv('THEANO_DEBUGMODE_CHECK_STRIDES', 0))) require_matching_strides = bool(int(os.getenv('THEANO_DEBUGMODE_CHECK_STRIDES', 1)))
""" """
Should we check for (and complain about) Ops whose python and C outputs are ndarrays with Should we check for (and complain about) Ops whose python and C outputs are ndarrays with
different strides? (This can catch bugs, but is generally overly strict.) different strides? (This can catch bugs, but is generally overly strict.) 0 no check, 1 warn, 2 err.
""" """
# This function will be used to create a FunctionMaker in # This function will be used to create a FunctionMaker in
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论