MCPcopy Create free account
hub / github.com/Pints-AI/1.5-Pints / SavingProxyForTensor

Class SavingProxyForTensor

lit_gpt/utils_old.py:295–306  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

293
294
295class SavingProxyForTensor:
296 def __init__(self, tensor, saver, protocol_version=5):
297 self.protocol_version = protocol_version
298 self.reduce_ret_fn, (storage, *other_reduce_args) = tensor.__reduce_ex__(protocol_version)
299 assert isinstance(storage, torch.storage.TypedStorage), "Please check for updates"
300 storage_proxy = SavingProxyForStorage(storage, saver, protocol_version=protocol_version)
301 self.reduce_args = (storage_proxy, *other_reduce_args)
302
303 def __reduce_ex__(self, protocol_version):
304 if protocol_version != self.protocol_version:
305 raise RuntimeError(f"Unexpected protocol version: expected {self.protocol_version}, got {protocol_version}")
306 return self.reduce_ret_fn, self.reduce_args
307
308
309class IncrementalPyTorchPickler(pickle.Pickler):

Callers 1

store_earlyMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected