提交 8dea107d authored 作者: abergeron's avatar abergeron

Merge pull request #2098 from nouiz/none_opt

[MRG] fix gh-2091
......@@ -89,19 +89,23 @@ def register_linker(name, linker):
exclude = []
if not theano.config.cxx:
exclude = ['cxx_only']
OPT_NONE = gof.Query(include=[], exclude=exclude)
OPT_MERGE = gof.Query(include=['merge'], exclude=exclude)
OPT_FAST_RUN = gof.Query(include=['fast_run'], exclude=exclude)
OPT_FAST_RUN_STABLE = OPT_FAST_RUN.requiring('stable')
OPT_FAST_COMPILE = gof.Query(include=['fast_compile'], exclude=exclude)
OPT_STABILIZE = gof.Query(include=['fast_run'], exclude=exclude)
OPT_STABILIZE.position_cutoff = 1.5000001
OPT_NONE.name = 'OPT_NONE'
OPT_MERGE.name = 'OPT_MERGE'
OPT_FAST_RUN.name = 'OPT_FAST_RUN'
OPT_FAST_RUN_STABLE.name = 'OPT_FAST_RUN_STABLE'
OPT_FAST_COMPILE.name = 'OPT_FAST_COMPILE'
OPT_STABILIZE.name = 'OPT_STABILIZE'
predefined_optimizers = {
None: (lambda fgraph: None),
'None': (lambda fgraph: None),
None: OPT_NONE,
'None': OPT_NONE,
'merge': gof.MergeOptimizer(),
'fast_run': OPT_FAST_RUN,
'fast_run_stable': OPT_FAST_RUN_STABLE,
......@@ -166,14 +170,14 @@ class PrintCurrentFunctionGraph(gof.Optimizer):
optdb = gof.SequenceDB()
optdb.register('merge1', gof.MergeOptimizer(),
0, 'fast_run', 'fast_compile')
0, 'fast_run', 'fast_compile', 'merge')
# rearranges elemwise expressions
optdb.register('canonicalize', gof.EquilibriumDB(),
1, 'fast_run', 'fast_compile')
optdb.register('merge1.2', gof.MergeOptimizer(),
1.2, 'fast_run', 'fast_compile')
1.2, 'fast_run', 'fast_compile', 'merge')
optdb.register('Print1.21', PrintCurrentFunctionGraph('Post-canonicalize'),
1.21,) # 'fast_run', 'fast_compile')
......@@ -199,14 +203,14 @@ optdb.register('specialize_device', gof.EquilibriumDB(),
# especially constant merge
optdb.register('merge2', gof.MergeOptimizer(),
49, 'fast_run')
49, 'fast_run', 'merge')
optdb.register('add_destroy_handler', AddDestroyHandler(),
49.5, 'fast_run', 'inplace')
# final pass just to make sure
optdb.register('merge3', gof.MergeOptimizer(),
100, 'fast_run')
100, 'fast_run', 'merge')
class Mode(object):
......
......@@ -61,7 +61,7 @@ from theano.gof.opt import (
Optimizer,
optimizer, inplace_optimizer,
SeqOptimizer,
MergeOptimizer, MergeOptMerge,
MergeOptimizer,
LocalOptimizer, local_optimizer, LocalOptGroup,
OpSub, OpRemove, PatternSub,
NavigatorOptimizer, TopoOptimizer, EquilibriumOptimizer,
......
......@@ -708,18 +708,6 @@ def is_same_graph_with_merge(var1, var2, givens=None):
return o1 is o2
def MergeOptMerge(opt):
"""WRITEME
Returns an Optimizer that merges the graph then applies the
optimizer in opt and then merges the graph again in case the
opt introduced additional similarities.
"""
merger = merge_optimizer
opt = SeqOptimizer([merger, opt, merger])
opt.name = "MergeOptMerge"
return opt
def pre_constant_merge(vars):
"""
Merge constants in the subgraph used to compute nodes in `vars`.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论