r""" Returns: `dict` of attention processors: A dictionary containing all attention processors used in the model with indexed by its weight name.
(self)
| 118 | @property |
| 119 | # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.attn_processors |
| 120 | def attn_processors(self): |
| 121 | r""" |
| 122 | Returns: |
| 123 | `dict` of attention processors: A dictionary containing all attention processors used in the model with |
| 124 | indexed by its weight name. |
| 125 | """ |
| 126 | # set recursively |
| 127 | processors = {} |
| 128 | |
| 129 | def fn_recursive_add_processors(name: str, module: torch.nn.Module, processors: Dict[str, AttentionProcessor]): |
| 130 | if hasattr(module, "get_processor"): |
| 131 | processors[f"{name}.processor"] = module.get_processor() |
| 132 | |
| 133 | for sub_name, child in module.named_children(): |
| 134 | fn_recursive_add_processors(f"{name}.{sub_name}", child, processors) |
| 135 | |
| 136 | return processors |
| 137 | |
| 138 | for name, module in self.named_children(): |
| 139 | fn_recursive_add_processors(name, module, processors) |
| 140 | |
| 141 | return processors |
| 142 | |
| 143 | # Copied from diffusers.models.unets.unet_2d_condition.UNet2DConditionModel.set_attn_processor |
| 144 | def set_attn_processor(self, processor): |
nothing calls this directly
no outgoing calls
no test coverage detected