MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / copy_optim_state_dict_cpu

Function copy_optim_state_dict_cpu

PATH/core/utils.py:670–681  ·  view source on GitHub ↗
(state_dict)

Source from the content-addressed store, hash-verified

668 return new_state
669
670def 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
683def copy_optim_state_dict_cpu_fp16(state_dict):
684 new_state = {}

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected