@@ -521,72 +521,72 @@ def fast_destroy(self, fgraph, app, reason):
521521 # assert len(v) <= 1
522522 # assert len(d) <= 1
523523
524- def on_import (self , fgraph , app , reason ):
524+ def on_import (self , fgraph , node , reason ):
525525 """
526526 Add Apply instance to set which must be computed.
527527
528528 """
529- if app in self .debug_all_apps :
529+ if node in self .debug_all_apps :
530530 raise ProtocolError ("double import" )
531- self .debug_all_apps .add (app )
531+ self .debug_all_apps .add (node )
532532 # print 'DH IMPORT', app, id(app), id(self), len(self.debug_all_apps)
533533
534534 # If it's a destructive op, add it to our watch list
535- dmap = app .op .destroy_map
536- vmap = app .op .view_map
535+ dmap = node .op .destroy_map
536+ vmap = node .op .view_map
537537 if dmap :
538- self .destroyers .add (app )
538+ self .destroyers .add (node )
539539 if self .algo == "fast" :
540- self .fast_destroy (fgraph , app , reason )
540+ self .fast_destroy (fgraph , node , reason )
541541
542542 # add this symbol to the forward and backward maps
543543 for o_idx , i_idx_list in vmap .items ():
544544 if len (i_idx_list ) > 1 :
545545 raise NotImplementedError (
546- "destroying this output invalidates multiple inputs" , (app .op )
546+ "destroying this output invalidates multiple inputs" , (node .op )
547547 )
548- o = app .outputs [o_idx ]
549- i = app .inputs [i_idx_list [0 ]]
548+ o = node .outputs [o_idx ]
549+ i = node .inputs [i_idx_list [0 ]]
550550 self .view_i [o ] = i
551551 self .view_o .setdefault (i , OrderedSet ()).add (o )
552552
553553 # update self.clients
554- for i , input in enumerate (app .inputs ):
555- self .clients .setdefault (input , {}).setdefault (app , 0 )
556- self .clients [input ][app ] += 1
554+ for i , input in enumerate (node .inputs ):
555+ self .clients .setdefault (input , {}).setdefault (node , 0 )
556+ self .clients [input ][node ] += 1
557557
558- for i , output in enumerate (app .outputs ):
558+ for i , output in enumerate (node .outputs ):
559559 self .clients .setdefault (output , {})
560560
561561 self .stale_droot = True
562562
563- def on_prune (self , fgraph , app , reason ):
563+ def on_prune (self , fgraph , node , reason ):
564564 """
565565 Remove Apply instance from set which must be computed.
566566
567567 """
568- if app not in self .debug_all_apps :
568+ if node not in self .debug_all_apps :
569569 raise ProtocolError ("prune without import" )
570- self .debug_all_apps .remove (app )
570+ self .debug_all_apps .remove (node )
571571
572572 # UPDATE self.clients
573- for input in set (app .inputs ):
574- del self .clients [input ][app ]
573+ for input in set (node .inputs ):
574+ del self .clients [input ][node ]
575575
576- if app .op .destroy_map :
577- self .destroyers .remove (app )
576+ if node .op .destroy_map :
577+ self .destroyers .remove (node )
578578
579579 # Note: leaving empty client dictionaries in the struct.
580580 # Why? It's a pain to remove them. I think they aren't doing any harm, they will be
581581 # deleted on_detach().
582582
583583 # UPDATE self.view_i, self.view_o
584- for o_idx , i_idx_list in app .op .view_map .items ():
584+ for o_idx , i_idx_list in node .op .view_map .items ():
585585 if len (i_idx_list ) > 1 :
586586 # destroying this output invalidates multiple inputs
587587 raise NotImplementedError ()
588- o = app .outputs [o_idx ]
589- i = app .inputs [i_idx_list [0 ]]
588+ o = node .outputs [o_idx ]
589+ i = node .inputs [i_idx_list [0 ]]
590590
591591 del self .view_i [o ]
592592
@@ -595,53 +595,53 @@ def on_prune(self, fgraph, app, reason):
595595 del self .view_o [i ]
596596
597597 self .stale_droot = True
598- if app in self .fail_validate :
599- del self .fail_validate [app ]
598+ if node in self .fail_validate :
599+ del self .fail_validate [node ]
600600
601- def on_change_input (self , fgraph , app , i , old_r , new_r , reason ):
601+ def on_change_input (self , fgraph , node , i , var , new_var , reason = None ):
602602 """
603- app .inputs[i] changed from old_r to new_r .
603+ node .inputs[i] changed from var to new_var .
604604
605605 """
606- if isinstance (app .op , Output ):
607- # app == 'output' is special key that means FunctionGraph is redefining which nodes are being
606+ if isinstance (node .op , Output ):
607+ # node == 'output' is special key that means FunctionGraph is redefining which nodes are being
608608 # considered 'outputs' of the graph.
609609 pass
610610 else :
611- if app not in self .debug_all_apps :
611+ if node not in self .debug_all_apps :
612612 raise ProtocolError ("change without import" )
613613
614614 # UPDATE self.clients
615- self .clients [old_r ][ app ] -= 1
616- if self .clients [old_r ][ app ] == 0 :
617- del self .clients [old_r ][ app ]
615+ self .clients [var ][ node ] -= 1
616+ if self .clients [var ][ node ] == 0 :
617+ del self .clients [var ][ node ]
618618
619- self .clients .setdefault (new_r , {}).setdefault (app , 0 )
620- self .clients [new_r ][ app ] += 1
619+ self .clients .setdefault (new_var , {}).setdefault (node , 0 )
620+ self .clients [new_var ][ node ] += 1
621621
622622 # UPDATE self.view_i, self.view_o
623- for o_idx , i_idx_list in app .op .view_map .items ():
623+ for o_idx , i_idx_list in node .op .view_map .items ():
624624 if len (i_idx_list ) > 1 :
625625 # destroying this output invalidates multiple inputs
626626 raise NotImplementedError ()
627627 i_idx = i_idx_list [0 ]
628- output = app .outputs [o_idx ]
628+ output = node .outputs [o_idx ]
629629 if i_idx == i :
630- if app .inputs [i_idx ] is not new_r :
630+ if node .inputs [i_idx ] is not new_var :
631631 raise ProtocolError ("wrong new_r on change" )
632632
633- self .view_i [output ] = new_r
633+ self .view_i [output ] = new_var
634634
635- self .view_o [old_r ].remove (output )
636- if not self .view_o [old_r ]:
637- del self .view_o [old_r ]
635+ self .view_o [var ].remove (output )
636+ if not self .view_o [var ]:
637+ del self .view_o [var ]
638638
639- self .view_o .setdefault (new_r , OrderedSet ()).add (output )
639+ self .view_o .setdefault (new_var , OrderedSet ()).add (output )
640640
641641 if self .algo == "fast" :
642- if app in self .fail_validate :
643- del self .fail_validate [app ]
644- self .fast_destroy (fgraph , app , reason )
642+ if node in self .fail_validate :
643+ del self .fail_validate [node ]
644+ self .fast_destroy (fgraph , node , reason )
645645 self .stale_droot = True
646646
647647 def validate (self , fgraph ):
0 commit comments