MCPcopy Create free account
hub / github.com/pytorch/pytorch / load

Method load

torch/nn/modules/module.py:2117–2137  ·  view source on GitHub ↗
(module, local_state_dict, prefix='')

Source from the content-addressed store, hash-verified

2115 state_dict._metadata = metadata # type: ignore[attr-defined]
2116
2117 def load(module, local_state_dict, prefix=''):
2118 local_metadata = {} if metadata is None else metadata.get(prefix[:-1], {})
2119 if assign:
2120 local_metadata['assign_to_params_buffers'] = assign
2121 module._load_from_state_dict(
2122 local_state_dict, prefix, local_metadata, True, missing_keys, unexpected_keys, error_msgs)
2123 for name, child in module._modules.items():
2124 if child is not None:
2125 child_prefix = prefix + name + '.'
2126 child_state_dict = {k: v for k, v in local_state_dict.items() if k.startswith(child_prefix)}
2127 load(child, child_state_dict, child_prefix)
2128
2129 # Note that the hook can modify missing_keys and unexpected_keys.
2130 incompatible_keys = _IncompatibleKeys(missing_keys, unexpected_keys)
2131 for hook in module._load_state_dict_post_hooks.values():
2132 out = hook(module, incompatible_keys)
2133 assert out is None, (
2134 "Hooks registered with ``register_load_state_dict_post_hook`` are not"
2135 "expected to return new values, if incompatible_keys need to be modified,"
2136 "it should be done inplace."
2137 )
2138
2139 load(self, state_dict)
2140 del load

Callers 15

_load_from_bytesFunction · 0.45
_load_storagesFunction · 0.45
loadFunction · 0.45
legacy_loadFunction · 0.45
_legacy_loadFunction · 0.45
_loadFunction · 0.45
_legacy_zip_loadFunction · 0.45
load_state_dict_from_urlFunction · 0.45
_sampled_addmm_kernelFunction · 0.45
_bsr_softmax_kernelFunction · 0.45
_scatter_mm2_kernelFunction · 0.45

Calls 7

_IncompatibleKeysClass · 0.85
hookFunction · 0.85
loadFunction · 0.50
getMethod · 0.45
_load_from_state_dictMethod · 0.45
itemsMethod · 0.45
valuesMethod · 0.45