(module, prefix='')
| 737 | |
| 738 | # use _load_from_state_dict to enable checkpoint version control |
| 739 | def load(module, prefix=''): |
| 740 | # recursively check parallel module in case that the model has a |
| 741 | # complicated structure, e.g., nn.Module(nn.Module(DDP)) |
| 742 | # if is_module_wrapper(module): |
| 743 | # module = module.module |
| 744 | local_metadata = {} if metadata is None else metadata.get( |
| 745 | prefix[:-1], {}) |
| 746 | module._load_from_state_dict(state_dict, prefix, local_metadata, True, |
| 747 | all_missing_keys, unexpected_keys, |
| 748 | err_msg) |
| 749 | for name, child in module._modules.items(): |
| 750 | if child is not None: |
| 751 | load(child, prefix + name + '.') |
| 752 | |
| 753 | load(module) |
| 754 | load = None # break load->load reference cycle |
no test coverage detected