提交 e0e7382a authored 作者: Frederic's avatar Frederic

Disable interactive debugger when inserting deep copy.

上级 26b235cf
...@@ -1655,11 +1655,11 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions ...@@ -1655,11 +1655,11 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
try: try:
theano.config.compute_test_value = "off" theano.config.compute_test_value = "off"
optimizer(env) optimizer(env)
theano.compile.function_module.insert_deepcopy(env, inputs, outputs+additional_outputs)
finally: finally:
theano.config.compute_test_value = compute_test_value_orig theano.config.compute_test_value = compute_test_value_orig
theano.compile.function_module.insert_deepcopy(env, inputs, outputs+additional_outputs)
if i: if i:
li = env.equivalence_tracker.event_list li = env.equivalence_tracker.event_list
l0 = env0.equivalence_tracker.event_list l0 = env0.equivalence_tracker.event_list
......
...@@ -995,17 +995,17 @@ class FunctionMaker(object): ...@@ -995,17 +995,17 @@ class FunctionMaker(object):
start_optimizer = time.time() start_optimizer = time.time()
optimizer(env) optimizer(env)
end_optimizer = time.time() end_optimizer = time.time()
finally:
theano.config.compute_test_value = compute_test_value_orig
opt_time = end_optimizer - start_optimizer opt_time = end_optimizer - start_optimizer
mode.optimizer_time += opt_time mode.optimizer_time += opt_time
if profile: if profile:
profile.optimizer_time += opt_time profile.optimizer_time += opt_time
_logger.debug('Optimizing took %f seconds', opt_time) _logger.debug('Optimizing took %f seconds', opt_time)
#Add deep copy to respect the memory interface #Add deep copy to respect the memory interface
insert_deepcopy(env, inputs, outputs+additional_outputs) insert_deepcopy(env, inputs, outputs+additional_outputs)
finally:
theano.config.compute_test_value = compute_test_value_orig
# initialize the linker # initialize the linker
if not hasattr(linker, 'accept'): if not hasattr(linker, 'accept'):
......
...@@ -372,3 +372,15 @@ class TestComputeTestValue(unittest.TestCase): ...@@ -372,3 +372,15 @@ class TestComputeTestValue(unittest.TestCase):
finally: finally:
theano.config.compute_test_value = orig_compute_test_value theano.config.compute_test_value = orig_compute_test_value
def test_disabled_during_compilation(self):
# We test that it is disabled when we include deep copy in the code
# This don't test that it is disabled during optimization, but the code do it.
orig_compute_test_value = theano.config.compute_test_value
try:
theano.config.compute_test_value = 'raise'
init_Mu1 = theano.shared(numpy.zeros((5,),dtype=config.floatX)).dimshuffle('x',0)
f = theano.function([], outputs=[init_Mu1])
finally:
theano.config.compute_test_value = orig_compute_test_value
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论