(obj)
| 19 | importers = sys_importer |
| 20 | |
| 21 | def persistent_id(obj): |
| 22 | if torch.is_storage(obj) or isinstance(obj, torch.storage.TypedStorage): |
| 23 | if isinstance(obj, torch.storage.TypedStorage): |
| 24 | # TODO: Once we decide to break serialization FC, we can |
| 25 | # remove this case |
| 26 | storage = obj._untyped_storage |
| 27 | dtype = obj.dtype |
| 28 | else: |
| 29 | storage = obj |
| 30 | dtype = torch.uint8 |
| 31 | |
| 32 | serialized_storages.append(obj) |
| 33 | serialized_dtypes.append(dtype) |
| 34 | return ("storage", len(serialized_storages) - 1) |
| 35 | |
| 36 | if hasattr(obj, "__reduce_deploy__"): |
| 37 | if _serialized_reduces.get(id(obj)) is None: |
| 38 | _serialized_reduces[id(obj)] = ( |
| 39 | "reduce_deploy", |
| 40 | id(obj), |
| 41 | *obj.__reduce_deploy__(importers), |
| 42 | ) |
| 43 | return _serialized_reduces[id(obj)] |
| 44 | |
| 45 | return None |
| 46 | |
| 47 | # Write the pickle data for `obj` |
| 48 | data_buf = io.BytesIO() |
nothing calls this directly
no test coverage detected
searching dependent graphs…