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

Function _coerce_bytes

exir/_serialize/_flatbuffer_program.py:77–87  ·  view source on GitHub ↗
(data: Any)

Source from the content-addressed store, hash-verified

75
76
77def _coerce_bytes(data: Any) -> bytes:
78 if isinstance(data, bytes):
79 return data
80 if isinstance(data, bytearray):
81 return bytes(data)
82 if isinstance(data, memoryview):
83 return data.tobytes()
84 tobytes = getattr(data, "tobytes", None)
85 if callable(tobytes):
86 return tobytes()
87 return bytes(data)
88
89
90def _pack_buffer(self: Any, builder: Any) -> int:

Callers 2

_pack_bufferFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected