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

Re-add the optimization in ShapeFeature made by James that was lost in the rebase.

上级 6ef3d960
...@@ -946,11 +946,17 @@ class ShapeFeature(object): ...@@ -946,11 +946,17 @@ class ShapeFeature(object):
# In either case, r could be in shape_of.values(), that is, r itself # In either case, r could be in shape_of.values(), that is, r itself
# is the shape of something. In that case, we want to update # is the shape of something. In that case, we want to update
# the value in shape_of, to keep it up-to-date. # the value in shape_of, to keep it up-to-date.
for k, v in self.shape_of.iteritems(): for v in self.shape_of_reverse_index.get(r, []):
if v is not None: # The reverse index is only approximate. It is not updated on
for ii, vi in enumerate(v): # deletion of variables, or on change_input so it might be the
if vi == r: # case that there are a few extra `v`'s in it that no longer have
self.set_shape_i(k, ii, new_r) # a shape of r or possibly have been deleted from shape_of
# entirely. The important thing is that it permits to recall
# all variables with r in their shape.
for ii, svi in enumerate(self.shape_of.get(v, [])):
if svi == r:
self.set_shape_i(v, ii, new_r)
self.shape_of_reverse_index[r] = set()
class ShapeOptimizer(Optimizer): class ShapeOptimizer(Optimizer):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论