MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / _find_children

Function _find_children

sat/sgm/modules/diffusionmodules/lora.py:217–231  ·  view source on GitHub ↗

Find all modules of a certain class (or union of classes). Returns all matching modules, along with the parent of those moduless and the names they are referenced by.

(
    model,
    search_class: List[Type[nn.Module]] = [nn.Linear],
)

Source from the content-addressed store, hash-verified

215
216
217def _find_children(
218 model,
219 search_class: List[Type[nn.Module]] = [nn.Linear],
220):
221 """
222 Find all modules of a certain class (or union of classes).
223
224 Returns all matching modules, along with the parent of those moduless and the
225 names they are referenced by.
226 """
227 # For each target find every linear_class module that isn't a child of a LoraInjectedLinear
228 for parent in model.modules():
229 for name, module in parent.named_children():
230 if any([isinstance(module, _class) for _class in search_class]):
231 yield parent, name, module
232
233
234def _find_modules_v2(

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected