Skip to content

Commit

Permalink
[VitisAI] add registered custom op for perf test (#21336)
Browse files Browse the repository at this point in the history
### Description
<!-- Describe your changes. -->
Register for custom op when testing the performance


### Motivation and Context
<!-- - Why is this change required? What problem does it solve?
- If it fixes an open issue, please link to the issue here. -->
This is needed for providers to test their implementation
  • Loading branch information
BoarQing authored Sep 4, 2024
1 parent bf8a8e7 commit 9031112
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion onnxruntime/test/perftest/command_args_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ namespace perftest {
"\t-Z [Force thread to stop spinning between runs]: disallow thread from spinning during runs to reduce cpu usage.\n"
"\t-n [Exit after session creation]: allow user to measure session creation time to measure impact of enabling any initialization optimizations.\n"
"\t-l Provide file as binary in memory by using fopen before session creation.\n"
"\t-R [Register custom op]: allow user to register custom op by .so or .dll file.\n"
"\t-h: help\n");
}
#ifdef _WIN32
Expand Down Expand Up @@ -206,7 +207,7 @@ static bool ParseSessionConfigs(const std::string& configs_string,

/*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:y:c:d:o:u:i:f:F:S:T:C:AMPIDZvhsqznl"))) != -1) {
while ((ch = getopt(argc, argv, ORT_TSTR("m:e:r:t:p:x:y:c:d:o:u:i:f:F:S:T:C:AMPIDZvhsqznlR:"))) != -1) {
switch (ch) {
case 'f': {
std::basic_string<ORTCHAR_T> dim_name;
Expand Down Expand Up @@ -393,6 +394,9 @@ static bool ParseSessionConfigs(const std::string& configs_string,
case 'l':
test_config.model_info.load_via_path = true;
break;
case 'R':
test_config.run_config.register_custom_op_path = optarg;
break;
case '?':
case 'h':
default:
Expand Down
4 changes: 4 additions & 0 deletions onnxruntime/test/perftest/ort_test_session.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,6 +636,10 @@ select from 'TF8', 'TF16', 'UINT8', 'FLOAT', 'ITENSOR'. \n)");
session_options.AddConfigEntry(kOrtSessionOptionsConfigForceSpinningStop, "1");
}

if (!performance_test_config.run_config.register_custom_op_path.empty()) {
session_options.RegisterCustomOpsLibrary(performance_test_config.run_config.register_custom_op_path.c_str());
}

if (performance_test_config.run_config.execution_mode == ExecutionMode::ORT_PARALLEL && performance_test_config.run_config.inter_op_num_threads > 0) {
fprintf(stdout, "Setting inter_op_num_threads to %d\n", performance_test_config.run_config.inter_op_num_threads);
session_options.SetInterOpNumThreads(performance_test_config.run_config.inter_op_num_threads);
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 @@ -65,6 +65,7 @@ struct RunConfig {
bool disable_spinning = false;
bool disable_spinning_between_run = false;
bool exit_after_session_creation = false;
std::basic_string<ORTCHAR_T> register_custom_op_path;
};

struct PerformanceTestConfig {
Expand Down

0 comments on commit 9031112

Please sign in to comment.