MCPcopy Create free account
hub / github.com/pytorch/executorch / _reconstruct_fake_tensor

Function _reconstruct_fake_tensor

exir/serde/export_serialize.py:297–308  ·  view source on GitHub ↗
(
    serialized_tensor_meta: bytes, is_parameter: bool
)

Source from the content-addressed store, hash-verified

295
296
297def _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
311def serialize_torch_artifact(artifact: Dict[str, Any]) -> bytes:

Callers

nothing calls this directly

Calls 3

_dict_to_dataclassFunction · 0.85
decodeMethod · 0.45

Tested by

no test coverage detected