Skip to content

Commit 2e5e058

Browse files
authored
Adapt to new pytorch onnx exporter API for dictionary (#3160)
* Adapt to new torch export API for dictionary
1 parent 0963ff7 commit 2e5e058

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
# need to install torchvision dependencies due to transitive imports
158158
pip install --user --progress-bar off --editable .
159159
pip install --user onnx
160-
pip install --user -i https://test.pypi.org/simple/ ort-nightly==1.5.2.dev202012031
160+
pip install --user onnxruntime
161161
python test/test_onnx.py
162162
163163
binary_linux_wheel:

.circleci/config.yml.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ jobs:
157157
# need to install torchvision dependencies due to transitive imports
158158
pip install --user --progress-bar off --editable .
159159
pip install --user onnx
160-
pip install --user -i https://test.pypi.org/simple/ ort-nightly==1.5.2.dev202012031
160+
pip install --user onnxruntime
161161
python test/test_onnx.py
162162

163163
binary_linux_wheel:

test/test_onnx.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ def run_model(self, model, inputs_list, tolerate_small_mismatch=False, do_consta
3333
model.eval()
3434

3535
onnx_io = io.BytesIO()
36+
if isinstance(inputs_list[0][-1], dict):
37+
torch_onnx_input = inputs_list[0] + ({},)
38+
else:
39+
torch_onnx_input = inputs_list[0]
3640
# export to onnx with the first input
37-
torch.onnx.export(model, inputs_list[0], onnx_io,
41+
torch.onnx.export(model, torch_onnx_input, onnx_io,
3842
do_constant_folding=do_constant_folding, opset_version=_onnx_opset_version,
3943
dynamic_axes=dynamic_axes, input_names=input_names, output_names=output_names)
4044
# validate the exported model with onnx runtime

0 commit comments

Comments
 (0)