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

Class MultiplyHook

tests/hooks/test_hooks.py:80–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

78
79
80class MultiplyHook(ModelHook):
81 def __init__(self, value: int):
82 super().__init__()
83 self.value = value
84
85 def pre_forward(self, module, *args, **kwargs):
86 logger.debug("MultiplyHook pre_forward")
87 args = ((x * self.value) if torch.is_tensor(x) else x for x in args)
88 return args, kwargs
89
90 def post_forward(self, module, output):
91 logger.debug("MultiplyHook post_forward")
92 return output
93
94 def __repr__(self):
95 return f"MultiplyHook(value={self.value})"
96
97
98class StatefulAddHook(ModelHook):

Calls

no outgoing calls

Used in the wild real call sites across dependent graphs

searching dependent graphs…