pytorch
f7574ea4 - `torch.load`: Replaced multiple one byte read() calls during the `_is_zipfile` check with a single call (#109119)

Commit
1 year ago
`torch.load`: Replaced multiple one byte read() calls during the `_is_zipfile` check with a single call (#109119) Fixes #108955. Right now, the `_is_zipfile` check in `torch.load` performs multiple `read()` calls, reading 1 byte at a time in a loop. This is rather wasteful and leads to performance problems when accessing files on a network share (see #108955) . This PR replaces those 1 byte calls with a single big call. Functionally, this is equivalent as `read(n)` only reads up to `n` bytes, so even if the file is shorter there should not be any problems. Pull Request resolved: https://github.com/pytorch/pytorch/pull/109119 Approved by: https://github.com/mikaylagawarecki
Author
Committer
Parents
Loading