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

Function _convert_to_flatcc

devtools/etdump/serialize.py:46–60  ·  view source on GitHub ↗
(etdump_json: str)

Source from the content-addressed store, hash-verified

44
45
46def _convert_to_flatcc(etdump_json: str) -> bytes:
47 with tempfile.TemporaryDirectory() as d:
48 # load given and common schema
49 _write_schema(d, ETDUMP_FLATCC_SCHEMA_NAME)
50 _write_schema(d, SCALAR_TYPE_SCHEMA_NAME)
51
52 schema_path = os.path.join(d, "{}.fbs".format(ETDUMP_FLATCC_SCHEMA_NAME))
53 json_path = os.path.join(d, "{}.json".format(ETDUMP_FLATCC_SCHEMA_NAME))
54 with open(json_path, "wb") as json_file:
55 json_file.write(etdump_json.encode("ascii"))
56
57 _flatc_compile(d, schema_path, json_path)
58 output_path = os.path.join(d, "{}.etdp".format(ETDUMP_FLATCC_SCHEMA_NAME))
59 with open(output_path, "rb") as output_file:
60 return output_file.read()
61
62
63def _convert_from_flatcc(etdump_flatbuffer: bytes, size_prefixed: bool = True) -> bytes:

Callers 1

Calls 4

_flatc_compileFunction · 0.90
_write_schemaFunction · 0.85
writeMethod · 0.80
encodeMethod · 0.45

Tested by

no test coverage detected