Add option for onnx_test_runner can pause after launch, make create_test_dir work on non-windows os (#4618)

* minor fix for test dir util

* add pause option for onnx_test_runner

* add flush std to show pause prompt text

Co-authored-by: gwang0000 <62914304+gwang0000@users.noreply.github.com>
This commit is contained in:
gwang-msft 2020-07-29 11:47:01 -07:00 committed by GitHub
parent 326cc686df
commit db475c4f35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 2 deletions

View file

@ -39,6 +39,7 @@ void usage() {
"\t-e [EXECUTION_PROVIDER]: EXECUTION_PROVIDER could be 'cpu', 'cuda', 'dnnl', 'tensorrt', 'ngraph', "
"'openvino', 'nuphar', 'migraphx', 'acl' or 'armnn'. "
"Default: 'cpu'.\n"
"\t-p: Pause after launch, can attach debugger and continue\n"
"\t-x: Use parallel executor, default (without -x): sequential executor.\n"
"\t-d [device_id]: Specifies the device id for multi-device (e.g. GPU). The value should > 0\n"
"\t-o [optimization level]: Default is 99. Valid values are 0 (disable), 1 (basic), 2 (extended), 99 (all).\n"
@ -109,9 +110,10 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
int verbosity_option_count = 0;
OrtLoggingLevel logging_level = ORT_LOGGING_LEVEL_ERROR;
bool pause = false;
{
int ch;
while ((ch = getopt(argc, argv, ORT_TSTR("Ac:hj:Mn:r:e:xvo:d:"))) != -1) {
while ((ch = getopt(argc, argv, ORT_TSTR("Ac:hj:Mn:r:e:xvo:d:p"))) != -1) {
switch (ch) {
case 'A':
enable_cpu_mem_arena = false;
@ -181,6 +183,9 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
case 'x':
execution_mode = ExecutionMode::ORT_PARALLEL;
break;
case 'p':
pause = true;
break;
case 'o': {
int tmp = static_cast<int>(OrtStrtol<PATH_CHAR_TYPE>(optarg, nullptr));
switch (tmp) {
@ -243,6 +248,12 @@ int real_main(int argc, char* argv[], Ort::Env& env) {
return -1;
}
if (pause) {
printf("Enter to continue...\n");
fflush(stdout);
getchar();
}
try {
env = Ort::Env{logging_level, "Default"};
} catch (std::exception& ex) {

View file

@ -87,7 +87,7 @@ def create_test_dir(model_path, root_path, test_name,
if not os.path.exists(test_dir) or not os.path.exists(test_data_dir):
os.makedirs(test_data_dir)
model_filename = model_path.split('\\')[-1]
model_filename = os.path.split(model_path)[-1]
test_model_filename = os.path.join(test_dir, model_filename)
shutil.copy(model_path, test_model_filename)