|
6 | 6 | import logging |
7 | 7 | import os |
8 | 8 | from collections import defaultdict |
9 | | -from typing import Any, cast, Dict, IO, Iterable, List, NamedTuple, Optional, Tuple |
| 9 | +from typing import Any, Dict, Iterable, List, NamedTuple, Optional, Tuple |
10 | 10 |
|
11 | 11 | import numpy as np |
12 | 12 | import torch |
@@ -125,8 +125,7 @@ def save(self, name: str, **kwargs: Any) -> None: |
125 | 125 | assert os.path.basename(save_file) == basename, basename |
126 | 126 | self.logger.info("Saving checkpoint to {}".format(save_file)) |
127 | 127 | with self.path_manager.open(save_file, "wb") as f: |
128 | | - # pyre-fixme[22]: The cast is redundant. |
129 | | - torch.save(data, cast(IO[bytes], f)) |
| 128 | + torch.save(data, f) |
130 | 129 | self.tag_last_checkpoint(basename) |
131 | 130 |
|
132 | 131 | def load( |
@@ -250,8 +249,7 @@ def _load_file(self, f: str) -> Dict[str, Any]: |
250 | 249 | to torch.Tensor or numpy arrays. |
251 | 250 | """ |
252 | 251 | with self.path_manager.open(f, "rb") as file: |
253 | | - # pyre-fixme[22]: The cast is redundant. |
254 | | - return torch.load(cast(IO[bytes], file), map_location=torch.device("cpu")) |
| 252 | + return torch.load(file, map_location=torch.device("cpu")) |
255 | 253 |
|
256 | 254 | def _load_model(self, checkpoint: Any) -> _IncompatibleKeys: |
257 | 255 | """ |
|
0 commit comments