r""" Returns: `dict` of attention processors: A dictionary containing all attention processors used in the model with indexed by its weight name.
(self)
| 517 | @property |
| 518 | # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.attn_processors |
| 519 | def attn_processors(self) -> Dict[str, AttentionProcessor]: |
| 520 | r""" |
| 521 | Returns: |
| 522 | `dict` of attention processors: A dictionary containing all attention processors used in the model with |
| 523 | indexed by its weight name. |
| 524 | """ |
| 525 | # set recursively |
| 526 | processors = {} |
| 527 | |
| 528 | def fn_recursive_add_processors(name: str, module: torch.nn.Module, processors: Dict[str, AttentionProcessor]): |
| 529 | if hasattr(module, "get_processor"): |
| 530 | processors[f"{name}.processor"] = module.get_processor(return_deprecated_lora=True) |
| 531 | |
| 532 | for sub_name, child in module.named_children(): |
| 533 | fn_recursive_add_processors(f"{name}.{sub_name}", child, processors) |
| 534 | |
| 535 | return processors |
| 536 | |
| 537 | for name, module in self.named_children(): |
| 538 | fn_recursive_add_processors(name, module, processors) |
| 539 | |
| 540 | return processors |
| 541 | |
| 542 | # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.set_attn_processor |
| 543 | def set_attn_processor(self, processor: Union[AttentionProcessor, Dict[str, AttentionProcessor]]): |
nothing calls this directly
no outgoing calls
no test coverage detected