提交 7f1f0fe9 authored 作者: Hengjean's avatar Hengjean 提交者: Frederic

Reversed useless refactoring.

上级 80db2da2
......@@ -1085,7 +1085,7 @@ class FunctionMaker(object):
# the inputs, outputs, and size of the graph to be optimized
inputs_new = fgraph.inputs
outputs_new = fgraph.outputs
size_new = len(fgraph.nodes)
size_new = len(fgraph.apply_nodes)
need_optimize = False
get_lock()
'''
......@@ -1117,7 +1117,7 @@ class FunctionMaker(object):
for i, graph_old in enumerate(graph_db.keys()):
inputs_old = graph_old.inputs
outputs_old = graph_old.outputs
size_old = len(graph_old.nodes)
size_old = len(graph_old.apply_nodes)
print 'looping through graph_db %d/%d'%(i+1,len(graph_db))
# Some heuristics to check is the same graphs have
# already been optimized before.
......@@ -1155,13 +1155,13 @@ class FunctionMaker(object):
def removeAllFgraph(remove):
if hasattr(remove, 'fgraph'):
remove.fgraph = None
del remove.fgraph
if hasattr(remove, 'owner'):
if remove.owner == None:
remove.fgraph = None
pass
else:
if hasattr(remove.owner, 'fgraph'):
remove.owner.fgraph = None
del remove.owner.fgraph
if hasattr(remove.owner, 'inputs'):
remove.owner.inputs = [removeAllFgraph(
i) for i in remove.owner.inputs]
......
......@@ -753,7 +753,12 @@ class FunctionGraph(utils.object2):
for attr in getattr(feature, "pickle_rm_attr", []):
del d[attr]
# The class Updater take fct as parameter and they are lambda function, so unpicklable.
# del d["execute_callbacks_times"]
# execute_callbacks_times have reference to optimizer, and they can't
# be pickled as the decorators with parameters aren't pickable.
if "execute_callbacks_times" in d:
del d["execute_callbacks_times"]
return d
def __setstate__(self, dct):
......
......@@ -297,6 +297,12 @@ class ReplaceValidate(History, Validator):
print >> out, reason, replacements
raise ReplacementDidntRemovedError()
def __getstate__(self):
d = self.__dict__.copy()
if "history" in d:
del d["history"]
return d
class NodeFinder(Bookkeeper):
......
......@@ -2664,6 +2664,7 @@ def local_useless_tile(node):
except NotScalarConstantError:
return
################
# Flatten Opts #
################
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论