(dtype, numel, key, location)
| 1365 | UserWarning) |
| 1366 | |
| 1367 | def load_tensor(dtype, numel, key, location): |
| 1368 | name = f'data/{key}' |
| 1369 | if overall_storage is not None: |
| 1370 | storage_offset = zip_file.get_record_offset(name) |
| 1371 | storage = overall_storage[storage_offset:storage_offset + numel] |
| 1372 | else: |
| 1373 | storage = zip_file.get_storage_from_record(name, numel, torch.UntypedStorage)._typed_storage()._untyped_storage |
| 1374 | # swap here if byteswapping is needed |
| 1375 | if byteorderdata is not None: |
| 1376 | if byteorderdata.decode() != sys.byteorder: |
| 1377 | storage.byteswap(dtype) |
| 1378 | |
| 1379 | # TODO: Once we decide to break serialization FC, we can |
| 1380 | # stop wrapping with TypedStorage |
| 1381 | typed_storage = torch.storage.TypedStorage( |
| 1382 | wrap_storage=restore_location(storage, location), |
| 1383 | dtype=dtype, |
| 1384 | _internal=True) |
| 1385 | |
| 1386 | if typed_storage._data_ptr() != 0: |
| 1387 | loaded_storages[key] = typed_storage |
| 1388 | |
| 1389 | return typed_storage |
| 1390 | |
| 1391 | def persistent_load(saved_id): |
| 1392 | assert isinstance(saved_id, tuple) |
no test coverage detected
searching dependent graphs…