mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
[export] Generate compatible thrift schema out of schema.py (#141611)
Summary: To make sure schema.py and schema.thrift are kept in sync, we use the int keys from thrift and use Python Annotated type to associate fields between thrift and schema.py. Later we will use this association to build a single source of truth between the schemas. Test Plan: CI Differential Revision: D66253157 Pull Request resolved: https://github.com/pytorch/pytorch/pull/141611 Approved by: https://github.com/yiming0416
This commit is contained in:
committed by
PyTorch MergeBot
parent
7dd9b5fc43
commit
a8a570512b
@ -72,6 +72,10 @@ if __name__ == "__main__":
|
||||
|
||||
yaml_content = yaml_header + "\n" + yaml_payload
|
||||
|
||||
thrift_schema = "// " + first_line
|
||||
thrift_schema += "\n// " + checksum
|
||||
thrift_schema += "\n" + commit.thrift_schema
|
||||
|
||||
if args.dry_run:
|
||||
print(yaml_content)
|
||||
print("\nWill write the above schema to" + args.prefix + commit.yaml_path)
|
||||
@ -80,3 +84,5 @@ if __name__ == "__main__":
|
||||
f.write(yaml_content)
|
||||
with open(args.prefix + commit.cpp_header_path, "w") as f:
|
||||
f.write(cpp_header)
|
||||
with open(args.prefix + commit.thrift_schema_path, "w") as f:
|
||||
f.write(thrift_schema)
|
||||
|
Reference in New Issue
Block a user