提交 79100e59 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Merged

...@@ -188,6 +188,16 @@ import theano and print the config variable, as in: ...@@ -188,6 +188,16 @@ import theano and print the config variable, as in:
When the mode is Mode, it sets the default optimizer used. When the mode is Mode, it sets the default optimizer used.
.. attribute:: on_opt_error
String value: 'warn' or 'raise'
Default: 'warn'
When a crash occurs while trying to apply some optimization, either warn
the user and skip this optimization ('warn'), or raise the exception
('raise').
.. attribute:: config.warn.ignore_bug_before .. attribute:: config.warn.ignore_bug_before
String value: 'None', 'all', '0.3' String value: 'None', 'all', '0.3'
......
...@@ -71,6 +71,10 @@ AddConfigVar('optimizer', ...@@ -71,6 +71,10 @@ AddConfigVar('optimizer',
"Default optimizer. If not None, will use this linker with the Mode object(not ProfileMode or DebugMode)", "Default optimizer. If not None, will use this linker with the Mode object(not ProfileMode or DebugMode)",
EnumStr('fast_run', 'merge', 'fast_compile', 'None')) EnumStr('fast_run', 'merge', 'fast_compile', 'None'))
AddConfigVar('on_opt_error',
"What to do when an optimization crashes: warn and skip it, or raise the exception",
EnumStr('warn', 'raise'))
AddConfigVar('home', AddConfigVar('home',
"User home directory", "User home directory",
StrParam(os.getenv("HOME", os.path.expanduser('~')))) StrParam(os.getenv("HOME", os.path.expanduser('~'))))
......
...@@ -14,9 +14,10 @@ import utils ...@@ -14,9 +14,10 @@ import utils
import unify import unify
import toolbox import toolbox
import op import op
import theano
from theano import config
from theano.gof.python25 import any, all from theano.gof.python25 import any, all
from theano.configparser import AddConfigVar, BoolParam, config from theano.configparser import AddConfigVar, BoolParam, config
import theano
#if sys.version_info[:2] >= (2,5): #if sys.version_info[:2] >= (2,5):
# from collections import defaultdict # from collections import defaultdict
...@@ -122,6 +123,8 @@ class SeqOptimizer(Optimizer, list): ...@@ -122,6 +123,8 @@ class SeqOptimizer(Optimizer, list):
_logger.error("ERROR: SeqOptimizer apply %s"% str(optimizer)) _logger.error("ERROR: SeqOptimizer apply %s"% str(optimizer))
_logger.error("Traceback:") _logger.error("Traceback:")
_logger.error(traceback.format_exc()) _logger.error(traceback.format_exc())
if config.on_opt_error == 'raise':
raise exc
def __init__(self, *opts, **kw): def __init__(self, *opts, **kw):
"""WRITEME""" """WRITEME"""
...@@ -767,7 +770,7 @@ class NavigatorOptimizer(Optimizer): ...@@ -767,7 +770,7 @@ class NavigatorOptimizer(Optimizer):
_logger.error("ERROR: Optimization failure due to: %s" % str(local_opt)) _logger.error("ERROR: Optimization failure due to: %s" % str(local_opt))
_logger.error("TRACEBACK:") _logger.error("TRACEBACK:")
_logger.error(traceback.format_exc()) _logger.error(traceback.format_exc())
if isinstance(exc, AssertionError): if isinstance(exc, AssertionError) or config.on_opt_error == 'raise':
raise exc raise exc
@staticmethod @staticmethod
def warn_inplace(exc, nav, repl_pairs, local_opt): def warn_inplace(exc, nav, repl_pairs, local_opt):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论