Recursively set the attribute of a module. Args: model (`torch.nn.Module`) The model to set the attribute in. module_name (`str`) The name of the module to set the attribute in. module (`torch.nn.Module`) The module to set the attr
(model, module_name, module)
| 170 | |
| 171 | |
| 172 | def recursive_setattr(model, module_name, module): |
| 173 | """ |
| 174 | Recursively set the attribute of a module. |
| 175 | Args: |
| 176 | model (`torch.nn.Module`) |
| 177 | The model to set the attribute in. |
| 178 | module_name (`str`) |
| 179 | The name of the module to set the attribute in. |
| 180 | module (`torch.nn.Module`) |
| 181 | The module to set the attribute to. |
| 182 | """ |
| 183 | split_list = module_name.split('.') |
| 184 | output = model |
| 185 | for name in split_list[:-1]: |
| 186 | output = getattr(output, name) |
| 187 | output.__setattr__(split_list[-1], module) |
| 188 | |
| 189 | |
| 190 | def concat_to_compat_param(quantized_weight: Tensor, |
no test coverage detected