(
serialized_tensor_meta: bytes, is_parameter: bool
)
| 295 | |
| 296 | |
| 297 | def _reconstruct_fake_tensor( |
| 298 | serialized_tensor_meta: bytes, is_parameter: bool |
| 299 | ) -> FakeTensor: |
| 300 | # Deserialize the bytes into a TensorMeta |
| 301 | json_tensor_meta = json.loads(serialized_tensor_meta.decode("utf-8")) |
| 302 | tensor_meta = _dict_to_dataclass(TensorMeta, json_tensor_meta) |
| 303 | # Find the current fake mode |
| 304 | assert len(_CURRENT_DESERIALIZER) != 0, "Need access to current deserializer state" |
| 305 | fake_tensor = _CURRENT_DESERIALIZER[-1].deserialize_tensor_meta(tensor_meta) |
| 306 | if is_parameter: |
| 307 | fake_tensor = torch.nn.Parameter(fake_tensor) # type: ignore[assignment] |
| 308 | return fake_tensor |
| 309 | |
| 310 | |
| 311 | def serialize_torch_artifact(artifact: Dict[str, Any]) -> bytes: |
nothing calls this directly
no test coverage detected