MCPcopy Create free account
hub / github.com/Vchitect/Latte / _reconstruct_persistent_obj

Function _reconstruct_persistent_obj

tools/torch_utils/persistence.py:179–202  ·  view source on GitHub ↗

r"""Hook that is called internally by the `pickle` module to unpickle a persistent object.

(meta)

Source from the content-addressed store, hash-verified

177#----------------------------------------------------------------------------
178
179def _reconstruct_persistent_obj(meta):
180 r"""Hook that is called internally by the `pickle` module to unpickle
181 a persistent object.
182 """
183 meta = dnnlib.EasyDict(meta)
184 meta.state = dnnlib.EasyDict(meta.state)
185 for hook in _import_hooks:
186 meta = hook(meta)
187 assert meta is not None
188
189 assert meta.version == _version
190 module = _src_to_module(meta.module_src)
191
192 assert meta.type == 'class'
193 orig_class = module.__dict__[meta.class_name]
194 decorator_class = persistent_class(orig_class)
195 obj = decorator_class.__new__(decorator_class)
196
197 setstate = getattr(obj, '__setstate__', None)
198 if callable(setstate):
199 setstate(meta.state) # pylint: disable=not-callable
200 else:
201 obj.__dict__.update(meta.state)
202 return obj
203
204#----------------------------------------------------------------------------
205

Callers

nothing calls this directly

Calls 3

_src_to_moduleFunction · 0.85
persistent_classFunction · 0.85
updateMethod · 0.45

Tested by

no test coverage detected