mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-31 23:27:43 +00:00
Add optimization level as cmd line arguments (#776)
* Add optimization level as cmd line arguments * fix the help info and add option.
This commit is contained in:
parent
36ed91ee9f
commit
3eddb2d61e
3 changed files with 14 additions and 1 deletions
|
|
@ -35,12 +35,13 @@ namespace perftest {
|
|||
"\t-s: Show statistics result, like P75, P90.\n"
|
||||
"\t-v: Show verbose information.\n"
|
||||
"\t-x [thread_size]: Use parallel executor, default (without -x): sequential executor.\n"
|
||||
"\t-o [optimization level]: 0: No transformer optimization, 1:basic optimization, 2: full optimization. \n"
|
||||
"\t-h: help\n");
|
||||
}
|
||||
|
||||
/*static*/ bool CommandLineParser::ParseArguments(PerformanceTestConfig& test_config, int argc, ORTCHAR_T* argv[]) {
|
||||
int ch;
|
||||
while ((ch = getopt(argc, argv, ORT_TSTR("m:e:r:t:p:x:vhs"))) != -1) {
|
||||
while ((ch = getopt(argc, argv, ORT_TSTR("m:e:r:t:p:x:o:vhs"))) != -1) {
|
||||
switch (ch) {
|
||||
case 'm':
|
||||
if (!CompareCString(optarg, ORT_TSTR("duration"))) {
|
||||
|
|
@ -96,6 +97,13 @@ namespace perftest {
|
|||
return false;
|
||||
}
|
||||
break;
|
||||
case 'o':
|
||||
test_config.run_config.optimization_level = static_cast<uint32_t>(OrtStrtol<PATH_CHAR_TYPE>(optarg, nullptr));
|
||||
// Valid values are: 0, 1, 2.
|
||||
if (test_config.run_config.optimization_level > 2 ) {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case '?':
|
||||
case 'h':
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -140,6 +140,10 @@ bool PerformanceRunner::Initialize() {
|
|||
sf.DisableSequentialExecution();
|
||||
fprintf(stdout, "Setting thread pool size to %d\n", performance_test_config_.run_config.session_thread_pool_size);
|
||||
sf.SetSessionThreadPoolSize(performance_test_config_.run_config.session_thread_pool_size);
|
||||
|
||||
// Set optimization level.
|
||||
sf.SetSessionGraphOptimizationLevel(performance_test_config_.run_config.optimization_level);
|
||||
|
||||
session_object_ = sf.OrtCreateSession(test_case->GetModelUrl());
|
||||
|
||||
auto provider_type = performance_test_config_.machine_config.provider_type_name;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ struct RunConfig {
|
|||
bool f_verbose{false};
|
||||
bool enable_sequential_execution{true};
|
||||
int session_thread_pool_size{6};
|
||||
uint32_t optimization_level{2};
|
||||
};
|
||||
|
||||
struct PerformanceTestConfig {
|
||||
|
|
|
|||
Loading…
Reference in a new issue