MCPcopy Index your code
hub / github.com/huggingface/diffusers / HookFunctionReference

Class HookFunctionReference

src/diffusers/hooks/hooks.py:144–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

142
143
144class HookFunctionReference:
145 def __init__(self) -> None:
146 """A container class that maintains mutable references to forward pass functions in a hook chain.
147
148 Its mutable nature allows the hook system to modify the execution chain dynamically without rebuilding the
149 entire forward pass structure.
150
151 Attributes:
152 pre_forward: A callable that processes inputs before the main forward pass.
153 post_forward: A callable that processes outputs after the main forward pass.
154 forward: The current forward function in the hook chain.
155 original_forward: The original forward function, stored when a hook provides a custom new_forward.
156
157 The class enables hook removal by allowing updates to the forward chain through reference modification rather
158 than requiring reconstruction of the entire chain. When a hook is removed, only the relevant references need to
159 be updated, preserving the execution order of the remaining hooks.
160 """
161 self.pre_forward = None
162 self.post_forward = None
163 self.forward = None
164 self.original_forward = None
165
166
167class HookRegistry:

Callers 1

register_hookMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…