Lazy loader Python 3.6 compatibility

The current lazy loader relies on a feature of the Python zipfile module
that was added in Python 3.7.0:

https://bugs.python.org/issue22908

This commit adds compatibility for Python 3.6.
This commit is contained in:
Gnome Ann
2022-04-02 15:02:54 -04:00
parent 8368b20421
commit fabbdf2bb1
2 changed files with 11 additions and 3 deletions

View File

@ -95,7 +95,7 @@ class LazyTensor:
nbytes = size if dtype is torch.bool else size * ((torch.finfo if dtype.is_floating_point else torch.iinfo)(dtype).bits >> 3)
if isinstance(checkpoint, zipfile.ZipFile):
f = checkpoint.open(f"archive/data/{self.key}", "r")
f.seek(self.seek_offset)
f.read(self.seek_offset)
else:
f = checkpoint
try: