Skip to content

Commit

Permalink
[ONNX] update default opset_version to 13 (#73898)
Browse files Browse the repository at this point in the history
Summary:
And add a new tool to update it in the future, which follows the policy
of using "latest as of 18 months ago". This policy is meant to balance:
* recent enough to increase the odds of being able to successfully
  export
* old enough to increase the odds of exported model being runnable by
  different ONNX implementations

Related changes:

* test_models.py: explicitly fix opset_version to 9 rather than relying on default. Caffe2 doesn't support newer versions.
* symbolic_helper.py:
  * Remove a misleading comment
  * Remove unnecessary check in `_set_opset_version`
  * Use a range to define `_onnx_stable_opsets`
* test_pytorch_common.py:
  * Rename a variable from min -> max. I think it was a copy-paste error.
  * Make skip test messages more informative.
  * Remove unused `skipIfONNXShapeInference`. More on that below.
* test_pytorch_onnx_onnxruntime.py:
  * Make all the `TestCase` classes explicitly specify opset version.
  * Make `test_unsupported_pad` respect `opset_version` by using `run_test`
  * Unrelated simplification: make it obvious that all tests run with `onnx_shape_inference=True`. AFAICT this was already the case.
  * There was one test that was entirely disabled (test_tolist) because it was asking to be skipped whenever `onnx_shape_inference=True`, but it was always True. I changed the model being tested so as to preserve the intended test coverage but still have the test actually pass.

Pull Request resolved: #73898

Reviewed By: msaroufim

Differential Revision: D35264615

Pulled By: malfet

fbshipit-source-id: cda8fbdffe4cc8210d8d96e659e3a9adf1b5f1d2
(cherry picked from commit b5e639e)
  • Loading branch information
garymm authored and pytorchmergebot committed Apr 7, 2022
1 parent 0dae42f commit ca37477
Show file tree
Hide file tree
Showing 137 changed files with 1,962 additions and 1,025 deletions.
2 changes: 1 addition & 1 deletion scripts/onnx/test.sh
Expand Up @@ -69,7 +69,7 @@ if [[ "$BUILD_ENVIRONMENT" == *ort_test1* || "${SHARD_NUMBER}" == "1" ]]; then
pytest "${args[@]}" \
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset7" \
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset8" \
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime" \
"$top_dir/test/onnx/test_pytorch_onnx_onnxruntime.py::TestONNXRuntime_opset9" \
"$top_dir/test/onnx/test_custom_ops.py" \
"$top_dir/test/onnx/test_models_onnxruntime.py" \
"$top_dir/test/onnx/test_utility_funs.py" \
Expand Down
4 changes: 3 additions & 1 deletion test/jit/test_export_modes.py
Expand Up @@ -82,7 +82,9 @@ def forward(self, x, y):
ModelWithAtenNotONNXOp(), (x, y),
add_node_names=False,
do_constant_folding=False,
operator_export_type=OperatorExportTypes.ONNX_ATEN_FALLBACK)
operator_export_type=OperatorExportTypes.ONNX_ATEN_FALLBACK,
# support for linalg.qr was added in later op set versions.
opset_version=9)

# torch.fmod is using to test ONNX_ATEN.
# If you plan to remove fmod from aten, or found this test failed.
Expand Down
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_acos.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -43,5 +43,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_add_broadcast.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -57,5 +57,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_add_left_broadcast.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -57,5 +57,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -60,5 +60,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -57,5 +57,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -60,5 +60,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_addconstant.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -57,5 +57,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_addmm.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -102,5 +102,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
9 changes: 7 additions & 2 deletions test/onnx/expect/TestOperators.test_argmax.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand All @@ -17,6 +17,11 @@ graph {
i: 0
type: INT
}
attribute {
name: "select_last_index"
i: 0
type: INT
}
}
name: "torch_jit"
input {
Expand Down Expand Up @@ -50,5 +55,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_asin.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -43,5 +43,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_at_op.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -54,5 +54,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_atan.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -43,5 +43,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
53 changes: 28 additions & 25 deletions test/onnx/expect/TestOperators.test_avg_pool2d.expect
@@ -1,40 +1,43 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
node {
output: "onnx::Pad_1"
name: "Constant_0"
op_type: "Constant"
attribute {
name: "value"
t {
dims: 8
data_type: 7
raw_data: "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
}
type: TENSOR
}
}
node {
input: "onnx::Pad_0"
output: "onnx::AveragePool_1"
name: "Pad_0"
input: "onnx::Pad_1"
output: "onnx::AveragePool_2"
name: "Pad_1"
op_type: "Pad"
attribute {
name: "mode"
s: "constant"
type: STRING
}
attribute {
name: "pads"
ints: 0
ints: 0
ints: 0
ints: 0
ints: 0
ints: 0
ints: 0
ints: 0
type: INTS
}
attribute {
name: "value"
f: 0
type: FLOAT
}
}
node {
input: "onnx::AveragePool_1"
output: "2"
name: "AveragePool_1"
input: "onnx::AveragePool_2"
output: "3"
name: "AveragePool_2"
op_type: "AveragePool"
attribute {
name: "ceil_mode"
i: 0
type: INT
}
attribute {
name: "kernel_shape"
ints: 3
Expand Down Expand Up @@ -80,7 +83,7 @@ graph {
}
}
output {
name: "2"
name: "3"
type {
tensor_type {
elem_type: 1
Expand All @@ -103,5 +106,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_baddbmm.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -119,5 +119,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_basic.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -76,5 +76,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_batchnorm.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -145,5 +145,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_batchnorm_1d.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -133,5 +133,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_batchnorm_noaffine.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -135,5 +135,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -93,5 +93,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}
4 changes: 2 additions & 2 deletions test/onnx/expect/TestOperators.test_batchnorm_training.expect
@@ -1,4 +1,4 @@
ir_version: 4
ir_version: 7
producer_name: "pytorch"
producer_version: "CURRENT_VERSION"
graph {
Expand Down Expand Up @@ -149,5 +149,5 @@ graph {
}
}
opset_import {
version: 9
version: 13
}

0 comments on commit ca37477

Please sign in to comment.