MCPcopy Create free account
hub / github.com/deepspeedai/DeepSpeed / load_module_recursive

Method load_module_recursive

deepspeed/inference/engine.py:386–398  ·  view source on GitHub ↗
(module, prefix='', level=0)

Source from the content-addressed store, hash-verified

384 }
385
386 def load_module_recursive(module, prefix='', level=0):
387 for name, child in module.named_children():
388 if child.__class__ in layer_policies:
389 checking_key = prefix + name + '.'
390 if not any(checking_key in item for item in self.key_list):
391 continue
392 if len(list(child.parameters())) > 0 and list(child.parameters())[0].numel() == 0:
393 if len(child.weight.ds_shape) == 1:
394 child = Normalize(dim=child.weight.ds_shape[-1], dtype=child.weight.dtype, eps=child.eps)
395 setattr(module, name, child)
396 load(child, self.sd, prefix + name + '.')
397 else:
398 load_module_recursive(child, prefix if level == 0 else prefix + name + '.', level + 1)
399
400 load_module_recursive(r_module)
401

Callers

nothing calls this directly

Calls 5

NormalizeClass · 0.85
load_module_recursiveFunction · 0.85
loadFunction · 0.50
parametersMethod · 0.45
numelMethod · 0.45

Tested by

no test coverage detected