Skip to content

Commit 49fb80f

Browse files
committed
small changes
1 parent fdfdfcd commit 49fb80f

2 files changed

Lines changed: 30 additions & 2 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
*.svg
2323
*.onnx.stats
2424
*.stats
25+
*.zip
2526
CodeLlama*
2627
_tools/benchenv**
2728
_tools/repos**

_scripts/export_qwen25_vl_visual.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
2020
python export_qwen25_vl_visual.py -m Qwen/Qwen2.5-VL-7B-Instruct --device cpu --dtype float32 --exporter onnx-dynamo --pretrained --second-input
2121
22+
Cheat sheet for tar commmands. To make a tar:
23+
``tar -czvf model.tar.gz model.onnx model.data``
24+
And to untar:
25+
``tar -xzvf model.tar.gz``.
26+
2227
Attention
2328
+++++++++
2429
@@ -32,6 +37,7 @@
3237
"""
3338

3439
import os
40+
import subprocess
3541
import sys
3642
import time
3743
from argparse import ArgumentParser, BooleanOptionalAction
@@ -60,6 +66,7 @@ def main(
6066
exporter: str = "onnx-dynamo",
6167
pretrained: bool = True,
6268
second_input: bool = True,
69+
zip: bool = False,
6370
):
6471
print("-- import torch")
6572
import torch
@@ -158,9 +165,10 @@ def _config_reduction(config, task):
158165
prefix = simplify_model_id_for_a_filename(model_id)
159166
if "QWEN25ATTENTION" in os.environ:
160167
prefix = f"{prefix}.{os.environ['QWEN25ATTENTION']}"
161-
filename = f"model.{prefix}.visual.{device}.{dtype}.{exporter}.onnx"
168+
basename = f"model.{prefix}.visual.{device}.{dtype}.{exporter}"
169+
filename = f"{basename}.onnx"
162170
print(f"-- export in {filename!r}")
163-
stat_file = filename.replace(".onnx", ".stats")
171+
stat_file = f"{basename}.stats"
164172
begin = time.perf_counter()
165173

166174
if exporter == "onnx-dynamo" and device == "cuda" and "QWEN25ATTENTION" not in os.environ:
@@ -229,6 +237,18 @@ def fprint(s):
229237
diff = max_diff(expected_big, big[0], hist=[0.1])
230238
fprint(f"-- discrepancies={diff}")
231239

240+
if zip:
241+
tar_file_name = f"{basename}.zip"
242+
print()
243+
print(f"-- make file {tar_file_name!r}")
244+
cmd = ["zip", "-v", "-1", tar_file_name]
245+
for name in [filename, f"{filename}.data"]:
246+
print(f"-- add {name!r}")
247+
cmd.append(name)
248+
print(f"-- cmd: {' '.join(cmd)}")
249+
subprocess.run(cmd, check=True)
250+
print("-- done.")
251+
232252

233253
def get_parser() -> ArgumentParser:
234254
parser = ArgumentParser(
@@ -260,6 +280,12 @@ def get_parser() -> ArgumentParser:
260280
help="check discrepancies with other inputs",
261281
action=BooleanOptionalAction,
262282
)
283+
parser.add_argument(
284+
"--zip",
285+
default=False,
286+
help="Creates a file .zip with onnx file and data file.",
287+
action=BooleanOptionalAction,
288+
)
263289
return parser
264290

265291

@@ -273,4 +299,5 @@ def get_parser() -> ArgumentParser:
273299
exporter=args.exporter,
274300
pretrained=args.pretrained,
275301
second_input=args.second_input,
302+
zip=args.zip,
276303
)

0 commit comments

Comments
 (0)