Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / benchmark_app / benchmark_app.hpp
1 // Copyright (C) 2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4
5 #pragma once
6
7 #include <string>
8 #include <vector>
9 #include <gflags/gflags.h>
10 #include <iostream>
11
12 #ifdef _WIN32
13 #include <os/windows/w_dirent.h>
14 #else
15 #include <sys/stat.h>
16 #include <dirent.h>
17 #endif
18
19 /// @brief message for help argument
20 static const char help_message[] = "Print a usage message";
21
22 /// @brief message for images argument
23 static const char image_message[] = "Required. Path to a folder with images or to image files.";
24
25 /// @brief message for images argument
26 static const char multi_input_message[] = "Path to multi input file containing.";
27
28 /// @brief message for model argument
29 static const char model_message[] = "Required. Path to an .xml file with a trained model.";
30
31 /// @brief message for plugin_path argument
32 static const char plugin_path_message[] = "Optional. Path to a plugin folder.";
33
34 /// @brief message for execution mode
35 static const char api_message[] = "Optional. Enable Sync/Async API. Default value is \"async\".";
36
37 /// @brief message for assigning cnn calculation to device
38 static const char target_device_message[] = "Optional. Specify a target device to infer on: CPU, GPU, FPGA, HDDL or MYRIAD. Default value is CPU. " \
39 "Use \"-d HETERO:<comma-separated_devices_list>\" format to specify HETERO plugin. " \
40 "The application looks for a suitable plugin for the specified device.";
41
42 /// @brief message for iterations count
43 static const char iterations_count_message[] = "Optional. Number of iterations. " \
44 "If not specified, the number of iterations is calculated depending on a device.";
45
46 /// @brief message for requests count
47 static const char infer_requests_count_message[] = "Optional. Number of infer requests. Default value is 2.";
48
49 /// @brief message for #threads for CPU inference
50 static const char infer_num_threads_message[] = "Optional. Number of threads to use for inference on the CPU "
51                                                 "(including HETERO cases).";
52
53 /// @brief message for user library argument
54 static const char custom_cpu_library_message[] = "Required for CPU custom layers. Absolute path to a shared library with the kernels implementations.";
55
56 /// @brief message for clDNN custom kernels desc
57 static const char custom_cldnn_message[] = "Required for GPU custom kernels. Absolute path to an .xml file with the kernels description.";
58
59 static const char batch_size_message[] = "Optional. Batch size value. If not specified, the batch size value is determined from Intermediate Representation.";
60
61 // @brief message for CPU threads pinning option
62 static const char infer_threads_pinning_message[] = "Optional. Enable (\"YES\" is default value) or disable (\"NO\") " \
63                                                     "CPU threads pinning for CPU-involved inference.";
64
65 // @brief message for stream_output option
66 static const char stream_output_message[] = "Optional. Print progress as a plain text. When specified, an interactive progress bar is replaced with a "
67                                             "multiline output.";
68
69 // @brief message for report_type option
70 static const char report_type_message[] = "Optional. Enable collecting statistics report. \"no_counters\" report contains "
71                                           "configuration options specified, resulting FPS and latency. \"median_counters\" "
72                                           "report extends \"no_counters\" report and additionally includes median PM "
73                                           "counters values for each layer from the network. \"detailed_counters\" report "
74                                           "extends \"median_counters\" report and additionally includes per-layer PM "
75                                           "counters and latency for each executed infer request.";
76
77 // @brief message for report_folder option
78 static const char report_folder_message[] = "Optional. Path to a folder where statistics report is stored.";
79
80 // @brief message for exec_graph_path option
81 static const char exec_graph_path_message[] = "Optional. Path to a file where to store executable graph information serialized.";
82
83 /// @brief Define flag for showing help message <br>
84 DEFINE_bool(h, false, help_message);
85
86 /// @brief Define parameter for set image file <br>
87 /// i or mif is a required parameter
88 DEFINE_string(i, "", image_message);
89
90 /// @brief Define parameter for set model file <br>
91 /// It is a required parameter
92 DEFINE_string(m, "", model_message);
93
94 /// @brief Define parameter for set path to plugins <br>
95 DEFINE_string(pp, "", plugin_path_message);
96
97 /// @brief Define execution mode
98 DEFINE_string(api, "async", api_message);
99
100 /// @brief device the target device to infer on <br>
101 DEFINE_string(d, "CPU", target_device_message);
102
103 /// @brief Absolute path to CPU library with user layers <br>
104 /// It is a required parameter
105 DEFINE_string(l, "", custom_cpu_library_message);
106
107 /// @brief Define parameter for clDNN custom kernels path <br>
108 /// Default is ./lib
109 DEFINE_string(c, "", custom_cldnn_message);
110
111 /// @brief Iterations count (default 0)
112 /// Sync mode: iterations count
113 /// Async mode: StartAsync counts
114 DEFINE_uint32(niter, 0, iterations_count_message);
115
116 /// @brief Number of infer requests in parallel
117 DEFINE_uint32(nireq, 2, infer_requests_count_message);
118
119 /// @brief Number of threads to use for inference on the CPU (also affects Hetero cases)
120 DEFINE_uint32(nthreads, 0, infer_num_threads_message);
121
122 /// @brief Define parameter for batch size <br>
123 /// Default is 0 (that means don't specify)
124 DEFINE_uint32(b, 0, batch_size_message);
125
126 // @brief Enable plugin messages
127 DEFINE_string(pin, "YES", infer_threads_pinning_message);
128
129 /// @brief Enables multiline text output instead of progress bar
130 DEFINE_bool(stream_output, false, stream_output_message);
131
132 /// @brief Enables statistics report collecting
133 DEFINE_string(report_type, "", report_type_message);
134
135 /// @brief Path to a folder where statistics report is stored
136 DEFINE_string(report_folder, "", report_folder_message);
137
138 /// @brief Path to a file where to store executable graph information serialized
139 DEFINE_string(exec_graph_path, "", exec_graph_path_message);
140
141 /**
142 * @brief This function show a help message
143 */
144 static void showUsage() {
145     std::cout << std::endl;
146     std::cout << "benchmark_app [OPTION]" << std::endl;
147     std::cout << "Options:" << std::endl;
148     std::cout << std::endl;
149     std::cout << "    -h                        " << help_message << std::endl;
150     std::cout << "    -i \"<path>\"               " << image_message << std::endl;
151     std::cout << "    -m \"<path>\"               " << model_message << std::endl;
152     std::cout << "    -pp \"<path>\"              " << plugin_path_message << std::endl;
153     std::cout << "    -d \"<device>\"             " << target_device_message << std::endl;
154     std::cout << "    -l \"<absolute_path>\"      " << custom_cpu_library_message << std::endl;
155     std::cout << "          Or" << std::endl;
156     std::cout << "    -c \"<absolute_path>\"      " << custom_cldnn_message << std::endl;
157     std::cout << "    -api \"<sync/async>\"       " << api_message << std::endl;
158     std::cout << "    -niter \"<integer>\"        " << iterations_count_message << std::endl;
159     std::cout << "    -nireq \"<integer>\"        " << infer_requests_count_message << std::endl;
160     std::cout << "    -b \"<integer>\"            " << batch_size_message << std::endl;
161     std::cout << "    -stream_output            " << stream_output_message << std::endl;
162     std::cout << std::endl << "  CPU-specific performance options:" << std::endl;
163     std::cout << "    -nthreads \"<integer>\"     " << infer_num_threads_message << std::endl;
164     std::cout << "    -pin \"YES\"/\"NO\"           " << infer_threads_pinning_message << std::endl;
165     std::cout << std::endl << "  Statistics dumping options:" << std::endl;
166     std::cout << "    -report_type \"<type>\"     " << report_type_message << std::endl;
167     std::cout << "    -report_folder            " << report_folder_message << std::endl;
168     std::cout << "    -exec_graph_path          " << exec_graph_path_message << std::endl;
169 }