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

Method serialize_bytes

exir/serde/serialize.py:267–274  ·  view source on GitHub ↗
(b: bytes)

Source from the content-addressed store, hash-verified

265 assert isinstance(lowered_module_arg.target, str)
266
267 def serialize_bytes(b: bytes) -> str:
268 # We want to serialize the bytes to string because JSON cannot
269 # serialize bytes.
270 # Since the given bytes may be serialized with any encoding, so we
271 # want to first encode with base64, and then decode it with
272 # ascii. During deserialization we can just directly decode with b64
273 # to get the original encoded bytes.
274 return base64.b64encode(b).decode("ascii")
275
276 lowered_module = getattr(
277 lowered_module_arg.graph.owning_module, lowered_module_arg.target

Callers

nothing calls this directly

Calls 1

decodeMethod · 0.45

Tested by

no test coverage detected