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

Function _apply_mag_cache_block_hook

src/diffusers/hooks/mag_cache.py:455–468  ·  view source on GitHub ↗
(
    block: torch.nn.Module,
    state_manager: StateManager,
    config: MagCacheConfig,
    is_tail: bool = False,
)

Source from the content-addressed store, hash-verified

453
454
455def _apply_mag_cache_block_hook(
456 block: torch.nn.Module,
457 state_manager: StateManager,
458 config: MagCacheConfig,
459 is_tail: bool = False,
460) -> None:
461 registry = HookRegistry.check_if_exists_or_initialize(block)
462
463 # Automatically remove existing hook to allow re-application
464 if registry.get_hook(_MAG_CACHE_BLOCK_HOOK) is not None:
465 registry.remove_hook(_MAG_CACHE_BLOCK_HOOK)
466
467 hook = MagCacheBlockHook(state_manager, is_tail, config)
468 registry.register_hook(hook, _MAG_CACHE_BLOCK_HOOK)

Callers 1

apply_mag_cacheFunction · 0.85

Calls 5

MagCacheBlockHookClass · 0.85
get_hookMethod · 0.80
remove_hookMethod · 0.80
register_hookMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…