Skip to content

Commit db53ee1

Browse files
committed
Merge branch 'xadupre/input_put' of https://github.com/microsoft/onnxscript into xadupre/input_put
2 parents ce6ba0b + d721b3d commit db53ee1

File tree

32 files changed

+759
-325
lines changed

32 files changed

+759
-325
lines changed

.github/workflows/main.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ jobs:
8383
token: ${{ secrets.CODECOV_TOKEN }}
8484
- name: Upload torchlib error reports
8585
if: always()
86-
uses: actions/upload-artifact@v4
86+
uses: actions/upload-artifact@v5
8787
with:
8888
name: Error reports (${{ matrix.name }}-${{ matrix.os }})
8989
path: error_reports

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.5.5
1+
0.5.6

noxfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"packaging",
4242
"protobuf",
4343
)
44-
ONNX_IR = "onnx_ir==0.1.10"
44+
ONNX_IR = "onnx_ir==0.1.12"
4545
ONNX_IR_MAIN = "git+https://github.com/onnx/ir-py.git@main#egg=onnx_ir"
4646

4747

onnxscript/_framework_apis/torch_2_5.py

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
]
1414

1515
import dataclasses
16+
import importlib.util
1617
import os
1718
import pathlib
1819
from typing import Callable
@@ -63,7 +64,9 @@ def check_model(model: ir.Model) -> None:
6364
del model # Unused yet
6465

6566

66-
def save_model_with_external_data(model: ir.Model, model_path: str | os.PathLike) -> None:
67+
def save_model_with_external_data(
68+
model: ir.Model, model_path: str | os.PathLike, verbose: bool = False
69+
) -> None:
6770
"""Save the model with external data. The model is unchanged after saving."""
6871

6972
# TODO(#1835): Decide if we want to externalize large attributes as well
@@ -78,7 +81,31 @@ def save_model_with_external_data(model: ir.Model, model_path: str | os.PathLike
7881
destination_path = pathlib.Path(model_path)
7982
data_path = f"{destination_path.name}.data"
8083

81-
ir.save(model, model_path, external_data=data_path)
84+
# Show a progress bar if verbose is True and tqdm is installed
85+
use_tqdm = verbose and importlib.util.find_spec("tqdm") is not None
86+
87+
if use_tqdm:
88+
import tqdm # pylint: disable=import-outside-toplevel
89+
90+
with tqdm.tqdm() as pbar:
91+
total_set = False
92+
93+
def callback(
94+
tensor: ir.TensorProtocol, metadata: ir.external_data.CallbackInfo
95+
) -> None:
96+
nonlocal total_set
97+
if not total_set:
98+
pbar.total = metadata.total
99+
total_set = True
100+
101+
pbar.update()
102+
pbar.set_description(
103+
f"Saving {tensor.name} ({tensor.dtype.short_name()}, {tensor.shape}) at offset {metadata.offset}"
104+
)
105+
106+
ir.save(model, model_path, external_data=data_path, callback=callback)
107+
else:
108+
ir.save(model, model_path, external_data=data_path)
82109

83110

84111
def get_torchlib_ops() -> list[_OnnxFunctionMeta]:

0 commit comments

Comments
 (0)