MCPcopy Create free account
hub / github.com/Shakker-Labs/RepText / attn_processors

Method attn_processors

controlnet_flux.py:120–141  ·  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

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):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected