r""" Returns: `dict` of attention processors: A dictionary containing all attention processors used in the model with indexed by its weight name.
(self)
| 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]]): |
nothing calls this directly
no outgoing calls
no test coverage detected