Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable ONNX test in circle CI #3144

Merged
merged 13 commits into from
Dec 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ jobs:
pip install --user --progress-bar off --editable .
python test/test_hub.py

torch_onnx_test:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run:
command: |
pip install --user --progress-bar off numpy
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
# need to install torchvision dependencies due to transitive imports
pip install --user --progress-bar off --editable .
pip install --user onnx
pip install --user -i https://test.pypi.org/simple/ ort-nightly==1.5.2.dev202012031
python test/test_onnx.py

binary_linux_wheel:
<<: *binary_common
docker:
Expand Down Expand Up @@ -1074,6 +1089,7 @@ workflows:
- python_type_check
- clang_format
- torchhub_test
- torch_onnx_test

unittest:
jobs:
Expand Down Expand Up @@ -1189,6 +1205,7 @@ workflows:
- python_type_check
- clang_format
- torchhub_test
- torch_onnx_test
- binary_linux_wheel:
cu_version: cpu
filters:
Expand Down
17 changes: 17 additions & 0 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,21 @@ jobs:
pip install --user --progress-bar off --editable .
python test/test_hub.py

torch_onnx_test:
docker:
- image: circleci/python:3.7
steps:
- checkout
- run:
command: |
pip install --user --progress-bar off numpy
pip install --user --progress-bar off --pre torch -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
# need to install torchvision dependencies due to transitive imports
pip install --user --progress-bar off --editable .
pip install --user onnx
pip install --user -i https://test.pypi.org/simple/ ort-nightly==1.5.2.dev202012031
python test/test_onnx.py

binary_linux_wheel:
<<: *binary_common
docker:
Expand Down Expand Up @@ -700,6 +715,7 @@ workflows:
- python_type_check
- clang_format
- torchhub_test
- torch_onnx_test

unittest:
jobs:
Expand All @@ -717,6 +733,7 @@ workflows:
- python_type_check
- clang_format
- torchhub_test
- torch_onnx_test
{{ build_workflows(prefix="nightly_", filter_branch="nightly", upload=True) }}
docker_build:
triggers:
Expand Down
18 changes: 9 additions & 9 deletions test/test_onnx.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def forward(self_module, images):
input = torch.rand(3, 10, 20)
input_test = torch.rand(3, 100, 150)
self.run_model(TransformModule(), [(input,), (input_test,)],
input_names=["input1"], dynamic_axes={"input1": [0, 1, 2, 3]})
input_names=["input1"], dynamic_axes={"input1": [0, 1, 2]})

def test_transform_images(self):

Expand Down Expand Up @@ -382,12 +382,12 @@ def test_faster_rcnn(self):
# Test exported model on images of different size, or dummy input
self.run_model(model, [(images,), (test_images,), (dummy_image,)], input_names=["images_tensors"],
output_names=["outputs"],
dynamic_axes={"images_tensors": [0, 1, 2, 3], "outputs": [0, 1, 2, 3]},
dynamic_axes={"images_tensors": [0, 1, 2], "outputs": [0, 1, 2]},
tolerate_small_mismatch=True)
# Test exported model for an image with no detections on other images
self.run_model(model, [(dummy_image,), (images,)], input_names=["images_tensors"],
output_names=["outputs"],
dynamic_axes={"images_tensors": [0, 1, 2, 3], "outputs": [0, 1, 2, 3]},
dynamic_axes={"images_tensors": [0, 1, 2], "outputs": [0, 1, 2]},
tolerate_small_mismatch=True)

# Verify that paste_mask_in_image beahves the same in tracing.
Expand Down Expand Up @@ -434,16 +434,16 @@ def test_mask_rcnn(self):
self.run_model(model, [(images,), (test_images,), (dummy_image,)],
input_names=["images_tensors"],
output_names=["boxes", "labels", "scores", "masks"],
dynamic_axes={"images_tensors": [0, 1, 2, 3], "boxes": [0, 1], "labels": [0],
"scores": [0], "masks": [0, 1, 2, 3]},
dynamic_axes={"images_tensors": [0, 1, 2], "boxes": [0, 1], "labels": [0],
"scores": [0], "masks": [0, 1, 2]},
tolerate_small_mismatch=True)
# TODO: enable this test once dynamic model export is fixed
# Test exported model for an image with no detections on other images
self.run_model(model, [(dummy_image,), (images,)],
input_names=["images_tensors"],
output_names=["boxes", "labels", "scores", "masks"],
dynamic_axes={"images_tensors": [0, 1, 2, 3], "boxes": [0, 1], "labels": [0],
"scores": [0], "masks": [0, 1, 2, 3]},
dynamic_axes={"images_tensors": [0, 1, 2], "boxes": [0, 1], "labels": [0],
"scores": [0], "masks": [0, 1, 2]},
tolerate_small_mismatch=True)

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

self.run_model(model, [(dummy_images,), (test_images,)],
input_names=["images_tensors"],
output_names=["outputs1", "outputs2", "outputs3", "outputs4"],
dynamic_axes={"images_tensors": [0, 1, 2, 3]},
dynamic_axes={"images_tensors": [0, 1, 2]},
tolerate_small_mismatch=True)


Expand Down