Skip to content

Commit ef5ea8b

Browse files
fmassafacebook-github-bot
authored andcommitted
Enable ONNX test in circle CI (#3144)
Summary: * Enable ONNX test in circle CI Reviewed By: datumbox Differential Revision: D25531035 fbshipit-source-id: 022b8613ac5bd8cb7165e9cbaa9daf99a9e1694e
1 parent 912a11f commit ef5ea8b

File tree

3 files changed

+43
-9
lines changed

3 files changed

+43
-9
lines changed

.circleci/config.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ jobs:
145145
pip install --user --progress-bar off --editable .
146146
python test/test_hub.py
147147
148+
torch_onnx_test:
149+
docker:
150+
- image: circleci/python:3.7
151+
steps:
152+
- checkout
153+
- run:
154+
command: |
155+
pip install --user --progress-bar off numpy
156+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
157+
# need to install torchvision dependencies due to transitive imports
158+
pip install --user --progress-bar off --editable .
159+
pip install --user onnx
160+
pip install --user -i https://test.pypi.org/simple/ ort-nightly==1.5.2.dev202012031
161+
python test/test_onnx.py
162+
148163
binary_linux_wheel:
149164
<<: *binary_common
150165
docker:
@@ -1074,6 +1089,7 @@ workflows:
10741089
- python_type_check
10751090
- clang_format
10761091
- torchhub_test
1092+
- torch_onnx_test
10771093

10781094
unittest:
10791095
jobs:
@@ -1189,6 +1205,7 @@ workflows:
11891205
- python_type_check
11901206
- clang_format
11911207
- torchhub_test
1208+
- torch_onnx_test
11921209
- binary_linux_wheel:
11931210
cu_version: cpu
11941211
filters:

.circleci/config.yml.in

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,21 @@ jobs:
145145
pip install --user --progress-bar off --editable .
146146
python test/test_hub.py
147147

148+
torch_onnx_test:
149+
docker:
150+
- image: circleci/python:3.7
151+
steps:
152+
- checkout
153+
- run:
154+
command: |
155+
pip install --user --progress-bar off numpy
156+
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
157+
# need to install torchvision dependencies due to transitive imports
158+
pip install --user --progress-bar off --editable .
159+
pip install --user onnx
160+
pip install --user -i https://test.pypi.org/simple/ ort-nightly==1.5.2.dev202012031
161+
python test/test_onnx.py
162+
148163
binary_linux_wheel:
149164
<<: *binary_common
150165
docker:
@@ -700,6 +715,7 @@ workflows:
700715
- python_type_check
701716
- clang_format
702717
- torchhub_test
718+
- torch_onnx_test
703719

704720
unittest:
705721
jobs:
@@ -717,6 +733,7 @@ workflows:
717733
- python_type_check
718734
- clang_format
719735
- torchhub_test
736+
- torch_onnx_test
720737
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
721738
docker_build:
722739
triggers:

test/test_onnx.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def forward(self_module, images):
170170
input = torch.rand(3, 10, 20)
171171
input_test = torch.rand(3, 100, 150)
172172
self.run_model(TransformModule(), [(input,), (input_test,)],
173-
input_names=["input1"], dynamic_axes={"input1": [0, 1, 2, 3]})
173+
input_names=["input1"], dynamic_axes={"input1": [0, 1, 2]})
174174

175175
def test_transform_images(self):
176176

@@ -382,12 +382,12 @@ def test_faster_rcnn(self):
382382
# Test exported model on images of different size, or dummy input
383383
self.run_model(model, [(images,), (test_images,), (dummy_image,)], input_names=["images_tensors"],
384384
output_names=["outputs"],
385-
dynamic_axes={"images_tensors": [0, 1, 2, 3], "outputs": [0, 1, 2, 3]},
385+
dynamic_axes={"images_tensors": [0, 1, 2], "outputs": [0, 1, 2]},
386386
tolerate_small_mismatch=True)
387387
# Test exported model for an image with no detections on other images
388388
self.run_model(model, [(dummy_image,), (images,)], input_names=["images_tensors"],
389389
output_names=["outputs"],
390-
dynamic_axes={"images_tensors": [0, 1, 2, 3], "outputs": [0, 1, 2, 3]},
390+
dynamic_axes={"images_tensors": [0, 1, 2], "outputs": [0, 1, 2]},
391391
tolerate_small_mismatch=True)
392392

393393
# Verify that paste_mask_in_image beahves the same in tracing.
@@ -434,16 +434,16 @@ def test_mask_rcnn(self):
434434
self.run_model(model, [(images,), (test_images,), (dummy_image,)],
435435
input_names=["images_tensors"],
436436
output_names=["boxes", "labels", "scores", "masks"],
437-
dynamic_axes={"images_tensors": [0, 1, 2, 3], "boxes": [0, 1], "labels": [0],
438-
"scores": [0], "masks": [0, 1, 2, 3]},
437+
dynamic_axes={"images_tensors": [0, 1, 2], "boxes": [0, 1], "labels": [0],
438+
"scores": [0], "masks": [0, 1, 2]},
439439
tolerate_small_mismatch=True)
440440
# TODO: enable this test once dynamic model export is fixed
441441
# Test exported model for an image with no detections on other images
442442
self.run_model(model, [(dummy_image,), (images,)],
443443
input_names=["images_tensors"],
444444
output_names=["boxes", "labels", "scores", "masks"],
445-
dynamic_axes={"images_tensors": [0, 1, 2, 3], "boxes": [0, 1], "labels": [0],
446-
"scores": [0], "masks": [0, 1, 2, 3]},
445+
dynamic_axes={"images_tensors": [0, 1, 2], "boxes": [0, 1], "labels": [0],
446+
"scores": [0], "masks": [0, 1, 2]},
447447
tolerate_small_mismatch=True)
448448

449449
# Verify that heatmaps_to_keypoints behaves the same in tracing.
@@ -483,13 +483,13 @@ def test_keypoint_rcnn(self):
483483
self.run_model(model, [(images,), (test_images,), (dummy_images,)],
484484
input_names=["images_tensors"],
485485
output_names=["outputs1", "outputs2", "outputs3", "outputs4"],
486-
dynamic_axes={"images_tensors": [0, 1, 2, 3]},
486+
dynamic_axes={"images_tensors": [0, 1, 2]},
487487
tolerate_small_mismatch=True)
488488

489489
self.run_model(model, [(dummy_images,), (test_images,)],
490490
input_names=["images_tensors"],
491491
output_names=["outputs1", "outputs2", "outputs3", "outputs4"],
492-
dynamic_axes={"images_tensors": [0, 1, 2, 3]},
492+
dynamic_axes={"images_tensors": [0, 1, 2]},
493493
tolerate_small_mismatch=True)
494494

495495

0 commit comments

Comments
 (0)