1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
9 #include <gflags/gflags.h>
13 #include <os/windows/w_dirent.h>
18 /// @brief message for help argument
19 static const char help_message[] = "Print a usage message.";
21 /// @brief message for images argument
22 static const char input_message[] = "Required. Path to an .ark file.";
24 /// @brief message for plugin_path argument
25 static const char plugin_path_message[] = "Path to a plugin folder.";
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).";
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";
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.";
40 /// @brief message for performance counters
41 static const char performance_counter_message[] = "Enables per-layer performance report";
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.";
47 /// @brief message for score output argument
48 static const char output_message[] = "Output file name (default name is scores.ark).";
50 /// @brief message for reference score file argument
51 static const char reference_score_message[] = "Read reference score .ark file and compare scores.";
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).";
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.";
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.";
62 /// @brief message for quantization argument
63 static const char quantization_message[] = "Input quantization mode: static (default), dynamic, or user (use with -sf).";
65 /// @brief message for quantization bits argument
66 static const char quantization_bits_message[] = "Weight bits for quantization: 8 or 16 (default)";
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).";
71 /// @brief message for batch size argument
72 static const char batch_size_message[] = "Batch size 1-8 (default 1)";
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.";
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.";
83 /// \brief Define flag for showing help message <br>
84 DEFINE_bool(h, false, help_message);
86 /// \brief Define parameter for set image file <br>
87 /// It is a required parameter
88 DEFINE_string(i, "", input_message);
90 /// \brief Define parameter for set model file <br>
91 /// It is a required parameter
92 DEFINE_string(m, "", model_message);
94 /// \brief Define parameter for set plugin name <br>
95 /// It is a required parameter
96 DEFINE_string(p, "", plugin_message);
98 /// \brief Define parameter for set path to plugins <br>
100 DEFINE_string(pp, "", plugin_path_message);
102 /// \brief device the target device to infer on <br>
103 DEFINE_string(d, "GNA_AUTO", target_device_message);
105 /// \brief Enable per-layer performance report
106 DEFINE_bool(pc, false, performance_counter_message);
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);
112 /// @brief Write model to file (model.bin)
113 DEFINE_string(o, "", output_message);
115 /// @brief Read reference score file
116 DEFINE_string(r, "", reference_score_message);
118 /// @brief Read GNA model from file (model.bin)
119 DEFINE_string(rg, "", read_gna_model_message);
121 /// @brief Write GNA model to file (model.bin)
122 DEFINE_string(wg, "", write_gna_model_message);
124 /// @brief Write GNA embedded model to file (model.bin)
125 DEFINE_string(we, "", write_embedded_model_message);
127 /// @brief Input quantization mode (default static)
128 DEFINE_string(q, "static", quantization_message);
130 /// @brief Input quantization bits (default 16)
131 DEFINE_int32(qb, 16, quantization_bits_message);
133 /// @brief Scale factor for quantization (default 1.0)
134 DEFINE_double(sf, 1.0, scale_factor_message);
136 /// @brief Batch size (default 1)
137 DEFINE_int32(bs, 1, batch_size_message);
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);
142 /// @brief Context window size (default 0)
143 DEFINE_int32(cw, 0, context_window_message);
146 * \brief This function show a help message
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;