提交 d024e8d1 authored 作者: Olivier Delalleau's avatar Olivier Delalleau

Fix so that manually setting theano.compile.mode.default_mode actually works

上级 328ef064
...@@ -13,7 +13,7 @@ from itertools import chain ...@@ -13,7 +13,7 @@ from itertools import chain
from functools import partial from functools import partial
import io, sys import io, sys
import function_module as F import function_module as F
from mode import default_mode import mode as get_mode
def name_join(*args): def name_join(*args):
...@@ -73,13 +73,15 @@ class Component(object): ...@@ -73,13 +73,15 @@ class Component(object):
""" """
raise NotImplementedError() raise NotImplementedError()
def make_no_init(self, mode=default_mode): def make_no_init(self, mode=None):
""" """
Allocates the necessary containers using allocate() and uses Allocates the necessary containers using allocate() and uses
build() with the provided mode to make an instance which will build() with the provided mode to make an instance which will
be returned. The initialize() method of the instance will not be returned. The initialize() method of the instance will not
be called. be called.
""" """
if mode is None:
mode = get_mode.default_mode
memo = {} memo = {}
self.allocate(memo) self.allocate(memo)
rval = self.build(mode, memo) rval = self.build(mode, memo)
...@@ -93,7 +95,7 @@ class Component(object): ...@@ -93,7 +95,7 @@ class Component(object):
arguments and the keyword arguments. If 'mode' is in the arguments and the keyword arguments. If 'mode' is in the
keyword arguments it will be passed to build(). keyword arguments it will be passed to build().
""" """
mode = kwargs.pop('mode', default_mode) mode = kwargs.pop('mode', get_mode.default_mode)
rval = self.make_no_init(mode) rval = self.make_no_init(mode)
if hasattr(rval, 'initialize'): if hasattr(rval, 'initialize'):
rval.initialize(*args, **kwargs) rval.initialize(*args, **kwargs)
...@@ -1075,7 +1077,7 @@ class Module(ComponentDict): ...@@ -1075,7 +1077,7 @@ class Module(ComponentDict):
""" """
self.make_module_instance(args,kwargs) self.make_module_instance(args,kwargs)
mode = kwargs.pop('mode', default_mode) mode = kwargs.pop('mode', get_mode.default_mode)
rval = self.make_no_init(mode) rval = self.make_no_init(mode)
if hasattr(rval, 'initialize'): if hasattr(rval, 'initialize'):
rval.initialize(*args, **kwargs) rval.initialize(*args, **kwargs)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论