提交 b5ff8452 authored 作者: Reyhane Askari's avatar Reyhane Askari

change of check_stack_trace value names

上级 7834b546
...@@ -1506,12 +1506,13 @@ AddConfigVar('cycle_detection', ...@@ -1506,12 +1506,13 @@ AddConfigVar('cycle_detection',
in_c_key=False) in_c_key=False)
AddConfigVar('check_stack_trace', AddConfigVar('check_stack_trace',
"A flag for checking the stack trace during the optimization" "A flag for checking the stack trace during the optimization process. "
" process. The default is not checking the stack trace of any" "default (off): does not check the stack trace of any optimization "
" optimization. check_all checks if the stack trace is added" "log: inserts a dummy stack trace that identifies the optimization"
" and check_and_skip checks all the stack trace of optimizations" "that inserted that variable."
" but skips the ones that have a dummy value ", "warn: prints a warning if a stack trace is missing"
EnumStr('not_checking', 'check_and_skip', 'check_all'), "raise: raises an exception if a stack trace is missing",
EnumStr('off', 'log', 'warn', 'raise'),
in_c_key=False) in_c_key=False)
......
...@@ -3043,18 +3043,20 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'): ...@@ -3043,18 +3043,20 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'):
class CheckStrackTraceFeature(object): class CheckStrackTraceFeature(object):
def on_import(self, fgraph, node, reason): def on_import(self, fgraph, node, reason):
if theano.config.check_stack_trace == 'check_all': if theano.config.check_stack_trace != 'off' and not check_stack_trace(fgraph, 'all'):
if not check_stack_trace(fgraph, 'all'): if theano.config.check_stack_trace == 'warn':
raise NotImplementedError( warnings.warn(
'Empty stack trace! The optimization that inserted that variable is' + str(reason)) 'Empty stack trace! The optimization that inserted this variable is' + str(reason))
if theano.config.check_stack_trace == 'check_and_skip': if theano.config.check_stack_trace == 'raise':
if not check_stack_trace(fgraph, 'all'): raise NotImplementedError(
apply_nodes_to_check = fgraph.apply_nodes 'Empty stack trace! The optimization that inserted this variable is' + str(reason))
for node in apply_nodes_to_check: if theano.config.check_stack_trace == 'log':
for output in node.outputs: apply_nodes_to_check = fgraph.apply_nodes
if not hasattr(output.tag, 'trace') or not output.tag.trace: for node in apply_nodes_to_check:
output.tag.trace = [[('', 0, 'Empty stack trace! The optimization that' + for output in node.outputs:
'inserted that variable is ' + str(reason), '')]] if not hasattr(output.tag, 'trace') or not output.tag.trace:
output.tag.trace = [[('', 0, 'Empty stack trace! The optimization that' +
'inserted this variable is ' + str(reason), '')]]
class CheckStackTraceOptimization(Optimizer): class CheckStackTraceOptimization(Optimizer):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论