Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion onnxruntime/test/perftest/command_args_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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"))) {
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/test/perftest/performance_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,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;
Expand Down
1 change: 1 addition & 0 deletions onnxruntime/test/perftest/test_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down