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

Function master_params_to_model_params

PATH/core/fp16/utils.py:310–328  ·  view source on GitHub ↗

Copy master parameters to model parameters. Args: model_params: List of model parameters created by :func:`prep_param_lists`. master_params: List of FP32 master parameters created by :func:`prep_param_lists`. If ``master_params`` was created with

(model_params, master_params, flat_master=False)

Source from the content-addressed store, hash-verified

308
309
310def master_params_to_model_params(model_params, master_params, flat_master=False):
311 """
312 Copy master parameters to model parameters.
313
314 Args:
315 model_params: List of model parameters created by :func:`prep_param_lists`.
316 master_params: List of FP32 master parameters created by
317 :func:`prep_param_lists`. If ``master_params`` was created with
318 ``flat_master=True``, ``flat_master=True`` should also be supplied
319 to :func:`master_params_to_model_params`.
320 """
321 if flat_master:
322 for model, master in zip(model_params,
323 _unflatten_dense_tensors(master_params[0].data,
324 model_params)):
325 model.data.copy_(master)
326 else:
327 for model, master in zip(model_params, master_params):
328 model.data.copy_(master.data)
329
330# Backward compatibility fixes
331

Calls

no outgoing calls

Tested by

no test coverage detected