(module, prefix='')
| 633 | |
| 634 | # use _load_from_state_dict to enable checkpoint version control |
| 635 | def load(module, prefix=''): |
| 636 | # recursively check parallel module in case that the model has a |
| 637 | # complicated structure, e.g., nn.Module(nn.Module(DDP)) |
| 638 | # if is_module_wrapper(module): |
| 639 | # module = module.module |
| 640 | local_metadata = {} if metadata is None else metadata.get( |
| 641 | prefix[:-1], {}) |
| 642 | module._load_from_state_dict(state_dict, prefix, local_metadata, True, |
| 643 | all_missing_keys, unexpected_keys, |
| 644 | err_msg) |
| 645 | for name, child in module._modules.items(): |
| 646 | if child is not None: |
| 647 | load(child, prefix + name + '.') |
| 648 | |
| 649 | load(module) |
| 650 | load = None # break load->load reference cycle |
no test coverage detected