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:
ybrnathan 2019-04-05 14:44:28 -07:00 committed by GitHub
parent 36ed91ee9f
commit 3eddb2d61e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 1 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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 {