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

Function recursive_getattr

deepspeed/utils/module_utils.py:7–20  ·  view source on GitHub ↗

Recursively get the attribute of a module. Args: model (`torch.nn.Module`) The model to get the attribute from. module_name (`str`) The name of the module to get the attribute from.

(model, module_name)

Source from the content-addressed store, hash-verified

5
6
7def recursive_getattr(model, module_name):
8 """
9 Recursively get the attribute of a module.
10 Args:
11 model (`torch.nn.Module`)
12 The model to get the attribute from.
13 module_name (`str`)
14 The name of the module to get the attribute from.
15 """
16 split_list = module_name.split('.')
17 output = model
18 for name in split_list:
19 output = getattr(output, name)
20 return output
21
22
23def recursive_setattr(model, module_name, module):

Callers 2

convert_to_random_ltdFunction · 0.90

Calls

no outgoing calls

Tested by 1