MCPcopy
hub / github.com/huggingface/diffusers / copy_to

Method copy_to

src/diffusers/training_utils.py:762–779  ·  view source on GitHub ↗

Copy current averaged parameters into given collection of parameters. Args: parameters: Iterable of `torch.nn.Parameter`; the parameters to be updated with the stored moving averages. If `None`, the parameters with which this `Exponential

(self, parameters: Iterable[torch.nn.Parameter])

Source from the content-addressed store, hash-verified

760 s_param.copy_(param)
761
762 def copy_to(self, parameters: Iterable[torch.nn.Parameter]) -> None:
763 """
764 Copy current averaged parameters into given collection of parameters.
765
766 Args:
767 parameters: Iterable of `torch.nn.Parameter`; the parameters to be
768 updated with the stored moving averages. If `None`, the parameters with which this
769 `ExponentialMovingAverage` was initialized will be used.
770 """
771 parameters = list(parameters)
772 if self.foreach:
773 torch._foreach_copy_(
774 [param.data for param in parameters],
775 [s_param.to(param.device).data for s_param, param in zip(self.shadow_params, parameters)],
776 )
777 else:
778 for s_param, param in zip(self.shadow_params, parameters):
779 param.data.copy_(s_param.to(param.device).data)
780
781 def pin_memory(self) -> None:
782 r"""

Callers 1

save_pretrainedMethod · 0.95

Calls 1

toMethod · 0.45

Tested by

no test coverage detected