提交 3540ba9e authored 作者: James Bergstra's avatar James Bergstra

add_tag_grace_on_call speeds up optimization

Adding tag traces is expensive. This PR disables adding tag traces during the optimization process itself, which is anyway not the point of tag traces. This saves 10 seconds of compilation on a graph I'm working with that ends up with about 240 nodes.
上级 d63ae441
......@@ -994,6 +994,8 @@ class FunctionMaker(object):
try:
theano.config.compute_test_value = "off"
start_optimizer = time.time()
add_stack_trace_on_call = gof.Op.add_stack_trace_on_call
gof.Op.add_stack_trace_on_call = False
optimizer(env)
end_optimizer = time.time()
......@@ -1007,6 +1009,7 @@ class FunctionMaker(object):
insert_deepcopy(env, inputs, outputs+additional_outputs)
finally:
theano.config.compute_test_value = compute_test_value_orig
gof.Op.add_stack_trace_on_call = add_stack_trace_on_call
# initialize the linker
if not hasattr(linker, 'accept'):
......
......@@ -310,6 +310,13 @@ class PureOp(object):
"""
add_stack_trace_on_call = True
"""This class variable governs whether __call__ adds a stack trace to the node it creates.
The tag trace is meant to connect a node to the line a user typed. It is nice for
debugging. It does not make as much sense during optimizations to store this information.
"""
#############
# make_node #
#############
......@@ -367,6 +374,7 @@ class PureOp(object):
"""
node = self.make_node(*inputs, **kwargs)
if self.add_stack_trace_on_call:
self.add_tag_trace(node)
if config.compute_test_value != 'off':
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论