From 00bcbc535b15558380c6dcb7daf613bbb30f698e Mon Sep 17 00:00:00 2001 From: PiotrKrzem Date: Mon, 10 Oct 2022 11:23:35 +0200 Subject: [PATCH 1/8] [SAMPLES/CPP] Show input command in output --- samples/cpp/benchmark_app/main.cpp | 8 ++++++++ tools/benchmark_tool/openvino/tools/benchmark/main.py | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 2f42c8ab83fed1..0cfabede31bb37 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -161,12 +161,20 @@ int main(int argc, char* argv[]) { // ----------------- 1. Parsing and validating input arguments // ------------------------------------------------- + std::stringstream args_string; + args_string << realpath(argv[0], nullptr) << " "; + for (int i = 1; i < argc; i++) { + args_string << argv[i] << " "; + } + next_step(); if (!parse_and_check_command_line(argc, argv)) { return 0; } + slog::info << "Input command: " << args_string.str() << slog::endl; + bool isNetworkCompiled = fileExt(FLAGS_m) == "blob"; if (isNetworkCompiled) { slog::info << "Network is compiled" << slog::endl; diff --git a/tools/benchmark_tool/openvino/tools/benchmark/main.py b/tools/benchmark_tool/openvino/tools/benchmark/main.py index ed925004170110..b2eed6d920b4f3 100644 --- a/tools/benchmark_tool/openvino/tools/benchmark/main.py +++ b/tools/benchmark_tool/openvino/tools/benchmark/main.py @@ -50,9 +50,15 @@ def main(): statistics = None try: # ------------------------------ 1. Parsing and validating input arguments ------------------------------ + args_string = f"{os.path.realpath(sys.argv[0])}" + for i in range(1,len(sys.argv)): + args_string += f"{sys.argv[i]} " + next_step() args, is_network_compiled = parse_and_check_command_line() + logger.info(f"Input command: {args_string}") + if args.number_streams is None: logger.warning(" -nstreams default value is determined automatically for a device. " "Although the automatic selection usually provides a reasonable performance, " From 7346166399a448d4c39e46eab61862d60ba6d8e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= Date: Tue, 11 Oct 2022 17:23:04 +0200 Subject: [PATCH 2/8] Update main.py --- tools/benchmark_tool/openvino/tools/benchmark/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/benchmark_tool/openvino/tools/benchmark/main.py b/tools/benchmark_tool/openvino/tools/benchmark/main.py index b2eed6d920b4f3..e6bfdccbd82df3 100644 --- a/tools/benchmark_tool/openvino/tools/benchmark/main.py +++ b/tools/benchmark_tool/openvino/tools/benchmark/main.py @@ -50,7 +50,7 @@ def main(): statistics = None try: # ------------------------------ 1. Parsing and validating input arguments ------------------------------ - args_string = f"{os.path.realpath(sys.argv[0])}" + args_string = f"{os.path.realpath(sys.argv[0])} " for i in range(1,len(sys.argv)): args_string += f"{sys.argv[i]} " From af2ca6bfee98a983c24f8089423ecf603ba766bc Mon Sep 17 00:00:00 2001 From: PiotrKrzem Date: Wed, 19 Oct 2022 15:29:59 +0200 Subject: [PATCH 3/8] [CPP] Add Windows-specific abspath method --- samples/cpp/benchmark_app/main.cpp | 41 +++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 96521cce7ed14e..c88db705845107 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -28,10 +28,41 @@ #include "remote_tensors_filling.hpp" #include "statistics_report.hpp" #include "utils.hpp" + +#if defined(_WIN32) || defined(WIN32) +# include +#endif // clang-format on static const size_t progressBarDefaultTotalCount = 1000; +void get_console_command(int argc, char* argv[]){ + std::stringstream args_string; + + + std::stringstream args_string; + + #if defined(_WIN32) || defined(WIN32) + uint32_t len = 1024; + std::string p(argv[0]); + std::string buf; + do + { + buf.resize(len); + len = GetFullPathNameA(p.data(), len, buf.data(), nullptr); + } while(len > buf.size()); + args_string << buf; + #else + args_string << realpath(argv[0], nullptr); + #endif + args_string << " "; + + for (int i = 1; i < argc; i++) { + args_string << argv[i] << " "; + } + +} + bool parse_and_check_command_line(int argc, char* argv[]) { // ---------------------------Parsing and validating input // arguments-------------------------------------- @@ -161,19 +192,15 @@ int main(int argc, char* argv[]) { // ----------------- 1. Parsing and validating input arguments // ------------------------------------------------- - std::stringstream args_string; - args_string << realpath(argv[0], nullptr) << " "; - for (int i = 1; i < argc; i++) { - args_string << argv[i] << " "; - } - + auto args_string = get_console_command(argc, argv); + next_step(); if (!parse_and_check_command_line(argc, argv)) { return 0; } - slog::info << "Input command: " << args_string.str() << slog::endl; + slog::info << "Input command: " << args_string << slog::endl; bool isNetworkCompiled = fileExt(FLAGS_m) == "blob"; if (isNetworkCompiled) { From def219d374467f0568144abff779e4169437c55f Mon Sep 17 00:00:00 2001 From: PiotrKrzem Date: Wed, 19 Oct 2022 15:38:40 +0200 Subject: [PATCH 4/8] [CPP] Formatting errors --- samples/cpp/benchmark_app/main.cpp | 32 ++++++++++++++---------------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index c88db705845107..83af92fc1ea7dd 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -36,31 +36,29 @@ static const size_t progressBarDefaultTotalCount = 1000; -void get_console_command(int argc, char* argv[]){ +std::string get_console_command(int argc, char* argv[]) { std::stringstream args_string; - - std::stringstream args_string; - - #if defined(_WIN32) || defined(WIN32) - uint32_t len = 1024; - std::string p(argv[0]); - std::string buf; - do - { - buf.resize(len); - len = GetFullPathNameA(p.data(), len, buf.data(), nullptr); - } while(len > buf.size()); - args_string << buf; - #else - args_string << realpath(argv[0], nullptr); - #endif +#if defined(_WIN32) || defined(WIN32) + uint32_t len = 1024; + std::string p(argv[0]); + std::string buf; + do + { + buf.resize(len); + len = GetFullPathNameA(p.data(), len, buf.data(), nullptr); + } while(len > buf.size()); + args_string << buf; +#else + args_string << realpath(argv[0], nullptr); +#endif args_string << " "; for (int i = 1; i < argc; i++) { args_string << argv[i] << " "; } + return args_string.str(); } bool parse_and_check_command_line(int argc, char* argv[]) { From 6772e7e76f7bcb00f0c6fbed671cbebf41f27e21 Mon Sep 17 00:00:00 2001 From: PiotrKrzem Date: Thu, 20 Oct 2022 15:24:37 +0200 Subject: [PATCH 5/8] [C++] Fix naming conventions, fix incorrect buffer type to store output path --- samples/cpp/benchmark_app/main.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 83af92fc1ea7dd..16f6691ed0ab6c 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -37,28 +37,31 @@ static const size_t progressBarDefaultTotalCount = 1000; std::string get_console_command(int argc, char* argv[]) { - std::stringstream args_string; + std::stringstream args_command; #if defined(_WIN32) || defined(WIN32) + std::stringstream args_command; + std::string relative_path(argv[0]); + std::vector buffer; + uint32_t len = 1024; - std::string p(argv[0]); - std::string buf; - do - { - buf.resize(len); - len = GetFullPathNameA(p.data(), len, buf.data(), nullptr); - } while(len > buf.size()); - args_string << buf; + do { + buffer.resize(len); + len = GetFullPathNameA(relative_path.data(), len, buffer.data(), nullptr); + } while (len > buffer.size()); + + std::string full_path(buffer.begin(), buffer.end()); + args_command << full_path; #else - args_string << realpath(argv[0], nullptr); + args_command << realpath(argv[0], nullptr); #endif - args_string << " "; + args_command << " "; for (int i = 1; i < argc; i++) { - args_string << argv[i] << " "; + args_command << argv[i] << " "; } - return args_string.str(); + return args_command.str(); } bool parse_and_check_command_line(int argc, char* argv[]) { From 5b6fd416de157d9b15278aac3caac61db197dad0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= Date: Thu, 20 Oct 2022 15:27:11 +0200 Subject: [PATCH 6/8] [C++] Formatting errors - invisible spaces remove --- samples/cpp/benchmark_app/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 16f6691ed0ab6c..395f6b4341bcc1 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -194,7 +194,7 @@ int main(int argc, char* argv[]) { // ----------------- 1. Parsing and validating input arguments // ------------------------------------------------- auto args_string = get_console_command(argc, argv); - + next_step(); if (!parse_and_check_command_line(argc, argv)) { From 89ce3b161af45f38edf35f71392ca97adb34efca Mon Sep 17 00:00:00 2001 From: PiotrKrzem Date: Thu, 20 Oct 2022 16:02:20 +0200 Subject: [PATCH 7/8] [C++] Add comments, fix name of the command_string variable --- samples/cpp/benchmark_app/main.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index 395f6b4341bcc1..cc1a1b6bc565fc 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -193,7 +193,10 @@ int main(int argc, char* argv[]) { // ----------------- 1. Parsing and validating input arguments // ------------------------------------------------- - auto args_string = get_console_command(argc, argv); + + // Must be executed before parse_and_check_command_line() + // gflags::ParseCommandLineNonHelpFlags() modifies the argv array + auto command_from_args = get_console_command(argc, argv); next_step(); @@ -201,7 +204,7 @@ int main(int argc, char* argv[]) { return 0; } - slog::info << "Input command: " << args_string << slog::endl; + slog::info << "Input command: " << command_from_args << slog::endl; bool isNetworkCompiled = fileExt(FLAGS_m) == "blob"; if (isNetworkCompiled) { From c61ef10961948ed1eace8f2a8e326e975af0287a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Krzemi=C5=84ski?= Date: Thu, 20 Oct 2022 18:34:57 +0200 Subject: [PATCH 8/8] [C++] Remove redefinition of symbol --- samples/cpp/benchmark_app/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/samples/cpp/benchmark_app/main.cpp b/samples/cpp/benchmark_app/main.cpp index cc1a1b6bc565fc..f51f9e6cd01f02 100644 --- a/samples/cpp/benchmark_app/main.cpp +++ b/samples/cpp/benchmark_app/main.cpp @@ -40,7 +40,6 @@ std::string get_console_command(int argc, char* argv[]) { std::stringstream args_command; #if defined(_WIN32) || defined(WIN32) - std::stringstream args_command; std::string relative_path(argv[0]); std::vector buffer;