torch.Tensor.module_load¶
- Tensor.module_load(other, assign=False)[source][source]¶
- Defines how to transform - otherwhen loading it into- selfin- load_state_dict().- Used when - get_swap_module_params_on_conversion()is- True.- It is expected that - selfis a parameter or buffer in an- nn.Moduleand- otheris the value in the state dictionary with the corresponding key, this method defines how- otheris remapped before being swapped with- selfvia- swap_tensors()in- load_state_dict().- Note - This method should always return a new object that is not - selfor- other. For example, the default implementation returns- self.copy_(other).detach()if- assignis- Falseor- other.detach()if- assignis- True.- Parameters
- other (Tensor) – value in state dict with key corresponding to - self
- assign (bool) – the assign argument passed to - nn.Module.load_state_dict()