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

change of check_stack_trace value names

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