Files
pytorch/torch/_export/db/gen_example.py
Zhengxu Chen e58ef5b65f [export] Rewrite exportdb formatting. (#129260)
Summary: It'll be easier to generate examples if the code doesn't depend on exportdb library.

Test Plan: CI

Differential Revision: D58886554

Pull Request resolved: https://github.com/pytorch/pytorch/pull/129260
Approved by: https://github.com/tugsbayasgalan
2024-06-25 21:04:53 +00:00

22 lines
462 B
Python

import os
import sys
import torch._export.db.examples as examples
TEMPLATE = '''import torch
def {case_name}(x):
"""
"""
return
'''
if __name__ == "__main__":
assert len(sys.argv) == 2
root_dir = examples.__name__.replace(".", "/")
assert os.path.exists(root_dir)
with open(os.path.join(root_dir, sys.argv[1] + ".py"), "w") as f:
print("Writing to", f.name, "...")
f.write(TEMPLATE.format(case_name=sys.argv[1]))