提交 58326c38 authored 作者: Reyhane Askari's avatar Reyhane Askari

check_and_skip implemented so a dummy value is added to empty stacks

上级 3497e16a
...@@ -1511,7 +1511,7 @@ AddConfigVar('check_stack_trace', ...@@ -1511,7 +1511,7 @@ AddConfigVar('check_stack_trace',
" optimization. check_all checks if the stack trace is added" " optimization. check_all checks if the stack trace is added"
" and check_and_skip checks all the stack trace of optimizations" " and check_and_skip checks all the stack trace of optimizations"
" but skips the ones that have a dummy value ", " but skips the ones that have a dummy value ",
EnumStr('check_all', 'not_checking', 'check_and_skip'), EnumStr('check_and_skip', 'check_all', 'not_checking'),
in_c_key=False) in_c_key=False)
......
...@@ -3041,20 +3041,29 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'): ...@@ -3041,20 +3041,29 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'):
return True return True
class CheckStrackTracehFeature(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 not check_stack_trace(fgraph, 'all'): if not check_stack_trace(fgraph, 'all'):
raise NotImplementedError( raise NotImplementedError(
"Empty stack trace! The optimization that whose" "Empty stack trace! The optimization that whose"
" stacktrace is empty is %s", reason) " stacktrace is empty is %s", 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 = ['This is a dummy value! The stack trace of ' +
str(reason) + ' was empty!']
class CheckStackTraceOptimization(Optimizer): class CheckStackTraceOptimization(Optimizer):
"""Optimizer that serves to add ShapeFeature as an fgraph feature.""" """Optimizer that serves to add ShapeFeature as an fgraph feature."""
def add_requirements(self, fgraph): def add_requirements(self, fgraph):
if not hasattr(fgraph, 'CheckStrackTracehFeature'): if not hasattr(fgraph, 'CheckStrackTraceFeature'):
fgraph.attach_feature(CheckStrackTracehFeature()) fgraph.attach_feature(CheckStrackTraceFeature())
def apply(self, fgraph): def apply(self, fgraph):
pass pass
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论