Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / samples / speech_sample / speech_sample.hpp
1 // Copyright (C) 2018-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 <dirent.h>
16 #endif
17
18 /// @brief message for help argument
19 static const char help_message[] = "Print a usage message.";
20
21 /// @brief message for images argument
22 static const char input_message[] = "Required. Path to an .ark file.";
23
24 /// @brief message for plugin_path argument
25 static const char plugin_path_message[] = "Path to a plugin folder.";
26
27 /// @brief message for model argument
28 static const char model_message[] = "Required. Path to an .xml file with a trained model (required if -rg is missing).";
29
30 /// @brief message for plugin argument
31 static const char plugin_message[] = "Plugin name. For example MKLDNNPlugin. If this parameter is pointed, " \
32                                      "the sample will look for this plugin only";
33
34 /// @brief message for assigning cnn calculation to device
35 static const char target_device_message[] = "Specify a target device to infer on. CPU, GPU, GNA_AUTO, GNA_HW, GNA_SW, "
36                                             "GNA_SW_EXACT and HETERO with combination of GNA as the primary device and CPU"
37                                             " as a secondary (e.g. HETERO:GNA,CPU) are supported. The sample will look "
38                                             "for a suitable plugin for device specified.";
39
40 /// @brief message for performance counters
41 static const char performance_counter_message[] = "Enables per-layer performance report";
42
43 /// @brief message for user library argument
44 static const char custom_cpu_library_message[] = "Required for MKLDNN (CPU)-targeted custom layers." \
45 "Absolute path to a shared library with the kernels impl.";
46
47 /// @brief message for score output argument
48 static const char output_message[] = "Output file name (default name is scores.ark).";
49
50 /// @brief message for reference score file argument
51 static const char reference_score_message[] = "Read reference score .ark file and compare scores.";
52
53 /// @brief message for read GNA model argument
54 static const char read_gna_model_message[] = "Read GNA model from file using path/filename provided (required if -m is missing).";
55
56 /// @brief message for write GNA model argument
57 static const char write_gna_model_message[] = "Write GNA model to file using path/filename provided.";
58
59 /// @brief message for write GNA embedded model argument
60 static const char write_embedded_model_message[] = "Write GNA embedded model to file using path/filename provided.";
61
62 /// @brief message for quantization argument
63 static const char quantization_message[] = "Input quantization mode:  static (default), dynamic, or user (use with -sf).";
64
65 /// @brief message for quantization bits argument
66 static const char quantization_bits_message[] = "Weight bits for quantization:  8 or 16 (default)";
67
68 /// @brief message for scale factor argument
69 static const char scale_factor_message[] = "Optional user-specified input scale factor for quantization (use with -q user).";
70
71 /// @brief message for batch size argument
72 static const char batch_size_message[] = "Batch size 1-8 (default 1)";
73
74 /// @brief message for #threads for CPU inference
75 static const char infer_num_threads_message[] = "Optional. Number of threads to use for concurrent async" \
76 " inference requests on the GNA.";
77
78 /// @brief message for context window argument
79 static const char context_window_message[] = "Optional. Number of frames for context windows (default is 0). " \
80                                              "Works only with context window networks."
81                                              " If you use the cw flag, then batch size and nthreads arguments are ignored.";
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 /// It is a required parameter
88 DEFINE_string(i, "", input_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 plugin name <br>
95 /// It is a required parameter
96 DEFINE_string(p, "", plugin_message);
97
98 /// \brief Define parameter for set path to plugins <br>
99 /// Default is ./lib
100 DEFINE_string(pp, "", plugin_path_message);
101
102 /// \brief device the target device to infer on <br>
103 DEFINE_string(d, "GNA_AUTO", target_device_message);
104
105 /// \brief Enable per-layer performance report
106 DEFINE_bool(pc, false, performance_counter_message);
107
108 /// @brief Absolute path to CPU library with user layers <br>
109 /// It is a optional parameter
110 DEFINE_string(l, "", custom_cpu_library_message);
111
112 /// @brief Write model to file (model.bin)
113 DEFINE_string(o, "", output_message);
114
115 /// @brief Read reference score file
116 DEFINE_string(r, "", reference_score_message);
117
118 /// @brief Read GNA model from file (model.bin)
119 DEFINE_string(rg, "", read_gna_model_message);
120
121 /// @brief Write GNA model to file (model.bin)
122 DEFINE_string(wg, "", write_gna_model_message);
123
124 /// @brief Write GNA embedded model to file (model.bin)
125 DEFINE_string(we, "", write_embedded_model_message);
126
127 /// @brief Input quantization mode (default static)
128 DEFINE_string(q, "static", quantization_message);
129
130 /// @brief Input quantization bits (default 16)
131 DEFINE_int32(qb, 16, quantization_bits_message);
132
133 /// @brief Scale factor for quantization (default 1.0)
134 DEFINE_double(sf, 1.0, scale_factor_message);
135
136 /// @brief Batch size (default 1)
137 DEFINE_int32(bs, 1, batch_size_message);
138
139 /// @brief Number of threads to use for inference on the CPU (also affects Hetero cases)
140 DEFINE_int32(nthreads, 1, infer_num_threads_message);
141
142 /// @brief Batch size (default 0)
143 DEFINE_int32(cw, 0, context_window_message);
144
145 /**
146  * \brief This function show a help message
147  */
148 static void showUsage() {
149     std::cout << std::endl;
150     std::cout << "speech_sample [OPTION]" << std::endl;
151     std::cout << "Options:" << std::endl;
152     std::cout << std::endl;
153     std::cout << "    -h                        " << help_message << std::endl;
154     std::cout << "    -i \"<path>\"             " << input_message << std::endl;
155     std::cout << "    -m \"<path>\"             " << model_message << std::endl;
156     std::cout << "    -o \"<path>\"             " << output_message << std::endl;
157     std::cout << "    -l \"<absolute_path>\"    " << custom_cpu_library_message << std::endl;
158     std::cout << "    -d \"<device>\"           " << target_device_message << std::endl;
159     std::cout << "    -p                        " << plugin_message << std::endl;
160     std::cout << "    -pp                       " << plugin_path_message << std::endl;
161     std::cout << "    -pc                       " << performance_counter_message << std::endl;
162     std::cout << "    -q \"<mode>\"             " << quantization_message << std::endl;
163     std::cout << "    -qb \"<integer>\"         " << quantization_bits_message << std::endl;
164     std::cout << "    -sf \"<double>\"          " << scale_factor_message << std::endl;
165     std::cout << "    -bs \"<integer>\"         " << batch_size_message << std::endl;
166     std::cout << "    -r \"<path>\"             " << reference_score_message << std::endl;
167     std::cout << "    -rg \"<path>\"            " << read_gna_model_message << std::endl;
168     std::cout << "    -wg \"<path>\"            " << write_gna_model_message << std::endl;
169     std::cout << "    -we \"<path>\"            " << write_embedded_model_message << std::endl;
170     std::cout << "    -nthreads \"<integer>\"   " << infer_num_threads_message << std::endl;
171     std::cout << "    -cw \"<integer>\"         " << context_window_message << std::endl;
172 }
173