-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathonnx_repl.py
More file actions
33 lines (25 loc) · 905 Bytes
/
Copy pathonnx_repl.py
File metadata and controls
33 lines (25 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
"""REPL for an ONNX-compiled torchwright model.
Usage:
python compile_interact.py model.onnx
"""
import argparse
from torchwright.compiler.repl import run_repl
def main() -> None:
parser = argparse.ArgumentParser(
description="Interactive REPL for a compiled ONNX model"
)
parser.add_argument("onnx_path", help="Path to the .onnx model file")
parser.add_argument(
"--max-tokens", type=int, default=20, help="Max tokens to generate"
)
parser.add_argument(
"-p", "--prompt", type=str, default=None, help="Single prompt (skip REPL)"
)
args = parser.parse_args()
if args.prompt is not None:
from torchwright.compiler.repl import run_once
run_once(args.onnx_path, args.prompt, max_new_tokens=args.max_tokens)
else:
run_repl(args.onnx_path, max_new_tokens=args.max_tokens)
if __name__ == "__main__":
main()