File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -103,10 +103,20 @@ def reset_state(self, module: torch.nn.Module):
103103
104104class  HookFunctionReference :
105105    def  __init__ (self ) ->  None :
106-         """ 
107-         Holding class for forward functions references used in Diffusers hooks. This struct allows you to easily swap 
108-         out the forward function in the when a hook is removed from a modules hook registry. 
106+         """A container class that maintains mutable references to forward pass functions in a hook chain. 
107+ 
108+         Its mutable nature allows the hook system to modify the execution chain dynamically without rebuilding the 
109+         entire forward pass structure. 
110+ 
111+         Attributes: 
112+             pre_forward: A callable that processes inputs before the main forward pass. 
113+             post_forward: A callable that processes outputs after the main forward pass. 
114+             forward: The current forward function in the hook chain. 
115+             original_forward: The original forward function, stored when a hook provides a custom new_forward. 
109116
117+         The class enables hook removal by allowing updates to the forward chain through reference modification rather 
118+         than requiring reconstruction of the entire chain. When a hook is removed, only the relevant references need to 
119+         be updated, preserving the execution order of the remaining hooks. 
110120        """ 
111121        self .pre_forward  =  None 
112122        self .post_forward  =  None 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments