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

Method from_bytes

backends/mlx/pte_inspector.py:55–70  ·  view source on GitHub ↗
(cls, data: bytes)

Source from the content-addressed store, hash-verified

53
54 @classmethod
55 def from_bytes(cls, data: bytes) -> "MLXHeader":
56 if len(data) < MLX_HEADER_LENGTH:
57 raise ValueError(
58 f"Not enough data for MLX header: {len(data)} < {MLX_HEADER_LENGTH}"
59 )
60
61 # Layout: [4 bytes padding][4 bytes magic][8 bytes offset][8 bytes size]
62 magic = data[4:8]
63 data_segment_offset = int.from_bytes(data[8:16], byteorder="little")
64 data_segment_size = int.from_bytes(data[16:24], byteorder="little")
65
66 return cls(
67 magic=magic,
68 data_segment_offset=data_segment_offset,
69 data_segment_size=data_segment_size,
70 )
71
72 def is_valid(self) -> bool:
73 return self.magic == MLX_MAGIC

Callers 5

_load_mlx_payloadFunction · 0.45
parse_mlx_payloadFunction · 0.45
parse_executorch_programFunction · 0.45
mainFunction · 0.45
_get_test_seedFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected