@@ -177,7 +177,7 @@ def _contains_cycle(fgraph, orderings):
177
177
178
178
def _build_droot_impact (destroy_handler ):
179
179
droot = {} # destroyed view + nonview variables -> foundation
180
- impact = {} # destroyed nonview variable -> it + all views of it
180
+ # impact = {} # destroyed nonview variable -> it + all views of it
181
181
root_destroyer = {} # root -> destroyer apply
182
182
183
183
for app in destroy_handler .destroyers :
@@ -202,24 +202,26 @@ def _build_droot_impact(destroy_handler):
202
202
203
203
# The code here add all the variables that are views of r into
204
204
# an OrderedSet input_impact
205
- input_impact = OrderedSet ()
205
+ # input_impact = OrderedSet()
206
206
207
207
q = deque ()
208
208
q .append (input_root )
209
+ view_o = destroy_handler .view_o
209
210
while len (q ) > 0 :
210
211
v = q .popleft ()
211
- for n in destroy_handler .view_o .get (v , []):
212
- input_impact .add (n )
212
+ for n in view_o .get (v , []):
213
+ droot [n ] = input_root
214
+ # input_impact.add(n)
213
215
q .append (n )
214
216
215
- for v in input_impact :
216
- assert v not in droot
217
- droot [v ] = input_root
217
+ # for v in input_impact:
218
+ # assert v not in droot
219
+ # droot[v] = input_root
218
220
219
- impact [input_root ] = input_impact
220
- impact [input_root ].add (input_root )
221
+ # impact[input_root] = input_impact
222
+ # impact[input_root].add(input_root)
221
223
222
- return droot , impact , root_destroyer
224
+ return droot , root_destroyer
223
225
224
226
225
227
def inplace_candidates (fgraph , inputs , protected_inputs = None ):
@@ -336,15 +338,10 @@ def __init__(self, do_imports_on_attach=True, algo=None):
336
338
self .droot = {}
337
339
338
340
"""
339
- Maps a variable to all variables that are indirect or direct views of it
341
+ Maps a "foundation" destroyed variable to all variables that are indirect or direct views of it
340
342
(including itself) essentially the inverse of droot.
341
- TODO: do all variables appear in this dict, or only those that are
342
- foundations?
343
- TODO: do only destroyed variables go in here? one old docstring said so.
344
- TODO: rename to x_to_views after reverse engineering what x is
345
-
346
343
"""
347
- self .impact = {}
344
+ # self.impact = {}
348
345
349
346
"""
350
347
If a var is destroyed, then this dict will map
@@ -454,9 +451,9 @@ def refresh_droot_impact(self):
454
451
455
452
"""
456
453
if self .stale_droot :
457
- self .droot , self .impact , self . root_destroyer = _build_droot_impact (self )
454
+ self .droot , self .root_destroyer = _build_droot_impact (self )
458
455
self .stale_droot = False
459
- return self .droot , self .impact , self . root_destroyer
456
+ return self .droot , self .root_destroyer
460
457
461
458
def on_detach (self , fgraph ):
462
459
if fgraph is not self .fgraph :
0 commit comments