提交 ec99e722 authored 作者: Frederic Bastien's avatar Frederic Bastien

Speed up Merge opt. When merging Constant, no need to call validate

上级 a552d638
...@@ -885,7 +885,13 @@ class MergeOptimizer(Optimizer): ...@@ -885,7 +885,13 @@ class MergeOptimizer(Optimizer):
pairs = [(pairs[0][1], pairs[0][0])] pairs = [(pairs[0][1], pairs[0][0])]
try: try:
fgraph.replace_all_validate(pairs, 'MergeOptimizer') # If all Constants, no need to call validate.
# Only need to check one of the var of each pairs.
# If it is a Constant, the other must also be a Constant as we merge them.
if all([isinstance(old, graph.Constant) for old, new in pairs]):
fgraph.replace_all(pairs, 'MergeOptimizer')
else:
fgraph.replace_all_validate(pairs, 'MergeOptimizer')
except InconsistencyError: except InconsistencyError:
success = False success = False
nb_fail += 1 nb_fail += 1
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论