From 02e35ce17b09951ff9381fba30d82b7ea22dbed8 Mon Sep 17 00:00:00 2001 From: Bowen Bao Date: Fri, 5 Nov 2021 10:27:10 -0700 Subject: [PATCH] [ONNX] Update onnx function export with comments and clean up (#66817) (#67803) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/67803 * Addresses comments from #63589 [ONNX] remove torch::onnx::PRODUCER_VERSION (#67107) Use constants from version.h instead. This simplifies things since we no longer have to update PRODUCER_VERSION for each release. Also add TORCH_VERSION to version.h so that a string is available for this purpose. [ONNX] Set `ir_version` based on opset_version. (#67128) This increases the odds that the exported ONNX model will be usable. Before this change, we were setting the IR version to a value which may be higher than what the model consumer supports. Also some minor clean-up in the test code: * Fix string replacement. * Use a temporary file so as to not leave files around in the test current working directory. Test Plan: Imported from OSS Reviewed By: msaroufim Differential Revision: D32181306 Pulled By: malfet fbshipit-source-id: 02f136d34ef8f664ade0bc1985a584f0e8c2b663 Co-authored-by: BowenBao Co-authored-by: Gary Miguel Co-authored-by: Nikita Shulga --- docs/cpp/source/notes/versioning.rst | 4 +- .../expect/TestOperators.test_acos.expect | 2 +- .../TestOperators.test_add_broadcast.expect | 2 +- ...stOperators.test_add_left_broadcast.expect | 2 +- ...tOperators.test_add_size1_broadcast.expect | 2 +- ...tors.test_add_size1_right_broadcast.expect | 2 +- ....test_add_size1_singleton_broadcast.expect | 2 +- .../TestOperators.test_addconstant.expect | 2 +- .../expect/TestOperators.test_addmm.expect | 2 +- .../TestOperators.test_arange_dynamic.expect | 2 +- .../expect/TestOperators.test_argmax.expect | 2 +- .../expect/TestOperators.test_asin.expect | 2 +- .../expect/TestOperators.test_at_op.expect | 2 +- .../expect/TestOperators.test_atan.expect | 2 +- .../TestOperators.test_avg_pool2d.expect | 2 +- .../expect/TestOperators.test_baddbmm.expect | 2 +- .../expect/TestOperators.test_basic.expect | 2 +- .../TestOperators.test_batchnorm.expect | 2 +- .../TestOperators.test_batchnorm_1d.expect | 2 +- ...stOperators.test_batchnorm_noaffine.expect | 2 +- ...tOperators.test_batchnorm_onnx_irv4.expect | 2 +- ...stOperators.test_batchnorm_training.expect | 2 +- .../expect/TestOperators.test_bitshift.expect | 2 +- .../expect/TestOperators.test_c2_op.expect | 2 +- .../expect/TestOperators.test_chunk.expect | 2 +- .../expect/TestOperators.test_clip.expect | 2 +- .../expect/TestOperators.test_clip_max.expect | 2 +- .../expect/TestOperators.test_clip_min.expect | 2 +- .../expect/TestOperators.test_concat2.expect | 2 +- .../expect/TestOperators.test_conv.expect | 2 +- .../TestOperators.test_conv_onnx_irv4.expect | 2 +- ...perators.test_conv_onnx_irv4_opset8.expect | 2 +- .../TestOperators.test_convtranspose.expect | 2 +- .../onnx/expect/TestOperators.test_cos.expect | 2 +- .../expect/TestOperators.test_cumsum.expect | 2 +- .../onnx/expect/TestOperators.test_det.expect | 2 +- .../expect/TestOperators.test_dict.expect | 2 +- .../expect/TestOperators.test_dict_str.expect | 2 +- .../onnx/expect/TestOperators.test_dim.expect | 2 +- .../expect/TestOperators.test_dropout.expect | 2 +- .../TestOperators.test_dropout_default.expect | 2 +- ...TestOperators.test_dropout_training.expect | 2 +- .../onnx/expect/TestOperators.test_elu.expect | 2 +- .../TestOperators.test_embedding_bags.expect | 2 +- .../TestOperators.test_empty_like.expect | 2 +- ...estOperators.test_empty_like_opset7.expect | 2 +- .../expect/TestOperators.test_equal.expect | 2 +- .../onnx/expect/TestOperators.test_erf.expect | 2 +- .../onnx/expect/TestOperators.test_exp.expect | 2 +- .../expect/TestOperators.test_expand.expect | 2 +- .../expect/TestOperators.test_flatten.expect | 2 +- .../TestOperators.test_flatten2D.expect | 2 +- .../expect/TestOperators.test_fmod.expect | 2 +- .../TestOperators.test_frobenius_norm.expect | 2 +- .../expect/TestOperators.test_full.expect | 2 +- .../TestOperators.test_full_like.expect | 2 +- .../expect/TestOperators.test_gather.expect | 2 +- .../TestOperators.test_gather_opset11.expect | 2 +- test/onnx/expect/TestOperators.test_ge.expect | 2 +- .../expect/TestOperators.test_gelu.expect | 2 +- test/onnx/expect/TestOperators.test_gt.expect | 2 +- .../expect/TestOperators.test_hardtanh.expect | 2 +- .../TestOperators.test_implicit_expand.expect | 2 +- .../expect/TestOperators.test_index.expect | 2 +- .../expect/TestOperators.test_isnan.expect | 2 +- .../TestOperators.test_layer_norm_aten.expect | 2 +- test/onnx/expect/TestOperators.test_le.expect | 2 +- .../expect/TestOperators.test_linear.expect | 2 +- .../TestOperators.test_log_sigmoid.expect | 2 +- .../TestOperators.test_logsoftmax.expect | 2 +- test/onnx/expect/TestOperators.test_lt.expect | 2 +- .../TestOperators.test_master_opset.expect | 2 +- .../onnx/expect/TestOperators.test_max.expect | 2 +- .../expect/TestOperators.test_maxpool.expect | 2 +- ...estOperators.test_maxpool_dilations.expect | 2 +- .../TestOperators.test_maxpool_indices.expect | 2 +- .../expect/TestOperators.test_mean.expect | 2 +- .../TestOperators.test_mean_dtype.expect | 2 +- .../expect/TestOperators.test_meshgrid.expect | 2 +- .../onnx/expect/TestOperators.test_min.expect | 2 +- test/onnx/expect/TestOperators.test_mm.expect | 2 +- .../expect/TestOperators.test_narrow.expect | 2 +- test/onnx/expect/TestOperators.test_ne.expect | 2 +- .../expect/TestOperators.test_nonzero.expect | 2 +- .../expect/TestOperators.test_norm_p1.expect | 2 +- .../expect/TestOperators.test_norm_p2.expect | 2 +- .../TestOperators.test_ones_like.expect | 2 +- .../onnx/expect/TestOperators.test_pad.expect | 2 +- .../expect/TestOperators.test_params.expect | 2 +- ...TestOperators.test_params_onnx_irv4.expect | 2 +- .../expect/TestOperators.test_permute2.expect | 2 +- .../TestOperators.test_pixel_shuffle.expect | 2 +- .../onnx/expect/TestOperators.test_pow.expect | 2 +- .../expect/TestOperators.test_prelu.expect | 2 +- .../expect/TestOperators.test_prod.expect | 2 +- .../TestOperators.test_prod_dtype.expect | 2 +- .../expect/TestOperators.test_rand.expect | 2 +- .../expect/TestOperators.test_randn.expect | 2 +- ...rs.test_reduce_sum_negative_indices.expect | 2 +- .../TestOperators.test_reduced_mean.expect | 2 +- ...stOperators.test_reduced_mean_dtype.expect | 2 +- ...Operators.test_reduced_mean_keepdim.expect | 2 +- .../TestOperators.test_reduced_prod.expect | 2 +- ...stOperators.test_reduced_prod_dtype.expect | 2 +- ...Operators.test_reduced_prod_keepdim.expect | 2 +- .../TestOperators.test_reduced_sum.expect | 2 +- ...estOperators.test_reduced_sum_dtype.expect | 2 +- ...tOperators.test_reduced_sum_keepdim.expect | 2 +- .../TestOperators.test_reducemax.expect | 2 +- .../TestOperators.test_reducemin.expect | 2 +- .../TestOperators.test_remainder.expect | 2 +- .../expect/TestOperators.test_repeat.expect | 2 +- ...tOperators.test_repeat_dim_overflow.expect | 2 +- ...ors.test_retain_param_name_disabled.expect | 2 +- .../expect/TestOperators.test_round.expect | 2 +- .../expect/TestOperators.test_rrelu.expect | 2 +- .../expect/TestOperators.test_rsqrt.expect | 2 +- .../expect/TestOperators.test_rsub.expect | 2 +- .../TestOperators.test_scatter_add.expect | 2 +- ...tOperators.test_scatter_add_opset11.expect | 2 +- .../expect/TestOperators.test_selu.expect | 2 +- .../expect/TestOperators.test_sign.expect | 2 +- .../onnx/expect/TestOperators.test_sin.expect | 2 +- .../expect/TestOperators.test_slice.expect | 2 +- .../TestOperators.test_slice_dynamic.expect | 2 +- .../expect/TestOperators.test_split.expect | 2 +- ...TestOperators.test_split_with_sizes.expect | 2 +- .../expect/TestOperators.test_sqrt.expect | 2 +- .../onnx/expect/TestOperators.test_std.expect | 2 +- .../onnx/expect/TestOperators.test_sum.expect | 2 +- .../TestOperators.test_sum_dtype.expect | 2 +- .../onnx/expect/TestOperators.test_tan.expect | 2 +- .../expect/TestOperators.test_topk.expect | 2 +- ...erators.test_topk_smallest_unsorted.expect | 2 +- .../TestOperators.test_transpose.expect | 2 +- .../expect/TestOperators.test_type_as.expect | 2 +- .../expect/TestOperators.test_unfold.expect | 2 +- .../expect/TestOperators.test_unique.expect | 2 +- .../TestOperators.test_unsqueeze.expect | 2 +- ...erators.test_upsample_nearest_scale.expect | 2 +- ..._nearest_scale_default_scale_factor.expect | 2 +- ...perators.test_upsample_nearest_size.expect | 2 +- .../expect/TestOperators.test_view.expect | 2 +- .../TestOperators.test_view_flatten.expect | 2 +- .../TestOperators.test_zeros_like.expect | 2 +- test/onnx/test_onnx_opset.py | 10 +- test/onnx/test_operators.py | 7 +- test/onnx/test_pytorch_onnx_onnxruntime.py | 16 ++ test/onnx/test_utility_funs.py | 57 ++++-- torch/_C/__init__.pyi.in | 2 +- torch/_C/_onnx.pyi | 1 - torch/csrc/api/include/torch/version.h.in | 4 + .../jit/passes/onnx/function_extraction.cpp | 183 ++++++------------ .../jit/passes/onnx/function_extraction.h | 16 +- torch/csrc/jit/passes/onnx/helper.cpp | 20 +- torch/csrc/jit/python/python_ir.cpp | 3 - torch/csrc/jit/serialization/export.cpp | 105 +++++++--- torch/csrc/jit/serialization/export.h | 1 - torch/csrc/onnx/init.cpp | 26 +-- torch/csrc/onnx/onnx.h | 5 - torch/onnx/__init__.py | 10 +- torch/onnx/utils.py | 20 +- torch/testing/_internal/common_utils.py | 2 +- 163 files changed, 402 insertions(+), 378 deletions(-) diff --git a/docs/cpp/source/notes/versioning.rst b/docs/cpp/source/notes/versioning.rst index 32a77a05588..b7c79427bb0 100644 --- a/docs/cpp/source/notes/versioning.rst +++ b/docs/cpp/source/notes/versioning.rst @@ -10,16 +10,18 @@ Example usage: #include int main() { - std::cout << "PyTorch version: " + std::cout << "PyTorch version from parts: " << TORCH_VERSION_MAJOR << "." << TORCH_VERSION_MINOR << "." << TORCH_VERSION_PATCH << std::endl; + std::cout << "PyTorch version: " << TORCH_VERSION << std::endl; } This will output something like: .. code-block:: text + PyTorch version from parts: 1.8.0 PyTorch version: 1.8.0 .. note:: diff --git a/test/onnx/expect/TestOperators.test_acos.expect b/test/onnx/expect/TestOperators.test_acos.expect index 14d54b456dc..f5a066614db 100644 --- a/test/onnx/expect/TestOperators.test_acos.expect +++ b/test/onnx/expect/TestOperators.test_acos.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_add_broadcast.expect b/test/onnx/expect/TestOperators.test_add_broadcast.expect index ae7aa88621d..576f4f109b1 100644 --- a/test/onnx/expect/TestOperators.test_add_broadcast.expect +++ b/test/onnx/expect/TestOperators.test_add_broadcast.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_add_left_broadcast.expect b/test/onnx/expect/TestOperators.test_add_left_broadcast.expect index f449f675224..39fe3f74538 100644 --- a/test/onnx/expect/TestOperators.test_add_left_broadcast.expect +++ b/test/onnx/expect/TestOperators.test_add_left_broadcast.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_add_size1_broadcast.expect b/test/onnx/expect/TestOperators.test_add_size1_broadcast.expect index b68b953c79b..63fb5a1a598 100644 --- a/test/onnx/expect/TestOperators.test_add_size1_broadcast.expect +++ b/test/onnx/expect/TestOperators.test_add_size1_broadcast.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_add_size1_right_broadcast.expect b/test/onnx/expect/TestOperators.test_add_size1_right_broadcast.expect index ae7aa88621d..576f4f109b1 100644 --- a/test/onnx/expect/TestOperators.test_add_size1_right_broadcast.expect +++ b/test/onnx/expect/TestOperators.test_add_size1_right_broadcast.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_add_size1_singleton_broadcast.expect b/test/onnx/expect/TestOperators.test_add_size1_singleton_broadcast.expect index 46b83aa47e7..11b8baea839 100644 --- a/test/onnx/expect/TestOperators.test_add_size1_singleton_broadcast.expect +++ b/test/onnx/expect/TestOperators.test_add_size1_singleton_broadcast.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_addconstant.expect b/test/onnx/expect/TestOperators.test_addconstant.expect index fa4d7aeeb00..d4155df14a2 100644 --- a/test/onnx/expect/TestOperators.test_addconstant.expect +++ b/test/onnx/expect/TestOperators.test_addconstant.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_addmm.expect b/test/onnx/expect/TestOperators.test_addmm.expect index 1ec96ac03b7..e42b70c4728 100644 --- a/test/onnx/expect/TestOperators.test_addmm.expect +++ b/test/onnx/expect/TestOperators.test_addmm.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_arange_dynamic.expect b/test/onnx/expect/TestOperators.test_arange_dynamic.expect index 04a1937df03..6de30ee46c4 100644 --- a/test/onnx/expect/TestOperators.test_arange_dynamic.expect +++ b/test/onnx/expect/TestOperators.test_arange_dynamic.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_argmax.expect b/test/onnx/expect/TestOperators.test_argmax.expect index 1ee77d710d6..073aa3b3128 100644 --- a/test/onnx/expect/TestOperators.test_argmax.expect +++ b/test/onnx/expect/TestOperators.test_argmax.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_asin.expect b/test/onnx/expect/TestOperators.test_asin.expect index 27cca19b839..da99df3cbe6 100644 --- a/test/onnx/expect/TestOperators.test_asin.expect +++ b/test/onnx/expect/TestOperators.test_asin.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_at_op.expect b/test/onnx/expect/TestOperators.test_at_op.expect index f245354a6fd..a0f13b75424 100644 --- a/test/onnx/expect/TestOperators.test_at_op.expect +++ b/test/onnx/expect/TestOperators.test_at_op.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_atan.expect b/test/onnx/expect/TestOperators.test_atan.expect index 3492e244df4..c72d6250a9b 100644 --- a/test/onnx/expect/TestOperators.test_atan.expect +++ b/test/onnx/expect/TestOperators.test_atan.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_avg_pool2d.expect b/test/onnx/expect/TestOperators.test_avg_pool2d.expect index c606b516701..ff3d86d6597 100644 --- a/test/onnx/expect/TestOperators.test_avg_pool2d.expect +++ b/test/onnx/expect/TestOperators.test_avg_pool2d.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_baddbmm.expect b/test/onnx/expect/TestOperators.test_baddbmm.expect index 0dedfe96647..d68a0cd8539 100644 --- a/test/onnx/expect/TestOperators.test_baddbmm.expect +++ b/test/onnx/expect/TestOperators.test_baddbmm.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_basic.expect b/test/onnx/expect/TestOperators.test_basic.expect index c18a636f8c4..65b5a49472f 100644 --- a/test/onnx/expect/TestOperators.test_basic.expect +++ b/test/onnx/expect/TestOperators.test_basic.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_batchnorm.expect b/test/onnx/expect/TestOperators.test_batchnorm.expect index c404aabc21a..5071995d8b3 100644 --- a/test/onnx/expect/TestOperators.test_batchnorm.expect +++ b/test/onnx/expect/TestOperators.test_batchnorm.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_batchnorm_1d.expect b/test/onnx/expect/TestOperators.test_batchnorm_1d.expect index 61eb404f7a8..136fc681ecf 100644 --- a/test/onnx/expect/TestOperators.test_batchnorm_1d.expect +++ b/test/onnx/expect/TestOperators.test_batchnorm_1d.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_batchnorm_noaffine.expect b/test/onnx/expect/TestOperators.test_batchnorm_noaffine.expect index 79b2c42d08a..076e8a1be98 100644 --- a/test/onnx/expect/TestOperators.test_batchnorm_noaffine.expect +++ b/test/onnx/expect/TestOperators.test_batchnorm_noaffine.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_batchnorm_onnx_irv4.expect b/test/onnx/expect/TestOperators.test_batchnorm_onnx_irv4.expect index 6552defe9a4..68ae47d8d24 100644 --- a/test/onnx/expect/TestOperators.test_batchnorm_onnx_irv4.expect +++ b/test/onnx/expect/TestOperators.test_batchnorm_onnx_irv4.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_batchnorm_training.expect b/test/onnx/expect/TestOperators.test_batchnorm_training.expect index 47d2a35d5ef..a0bc171ed9e 100644 --- a/test/onnx/expect/TestOperators.test_batchnorm_training.expect +++ b/test/onnx/expect/TestOperators.test_batchnorm_training.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_bitshift.expect b/test/onnx/expect/TestOperators.test_bitshift.expect index ede6be0b8f1..af67f38bb5e 100644 --- a/test/onnx/expect/TestOperators.test_bitshift.expect +++ b/test/onnx/expect/TestOperators.test_bitshift.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_c2_op.expect b/test/onnx/expect/TestOperators.test_c2_op.expect index 884b8c5cce6..3c935b3bbed 100644 --- a/test/onnx/expect/TestOperators.test_c2_op.expect +++ b/test/onnx/expect/TestOperators.test_c2_op.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_chunk.expect b/test/onnx/expect/TestOperators.test_chunk.expect index bdbffa146cd..4da0abae5a0 100644 --- a/test/onnx/expect/TestOperators.test_chunk.expect +++ b/test/onnx/expect/TestOperators.test_chunk.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_clip.expect b/test/onnx/expect/TestOperators.test_clip.expect index 5c08e753924..d5170263e97 100644 --- a/test/onnx/expect/TestOperators.test_clip.expect +++ b/test/onnx/expect/TestOperators.test_clip.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_clip_max.expect b/test/onnx/expect/TestOperators.test_clip_max.expect index 0827b214e0f..2faa1e16cef 100644 --- a/test/onnx/expect/TestOperators.test_clip_max.expect +++ b/test/onnx/expect/TestOperators.test_clip_max.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_clip_min.expect b/test/onnx/expect/TestOperators.test_clip_min.expect index 3fcee9ddadf..050a37eed88 100644 --- a/test/onnx/expect/TestOperators.test_clip_min.expect +++ b/test/onnx/expect/TestOperators.test_clip_min.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_concat2.expect b/test/onnx/expect/TestOperators.test_concat2.expect index 0a6018d4d67..9ba5b1c9bc3 100644 --- a/test/onnx/expect/TestOperators.test_concat2.expect +++ b/test/onnx/expect/TestOperators.test_concat2.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_conv.expect b/test/onnx/expect/TestOperators.test_conv.expect index a32406df311..9f63f64dae0 100644 --- a/test/onnx/expect/TestOperators.test_conv.expect +++ b/test/onnx/expect/TestOperators.test_conv.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_conv_onnx_irv4.expect b/test/onnx/expect/TestOperators.test_conv_onnx_irv4.expect index 835e4b2c2fc..2347dc7da91 100644 --- a/test/onnx/expect/TestOperators.test_conv_onnx_irv4.expect +++ b/test/onnx/expect/TestOperators.test_conv_onnx_irv4.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_conv_onnx_irv4_opset8.expect b/test/onnx/expect/TestOperators.test_conv_onnx_irv4_opset8.expect index ad4aa2ec892..3737ed4a571 100644 --- a/test/onnx/expect/TestOperators.test_conv_onnx_irv4_opset8.expect +++ b/test/onnx/expect/TestOperators.test_conv_onnx_irv4_opset8.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 3 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_convtranspose.expect b/test/onnx/expect/TestOperators.test_convtranspose.expect index 0005513b6f1..bef98d2f601 100644 --- a/test/onnx/expect/TestOperators.test_convtranspose.expect +++ b/test/onnx/expect/TestOperators.test_convtranspose.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_cos.expect b/test/onnx/expect/TestOperators.test_cos.expect index 5b82f04dc77..03693a53ff6 100644 --- a/test/onnx/expect/TestOperators.test_cos.expect +++ b/test/onnx/expect/TestOperators.test_cos.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_cumsum.expect b/test/onnx/expect/TestOperators.test_cumsum.expect index e7a7ff6a12f..a4daeb9233d 100644 --- a/test/onnx/expect/TestOperators.test_cumsum.expect +++ b/test/onnx/expect/TestOperators.test_cumsum.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_det.expect b/test/onnx/expect/TestOperators.test_det.expect index c4f363dc84a..45c0b7a7f1b 100644 --- a/test/onnx/expect/TestOperators.test_det.expect +++ b/test/onnx/expect/TestOperators.test_det.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_dict.expect b/test/onnx/expect/TestOperators.test_dict.expect index 252fe2339f8..ac235a80dbc 100644 --- a/test/onnx/expect/TestOperators.test_dict.expect +++ b/test/onnx/expect/TestOperators.test_dict.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_dict_str.expect b/test/onnx/expect/TestOperators.test_dict_str.expect index 25997e1ef1a..6de080b051a 100644 --- a/test/onnx/expect/TestOperators.test_dict_str.expect +++ b/test/onnx/expect/TestOperators.test_dict_str.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_dim.expect b/test/onnx/expect/TestOperators.test_dim.expect index 52c8b09d640..4b1f6a3881d 100644 --- a/test/onnx/expect/TestOperators.test_dim.expect +++ b/test/onnx/expect/TestOperators.test_dim.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_dropout.expect b/test/onnx/expect/TestOperators.test_dropout.expect index f8ba8c39e00..6cea69c5c17 100644 --- a/test/onnx/expect/TestOperators.test_dropout.expect +++ b/test/onnx/expect/TestOperators.test_dropout.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_dropout_default.expect b/test/onnx/expect/TestOperators.test_dropout_default.expect index 4e406513546..cc0d6881b85 100644 --- a/test/onnx/expect/TestOperators.test_dropout_default.expect +++ b/test/onnx/expect/TestOperators.test_dropout_default.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_dropout_training.expect b/test/onnx/expect/TestOperators.test_dropout_training.expect index 4e406513546..cc0d6881b85 100644 --- a/test/onnx/expect/TestOperators.test_dropout_training.expect +++ b/test/onnx/expect/TestOperators.test_dropout_training.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_elu.expect b/test/onnx/expect/TestOperators.test_elu.expect index 74fb4ae8635..5dc0dc6db48 100644 --- a/test/onnx/expect/TestOperators.test_elu.expect +++ b/test/onnx/expect/TestOperators.test_elu.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_embedding_bags.expect b/test/onnx/expect/TestOperators.test_embedding_bags.expect index 546a5138d23..630fee8ba8e 100644 --- a/test/onnx/expect/TestOperators.test_embedding_bags.expect +++ b/test/onnx/expect/TestOperators.test_embedding_bags.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_empty_like.expect b/test/onnx/expect/TestOperators.test_empty_like.expect index beef8cac8db..27ac2298318 100644 --- a/test/onnx/expect/TestOperators.test_empty_like.expect +++ b/test/onnx/expect/TestOperators.test_empty_like.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_empty_like_opset7.expect b/test/onnx/expect/TestOperators.test_empty_like_opset7.expect index 9d8dd0b9dd0..045c4e15a48 100644 --- a/test/onnx/expect/TestOperators.test_empty_like_opset7.expect +++ b/test/onnx/expect/TestOperators.test_empty_like_opset7.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 3 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_equal.expect b/test/onnx/expect/TestOperators.test_equal.expect index b63a936c733..0f348cc4989 100644 --- a/test/onnx/expect/TestOperators.test_equal.expect +++ b/test/onnx/expect/TestOperators.test_equal.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_erf.expect b/test/onnx/expect/TestOperators.test_erf.expect index e2c3e132a27..4d31a9d9eab 100644 --- a/test/onnx/expect/TestOperators.test_erf.expect +++ b/test/onnx/expect/TestOperators.test_erf.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_exp.expect b/test/onnx/expect/TestOperators.test_exp.expect index 5396510a93b..057cc6181a3 100644 --- a/test/onnx/expect/TestOperators.test_exp.expect +++ b/test/onnx/expect/TestOperators.test_exp.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_expand.expect b/test/onnx/expect/TestOperators.test_expand.expect index 3a1a1518098..48175ca3a47 100644 --- a/test/onnx/expect/TestOperators.test_expand.expect +++ b/test/onnx/expect/TestOperators.test_expand.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_flatten.expect b/test/onnx/expect/TestOperators.test_flatten.expect index 55471e72a15..9425c628192 100644 --- a/test/onnx/expect/TestOperators.test_flatten.expect +++ b/test/onnx/expect/TestOperators.test_flatten.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_flatten2D.expect b/test/onnx/expect/TestOperators.test_flatten2D.expect index 4b03b939bd3..e5f7b68b04f 100644 --- a/test/onnx/expect/TestOperators.test_flatten2D.expect +++ b/test/onnx/expect/TestOperators.test_flatten2D.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_fmod.expect b/test/onnx/expect/TestOperators.test_fmod.expect index 05addc2ba3e..0a3dc365437 100644 --- a/test/onnx/expect/TestOperators.test_fmod.expect +++ b/test/onnx/expect/TestOperators.test_fmod.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 5 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_frobenius_norm.expect b/test/onnx/expect/TestOperators.test_frobenius_norm.expect index a689f8d0b84..25270b287ce 100644 --- a/test/onnx/expect/TestOperators.test_frobenius_norm.expect +++ b/test/onnx/expect/TestOperators.test_frobenius_norm.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_full.expect b/test/onnx/expect/TestOperators.test_full.expect index ea1eec5b212..a832bd8e2c5 100644 --- a/test/onnx/expect/TestOperators.test_full.expect +++ b/test/onnx/expect/TestOperators.test_full.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_full_like.expect b/test/onnx/expect/TestOperators.test_full_like.expect index ea1eec5b212..a832bd8e2c5 100644 --- a/test/onnx/expect/TestOperators.test_full_like.expect +++ b/test/onnx/expect/TestOperators.test_full_like.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_gather.expect b/test/onnx/expect/TestOperators.test_gather.expect index 3963e54eecf..fede00e1123 100644 --- a/test/onnx/expect/TestOperators.test_gather.expect +++ b/test/onnx/expect/TestOperators.test_gather.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_gather_opset11.expect b/test/onnx/expect/TestOperators.test_gather_opset11.expect index f8c4364b1dc..c2e9bd35580 100644 --- a/test/onnx/expect/TestOperators.test_gather_opset11.expect +++ b/test/onnx/expect/TestOperators.test_gather_opset11.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_ge.expect b/test/onnx/expect/TestOperators.test_ge.expect index b63801d50e7..ce75fa3996a 100644 --- a/test/onnx/expect/TestOperators.test_ge.expect +++ b/test/onnx/expect/TestOperators.test_ge.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_gelu.expect b/test/onnx/expect/TestOperators.test_gelu.expect index 3dead9356af..27291c5cd24 100644 --- a/test/onnx/expect/TestOperators.test_gelu.expect +++ b/test/onnx/expect/TestOperators.test_gelu.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_gt.expect b/test/onnx/expect/TestOperators.test_gt.expect index 7b1ed6967ce..03609ca153c 100644 --- a/test/onnx/expect/TestOperators.test_gt.expect +++ b/test/onnx/expect/TestOperators.test_gt.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_hardtanh.expect b/test/onnx/expect/TestOperators.test_hardtanh.expect index 4c04dcebab3..3648a367d05 100644 --- a/test/onnx/expect/TestOperators.test_hardtanh.expect +++ b/test/onnx/expect/TestOperators.test_hardtanh.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_implicit_expand.expect b/test/onnx/expect/TestOperators.test_implicit_expand.expect index 5907ff9e5f6..b73e33fb3bc 100644 --- a/test/onnx/expect/TestOperators.test_implicit_expand.expect +++ b/test/onnx/expect/TestOperators.test_implicit_expand.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_index.expect b/test/onnx/expect/TestOperators.test_index.expect index f3810b7c830..adb93c05825 100644 --- a/test/onnx/expect/TestOperators.test_index.expect +++ b/test/onnx/expect/TestOperators.test_index.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_isnan.expect b/test/onnx/expect/TestOperators.test_isnan.expect index 8af57aca700..7cfe84e1f0a 100644 --- a/test/onnx/expect/TestOperators.test_isnan.expect +++ b/test/onnx/expect/TestOperators.test_isnan.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_layer_norm_aten.expect b/test/onnx/expect/TestOperators.test_layer_norm_aten.expect index 4062c9e85be..41a1ae69501 100644 --- a/test/onnx/expect/TestOperators.test_layer_norm_aten.expect +++ b/test/onnx/expect/TestOperators.test_layer_norm_aten.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_le.expect b/test/onnx/expect/TestOperators.test_le.expect index efe8bda9bda..ba12675e986 100644 --- a/test/onnx/expect/TestOperators.test_le.expect +++ b/test/onnx/expect/TestOperators.test_le.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_linear.expect b/test/onnx/expect/TestOperators.test_linear.expect index 63981a37a33..2c1adc42eff 100644 --- a/test/onnx/expect/TestOperators.test_linear.expect +++ b/test/onnx/expect/TestOperators.test_linear.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_log_sigmoid.expect b/test/onnx/expect/TestOperators.test_log_sigmoid.expect index fa2949cfc31..d99866fc3c2 100644 --- a/test/onnx/expect/TestOperators.test_log_sigmoid.expect +++ b/test/onnx/expect/TestOperators.test_log_sigmoid.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_logsoftmax.expect b/test/onnx/expect/TestOperators.test_logsoftmax.expect index fcf4f8ef69a..4ae37e23b95 100644 --- a/test/onnx/expect/TestOperators.test_logsoftmax.expect +++ b/test/onnx/expect/TestOperators.test_logsoftmax.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_lt.expect b/test/onnx/expect/TestOperators.test_lt.expect index 40445e1d5d0..3ad79bf27b5 100644 --- a/test/onnx/expect/TestOperators.test_lt.expect +++ b/test/onnx/expect/TestOperators.test_lt.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_master_opset.expect b/test/onnx/expect/TestOperators.test_master_opset.expect index ae2af81d0c2..79c3ea3a3cb 100644 --- a/test/onnx/expect/TestOperators.test_master_opset.expect +++ b/test/onnx/expect/TestOperators.test_master_opset.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 5 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_max.expect b/test/onnx/expect/TestOperators.test_max.expect index bee5036e6ff..c86713d7aa5 100644 --- a/test/onnx/expect/TestOperators.test_max.expect +++ b/test/onnx/expect/TestOperators.test_max.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_maxpool.expect b/test/onnx/expect/TestOperators.test_maxpool.expect index 0e06b6e4655..1bfb8fab345 100644 --- a/test/onnx/expect/TestOperators.test_maxpool.expect +++ b/test/onnx/expect/TestOperators.test_maxpool.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_maxpool_dilations.expect b/test/onnx/expect/TestOperators.test_maxpool_dilations.expect index a297a3a32df..a76bb488bca 100644 --- a/test/onnx/expect/TestOperators.test_maxpool_dilations.expect +++ b/test/onnx/expect/TestOperators.test_maxpool_dilations.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 5 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_maxpool_indices.expect b/test/onnx/expect/TestOperators.test_maxpool_indices.expect index f8624dd1f62..845b0d92529 100644 --- a/test/onnx/expect/TestOperators.test_maxpool_indices.expect +++ b/test/onnx/expect/TestOperators.test_maxpool_indices.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_mean.expect b/test/onnx/expect/TestOperators.test_mean.expect index 2c517770551..d62bcb708fb 100644 --- a/test/onnx/expect/TestOperators.test_mean.expect +++ b/test/onnx/expect/TestOperators.test_mean.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_mean_dtype.expect b/test/onnx/expect/TestOperators.test_mean_dtype.expect index 05e9ce1b02f..918a1fc75f5 100644 --- a/test/onnx/expect/TestOperators.test_mean_dtype.expect +++ b/test/onnx/expect/TestOperators.test_mean_dtype.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_meshgrid.expect b/test/onnx/expect/TestOperators.test_meshgrid.expect index a901fbcc30f..3ff81b18edb 100644 --- a/test/onnx/expect/TestOperators.test_meshgrid.expect +++ b/test/onnx/expect/TestOperators.test_meshgrid.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_min.expect b/test/onnx/expect/TestOperators.test_min.expect index 8394a22cb0d..ae91947df34 100644 --- a/test/onnx/expect/TestOperators.test_min.expect +++ b/test/onnx/expect/TestOperators.test_min.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_mm.expect b/test/onnx/expect/TestOperators.test_mm.expect index be7ab78ed4e..5eb444c5292 100644 --- a/test/onnx/expect/TestOperators.test_mm.expect +++ b/test/onnx/expect/TestOperators.test_mm.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_narrow.expect b/test/onnx/expect/TestOperators.test_narrow.expect index 5b8cf3b9cbd..3e04843e8c7 100644 --- a/test/onnx/expect/TestOperators.test_narrow.expect +++ b/test/onnx/expect/TestOperators.test_narrow.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_ne.expect b/test/onnx/expect/TestOperators.test_ne.expect index 8b858eb0751..6aae36c92b0 100644 --- a/test/onnx/expect/TestOperators.test_ne.expect +++ b/test/onnx/expect/TestOperators.test_ne.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_nonzero.expect b/test/onnx/expect/TestOperators.test_nonzero.expect index 515f7758d96..88534fedefb 100644 --- a/test/onnx/expect/TestOperators.test_nonzero.expect +++ b/test/onnx/expect/TestOperators.test_nonzero.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_norm_p1.expect b/test/onnx/expect/TestOperators.test_norm_p1.expect index 964112ca91f..c73b5b35b37 100644 --- a/test/onnx/expect/TestOperators.test_norm_p1.expect +++ b/test/onnx/expect/TestOperators.test_norm_p1.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_norm_p2.expect b/test/onnx/expect/TestOperators.test_norm_p2.expect index 063af8344e6..6eb7dace54a 100644 --- a/test/onnx/expect/TestOperators.test_norm_p2.expect +++ b/test/onnx/expect/TestOperators.test_norm_p2.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_ones_like.expect b/test/onnx/expect/TestOperators.test_ones_like.expect index 5749bdc1e7a..ec25d269f79 100644 --- a/test/onnx/expect/TestOperators.test_ones_like.expect +++ b/test/onnx/expect/TestOperators.test_ones_like.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_pad.expect b/test/onnx/expect/TestOperators.test_pad.expect index 2208d822466..db2cdefe75c 100644 --- a/test/onnx/expect/TestOperators.test_pad.expect +++ b/test/onnx/expect/TestOperators.test_pad.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_params.expect b/test/onnx/expect/TestOperators.test_params.expect index a65f7c48274..c364bdf883e 100644 --- a/test/onnx/expect/TestOperators.test_params.expect +++ b/test/onnx/expect/TestOperators.test_params.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_params_onnx_irv4.expect b/test/onnx/expect/TestOperators.test_params_onnx_irv4.expect index 6aedfa7ec95..5c47c0f6ad3 100644 --- a/test/onnx/expect/TestOperators.test_params_onnx_irv4.expect +++ b/test/onnx/expect/TestOperators.test_params_onnx_irv4.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_permute2.expect b/test/onnx/expect/TestOperators.test_permute2.expect index e02ee4bfa91..6d9d5a44220 100644 --- a/test/onnx/expect/TestOperators.test_permute2.expect +++ b/test/onnx/expect/TestOperators.test_permute2.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_pixel_shuffle.expect b/test/onnx/expect/TestOperators.test_pixel_shuffle.expect index 67d01030fc2..4a8a0590b00 100644 --- a/test/onnx/expect/TestOperators.test_pixel_shuffle.expect +++ b/test/onnx/expect/TestOperators.test_pixel_shuffle.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_pow.expect b/test/onnx/expect/TestOperators.test_pow.expect index f84f5b45f86..56d46868871 100644 --- a/test/onnx/expect/TestOperators.test_pow.expect +++ b/test/onnx/expect/TestOperators.test_pow.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_prelu.expect b/test/onnx/expect/TestOperators.test_prelu.expect index 24810cb424f..dd719156215 100644 --- a/test/onnx/expect/TestOperators.test_prelu.expect +++ b/test/onnx/expect/TestOperators.test_prelu.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_prod.expect b/test/onnx/expect/TestOperators.test_prod.expect index 2e4ba85ab50..5840b89b1f7 100644 --- a/test/onnx/expect/TestOperators.test_prod.expect +++ b/test/onnx/expect/TestOperators.test_prod.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_prod_dtype.expect b/test/onnx/expect/TestOperators.test_prod_dtype.expect index 888553b0cb9..273c059ab4d 100644 --- a/test/onnx/expect/TestOperators.test_prod_dtype.expect +++ b/test/onnx/expect/TestOperators.test_prod_dtype.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_rand.expect b/test/onnx/expect/TestOperators.test_rand.expect index 88fde7562c8..3bb585203ef 100644 --- a/test/onnx/expect/TestOperators.test_rand.expect +++ b/test/onnx/expect/TestOperators.test_rand.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_randn.expect b/test/onnx/expect/TestOperators.test_randn.expect index 15acc08b3f4..c0b736e4381 100644 --- a/test/onnx/expect/TestOperators.test_randn.expect +++ b/test/onnx/expect/TestOperators.test_randn.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduce_sum_negative_indices.expect b/test/onnx/expect/TestOperators.test_reduce_sum_negative_indices.expect index 486d0f80e20..a136d606f33 100644 --- a/test/onnx/expect/TestOperators.test_reduce_sum_negative_indices.expect +++ b/test/onnx/expect/TestOperators.test_reduce_sum_negative_indices.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_mean.expect b/test/onnx/expect/TestOperators.test_reduced_mean.expect index c071d17f6e8..f044f5f2a30 100644 --- a/test/onnx/expect/TestOperators.test_reduced_mean.expect +++ b/test/onnx/expect/TestOperators.test_reduced_mean.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_mean_dtype.expect b/test/onnx/expect/TestOperators.test_reduced_mean_dtype.expect index f7794768421..560a52fa9da 100644 --- a/test/onnx/expect/TestOperators.test_reduced_mean_dtype.expect +++ b/test/onnx/expect/TestOperators.test_reduced_mean_dtype.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_mean_keepdim.expect b/test/onnx/expect/TestOperators.test_reduced_mean_keepdim.expect index 9c21895b592..177d401fcd3 100644 --- a/test/onnx/expect/TestOperators.test_reduced_mean_keepdim.expect +++ b/test/onnx/expect/TestOperators.test_reduced_mean_keepdim.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_prod.expect b/test/onnx/expect/TestOperators.test_reduced_prod.expect index 84990b62368..cce8e5b2e24 100644 --- a/test/onnx/expect/TestOperators.test_reduced_prod.expect +++ b/test/onnx/expect/TestOperators.test_reduced_prod.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_prod_dtype.expect b/test/onnx/expect/TestOperators.test_reduced_prod_dtype.expect index 2be2fcdc9c8..2f7501ed7e5 100644 --- a/test/onnx/expect/TestOperators.test_reduced_prod_dtype.expect +++ b/test/onnx/expect/TestOperators.test_reduced_prod_dtype.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_prod_keepdim.expect b/test/onnx/expect/TestOperators.test_reduced_prod_keepdim.expect index f5eb8d137cc..38cdb9ff90b 100644 --- a/test/onnx/expect/TestOperators.test_reduced_prod_keepdim.expect +++ b/test/onnx/expect/TestOperators.test_reduced_prod_keepdim.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_sum.expect b/test/onnx/expect/TestOperators.test_reduced_sum.expect index 6e120f1a421..1a863dab4cc 100644 --- a/test/onnx/expect/TestOperators.test_reduced_sum.expect +++ b/test/onnx/expect/TestOperators.test_reduced_sum.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_sum_dtype.expect b/test/onnx/expect/TestOperators.test_reduced_sum_dtype.expect index b6b5ecf0066..1296cc4b289 100644 --- a/test/onnx/expect/TestOperators.test_reduced_sum_dtype.expect +++ b/test/onnx/expect/TestOperators.test_reduced_sum_dtype.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reduced_sum_keepdim.expect b/test/onnx/expect/TestOperators.test_reduced_sum_keepdim.expect index e574511c3be..5c30a195daa 100644 --- a/test/onnx/expect/TestOperators.test_reduced_sum_keepdim.expect +++ b/test/onnx/expect/TestOperators.test_reduced_sum_keepdim.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reducemax.expect b/test/onnx/expect/TestOperators.test_reducemax.expect index a0fcd108488..270962d22d3 100644 --- a/test/onnx/expect/TestOperators.test_reducemax.expect +++ b/test/onnx/expect/TestOperators.test_reducemax.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_reducemin.expect b/test/onnx/expect/TestOperators.test_reducemin.expect index 3a9d7ec4600..eff6285daf4 100644 --- a/test/onnx/expect/TestOperators.test_reducemin.expect +++ b/test/onnx/expect/TestOperators.test_reducemin.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_remainder.expect b/test/onnx/expect/TestOperators.test_remainder.expect index 60de2688c03..535d1a08a5b 100644 --- a/test/onnx/expect/TestOperators.test_remainder.expect +++ b/test/onnx/expect/TestOperators.test_remainder.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_repeat.expect b/test/onnx/expect/TestOperators.test_repeat.expect index 60593508625..73d8aad59a2 100644 --- a/test/onnx/expect/TestOperators.test_repeat.expect +++ b/test/onnx/expect/TestOperators.test_repeat.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_repeat_dim_overflow.expect b/test/onnx/expect/TestOperators.test_repeat_dim_overflow.expect index 3cb18357fc8..8ea1c53ceec 100644 --- a/test/onnx/expect/TestOperators.test_repeat_dim_overflow.expect +++ b/test/onnx/expect/TestOperators.test_repeat_dim_overflow.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_retain_param_name_disabled.expect b/test/onnx/expect/TestOperators.test_retain_param_name_disabled.expect index 54b10929338..bf10025d9f2 100644 --- a/test/onnx/expect/TestOperators.test_retain_param_name_disabled.expect +++ b/test/onnx/expect/TestOperators.test_retain_param_name_disabled.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 8 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_round.expect b/test/onnx/expect/TestOperators.test_round.expect index b1daa0eebd1..743c8e2d89d 100644 --- a/test/onnx/expect/TestOperators.test_round.expect +++ b/test/onnx/expect/TestOperators.test_round.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_rrelu.expect b/test/onnx/expect/TestOperators.test_rrelu.expect index d124d1e1c1f..a4bfc5fea4b 100644 --- a/test/onnx/expect/TestOperators.test_rrelu.expect +++ b/test/onnx/expect/TestOperators.test_rrelu.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_rsqrt.expect b/test/onnx/expect/TestOperators.test_rsqrt.expect index fa1e4fcfdf5..8129ccc47eb 100644 --- a/test/onnx/expect/TestOperators.test_rsqrt.expect +++ b/test/onnx/expect/TestOperators.test_rsqrt.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_rsub.expect b/test/onnx/expect/TestOperators.test_rsub.expect index ae4031d2bcf..e9621a1d0c0 100644 --- a/test/onnx/expect/TestOperators.test_rsub.expect +++ b/test/onnx/expect/TestOperators.test_rsub.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_scatter_add.expect b/test/onnx/expect/TestOperators.test_scatter_add.expect index 4d5613707c3..5e1cf633ce3 100644 --- a/test/onnx/expect/TestOperators.test_scatter_add.expect +++ b/test/onnx/expect/TestOperators.test_scatter_add.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_scatter_add_opset11.expect b/test/onnx/expect/TestOperators.test_scatter_add_opset11.expect index f2306493b99..2dd92a71d00 100644 --- a/test/onnx/expect/TestOperators.test_scatter_add_opset11.expect +++ b/test/onnx/expect/TestOperators.test_scatter_add_opset11.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_selu.expect b/test/onnx/expect/TestOperators.test_selu.expect index 1240c4f6999..bbfedf15051 100644 --- a/test/onnx/expect/TestOperators.test_selu.expect +++ b/test/onnx/expect/TestOperators.test_selu.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_sign.expect b/test/onnx/expect/TestOperators.test_sign.expect index 9ae5abe46da..39f4bf5921a 100644 --- a/test/onnx/expect/TestOperators.test_sign.expect +++ b/test/onnx/expect/TestOperators.test_sign.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_sin.expect b/test/onnx/expect/TestOperators.test_sin.expect index 115756eb152..d78a4aaf28c 100644 --- a/test/onnx/expect/TestOperators.test_sin.expect +++ b/test/onnx/expect/TestOperators.test_sin.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_slice.expect b/test/onnx/expect/TestOperators.test_slice.expect index 4752f83e72f..b0b1a9e16d8 100644 --- a/test/onnx/expect/TestOperators.test_slice.expect +++ b/test/onnx/expect/TestOperators.test_slice.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_slice_dynamic.expect b/test/onnx/expect/TestOperators.test_slice_dynamic.expect index bbc88639193..da6c585a659 100644 --- a/test/onnx/expect/TestOperators.test_slice_dynamic.expect +++ b/test/onnx/expect/TestOperators.test_slice_dynamic.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 5 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_split.expect b/test/onnx/expect/TestOperators.test_split.expect index 1c76dc579c6..5566c1bfa3b 100644 --- a/test/onnx/expect/TestOperators.test_split.expect +++ b/test/onnx/expect/TestOperators.test_split.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_split_with_sizes.expect b/test/onnx/expect/TestOperators.test_split_with_sizes.expect index 10e80c74ce5..addd7dba342 100644 --- a/test/onnx/expect/TestOperators.test_split_with_sizes.expect +++ b/test/onnx/expect/TestOperators.test_split_with_sizes.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_sqrt.expect b/test/onnx/expect/TestOperators.test_sqrt.expect index ca25027527d..6ec144f9e02 100644 --- a/test/onnx/expect/TestOperators.test_sqrt.expect +++ b/test/onnx/expect/TestOperators.test_sqrt.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_std.expect b/test/onnx/expect/TestOperators.test_std.expect index 970a28c0559..9811bbb1c60 100644 --- a/test/onnx/expect/TestOperators.test_std.expect +++ b/test/onnx/expect/TestOperators.test_std.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_sum.expect b/test/onnx/expect/TestOperators.test_sum.expect index 0ef63e5740a..911c65e7820 100644 --- a/test/onnx/expect/TestOperators.test_sum.expect +++ b/test/onnx/expect/TestOperators.test_sum.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_sum_dtype.expect b/test/onnx/expect/TestOperators.test_sum_dtype.expect index a41761449f9..547bb931ace 100644 --- a/test/onnx/expect/TestOperators.test_sum_dtype.expect +++ b/test/onnx/expect/TestOperators.test_sum_dtype.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_tan.expect b/test/onnx/expect/TestOperators.test_tan.expect index e2c58327b7b..90aa3a18837 100644 --- a/test/onnx/expect/TestOperators.test_tan.expect +++ b/test/onnx/expect/TestOperators.test_tan.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_topk.expect b/test/onnx/expect/TestOperators.test_topk.expect index 36ce07f8237..7ac74f4edbc 100644 --- a/test/onnx/expect/TestOperators.test_topk.expect +++ b/test/onnx/expect/TestOperators.test_topk.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 5 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_topk_smallest_unsorted.expect b/test/onnx/expect/TestOperators.test_topk_smallest_unsorted.expect index d881ee17baf..15ef6ad4efd 100644 --- a/test/onnx/expect/TestOperators.test_topk_smallest_unsorted.expect +++ b/test/onnx/expect/TestOperators.test_topk_smallest_unsorted.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_transpose.expect b/test/onnx/expect/TestOperators.test_transpose.expect index a645423bb3c..d2a5ca009fe 100644 --- a/test/onnx/expect/TestOperators.test_transpose.expect +++ b/test/onnx/expect/TestOperators.test_transpose.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_type_as.expect b/test/onnx/expect/TestOperators.test_type_as.expect index f8348aa7385..29dfd2d804f 100644 --- a/test/onnx/expect/TestOperators.test_type_as.expect +++ b/test/onnx/expect/TestOperators.test_type_as.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_unfold.expect b/test/onnx/expect/TestOperators.test_unfold.expect index 0b571e12d2b..4eb566d7bb8 100644 --- a/test/onnx/expect/TestOperators.test_unfold.expect +++ b/test/onnx/expect/TestOperators.test_unfold.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_unique.expect b/test/onnx/expect/TestOperators.test_unique.expect index ff0bd1a7e4b..1ceb90528b2 100644 --- a/test/onnx/expect/TestOperators.test_unique.expect +++ b/test/onnx/expect/TestOperators.test_unique.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 6 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_unsqueeze.expect b/test/onnx/expect/TestOperators.test_unsqueeze.expect index 085b7325613..e2e4bcf7e4f 100644 --- a/test/onnx/expect/TestOperators.test_unsqueeze.expect +++ b/test/onnx/expect/TestOperators.test_unsqueeze.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_upsample_nearest_scale.expect b/test/onnx/expect/TestOperators.test_upsample_nearest_scale.expect index 18664b44251..be79712218b 100644 --- a/test/onnx/expect/TestOperators.test_upsample_nearest_scale.expect +++ b/test/onnx/expect/TestOperators.test_upsample_nearest_scale.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_upsample_nearest_scale_default_scale_factor.expect b/test/onnx/expect/TestOperators.test_upsample_nearest_scale_default_scale_factor.expect index 18664b44251..be79712218b 100644 --- a/test/onnx/expect/TestOperators.test_upsample_nearest_scale_default_scale_factor.expect +++ b/test/onnx/expect/TestOperators.test_upsample_nearest_scale_default_scale_factor.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_upsample_nearest_size.expect b/test/onnx/expect/TestOperators.test_upsample_nearest_size.expect index 25fdf52dec3..be7d5e8aa97 100644 --- a/test/onnx/expect/TestOperators.test_upsample_nearest_size.expect +++ b/test/onnx/expect/TestOperators.test_upsample_nearest_size.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_view.expect b/test/onnx/expect/TestOperators.test_view.expect index 156d48e79cf..6726e10532e 100644 --- a/test/onnx/expect/TestOperators.test_view.expect +++ b/test/onnx/expect/TestOperators.test_view.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_view_flatten.expect b/test/onnx/expect/TestOperators.test_view_flatten.expect index ac8c8eda0b9..23f5187879b 100644 --- a/test/onnx/expect/TestOperators.test_view_flatten.expect +++ b/test/onnx/expect/TestOperators.test_view_flatten.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/expect/TestOperators.test_zeros_like.expect b/test/onnx/expect/TestOperators.test_zeros_like.expect index beef8cac8db..27ac2298318 100644 --- a/test/onnx/expect/TestOperators.test_zeros_like.expect +++ b/test/onnx/expect/TestOperators.test_zeros_like.expect @@ -1,4 +1,4 @@ -ir_version: 7 +ir_version: 4 producer_name: "pytorch" producer_version: "CURRENT_VERSION" graph { diff --git a/test/onnx/test_onnx_opset.py b/test/onnx/test_onnx_opset.py index ac566ebfbef..c6b13f8693b 100644 --- a/test/onnx/test_onnx_opset.py +++ b/test/onnx/test_onnx_opset.py @@ -11,15 +11,15 @@ import onnx import io from torch.onnx.symbolic_helper import _export_onnx_opset_version -from torch.onnx import ir_version, producer_name, producer_version +from torch.onnx import producer_name, producer_version def check_onnx_opset_operator(model, ops, opset_version=_export_onnx_opset_version): # check_onnx_components - assert model.ir_version == ir_version and \ - model.producer_name == producer_name and \ - model.producer_version == producer_version and \ - model.opset_import[0].version == opset_version + assert ( + model.producer_name == producer_name and + model.producer_version == producer_version and + model.opset_import[0].version == opset_version) # check the schema with the onnx checker onnx.checker.check_model(model) diff --git a/test/onnx/test_operators.py b/test/onnx/test_operators.py index 73ec0941cb0..3945f2c707c 100644 --- a/test/onnx/test_operators.py +++ b/test/onnx/test_operators.py @@ -17,6 +17,7 @@ import inspect import glob import os import shutil +import tempfile import torch.testing._internal.common_utils as common '''Usage: python test/onnx/test_operators.py [--no-onnx] [--produce-onnx-test-data] @@ -282,12 +283,12 @@ class TestOperators(TestCase): model = torch.nn.Conv2d(3, 2, 3) dynamic_axes = {"input_1": [0, 2, 3], "output_1": {0: "output_1_variable_dim_0", 1: "output_1_variable_dim_1"}} - model_proto_name = "conv2d.onnx" - torch.onnx.export(model, x, model_proto_name, verbose=True, input_names=["input_1"], output_names=["output_1"], + model_proto_file = tempfile.NamedTemporaryFile() + torch.onnx.export(model, x, model_proto_file.name, verbose=True, input_names=["input_1"], output_names=["output_1"], dynamic_axes=dynamic_axes) import onnx - onnx_model = onnx.load(model_proto_name) + onnx_model = onnx.load(model_proto_file.name) onnx.checker.check_model(onnx_model) # Asserting the default dynamic axes names are generated when custom names are not provided diff --git a/test/onnx/test_pytorch_onnx_onnxruntime.py b/test/onnx/test_pytorch_onnx_onnxruntime.py index e2b13c85651..ddadd75ee85 100644 --- a/test/onnx/test_pytorch_onnx_onnxruntime.py +++ b/test/onnx/test_pytorch_onnx_onnxruntime.py @@ -1684,6 +1684,7 @@ class TestONNXRuntime(unittest.TestCase): x = torch.randn(2, 3, 4) self.run_test(ArithmeticModule(), x, remained_onnx_input_idx=[]) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_arithmetic_prim_bool(self): class ArithmeticModule(torch.nn.Module): def forward(self, x, y: int, z: bool, t: float): @@ -2755,6 +2756,7 @@ class TestONNXRuntime(unittest.TestCase): with self.assertRaises(RuntimeError) as cm: self._interpolate(x, "area", False, True) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_groupnorm(self): model = torch.nn.GroupNorm(3, 6, 0.002) x = torch.randn(4, 6, 180, 180, 180) @@ -2768,6 +2770,7 @@ class TestONNXRuntime(unittest.TestCase): x = torch.randn(4, 6, 180, 180) self.run_test(model, x) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_groupnorm_noaffine(self): model = torch.nn.GroupNorm(4, 8, 0.002, affine=False) x = torch.randn(3, 8, 224, 224) @@ -3464,6 +3467,7 @@ class TestONNXRuntime(unittest.TestCase): x = torch.randn(10, 10, 128) self.run_test(model, x) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_batchnorm1d_norunningstats(self): x = torch.randn(10, 10) model = torch.nn.BatchNorm1d(10, track_running_stats=False) @@ -3482,6 +3486,7 @@ class TestONNXRuntime(unittest.TestCase): model = torch.nn.BatchNorm2d(3, affine=False) self.run_test(model, x) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_batchnorm2d_norunningstats(self): x = torch.randn(10, 3, 128, 128) model = torch.nn.BatchNorm2d(3, track_running_stats=False) @@ -3506,6 +3511,7 @@ class TestONNXRuntime(unittest.TestCase): model = torch.nn.InstanceNorm1d(5, affine=False, track_running_stats=True) self.run_test(model, x) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_instancenorm1d_norunningstats(self): x = torch.randn(10, 5, 128) model = torch.nn.InstanceNorm1d(5, affine=True, track_running_stats=False) @@ -3523,6 +3529,7 @@ class TestONNXRuntime(unittest.TestCase): model = torch.nn.InstanceNorm2d(3, affine=False, track_running_stats=True) self.run_test(model, x) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_instancenorm2d_norunningstats(self): x = torch.randn(10, 3, 128, 128) model = torch.nn.InstanceNorm2d(3, affine=True, track_running_stats=False) @@ -3540,6 +3547,7 @@ class TestONNXRuntime(unittest.TestCase): model = torch.nn.InstanceNorm3d(3, affine=False, track_running_stats=True) self.run_test(model, x) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_instancenorm3d_norunningstats(self): x = torch.randn(10, 3, 128, 128, 128) model = torch.nn.InstanceNorm3d(3, affine=True, track_running_stats=False) @@ -8191,6 +8199,7 @@ class TestONNXRuntime(unittest.TestCase): x = torch.randn(6, 4, 3, 3) self.run_test(FakeQuantizePerChannelModel(), (x)) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_batchnorm_training(self): class MyModule(torch.nn.Module): def __init__(self): @@ -8215,6 +8224,7 @@ class TestONNXRuntime(unittest.TestCase): model_export.train() self.run_test(model_export, (x, ), training=torch.onnx.TrainingMode.PRESERVE, rtol=1e-3, atol=1e-5) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_batchnorm_training_mode_fix_layer(self): class MyModule(torch.nn.Module): def __init__(self): @@ -8265,6 +8275,7 @@ class TestONNXRuntime(unittest.TestCase): model_export.eval() self.run_test(model_export, (x,), training=torch.onnx.TrainingMode.PRESERVE, rtol=1e-3, atol=1e-5) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_instancenorm_training(self): class MyModule(torch.nn.Module): def __init__(self): @@ -8289,6 +8300,7 @@ class TestONNXRuntime(unittest.TestCase): model_export.train() self.run_test(model_export, (x, ), training=torch.onnx.TrainingMode.PRESERVE, rtol=1e-3, atol=1e-5) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_instancenorm_training_mode_fix_layer(self): class MyModule(torch.nn.Module): def __init__(self): @@ -8314,6 +8326,7 @@ class TestONNXRuntime(unittest.TestCase): model_export.train() self.run_test(model_export, (x,), training=torch.onnx.TrainingMode.PRESERVE, rtol=1e-3, atol=1e-5) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_instancenorm_eval_mode_train_layer(self): class MyModule(torch.nn.Module): def __init__(self): @@ -8415,6 +8428,7 @@ class TestONNXRuntime(unittest.TestCase): np.testing.assert_allclose(ratio_pytorch, ratio_ort, rtol=0.01, atol=0.01) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_conv_bn(self): class MyModule(torch.nn.Module): def __init__(self): @@ -8432,6 +8446,7 @@ class TestONNXRuntime(unittest.TestCase): self.run_test(model_export, (x,), training=torch.onnx.TrainingMode.EVAL) self.run_test(model_export, (x,), training=torch.onnx.TrainingMode.TRAINING, rtol=1e-3, atol=1e-5) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_multiple_conv_bn(self): class MyModule(torch.nn.Module): def __init__(self): @@ -10119,6 +10134,7 @@ class TestONNXRuntime(unittest.TestCase): loaded_model = onnx.load_from_string(f.getvalue()) + @skipIfUnsupportedMinOpsetVersion(9) # https://github.com/microsoft/onnxruntime/issues/9663 def test_tuple_output_from_if_with_raised_exception(self): class M(torch.nn.Module): def __init__(self): diff --git a/test/onnx/test_utility_funs.py b/test/onnx/test_utility_funs.py index a653cf0eeca..599aea16188 100644 --- a/test/onnx/test_utility_funs.py +++ b/test/onnx/test_utility_funs.py @@ -662,7 +662,7 @@ class TestUtilityFuns_opset9(_BaseTestCase): self.celu2 = torch.nn.CELU(2.0) self.dropout = N(0.5) - def forward(self, x: torch.Tensor, y: torch.Tensor, z: torch.Tensor) -> torch.Tensor: + def forward(self, x, y, z): res1 = self.celu1(x) res2 = self.celu2(y) for ln in self.lns: @@ -673,9 +673,10 @@ class TestUtilityFuns_opset9(_BaseTestCase): y = torch.randn(2, 3) z = torch.randn(2, 3) - """ - Export specified modules, containing non-existed dropout. - """ + # Export specified modules. Test against specifying modules that won't + # exist in the exported model. + # Model export in inference mode will remove dropout node, + # thus the dropout module no longer exist in graph. f = io.BytesIO() torch.onnx.export(M(3), (x, y, z), f, opset_version=self.opset_version, export_modules_as_functions={torch.nn.CELU, torch.nn.Dropout, torch.nn.LayerNorm}) @@ -704,21 +705,17 @@ class TestUtilityFuns_opset9(_BaseTestCase): self.assertEqual(ln_ns[0].domain, "torch.nn.modules.normalization") self.assertEqual(len(ln_ns[0].attribute), 1) - """ - Export specified modules. - """ + # Export specified modules. f = io.BytesIO() torch.onnx.export(M(3), (x, y, z), f, opset_version=self.opset_version, - export_modules_as_functions={"torch.nn.modules.activation.CELU"}) + export_modules_as_functions={torch.nn.CELU}) onnx_model = onnx.load(io.BytesIO(f.getvalue())) funcs = onnx_model.functions self.assertEqual(len(funcs), 1) self.assertEqual(funcs[0].name, "CELU") - """ - Export with empty specified modules. Normal export. - """ + # Export with empty specified modules. Normal export. f = io.BytesIO() torch.onnx.export(M(3), (x, y, z), f, opset_version=self.opset_version, export_modules_as_functions=set()) @@ -727,9 +724,7 @@ class TestUtilityFuns_opset9(_BaseTestCase): funcs = onnx_model.functions self.assertEqual(len(funcs), 0) - """ - Export all modules. Should contain {M, CELU, LayerNorm}. - """ + # Export all modules. Should contain {M, CELU, LayerNorm}. f = io.BytesIO() torch.onnx.export(M(3), (x, y, z), f, opset_version=self.opset_version, export_modules_as_functions=True) @@ -738,6 +733,40 @@ class TestUtilityFuns_opset9(_BaseTestCase): funcs = onnx_model.functions self.assertEqual(len(funcs), 3) + def test_local_function_overloads(self): + class NWithOverloads(torch.nn.Module): + def forward(self, x, y=None, z=None): + if y is None: + return x + 1 + elif z is None: + return x + y + else: + return x + y, x + z + + class M(torch.nn.Module): + def __init__(self, num_layers): + super().__init__() + self.n = NWithOverloads() + + def forward(self, x, y, z): + return self.n(x), self.n(x, y), self.n(x, y, z) + + x = torch.randn(2, 3) + y = torch.randn(2, 3) + z = torch.randn(2, 3) + + f = io.BytesIO() + torch.onnx.export(M(3), (x, y, z), f, opset_version=self.opset_version, + export_modules_as_functions={NWithOverloads}) + + onnx_model = onnx.load(io.BytesIO(f.getvalue())) + funcs = onnx_model.functions + self.assertEqual(len(funcs), 3) + func_names = [f.name for f in funcs] + self.assertIn("NWithOverloads", func_names) + self.assertIn("NWithOverloads.1", func_names) + self.assertIn("NWithOverloads.2", func_names) + def test_aten_fallthrough(self): # Test aten export of op with no symbolic class Module(torch.nn.Module): diff --git a/torch/_C/__init__.pyi.in b/torch/_C/__init__.pyi.in index 3e660ee64fc..ebbb912c16e 100644 --- a/torch/_C/__init__.pyi.in +++ b/torch/_C/__init__.pyi.in @@ -329,7 +329,7 @@ def _jit_pass_onnx_scalar_type_analysis(graph: Graph, lowprecision_cast: _bool, def _jit_pass_onnx_peephole(graph: Graph, opset_version: _int, fixed_batch_size: _bool) -> None: ... def _jit_pass_dce_allow_deleting_nodes_with_side_effects(graph: Graph) -> None: ... def _jit_pass_onnx_function_substitution(graph: Graph) -> None: ... -def _jit_pass_onnx_function_extraction(graph: Graph, module_names : Set[str], param_names : List[str]) -> Tuple[Dict[Value, str], Dict[Node, Dict[str, str]]]: ... +def _jit_pass_onnx_function_extraction(graph: Graph, module_names : Set[str], param_names : List[str]) -> Dict[Node, Dict[str, str]]: ... def _jit_pass_lower_graph(graph: Graph, m: Module) -> Tuple[Graph, List[IValue]]: ... def _jit_pass_inline_fork_wait(graph: Graph) -> None: ... def _jit_pass_onnx_eval_peephole(graph: Graph, paramsDict: Dict[str, IValue]) -> Dict[str, IValue]: ... diff --git a/torch/_C/_onnx.pyi b/torch/_C/_onnx.pyi index 9489c9cf907..41a31d2383e 100644 --- a/torch/_C/_onnx.pyi +++ b/torch/_C/_onnx.pyi @@ -3,7 +3,6 @@ from enum import Enum PYTORCH_ONNX_CAFFE2_BUNDLE: bool -IR_VERSION: int PRODUCER_VERSION: str class TensorProtoDataType(Enum): diff --git a/torch/csrc/api/include/torch/version.h.in b/torch/csrc/api/include/torch/version.h.in index f64554d06c3..ff2106aa16f 100644 --- a/torch/csrc/api/include/torch/version.h.in +++ b/torch/csrc/api/include/torch/version.h.in @@ -8,3 +8,7 @@ /// Indicates the patch version of LibTorch. #define TORCH_VERSION_PATCH @TORCH_VERSION_PATCH@ + +/// Indicates the version of LibTorch. +#define TORCH_VERSION \ + "@TORCH_VERSION_MAJOR@.@TORCH_VERSION_MINOR@.@TORCH_VERSION_PATCH@" diff --git a/torch/csrc/jit/passes/onnx/function_extraction.cpp b/torch/csrc/jit/passes/onnx/function_extraction.cpp index 23e5674ceeb..5a0f8592f3b 100644 --- a/torch/csrc/jit/passes/onnx/function_extraction.cpp +++ b/torch/csrc/jit/passes/onnx/function_extraction.cpp @@ -23,7 +23,7 @@ struct FunctionExtractor { : graph_(graph), module_names_(module_names.begin(), module_names.end()), param_names_(param_names.begin(), param_names.end()) {} - std::pair run(); + NodeAttrNameMap run(); private: struct ScopeContext { @@ -55,14 +55,12 @@ struct FunctionExtractor { ScopePtr scope_key_; scope_ctx_map scope_ctxs_; - std::unordered_map> constant_map_; std::unordered_map< Node*, std::unordered_map>> attribute_map_; // Passed later to serialization. - ValAttrNameMap val_attr_to_name_; NodeAttrNameMap node_attr_to_name_; }; @@ -120,18 +118,18 @@ FunctionExtractor::FunctionContext::FunctionContext( scope_ctx_map& scope_ctxs) : scope_key_(std::move(key)) { GRAPH_UPDATE( - "Process function family for scope ", + "Process function context for scope ", scope_key_->name().toDisplayString()); TORCH_INTERNAL_ASSERT(scopes.size() > 0); const auto& ref_ctx = scope_ctxs[scope_key_]; - // NOTE: Family scopes must have same number and order of nodes. + // NOTE: Function scopes must have same number and order of nodes. GRAPH_DEBUG( - "Initialized family context for scope ", + "Initialized function context for scope ", scope_key_->name().toDisplayString()); for (const auto& scope : scopes) { GRAPH_DEBUG( - "Process scope family with scope ", scope->name().toDisplayString()); + "Process function context for scope ", scope->name().toDisplayString()); TORCH_INTERNAL_ASSERT(scope_ctxs.find(scope) != scope_ctxs.end()); scope_ctxs_[scope] = scope_ctxs[scope]; if (scope_key_ == scope) { @@ -148,39 +146,31 @@ FunctionExtractor::FunctionContext::FunctionContext( TORCH_INTERNAL_ASSERT(ns_a[i]->kind() == ns_b[i]->kind()); auto n_a = ns_a[i]; auto n_b = ns_b[i]; - if (n_a->kind() == c10::onnx::Constant) { - const auto& t_a = n_a->t(attr::value); - const auto& t_b = n_b->t(attr::value); - if (!t_a.equal(t_b)) { - constant_map_[n_a].insert(n_b); - } - } else { - std::vector diff_attrs; - std::vector same_attrs; - auto n_a_attr_names = n_a->attributeNames(); - auto n_b_attr_names = n_b->attributeNames(); - std::sort(n_a_attr_names.begin(), n_a_attr_names.end()); - std::sort(n_b_attr_names.begin(), n_b_attr_names.end()); - std::set_difference( - n_a_attr_names.begin(), - n_a_attr_names.end(), - n_b_attr_names.begin(), - n_b_attr_names.end(), - std::inserter(diff_attrs, diff_attrs.begin())); - std::set_intersection( - n_a_attr_names.begin(), - n_a_attr_names.end(), - n_b_attr_names.begin(), - n_b_attr_names.end(), - std::inserter(same_attrs, same_attrs.begin())); - for (auto attr_name : diff_attrs) { - attribute_map_[n_a][attr_name].insert(n_b); - } + std::vector diff_attrs; + std::vector same_attrs; + auto n_a_attr_names = n_a->attributeNames(); + auto n_b_attr_names = n_b->attributeNames(); + std::sort(n_a_attr_names.begin(), n_a_attr_names.end()); + std::sort(n_b_attr_names.begin(), n_b_attr_names.end()); + std::set_difference( + n_a_attr_names.begin(), + n_a_attr_names.end(), + n_b_attr_names.begin(), + n_b_attr_names.end(), + std::inserter(diff_attrs, diff_attrs.begin())); + std::set_intersection( + n_a_attr_names.begin(), + n_a_attr_names.end(), + n_b_attr_names.begin(), + n_b_attr_names.end(), + std::inserter(same_attrs, same_attrs.begin())); + for (auto attr_name : diff_attrs) { + attribute_map_[n_a][attr_name].insert(n_b); + } - for (auto attr_name : same_attrs) { - if (!HasSameAttribute(n_a, n_b, attr_name)) { - attribute_map_[n_a][attr_name].insert(n_b); - } + for (auto attr_name : same_attrs) { + if (!HasSameAttribute(n_a, n_b, attr_name)) { + attribute_map_[n_a][attr_name].insert(n_b); } } } @@ -188,21 +178,14 @@ FunctionExtractor::FunctionContext::FunctionContext( } GRAPH_DEBUG( - "Process scope family complete. ", scope_key_->name().toDisplayString()); + "Process function context complete. ", + scope_key_->name().toDisplayString()); DebugPrint(); } void FunctionExtractor::FunctionContext::DebugPrint() const { GRAPH_DEBUG("Scope name: ", scope_key_->name().toDisplayString()); - for (const auto& it : constant_map_) { - GRAPH_DEBUG("Constant value difference: "); - GRAPH_DEBUG(*it.first); - for (auto n : it.second) { - GRAPH_DEBUG(*n); - } - } - for (const auto& it : attribute_map_) { for (const auto& attr_it : it.second) { GRAPH_DEBUG( @@ -228,19 +211,6 @@ void FunctionExtractor::FunctionContext::SetAttrName( auto n_attr_it = node_attr_to_name_[n_in_def][attr.toUnqualString()] = name; } -void FunctionExtractor::FunctionContext::SetAttrName( - Node* ref_const_n, - const std::string& name) { - TORCH_INTERNAL_ASSERT(ref_const_n->kind() == c10::onnx::Constant); - auto v_it = - scope_ctxs_[scope_key_]->env_to_subgraph_.find(ref_const_n->output()); - TORCH_INTERNAL_ASSERT( - v_it != scope_ctxs_[scope_key_]->env_to_subgraph_.end(), - "node not found in env: ", - *ref_const_n); - val_attr_to_name_[v_it->second] = name; -} - c10::optional FunctionExtractor::FunctionContext::FindAttrName( Node* ref_n, Symbol attr) { @@ -261,21 +231,6 @@ c10::optional FunctionExtractor::FunctionContext::FindAttrName( return name_it->second; } -c10::optional FunctionExtractor::FunctionContext::FindAttrName( - Node* ref_const_n) { - TORCH_INTERNAL_ASSERT(ref_const_n->kind() == c10::onnx::Constant); - auto v_it = - scope_ctxs_[scope_key_]->env_to_subgraph_.find(ref_const_n->output()); - if (v_it == scope_ctxs_[scope_key_]->env_to_subgraph_.end()) { - return c10::nullopt; - } - auto name_it = val_attr_to_name_.find(v_it->second); - if (name_it == val_attr_to_name_.end()) { - return c10::nullopt; - } - return name_it->second; -} - void FunctionExtractor::DebugPrintScopeContexts( const scope_ctx_map& scope_ctxs) { for (auto& it : scope_ctxs) { @@ -429,9 +384,7 @@ c10::optional FunctionExtractor::InferScope(Node* n) { IsValidScope); if (scopes.size() > 0) { - // find common ancestor. auto common_ancestor = FindCommonAncestor(scopes); - if (common_ancestor.has_value() && IsValidScope(common_ancestor.value())) { return common_ancestor.value(); @@ -452,7 +405,11 @@ std::shared_ptr FunctionExtractor::ConstructFuncGraph( auto g = std::make_shared(); GRAPH_DEBUG("Constructing graph for ", scope->namesFromRoot()); - // TODO: update input name of function to common name? + // TODO: Update input names of function to match those in Module source code + // signature. + // This requires mapping between function node inputs and Module inputs. + // Due to the lack of such mapping, currently debugName is used as input + // names. ctx.PopulateInputsOutputs(param_names_); for (auto* v : ctx.inputs_) { env[v] = g->addInput()->copyMetadata(v); @@ -519,15 +476,6 @@ Node* FunctionExtractor::CreateFunctionDefNode( return attr_name; }; - for (const auto& c_it : func_ctx.constant_map_) { - auto* c_n = c_it.first; - TORCH_INTERNAL_ASSERT(c_n->kind() == c10::onnx::Constant); - auto attr_name = std::string(c_n->kind().toUnqualString()) + '_' + - c_n->output()->debugNameBase(); - auto final_attr_name = adjust_attr_name(attr_name); - final_attr_names.emplace_back(final_attr_name); - func_ctx.SetAttrName(c_n, final_attr_name); - } for (const auto& n_it : func_ctx.attribute_map_) { auto* n = n_it.first; for (const auto& attr_it : n_it.second) { @@ -553,13 +501,14 @@ Node* FunctionExtractor::CreateFunctionNode( const std::string& func_name) { const auto& func_scope = func_ctx.scope_key_; const auto& func_scope_ctx = func_ctx.scope_ctxs_[func_scope]; - const auto func_nk = Symbol::fromQualString(domain_name + "::" + func_name); GRAPH_DEBUG( "Create and insert local function for scope: ", func_scope->namesFromRoot()); scope_ctx.PopulateInputsOutputs(param_names_); auto last_n = *scope_ctx.nlist_.rbegin(); - auto func_n = graph->create(func_nk, scope_ctx.outputs_.size()); + auto func_n = graph->create( + Symbol::fromQualString(domain_name + "::" + func_name), + scope_ctx.outputs_.size()); func_n->copyMetadata(last_n); for (auto* v : scope_ctx.inputs_) { func_n->addInput(v); @@ -569,22 +518,7 @@ Node* FunctionExtractor::CreateFunctionNode( scope_ctx.outputs_[i]->replaceAllUsesWith(func_n->output(i)); } - // set constants and attributes of different values as function attributes. - - for (const auto& it : func_ctx.constant_map_) { - TORCH_INTERNAL_ASSERT(it.first->kind() == c10::onnx::Constant); - TORCH_INTERNAL_ASSERT(it.first->outputs().size() == 1); - auto attr_name = func_ctx.FindAttrName(it.first).value(); - auto val = it.first->t(attr::value); - for (auto* n : scope_ctx.nlist_) { - if (it.second.find(n) != it.second.end()) { - val = n->t(attr::value); - break; - } - } - func_n->t_(Symbol::attr(attr_name), val); - } - + // set attributes of different values as function attributes. auto copy_attr = [](Node* a, Node* b, Symbol attr, const std::string& new_name) { #define COPY_ATTR(kind) \ @@ -635,7 +569,6 @@ Node* FunctionExtractor::CreateFunctionNode( } func_n->insertAfter(last_n); - return func_n; } @@ -663,11 +596,11 @@ void FunctionExtractor::ConvertScopeToFunction( auto construct_unique_module_name = [&](std::string module_name) { auto module_name_variant = module_variant_count_.find(module_name); if (module_name_variant != module_variant_count_.end()) { + module_variant_count_[module_name]++; module_name += ("." + std::to_string(module_name_variant->second)); } else { module_variant_count_[module_name] = 0; } - module_variant_count_[module_name]++; return module_name; }; @@ -689,7 +622,7 @@ void FunctionExtractor::ConvertScopeToFunction( scope_ctx.nlist_.begin(), scope_ctx.nlist_.end()); auto last_n = *scope_ctx.nlist_.rbegin(); - // replace local function node in parent scopes. + // replace function body nodes in parent scopes with local function node. for (auto& it : scope_ctxs) { const auto& parent_scope = it.first; auto& parent_ctx = *it.second; @@ -742,10 +675,13 @@ void FunctionExtractor::ConvertScopeToFunction( bool FunctionExtractor::ScopeContext::IsIdenticalFuncion( const ScopeContext& other_ctx) const { - // TODO: need to differentiate same function under different inputs. - // when constants are passed inplace of inputs, this leads to different - // input count and node count. Likewise, due to different uses, output - // count can be different as well. + // Differentiate same function under different inputs. + // When constants are passed in place of inputs, it leads to different + // input count and node count. Likewise, due to different uses, output + // count can be different as well. + // For now export them as different functions. + // Covered by `test_local_function_overloads` in + // `test/onnx/test_utility_funs.py`. if (&other_ctx == this) { return true; } @@ -1040,7 +976,7 @@ scope_list FunctionExtractor::SortScopesByMaxDepth( return sorted_scopes; } -std::pair FunctionExtractor::run() { +NodeAttrNameMap FunctionExtractor::run() { auto scope_ctxs = PartitionNodesByScope(graph_); DebugPrintScopeContexts(scope_ctxs); auto identical_scope_map = PartitionIdenticalScopes(scope_ctxs); @@ -1057,12 +993,9 @@ std::pair FunctionExtractor::run() { DebugPrintGraphWithFunction(graph_); // Construct return mappings - ValAttrNameMap val_attr_to_name; NodeAttrNameMap node_attr_to_name; for (const auto& it : func_ctxs_) { - auto func_val_map = it.second->val_attr_to_name_; - val_attr_to_name.insert(func_val_map.begin(), func_val_map.end()); auto func_ref_map = it.second->node_attr_to_name_; node_attr_to_name.insert(func_ref_map.begin(), func_ref_map.end()); } @@ -1077,12 +1010,24 @@ std::pair FunctionExtractor::run() { } func_ctxs_.clear(); - return std::make_pair(val_attr_to_name, node_attr_to_name); + return node_attr_to_name; } } // namespace -std::pair ONNXFunctionExtraction( +// FunctionExtractor runs in the following steps. Updates are made inplace to +// the graph argument. +// 1. Partition nodes into groups based on their scope information. +// Each scope represents an individual nn.Module call. A ScopeContext object +// is created for each group. +// 2. Compare and find groups with the same subgraph pattern from step 1. +// 3. Scopes are nested. Starting from the deepest scope, extract the +// subgraph pattern, and define as local function node. Replace subgraph +// pattern with a single node of the new local function node type. A +// FunctionContext object is created for each function. +// 4. Construct NodeAttrNameMap tracking mapping from attribute name of +// IR Node inside function subgraph, to function attribute name. +NodeAttrNameMap ONNXFunctionExtraction( std::shared_ptr& graph, const std::unordered_set& module_names, const std::vector& param_names) { diff --git a/torch/csrc/jit/passes/onnx/function_extraction.h b/torch/csrc/jit/passes/onnx/function_extraction.h index e50b03bfa7b..b46e095433f 100644 --- a/torch/csrc/jit/passes/onnx/function_extraction.h +++ b/torch/csrc/jit/passes/onnx/function_extraction.h @@ -7,9 +7,10 @@ namespace jit { // This api will be used by serialization/export.cpp to extract function // information. It should do conversion on graph to -// 1. Extract and preserve functions definition. -// 2. Replace nodes within functions with a single node reflecting that -// function type. +// 1. Extract subgraph pattern of functions and define as local function +// node. +// 2. Replace subgraph pattern of functions with a single node reflecting +// that local function node type. // Function attribute map information is also returned, as Torch IR cannot // represent these info inside Graph object. // export.cpp will serialize the ONNX model with function_proto with @@ -18,8 +19,6 @@ namespace onnx { // The following return types are used to track information regarding function // attributes, that are unable to be traced through Torch IR. -// ValAttrNameMap tracks mapping from IR Value inside function subgraph, -// to function attribute name. // NodeAttrNameMap tracks mapping from attribute name of IR Node inside function // subgraph, to function attribute name. Here's an example of exporting CELU and // LayerNorm. @@ -42,10 +41,6 @@ namespace onnx { // // Returning // -// ValAttrNameMap: -// { -// %8 : Float = onnx::Constant[value={1}]() : 'Constant_25' -// } // NodeAttrNameMap: // { // %1 : Float(2, 3) = onnx::Celu[alpha=2.](%y) : { @@ -55,11 +50,10 @@ namespace onnx { // // The info here helps graph._export_onnx to construct function attributes for // onnx local FunctionProto. -using ValAttrNameMap = std::unordered_map; using NodeAttrNameMap = std:: unordered_map>; -TORCH_API std::pair ONNXFunctionExtraction( +TORCH_API NodeAttrNameMap ONNXFunctionExtraction( std::shared_ptr& graph, const std::unordered_set& module_names, const std::vector& param_names); diff --git a/torch/csrc/jit/passes/onnx/helper.cpp b/torch/csrc/jit/passes/onnx/helper.cpp index f6a52a14880..e88775c218f 100644 --- a/torch/csrc/jit/passes/onnx/helper.cpp +++ b/torch/csrc/jit/passes/onnx/helper.cpp @@ -197,16 +197,16 @@ Node* transformToONNXConcatNode( void ONNXLintGraph( const Block* b, - std::vector& n_miss_sourceRange, + std::vector& n_miss_source_range, std::vector& n_miss_scope) { for (const auto* n : b->nodes()) { for (const auto* sub_b : n->blocks()) { - ONNXLintGraph(sub_b, n_miss_sourceRange, n_miss_scope); + ONNXLintGraph(sub_b, n_miss_source_range, n_miss_scope); } if (nullptr == n->sourceRange().source()) { GRAPH_DEBUG("Node does not set sourceRange:", *n); - n_miss_sourceRange.emplace_back(n->kind()); + n_miss_source_range.emplace_back(n->kind()); } if (n->scopeName() == "") { GRAPH_DEBUG("Node does not set scope:", *n); @@ -216,9 +216,9 @@ void ONNXLintGraph( } void ONNXLintGraph(const std::shared_ptr& graph) { - // 1. Print nodes that does not have scope/source range covered. - std::vector n_miss_sourceRange, n_miss_scope; - ONNXLintGraph(graph->block(), n_miss_sourceRange, n_miss_scope); + // Print nodes that do not have scope/source range covered. + std::vector n_miss_source_range, n_miss_scope; + ONNXLintGraph(graph->block(), n_miss_source_range, n_miss_scope); auto count_const = [](const std::vector& vec) -> size_t { size_t count = 0; for (auto k : vec) { @@ -232,17 +232,17 @@ void ONNXLintGraph(const std::shared_ptr& graph) { } return count; }; - auto const_count_src = count_const(n_miss_sourceRange); + auto const_count_src = count_const(n_miss_source_range); auto const_count_scope = count_const(n_miss_scope); - GRAPH_UPDATE("Missing sourceRange.") GRAPH_UPDATE( + "Missing source range.\n", "Total ", - n_miss_sourceRange.size(), + n_miss_source_range.size(), " nodes. Including ", const_count_src, " constants."); - GRAPH_UPDATE("Missing scope.") GRAPH_UPDATE( + "Missing scope.\n", "Total ", n_miss_scope.size(), " nodes. Including ", diff --git a/torch/csrc/jit/python/python_ir.cpp b/torch/csrc/jit/python/python_ir.cpp index 4fec194c136..e13d84f72e8 100644 --- a/torch/csrc/jit/python/python_ir.cpp +++ b/torch/csrc/jit/python/python_ir.cpp @@ -235,7 +235,6 @@ void initPythonIRBindings(PyObject* module_) { bool add_node_names, bool use_external_data_format, const std::string& onnx_file_path, - const ValAttrNameMap& val_attr_to_name, const NodeAttrNameMap& node_attr_to_name) { std::string graph; std::shared_ptr<::ONNX_NAMESPACE::ModelProto> model_proto; @@ -260,7 +259,6 @@ void initPythonIRBindings(PyObject* module_) { add_node_names, use_external_data_format, onnx_file_path, - val_attr_to_name, node_attr_to_name); std::unordered_map python_serialized_export_map; @@ -291,7 +289,6 @@ void initPythonIRBindings(PyObject* module_) { py::arg("add_node_names") = true, py::arg("use_external_data_format") = false, py::arg("onnx_file_path") = std::string(), - py::arg("val_attr_to_name") = ValAttrNameMap(), py::arg("node_attr_to_name") = NodeAttrNameMap()) .def( "_pretty_print_onnx", diff --git a/torch/csrc/jit/serialization/export.cpp b/torch/csrc/jit/serialization/export.cpp index 261e28de4e8..edf1ff2764f 100644 --- a/torch/csrc/jit/serialization/export.cpp +++ b/torch/csrc/jit/serialization/export.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,27 @@ namespace { namespace onnx_torch = ::torch::onnx; namespace onnx = ::ONNX_NAMESPACE; +const static int kInvalidOpsetVersion = -1; +// Based on OP_SET_ID_VERSION_MAP in +// https://github.com/onnx/onnx/blob/master/onnx/helper.py. +constexpr static std::array kOpsetVersionToIRVersion = { + kInvalidOpsetVersion, + 3, + kInvalidOpsetVersion, + kInvalidOpsetVersion, + kInvalidOpsetVersion, + 3, + 3, + 3, + 3, + 4, + 5, + 6, + 7, + 7, + 7, + 8}; + std::string getNodeStackTraceString(const Node* n) { return n->sourceRange().str(); } @@ -187,7 +209,6 @@ class GraphEncoder { bool add_node_names, bool use_external_data_format, const std::string& onnx_file_path, - const ValAttrNameMap& val_attr_to_name = {}, const NodeAttrNameMap& node_attr_to_name = {}); onnx::ModelProto get_model_proto() { @@ -310,7 +331,8 @@ class GraphEncoder { void AddAttribute( onnx::NodeProto* node_proto, const jit::Symbol name, - const std::string& ref_attr_name); + const std::string& ref_attr_name, + const AttributeKind attr_kind); void AddAttribute( onnx::NodeProto* node_proto, @@ -335,7 +357,6 @@ class GraphEncoder { int64_t onnx_opset_version_; std::map custom_opsets_; std::shared_ptr graph_; - ValAttrNameMap val_attr_to_name_; NodeAttrNameMap node_attr_to_name_; // For large models, the parameters can be stored in separate binary files. // This parameter sets a threshold on the number of elements in the parameter @@ -376,6 +397,38 @@ onnx::TensorProto_DataType ATenTypeToOnnxType(at::ScalarType at_type) { } } +onnx::AttributeProto_AttributeType ATenAttributeKindToOnnxAttributeType( + AttributeKind at_kind, + const jit::Symbol name) { + switch (at_kind) { + case AttributeKind::f: + return onnx::AttributeProto_AttributeType_FLOAT; + case AttributeKind::fs: + return onnx::AttributeProto_AttributeType_FLOATS; + case AttributeKind::i: + return onnx::AttributeProto_AttributeType_INT; + case AttributeKind::is: + return onnx::AttributeProto_AttributeType_INTS; + case AttributeKind::s: + return onnx::AttributeProto_AttributeType_STRING; + case AttributeKind::ss: + return onnx::AttributeProto_AttributeType_STRINGS; + case AttributeKind::t: + return onnx::AttributeProto_AttributeType_TENSOR; + case AttributeKind::ts: + return onnx::AttributeProto_AttributeType_TENSORS; + case AttributeKind::g: + return onnx::AttributeProto_AttributeType_GRAPH; + case AttributeKind::gs: + return onnx::AttributeProto_AttributeType_GRAPHS; + default: + std::ostringstream err_msg; + err_msg << "attribute \"" << name.toDisplayString() + << "\" has unexpected kind: " << toString(at_kind); + throw std::runtime_error(err_msg.str()); + } +} + GraphEncoder::GraphEncoder( const std::shared_ptr& graph, int64_t onnx_opset_version, @@ -391,7 +444,6 @@ GraphEncoder::GraphEncoder( bool add_node_names, bool use_external_data_format, const std::string& onnx_file_path, - const ValAttrNameMap& val_attr_to_name, const NodeAttrNameMap& node_attr_to_name) : num_blocks_(0), num_op_nodes_(0), @@ -403,15 +455,17 @@ GraphEncoder::GraphEncoder( onnx_opset_version_(onnx_opset_version), custom_opsets_(custom_opsets), graph_(graph), - val_attr_to_name_(val_attr_to_name), node_attr_to_name_(node_attr_to_name) { model_proto_.set_producer_name("pytorch"); - // we pin IR version to version 6 (12/11/2019) instead of using - // onnx::IR_VERSION. with this change, the test_operators.py will be more - // stable. only bump it when it's necessary - model_proto_.set_ir_version(onnx_torch::IR_VERSION); - // TODO: set the producer version using appropriate function call - model_proto_.set_producer_version(onnx_torch::PRODUCER_VERSION); + TORCH_CHECK( + onnx_opset_version > 0 && + onnx_opset_version < kOpsetVersionToIRVersion.size() && + kOpsetVersionToIRVersion[onnx_opset_version] != kInvalidOpsetVersion, + "Unsupported onnx_opset_version: ", + onnx_opset_version); + + model_proto_.set_ir_version(kOpsetVersionToIRVersion[onnx_opset_version]); + model_proto_.set_producer_version(TORCH_VERSION); validateGraph(graph, operator_export_type); @@ -726,12 +780,7 @@ void GraphEncoder::EncodeNode( if (input->node()->mustBeNone()) { node_proto->add_input(""); } else { - auto attr_it = val_attr_to_name_.find(input); - if (attr_it != val_attr_to_name_.end()) { - node_proto->add_input(attr_it->second); - } else { - node_proto->add_input(input->debugName()); - } + node_proto->add_input(input->debugName()); } } for (auto output : node->outputs()) { @@ -765,7 +814,8 @@ void GraphEncoder::EncodeNode( if (attrs_it != node_attr_to_name_.end()) { auto attr_it = attrs_it->second.find(attr_name.toUnqualString()); if (attr_it != attrs_it->second.end()) { - AddAttribute(node_proto, attr_name, attr_it->second); + AddAttribute( + node_proto, attr_name, attr_it->second, node->kindOf(attr_name)); continue; } } @@ -825,11 +875,13 @@ void GraphEncoder::EncodeNode( void GraphEncoder::AddAttribute( onnx::NodeProto* node_proto, const jit::Symbol name, - const std::string& ref_attr_name) { + const std::string& ref_attr_name, + const AttributeKind attr_kind) { auto attr = node_proto->add_attribute(); AT_ASSERT(name.is_attr()); attr->set_name(name.toUnqualString()); attr->set_ref_attr_name(ref_attr_name); + attr->set_type(ATenAttributeKindToOnnxAttributeType(attr_kind, name)); } void GraphEncoder::AddAttribute( @@ -859,37 +911,32 @@ void GraphEncoder::AddAttribute( auto attr = node_proto->add_attribute(); AT_ASSERT(name.is_attr()); attr->set_name(name.toUnqualString()); + attr->set_type( + ATenAttributeKindToOnnxAttributeType(node->kindOf(name), name)); switch (node->kindOf(name)) { case AttributeKind::f: attr->set_f(node->f(name)); - attr->set_type(onnx::AttributeProto_AttributeType_FLOAT); break; case AttributeKind::fs: - attr->set_type(onnx::AttributeProto_AttributeType_FLOATS); for (auto& v : node->fs(name)) // NOLINTNEXTLINE(bugprone-narrowing-conversions,cppcoreguidelines-narrowing-conversions) attr->add_floats(v); break; case AttributeKind::i: - attr->set_type(onnx::AttributeProto_AttributeType_INT); attr->set_i(node->i(name)); break; case AttributeKind::is: - attr->set_type(onnx::AttributeProto_AttributeType_INTS); for (auto& v : node->is(name)) attr->add_ints(v); break; case AttributeKind::s: - attr->set_type(onnx::AttributeProto_AttributeType_STRING); attr->set_s(node->s(name)); break; case AttributeKind::ss: - attr->set_type(onnx::AttributeProto_AttributeType_STRINGS); for (auto& v : node->ss(name)) attr->add_strings(v); break; case AttributeKind::t: { - attr->set_type(onnx::AttributeProto_AttributeType_TENSOR); auto t = attr->mutable_t(); if (use_external_data_format && !t->has_name()) { t->set_name( @@ -899,7 +946,6 @@ void GraphEncoder::AddAttribute( t, node->t(name), {}, use_external_data_format, onnx_file_path); } break; case AttributeKind::ts: - attr->set_type(onnx::AttributeProto_AttributeType_TENSORS); for (auto& v : node->ts(name)) { auto t = attr->add_tensors(); if (use_external_data_format && !t->has_name()) { @@ -910,7 +956,6 @@ void GraphEncoder::AddAttribute( } break; case AttributeKind::g: { - attr->set_type(onnx::AttributeProto_AttributeType_GRAPH); auto g = attr->mutable_g(); EncodeGraph( g, @@ -923,7 +968,6 @@ void GraphEncoder::AddAttribute( onnx_file_path); } break; case AttributeKind::gs: - attr->set_type(onnx::AttributeProto_AttributeType_GRAPHS); for (auto& v : node->gs(name)) { auto g = attr->add_graphs(); EncodeGraph( @@ -1167,7 +1211,6 @@ export_onnx( bool add_node_names, bool use_external_data_format, const std::string& onnx_file_path, - const ValAttrNameMap& val_attr_to_name, const NodeAttrNameMap& node_attr_to_name) { auto graph_encoder = GraphEncoder( graph, @@ -1182,8 +1225,6 @@ export_onnx( add_node_names, use_external_data_format, onnx_file_path, - // module_names_to_function, - val_attr_to_name, node_attr_to_name); GRAPH_DEBUG("onnx proto:", prettyPrint(graph_encoder.get_model_proto())); return std::make_tuple( diff --git a/torch/csrc/jit/serialization/export.h b/torch/csrc/jit/serialization/export.h index d9f12448dac..b73817fb23c 100644 --- a/torch/csrc/jit/serialization/export.h +++ b/torch/csrc/jit/serialization/export.h @@ -56,7 +56,6 @@ export_onnx( bool add_node_names = true, bool use_external_data_format = false, const std::string& onnx_file_path = std::string(), - const ValAttrNameMap& val_attr_to_name = {}, const NodeAttrNameMap& node_attr_to_name = {}); TORCH_API std::string serialize_model_proto_to_string( diff --git a/torch/csrc/onnx/init.cpp b/torch/csrc/onnx/init.cpp index 2223ebc2f12..ab2b350a6cd 100644 --- a/torch/csrc/onnx/init.cpp +++ b/torch/csrc/onnx/init.cpp @@ -1,8 +1,10 @@ +#include #include #include -#include +#include -namespace torch { namespace onnx { +namespace torch { +namespace onnx { void initONNXBindings(PyObject* module) { auto m = py::handle(module).cast(); auto onnx = m.def_submodule("_onnx"); @@ -25,18 +27,17 @@ void initONNXBindings(PyObject* module) { .value("COMPLEX128", ::ONNX_NAMESPACE::TensorProto_DataType_COMPLEX128); py::enum_(onnx, "OperatorExportTypes") - .value("ONNX", OperatorExportTypes::ONNX) - .value("ONNX_ATEN", OperatorExportTypes::ONNX_ATEN) - .value("ONNX_ATEN_FALLBACK", OperatorExportTypes::ONNX_ATEN_FALLBACK) - .value("ONNX_FALLTHROUGH", OperatorExportTypes::ONNX_FALLTHROUGH); + .value("ONNX", OperatorExportTypes::ONNX) + .value("ONNX_ATEN", OperatorExportTypes::ONNX_ATEN) + .value("ONNX_ATEN_FALLBACK", OperatorExportTypes::ONNX_ATEN_FALLBACK) + .value("ONNX_FALLTHROUGH", OperatorExportTypes::ONNX_FALLTHROUGH); py::enum_(onnx, "TrainingMode") - .value("EVAL", TrainingMode::EVAL) - .value("PRESERVE", TrainingMode::PRESERVE) - .value("TRAINING", TrainingMode::TRAINING); + .value("EVAL", TrainingMode::EVAL) + .value("PRESERVE", TrainingMode::PRESERVE) + .value("TRAINING", TrainingMode::TRAINING); - onnx.attr("IR_VERSION") = IR_VERSION; - onnx.attr("PRODUCER_VERSION") = py::str(PRODUCER_VERSION); + onnx.attr("PRODUCER_VERSION") = py::str(TORCH_VERSION); #ifdef PYTORCH_ONNX_CAFFE2_BUNDLE onnx.attr("PYTORCH_ONNX_CAFFE2_BUNDLE") = true; @@ -44,4 +45,5 @@ void initONNXBindings(PyObject* module) { onnx.attr("PYTORCH_ONNX_CAFFE2_BUNDLE") = false; #endif } -}} // namespace torch::onnx +} // namespace onnx +} // namespace torch diff --git a/torch/csrc/onnx/onnx.h b/torch/csrc/onnx/onnx.h index d01d8f5e804..163bcdaf700 100644 --- a/torch/csrc/onnx/onnx.h +++ b/torch/csrc/onnx/onnx.h @@ -16,10 +16,5 @@ enum class TrainingMode { TRAINING, // Training mode }; -// We pin IR version instead of using onnx::IR_VERSION so that the -// test_operators.py will be more stable. Only bump it when -// necessary. -constexpr size_t IR_VERSION = 7; -constexpr const char* PRODUCER_VERSION = "1.11"; } // namespace onnx } // namespace torch diff --git a/torch/onnx/__init__.py b/torch/onnx/__init__.py index ffcafa37cc5..73fef276533 100644 --- a/torch/onnx/__init__.py +++ b/torch/onnx/__init__.py @@ -7,10 +7,6 @@ PYTORCH_ONNX_CAFFE2_BUNDLE = _C._onnx.PYTORCH_ONNX_CAFFE2_BUNDLE ONNX_ARCHIVE_MODEL_PROTO_NAME = "__MODEL_PROTO" -# TODO: Update these variables when there -# is a new ir_version and producer_version -# and use these values in the exporter -ir_version = _C._onnx.IR_VERSION producer_name = "pytorch" producer_version = _C._onnx.PRODUCER_VERSION constant_folding_opset_versions = [9, 10, 11, 12, 13, 14] @@ -292,14 +288,14 @@ def export(model, args, f, export_params=True, verbose=False, training=TrainingM use_external_data_format (bool, default False): Deprecated and ignored. Will be removed in next Pytorch release. - export_modules_as_functions (bool or set of str, type or nn.Module, default False): Flag to enable + export_modules_as_functions (bool or set of type of nn.Module, default False): Flag to enable exporting all ``nn.Module`` forward calls as local functions in ONNX. Or a set to indicate the particular modules to export as local functions in ONNX. * ``False``(default): export ``nn.Module`` forward calls as fine grained nodes. * ``True``: export all ``nn.Module`` forward calls as local function nodes. - * Set of str, type or nn.Module: export ``nn.Module`` forward calls as local function nodes, - only if the name, type or obj of the ``nn.Module`` is found in the set. + * Set of type of nn.Module: export ``nn.Module`` forward calls as local function nodes, + only if the type of the ``nn.Module`` is found in the set. Raises: CheckerError: If the ONNX checker detects an invalid ONNX graph. Will still export the diff --git a/torch/onnx/utils.py b/torch/onnx/utils.py index 83b5a8a972f..6745a718382 100644 --- a/torch/onnx/utils.py +++ b/torch/onnx/utils.py @@ -669,7 +669,7 @@ def unconvertible_ops(model, args, training=TrainingMode.EVAL, opset_version=Non def _setup_trace_module_map(model, export_modules_as_functions): def __setup_trace_module_map(): - trace_module_map = {_m : torch.typename(_m) for _m in model.modules()} + trace_module_map = {_m : torch.typename(type(_m)) for _m in model.modules()} torch.jit._trace._trace_module_map = trace_module_map return trace_module_map @@ -677,9 +677,15 @@ def _setup_trace_module_map(model, export_modules_as_functions): trace_module_map = __setup_trace_module_map() export_modules_as_functions = {v for k, v in trace_module_map.items()} elif isinstance(export_modules_as_functions, set) and len(export_modules_as_functions) > 0: + def _find_typename(v): + if isinstance(v, type): + return torch.typename(v) + else: + raise RuntimeError("Only type of the `nn.Module` should be " + "passed in the set for argument `export_modules_as_functions`. " + "Got `%s`." % (type(v).__name__)) trace_module_map = __setup_trace_module_map() - module_typenames = {torch.typename(v) if isinstance(v, (torch.nn.Module, type)) else v - for v in export_modules_as_functions} + module_typenames = {_find_typename(v) for v in export_modules_as_functions} export_modules_as_functions = module_typenames else: export_modules_as_functions = None @@ -757,25 +763,23 @@ def _export(model, args, f, export_params=True, verbose=False, training=None, custom_opsets = {} torch._C._jit_pass_dce_allow_deleting_nodes_with_side_effects(graph) - val_attr_to_name = {} # type: ignore[var-annotated] node_attr_to_name = {} # type: ignore[var-annotated] if export_modules_as_functions is not None: # NOTE: cannot call DCE after this pass. DCE will remove function definition nodes. - val_attr_to_name, node_attr_to_name = torch._C._jit_pass_onnx_function_extraction( + node_attr_to_name = torch._C._jit_pass_onnx_function_extraction( graph, export_modules_as_functions, list(params_dict.keys())) if export_params: proto, export_map, val_use_external_data_format = graph._export_onnx( params_dict, opset_version, dynamic_axes, defer_weight_export, operator_export_type, not verbose, val_keep_init_as_ip, custom_opsets, val_add_node_names, val_use_external_data_format, model_file_location, - val_attr_to_name, node_attr_to_name) + node_attr_to_name) else: proto, export_map, val_use_external_data_format = graph._export_onnx( {}, opset_version, dynamic_axes, False, operator_export_type, not verbose, val_keep_init_as_ip, custom_opsets, val_add_node_names, val_use_external_data_format, model_file_location, - val_attr_to_name, node_attr_to_name) - + node_attr_to_name) if export_type == ExportTypes.PROTOBUF_FILE: assert(len(export_map) == 0) with torch.serialization._open_file_like(f, "wb") as opened_file: diff --git a/torch/testing/_internal/common_utils.py b/torch/testing/_internal/common_utils.py index 631692ebc7f..4248caca809 100644 --- a/torch/testing/_internal/common_utils.py +++ b/torch/testing/_internal/common_utils.py @@ -2113,7 +2113,7 @@ class TestCase(expecttest.TestCase): with open(expected_file, 'w') as f: # Adjust for producer_version, leave s unmodified s_tag = re.sub(r'(producer_version): "[0-9.]*"', - r'\1producer_version: "CURRENT_VERSION"', s) + r'\1: "CURRENT_VERSION"', s) f.write(s_tag) try: