MCPcopy Create free account
hub / github.com/AMAP-ML/EMF / attn_processors

Method attn_processors

sana_transformer.py:433–454  ·  view source on GitHub ↗

r""" Returns: `dict` of attention processors: A dictionary containing all attention processors used in the model with indexed by its weight name.

(self)

Source from the content-addressed store, hash-verified

431 @property
432 # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.attn_processors
433 def attn_processors(self) -> Dict[str, AttentionProcessor]:
434 r"""
435 Returns:
436 `dict` of attention processors: A dictionary containing all attention processors used in the model with
437 indexed by its weight name.
438 """
439 # set recursively
440 processors = {}
441
442 def fn_recursive_add_processors(name: str, module: torch.nn.Module, processors: Dict[str, AttentionProcessor]):
443 if hasattr(module, "get_processor"):
444 processors[f"{name}.processor"] = module.get_processor()
445
446 for sub_name, child in module.named_children():
447 fn_recursive_add_processors(f"{name}.{sub_name}", child, processors)
448
449 return processors
450
451 for name, module in self.named_children():
452 fn_recursive_add_processors(name, module, processors)
453
454 return processors
455
456 # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.set_attn_processor
457 def set_attn_processor(self, processor: Union[AttentionProcessor, Dict[str, AttentionProcessor]]):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected