(state_dict)
| 668 | return new_state |
| 669 | |
| 670 | def copy_optim_state_dict_cpu(state_dict): |
| 671 | new_state = {} |
| 672 | new_state['param_groups'] = copy.deepcopy(state_dict['param_groups']) |
| 673 | new_state['state'] = {} |
| 674 | for k,v in state_dict['state'].items(): |
| 675 | new_state['state'][k] = {} |
| 676 | for name,x in v.items(): |
| 677 | if isinstance(x, torch.Tensor): |
| 678 | new_state['state'][k][name] = x.cpu() |
| 679 | else: |
| 680 | new_state['state'][k][name] = copy.deepcopy(x) |
| 681 | return new_state |
| 682 | |
| 683 | def copy_optim_state_dict_cpu_fp16(state_dict): |
| 684 | new_state = {} |
no outgoing calls
no test coverage detected