|
1 | 1 | // Copyright (c) Microsoft Corporation. All rights reserved.
|
2 |
| -// Copyright (c) 2023 NVIDIA Corporation. |
3 | 2 | // Licensed under the MIT License.
|
4 | 3 |
|
5 | 4 | #include "command_args_parser.h"
|
@@ -29,28 +28,30 @@ namespace qnnctxgen {
|
29 | 28 |
|
30 | 29 | /*static*/ void CommandLineParser::ShowUsage() {
|
31 | 30 | printf(
|
32 |
| - "onnxruntime_qnn_ctx_gen [options...] model1_path,model2_path\n" |
33 |
| - "Example: ./onnxruntime_qnn_ctx_gen -i \"soc_model|60 htp_graph_finalization_optimization_mode|3\" -C \"ep.context_node_name_prefix|_part1\" ./model1.onnx,./model2.onnx\n" |
| 31 | + "ep_weight_sharing_ctx_gen [options...] model1_path,model2_path\n" |
| 32 | + "Example: ./ep_weight_sharing_ctx_gen -i \"soc_model|60 htp_graph_finalization_optimization_mode|3\" -C \"ep.context_node_name_prefix|_part1\" ./model1.onnx,./model2.onnx\n" |
34 | 33 | "Options:\n"
|
| 34 | + "\t-e [qnn|tensorrt|openvino|vitisai]: Specifies the compile based provider 'qnn','tensorrt','openvino', 'vitisai'. " |
| 35 | + "Default:'qnn'.\n" |
35 | 36 | "\t-v: Show verbose information.\n"
|
36 | 37 | "\t-C: Specify session configuration entries as key-value pairs: -C \"<key1>|<value1> <key2>|<value2>\" \n"
|
37 | 38 | "\t Refer to onnxruntime_session_options_config_keys.h for valid keys and values. \n"
|
38 | 39 | "\t Force ep.context_enable to 1 and ep.context_embed_mode to 0. Change ep.context_file_path is not allowed."
|
39 | 40 | "\t [Example] -C \"ep.context_node_name_prefix|_part1\" \n"
|
40 |
| - "\t-i: Specify QNN EP specific runtime options as key value pairs. Different runtime options available are: \n" |
| 41 | + "\t-i: Specify EP specific runtime options as key value pairs. Different runtime options available are: \n" |
41 | 42 | "\t [Usage]: -i '<key1>|<value1> <key2>|<value2>'\n"
|
42 | 43 | "\n"
|
43 |
| - "\t [backend_path]: QNN backend path. e.g '/folderpath/libQnnHtp.so', '/winfolderpath/QnnHtp.dll'. default to HTP backend\n" |
44 |
| - "\t [vtcm_mb]: QNN VTCM size in MB. default to 0(not set).\n" |
45 |
| - "\t [htp_graph_finalization_optimization_mode]: QNN graph finalization optimization mode, options: '0', '1', '2', '3', default is '0'.\n" |
46 |
| - "\t [soc_model]: The SoC Model number. Refer to QNN SDK documentation for specific values. Defaults to '0' (unknown). \n" |
47 |
| - "\t [htp_arch]: The minimum HTP architecture. The driver will use ops compatible with this architecture. eg: '0', '68', '69', '73', '75'. Defaults to '0' (none). \n" |
48 |
| - "\t [enable_htp_fp16_precision]: Enable the HTP_FP16 precision so that the float32 model will be inferenced with fp16 precision. \n" |
| 44 | + "\t [QNN only] [backend_path]: QNN backend path. e.g '/folderpath/libQnnHtp.so', '/winfolderpath/QnnHtp.dll'. default to HTP backend\n" |
| 45 | + "\t [QNN only] [vtcm_mb]: QNN VTCM size in MB. default to 0(not set).\n" |
| 46 | + "\t [QNN only] [htp_graph_finalization_optimization_mode]: QNN graph finalization optimization mode, options: '0', '1', '2', '3', default is '0'.\n" |
| 47 | + "\t [QNN only] [soc_model]: The SoC Model number. Refer to QNN SDK documentation for specific values. Defaults to '0' (unknown). \n" |
| 48 | + "\t [QNN only] [htp_arch]: The minimum HTP architecture. The driver will use ops compatible with this architecture. eg: '0', '68', '69', '73', '75'. Defaults to '0' (none). \n" |
| 49 | + "\t [QNN only] [enable_htp_fp16_precision]: Enable the HTP_FP16 precision so that the float32 model will be inferenced with fp16 precision. \n" |
49 | 50 | "\t Otherwise, it will be fp32 precision. Works for float32 model for HTP backend. Defaults to '1' (with FP16 precision.). \n"
|
50 |
| - "\t [enable_htp_weight_sharing]: Allows common weights across graphs to be shared and stored in a single context binary. Defaults to '1' (enabled).\n" |
51 |
| - "\t [offload_graph_io_quantization]: Offload graph input quantization and graph output dequantization to another EP (typically CPU EP). \n" |
52 |
| - "\t Defaults to '0' (QNN EP handles the graph I/O quantization and dequantization). \n" |
53 |
| - "\t [enable_htp_spill_fill_buffer]: Enable HTP spill file buffer, used while generating QNN context binary." |
| 51 | + "\t [QNN only] [enable_htp_weight_sharing]: Allows common weights across graphs to be shared and stored in a single context binary. Defaults to '1' (enabled).\n" |
| 52 | + "\t [QNN only] [offload_graph_io_quantization]: Offload graph input quantization and graph output dequantization to another EP (typically CPU EP). \n" |
| 53 | + "\t Defaults to '1' (QNN EP handles the graph I/O quantization and dequantization). \n" |
| 54 | + "\t [QNN only] [enable_htp_spill_fill_buffer]: Enable HTP spill file buffer, used while generating QNN context binary." |
54 | 55 | "\t [Example] -i \"vtcm_mb|8 htp_arch|73\" \n"
|
55 | 56 | "\n"
|
56 | 57 | "\t-h: help\n");
|
@@ -109,8 +110,22 @@ static bool ParseSessionConfigs(const std::string& configs_string,
|
109 | 110 |
|
110 | 111 | /*static*/ bool CommandLineParser::ParseArguments(TestConfig& test_config, int argc, ORTCHAR_T* argv[]) {
|
111 | 112 | int ch;
|
112 |
| - while ((ch = getopt(argc, argv, ORT_TSTR("o:u:i:C:vh"))) != -1) { |
| 113 | + while ((ch = getopt(argc, argv, ORT_TSTR("e:o:u:i:C:vh"))) != -1) { |
113 | 114 | switch (ch) {
|
| 115 | + case 'e': |
| 116 | + if (!CompareCString(optarg, ORT_TSTR("qnn"))) { |
| 117 | + test_config.machine_config.provider_type_name = onnxruntime::kQnnExecutionProvider; |
| 118 | + } else if (!CompareCString(optarg, ORT_TSTR("openvino"))) { |
| 119 | + test_config.machine_config.provider_type_name = onnxruntime::kOpenVINOExecutionProvider; |
| 120 | + } else if (!CompareCString(optarg, ORT_TSTR("tensorrt"))) { |
| 121 | + test_config.machine_config.provider_type_name = onnxruntime::kTensorrtExecutionProvider; |
| 122 | + } else if (!CompareCString(optarg, ORT_TSTR("vitisai"))) { |
| 123 | + test_config.machine_config.provider_type_name = onnxruntime::kVitisAIExecutionProvider; |
| 124 | + } else { |
| 125 | + fprintf(stderr, "The execution provider is not included in this tool.\n"); |
| 126 | + return false; |
| 127 | + } |
| 128 | + break; |
114 | 129 | case 'v':
|
115 | 130 | test_config.run_config.f_verbose = true;
|
116 | 131 | break;
|
@@ -162,7 +177,7 @@ static bool ParseSessionConfigs(const std::string& configs_string,
|
162 | 177 | 'offload_graph_io_quantization', 'enable_htp_spill_fill_buffer'])");
|
163 | 178 | }
|
164 | 179 |
|
165 |
| - test_config.run_config.qnn_options[key] = value; |
| 180 | + test_config.run_config.provider_options[key] = value; |
166 | 181 | }
|
167 | 182 | break;
|
168 | 183 | }
|
|
0 commit comments