提交 2efb1167 authored 作者: Frederic Bastien's avatar Frederic Bastien

If DebugMode receive a specific linker, raise an error at it can only use its own linker.

updated Doc and the handling of theano flags to don't pass him one linker.
上级 4d263eb0
...@@ -1674,6 +1674,9 @@ class DebugMode(Mode): ...@@ -1674,6 +1674,9 @@ class DebugMode(Mode):
If any of these arguments (except optimizer) is not None, it overrides the class default. If any of these arguments (except optimizer) is not None, it overrides the class default.
The linker arguments is not used. It is set their to allow Mode.requiring() and some other fct to work with DebugMode too. The linker arguments is not used. It is set their to allow Mode.requiring() and some other fct to work with DebugMode too.
""" """
if linker is not None and not isinstance(linker,_Linker):
raise Exception("DebugMode can use only its own linker! Don't give him one to use it.")
super(DebugMode, self).__init__( super(DebugMode, self).__init__(
optimizer=optimizer, optimizer=optimizer,
linker=_Linker) linker=_Linker)
......
...@@ -285,10 +285,13 @@ def get_mode(orig_string): ...@@ -285,10 +285,13 @@ def get_mode(orig_string):
if instanciated_default_mode: if instanciated_default_mode:
return instanciated_default_mode return instanciated_default_mode
#need to import later to break circular dependency. #need to import later to break circular dependency.
from profilemode import ProfileMode,prof_mode_instance_to_print if string == 'DebugMode':
from debugmode import DebugMode from debugmode import DebugMode
#DebugMode use its own linker.
ret = eval(string+'(linker=config.linker, optimizer=config.optimizer)') ret = eval(string+'(optimizer=config.optimizer)')
else:
from profilemode import ProfileMode,prof_mode_instance_to_print
ret = eval(string+'(linker=config.linker, optimizer=config.optimizer)')
elif not predefined_modes.has_key(string): elif not predefined_modes.has_key(string):
raise Exception("No predefined mode exist for string: %s"%string) raise Exception("No predefined mode exist for string: %s"%string)
......
...@@ -49,14 +49,13 @@ try: ...@@ -49,14 +49,13 @@ try:
subprocess.Popen('gcc', stdout=subprocess.PIPE, stderr=subprocess.PIPE) subprocess.Popen('gcc', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# Keep the default linker the same as the one for the mode FAST_RUN # Keep the default linker the same as the one for the mode FAST_RUN
AddConfigVar('linker', AddConfigVar('linker',
"Default linker. If not None, will use this linker with the Mode "+ "Default linker used if the theano flags mode is Mode or ProfileMode",
"object(not ProfileMode or DebugMode)", EnumStr('c|py', 'py', 'c', 'c|py_nogc', 'c&py'))
EnumStr('c|py', 'py', 'c', 'c|py_nogc', 'c&py'))
except OSError: except OSError:
# gcc is not present, linker should default to python only # gcc is not present, linker should default to python only
AddConfigVar('linker', AddConfigVar('linker',
"Default linker. If not None, will use this linker with the Mode object(not ProfileMode or DebugMode)", "Default linker used if the theano flags mode is Mode or ProfileMode",
EnumStr('py', 'c|py', 'c', 'c|py_nogc', 'c&py')) EnumStr('py', 'c|py', 'c', 'c|py_nogc', 'c&py'))
warning('GCC not detected ! Theano will be unable to execute optimized '+ warning('GCC not detected ! Theano will be unable to execute optimized '+
'C-implementations (for both CPU and GPU) and will default to '+ 'C-implementations (for both CPU and GPU) and will default to '+
'Python implementations. Performance will be severely degraded.') 'Python implementations. Performance will be severely degraded.')
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论