From db475c4f358b0e936c8eb4b69d2eefa0b6be160d Mon Sep 17 00:00:00 2001 From: gwang-msft <62914304+gwang-msft@users.noreply.github.com> Date: Wed, 29 Jul 2020 11:47:01 -0700 Subject: [PATCH] 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> --- onnxruntime/test/onnx/main.cc | 13 ++++++++++++- tools/python/ort_test_dir_utils.py | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/onnxruntime/test/onnx/main.cc b/onnxruntime/test/onnx/main.cc index 3864461149..63540c28c6 100644 --- a/onnxruntime/test/onnx/main.cc +++ b/onnxruntime/test/onnx/main.cc @@ -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(OrtStrtol(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) { diff --git a/tools/python/ort_test_dir_utils.py b/tools/python/ort_test_dir_utils.py index 993bd1cb41..6dc3fb0217 100644 --- a/tools/python/ort_test_dir_utils.py +++ b/tools/python/ort_test_dir_utils.py @@ -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)