torch.Tensor.module_load¶
- Tensor.module_load(other, assign=False)[source]¶
Defines how to transform
other
when loading it intoself
inload_state_dict()
.Used when
get_swap_module_params_on_conversion()
isTrue
.It is expected that
self
is a parameter or buffer in annn.Module
andother
is the value in the state dictionary with the corresponding key, this method defines howother
is remapped before being swapped withself
viaswap_tensors()
inload_state_dict()
.Note
This method should always return a new object that is not
self
orother
. For example, the default implementation returnsself.copy_(other).detach()
ifassign
isFalse
orother.detach()
ifassign
isTrue
.- Parameters
other (Tensor) – value in state dict with key corresponding to
self
assign (bool) – the assign argument passed to
nn.Module.load_state_dict()