From 269be2fe632c5ebf8b37b038fc7b36b4d4e6d95f Mon Sep 17 00:00:00 2001 From: Edward Chen <18449977+edgchen1@users.noreply.github.com> Date: Mon, 11 Apr 2022 11:19:21 -0700 Subject: [PATCH] Remove unnecessary option from convert_onnx_models_to_ort.py, fix old instructions. (#11088) Remove unnecessary --nnapi_partitioning_stop_ops option from convert_onnx_models_to_ort.py, fix old instructions. --- objectivec/test/testdata/gen_models.sh | 2 +- .../graph_runtime_optimization_test.cc | 2 +- onnxruntime/test/testdata/mnist.readme.txt | 8 +++++--- .../test/testdata/ort_backwards_compat/readme.md | 14 ++++++++------ tools/python/util/convert_onnx_models_to_ort.py | 8 -------- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/objectivec/test/testdata/gen_models.sh b/objectivec/test/testdata/gen_models.sh index 45b0ce3ae6..0a58ca8463 100755 --- a/objectivec/test/testdata/gen_models.sh +++ b/objectivec/test/testdata/gen_models.sh @@ -8,5 +8,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd ${DIR} python3 ./single_add_gen.py -python3 -m onnxruntime.tools.convert_onnx_models_to_ort --optimization_level basic . +ORT_CONVERT_ONNX_MODELS_TO_ORT_OPTIMIZATION_LEVEL=basic python3 -m onnxruntime.tools.convert_onnx_models_to_ort --optimization_style=Fixed . diff --git a/onnxruntime/test/optimizer/runtime_optimization/graph_runtime_optimization_test.cc b/onnxruntime/test/optimizer/runtime_optimization/graph_runtime_optimization_test.cc index 2d8457721f..d5c5e6de8e 100644 --- a/onnxruntime/test/optimizer/runtime_optimization/graph_runtime_optimization_test.cc +++ b/onnxruntime/test/optimizer/runtime_optimization/graph_runtime_optimization_test.cc @@ -350,7 +350,7 @@ TEST(GraphRuntimeOptimizationTest, TestNhwcTransformerDirectlyUpdatesQLinearConv // - set environment variable ORT_CONVERT_ONNX_MODELS_TO_ORT_OPTIMIZATION_LEVEL=extended // - run: // python -m onnxruntime.tools.convert_onnx_models_to_ort - // --optimization_style Fixed + // --optimization_style=Fixed // testdata/transform/runtime_optimization/qdq_convs.onnx ORT_TSTR("testdata/transform/runtime_optimization/qdq_convs.extended.ort"), [](const OpCountMap& loaded_ops, const OpCountMap& initialized_ops) { diff --git a/onnxruntime/test/testdata/mnist.readme.txt b/onnxruntime/test/testdata/mnist.readme.txt index e030fa5067..bf5cca9451 100644 --- a/onnxruntime/test/testdata/mnist.readme.txt +++ b/onnxruntime/test/testdata/mnist.readme.txt @@ -5,6 +5,8 @@ We also save both ONNX and ORT format versions of the model with level 1 (aka 'b required_ops.config, which is used in the reduced ops CI build. - mnist.level1_opt.ort is used in NNAPI unit tests. -The level 1 optimized model files can be generated by running the following command from the repo root and renaming the -resulting .onnx and .ort files accordingly: - $ python ./tools/python/convert_onnx_models_to_ort.py --optimization_level basic --save_optimized_onnx_model ./onnxruntime/test/testdata/mnist.onnx +The level 1 optimized model files can be generated with the following steps: +- Set environment variable ORT_CONVERT_ONNX_MODELS_TO_ORT_OPTIMIZATION_LEVEL=basic +- From this directory, run + $ python -m onnxruntime.tools.convert_onnx_models_to_ort --optimization_style=Fixed --save_optimized_onnx_model ./mnist.onnx +- Rename the resulting .onnx and .ort files accordingly diff --git a/onnxruntime/test/testdata/ort_backwards_compat/readme.md b/onnxruntime/test/testdata/ort_backwards_compat/readme.md index 0c5a3de3c2..c8f31f8f70 100644 --- a/onnxruntime/test/testdata/ort_backwards_compat/readme.md +++ b/onnxruntime/test/testdata/ort_backwards_compat/readme.md @@ -1,16 +1,18 @@ This directory contains ORT format models to test for backwards compatibility when we are forced to make an update that invalidates a kernel hash. -When this happens, first create a new directory for the currently released ORT version. +When this happens, first create a directory for the currently released ORT version if one doesn't already exist. -Find a model that uses the operator with the kernel hash change. The ONNX test data is generally a good place to do this. See cmake/external/onnx/onnx/backend/test/data/node +Find a model that uses the operator with the kernel hash change and copy it to the directory for the currently released ORT version. +The ONNX test data is generally a good place to do this. See cmake/external/onnx/onnx/backend/test/data/node. Convert the model to ORT format using the currently released ORT version. This model will contain the original hash. -e.g. -Running `python -m onnxruntime.tools.convert_onnx_models_to_ort --optimization_level=basic ORTv1.10/not1.onnx` +e.g. +Setting environment variable ORT_CONVERT_ONNX_MODELS_TO_ORT_OPTIMIZATION_LEVEL=basic +and then running `python -m onnxruntime.tools.convert_onnx_models_to_ort --optimization_style=Fixed ORTv1.10/not1.onnx` will create the ORT format model `not1.basic.ort` -Add both the ONNX and the ORT format models to the repository. +Add both the ONNX and the ORT format models to the repository. See onnxruntime/test/providers/kernel_def_hash_test.cc for information on updating the backwards compatibility hash -information and unit tests to use the new model. \ No newline at end of file +information and unit tests to use the new model. diff --git a/tools/python/util/convert_onnx_models_to_ort.py b/tools/python/util/convert_onnx_models_to_ort.py index e798cd3a57..8e1776ebca 100644 --- a/tools/python/util/convert_onnx_models_to_ort.py +++ b/tools/python/util/convert_onnx_models_to_ort.py @@ -189,11 +189,6 @@ def parse_args(): parser.add_argument('--allow_conversion_failures', action='store_true', help='Whether to proceed after encountering model conversion failures.') - parser.add_argument('--nnapi_partitioning_stop_ops', - help='Specify the list of NNAPI EP partitioning stop ops. ' - 'In particular, specify the value of the "ep.nnapi.partitioning_stop_ops" session ' - 'options config entry.') - parser.add_argument('--target_platform', type=str, default=None, choices=['arm', 'amd64'], help='Specify the target platform where the exported model will be used. ' 'This parameter can be used to choose between platform-specific options, ' @@ -226,9 +221,6 @@ def convert_onnx_models_to_ort(): session_options_config_entries = {} - if args.nnapi_partitioning_stop_ops is not None: - session_options_config_entries["ep.nnapi.partitioning_stop_ops"] = args.nnapi_partitioning_stop_ops - if args.target_platform == 'arm': session_options_config_entries["session.qdqisint8allowed"] = "1" else: