ie_plugin_config.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2019 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief a header for advanced hardware related properties for IE plugins
7  * To use in SetConfig() method of plugins
8  * LoadNetwork() method overloads that accept config as parameter
9  *
10  * @file ie_plugin_config.hpp
11  */
12 #pragma once
13 
14 #include <string>
15 #include <tuple>
16 #include <vector>
17 
18 namespace InferenceEngine {
19 
20 /**
21  * @brief %Metrics
22  */
23 namespace Metrics {
24 
25 #ifndef DECLARE_METRIC_KEY_IMPL
26 # define DECLARE_METRIC_KEY_IMPL(...)
27 #endif
28 
29 /**
30  * @def METRIC_KEY(name)
31  * @brief shortcut for defining common Inference Engine metrics
32  */
33 #define METRIC_KEY(name) InferenceEngine::Metrics::METRIC_##name
34 
35 /**
36  * @def EXEC_NETWORK_METRIC_KEY(name)
37  * @brief shortcut for defining common Inference Engine ExecutableNetwork metrics
38  */
39 #define EXEC_NETWORK_METRIC_KEY(name) METRIC_KEY(name)
40 
41 #define DECLARE_METRIC_KEY(name, ...) \
42  static constexpr auto METRIC_##name = #name; \
43  DECLARE_METRIC_KEY_IMPL(name, __VA_ARGS__)
44 
45 #define DECLARE_EXEC_NETWORK_METRIC_KEY(name, ...) DECLARE_METRIC_KEY(name, __VA_ARGS__)
46 
47 /**
48  * @def METRIC_VALUE(name)
49  * @brief shortcut for defining metric values
50  */
51 #define METRIC_VALUE(name) InferenceEngine::Metrics::name
52 #define DECLARE_METRIC_VALUE(name) static constexpr auto name = #name
53 
54 /**
55 * @brief Metric to get a std::vector<std::string> of available device IDs. String value is "AVAILABLE_DEVICES"
56 */
57 DECLARE_METRIC_KEY(AVAILABLE_DEVICES, std::vector<std::string>);
58 
59 /**
60 * @brief Metric to get a std::vector<std::string> of supported metrics. String value is "SUPPORTED_METRICS"
61 * This can be used as an executable network metric as well.
62 *
63 * Each of the returned device metrics can be passed to Core::GetMetric, executable network metrics
64 * can be passed to ExecutableNetwork::GetMetric.
65 *
66 */
67 DECLARE_METRIC_KEY(SUPPORTED_METRICS, std::vector<std::string>);
68 
69 /**
70 * @brief Metric to get a std::vector<std::string> of supported config keys. String value is "SUPPORTED_CONFIG_KEYS"
71 * This can be used as an executable network metric as well.
72 *
73 * Each of the returned device configuration keys can be passed to Core::SetConfig, Core::GetConfig, and Core::LoadNetwork,
74 * configuration keys for executable networks can be passed to ExecutableNetwork::SetConfig and ExecutableNetwork::GetConfig.
75 *
76 */
77 DECLARE_METRIC_KEY(SUPPORTED_CONFIG_KEYS, std::vector<std::string>);
78 
79 /**
80 * @brief Metric to get a std::string value representing a full device name. String value is "FULL_DEVICE_NAME"
81 */
82 DECLARE_METRIC_KEY(FULL_DEVICE_NAME, std::string);
83 
84 /**
85 * @brief Metric to get a std::vector<std::string> of optimization options per device. String value is "OPTIMIZATION_CAPABILITIES"
86 * The possible values:
87 * - "FP32" - device can support FP32 models
88 * - "FP16" - device can support FP16 models
89 * - "INT8" - device can support models with INT8 layers
90 * - "BIN" - device can support models with BIN layers
91 * - "WINOGRAD" - device can support models where convolution implemented via Winograd transformations
92 */
93 DECLARE_METRIC_KEY(OPTIMIZATION_CAPABILITIES, std::vector<std::string>);
94 
95 DECLARE_METRIC_VALUE(FP32);
96 DECLARE_METRIC_VALUE(FP16);
97 DECLARE_METRIC_VALUE(INT8);
98 DECLARE_METRIC_VALUE(BIN);
99 DECLARE_METRIC_VALUE(WINOGRAD);
100 
101 /**
102 * @brief Metric to provide information about a range for streams on platforms where streams are supported.
103 * Metric returns a value of std::tuple<unsigned int, unsigned int> type, where:
104 * - First value is bottom bound.
105 * - Second value is upper bound.
106 * String value for metric name is "RANGE_FOR_STREAMS".
107 */
108 DECLARE_METRIC_KEY(RANGE_FOR_STREAMS, std::tuple<unsigned int, unsigned int>);
109 
110 /**
111 * @brief Metric to provide a hint for a range for number of async infer requests. If device supports streams,
112 * the metric provides range for number of IRs per stream.
113 * Metric returns a value of std::tuple<unsigned int, unsigned int, unsigned int> type, where:
114 * - First value is bottom bound.
115 * - Second value is upper bound.
116 * - Third value is step inside this range.
117 * String value for metric name is "RANGE_FOR_ASYNC_INFER_REQUESTS".
118 */
119 DECLARE_METRIC_KEY(RANGE_FOR_ASYNC_INFER_REQUESTS, std::tuple<unsigned int, unsigned int, unsigned int>);
120 
121 /**
122 * @brief Metric to get an unsigned int value of number of waiting infer request.
123 * String value is "NUMBER_OF_WAITNING_INFER_REQUESTS". This can be used as an executable network metric as well
124 */
125 DECLARE_METRIC_KEY(NUMBER_OF_WAITING_INFER_REQUESTS, unsigned int);
126 
127 /**
128 * @brief Metric to get an unsigned int value of number of infer request in execution stage.
129 * String value is "NUMBER_OF_EXEC_INFER_REQUESTS". This can be used as an executable network metric as well
130 */
131 DECLARE_METRIC_KEY(NUMBER_OF_EXEC_INFER_REQUESTS, unsigned int);
132 
133 /**
134 * @brief Metric to get a name of network. String value is "NETWORK_NAME".
135 */
136 DECLARE_EXEC_NETWORK_METRIC_KEY(NETWORK_NAME, std::string);
137 
138 /**
139  * @brief Metric to get a float of device thermal. String value is "DEVICE_THERMAL"
140  */
141 DECLARE_METRIC_KEY(DEVICE_THERMAL, float);
142 
143 /**
144 * @brief Metric to get an unsigned integer value of optimal number of executable network infer requests.
145 */
146 DECLARE_EXEC_NETWORK_METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS, unsigned int);
147 
148 } // namespace Metrics
149 
150 /**
151  * @brief Generic plugin configuration
152  */
153 namespace PluginConfigParams {
154 
155 /**
156  * @def CONFIG_KEY(name)
157  * @brief shortcut for defining configuration keys
158  */
159 #define CONFIG_KEY(name) InferenceEngine::PluginConfigParams::_CONFIG_KEY(name)
160 #define _CONFIG_KEY(name) KEY_##name
161 #define DECLARE_CONFIG_KEY(name) static constexpr auto _CONFIG_KEY(name) = #name
162 
163 /**
164  * @def CONFIG_VALUE(name)
165  * @brief shortcut for defining configuration values
166  */
167 #define CONFIG_VALUE(name) InferenceEngine::PluginConfigParams::name
168 #define DECLARE_CONFIG_VALUE(name) static constexpr auto name = #name
169 
170 /**
171 * @brief generic boolean values
172 */
173 DECLARE_CONFIG_VALUE(YES);
174 DECLARE_CONFIG_VALUE(NO);
175 
176 /**
177 * @brief Limit #threads that are used by Inference Engine for inference on the CPU.
178 */
179 DECLARE_CONFIG_KEY(CPU_THREADS_NUM);
180 
181 /**
182 * @brief The name for setting CPU affinity per thread option.
183 * It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
184 * PluginConfigParams::YES or PluginConfigParams::NO
185 * Ignored, if the OpenVINO compiled with OpenMP threading and any affinity-related OpenMP's
186 * environment variable is set
187 */
188 DECLARE_CONFIG_KEY(CPU_BIND_THREAD);
189 
190 /**
191 * @brief Optimize CPU execution to maximize throughput.
192 * It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
193 * - KEY_CPU_THROUGHPUT_NUMA creates as many streams as needed to accomodate NUMA and avoid associated penalties
194 * - KEY_CPU_THROUGHPUT_AUTO creates bare minimum of streams to improve the performance,
195 * this is the most portable option if you have no insights into how many cores you target machine will have
196 * (and what is the optimal number of streams)
197 * - finally, specifying the positive integer value creates the requested number of streams
198 */
199 DECLARE_CONFIG_VALUE(CPU_THROUGHPUT_NUMA);
200 DECLARE_CONFIG_VALUE(CPU_THROUGHPUT_AUTO);
201 DECLARE_CONFIG_KEY(CPU_THROUGHPUT_STREAMS);
202 
203 /**
204 * @brief Optimize GPU plugin execution to maximize throughput.
205 * It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
206 * - KEY_GPU_THROUGHPUT_AUTO creates bare minimum of streams that might improve performance in some cases,
207 * this option allows to enable throttle hint for opencl queue thus reduce CPU load without significant performance drop
208 * - a positive integer value creates the requested number of streams
209 */
210 DECLARE_CONFIG_VALUE(GPU_THROUGHPUT_AUTO);
211 DECLARE_CONFIG_KEY(GPU_THROUGHPUT_STREAMS);
212 
213 
214 /**
215 * @brief The name for setting performance counters option.
216 * It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
217 * PluginConfigParams::YES or PluginConfigParams::NO
218 */
219 DECLARE_CONFIG_KEY(PERF_COUNT);
220 
221 /**
222 * @brief The key defines dynamic limit of batch processing.
223 * Specified value is applied to all following Infer() calls. Inference Engine processes
224 * min(batch_limit, original_batch_size) first pictures from input blob. For example, if input
225 * blob has sizes 32x3x224x224 after applying plugin.SetConfig({KEY_DYN_BATCH_LIMIT, 10})
226 * Inference Engine primitives processes only beginner subblobs with size 10x3x224x224.
227 * This value can be changed before any Infer() call to specify a new batch limit.
228 *
229 * The paired parameter value should be convertible to integer number. Acceptable values:
230 * -1 - Do not limit batch processing
231 * >0 - Direct value of limit. Batch size to process is min(new batch_limit, original_batch)
232 */
233 DECLARE_CONFIG_KEY(DYN_BATCH_LIMIT);
234 
235 DECLARE_CONFIG_KEY(DYN_BATCH_ENABLED);
236 
237 /**
238 * @brief The key controls threading inside Inference Engine.
239 * It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
240 * PluginConfigParams::YES or PluginConfigParams::NO
241 */
242 DECLARE_CONFIG_KEY(SINGLE_THREAD);
243 
244 /**
245 * @brief This key directs the plugin to load a configuration file.
246 * The value should be a file name with the plugin specific configuration
247 */
248 DECLARE_CONFIG_KEY(CONFIG_FILE);
249 
250 /**
251 * @brief This key enables dumping of the kernels used by the plugin for custom layers.
252 * This option should be used with values: PluginConfigParams::YES or PluginConfigParams::NO (default)
253 */
254 DECLARE_CONFIG_KEY(DUMP_KERNELS);
255 
256 /**
257 * @brief This key controls performance tuning done or used by the plugin.
258 * This option should be used with values: PluginConfigParams::TUNING_CREATE,
259 * PluginConfigParams::TUNING_USE_EXISTING or PluginConfigParams::TUNING_DISABLED (default)
260 */
261 DECLARE_CONFIG_KEY(TUNING_MODE);
262 
263 
264 DECLARE_CONFIG_VALUE(TUNING_CREATE);
265 DECLARE_CONFIG_VALUE(TUNING_USE_EXISTING);
266 DECLARE_CONFIG_VALUE(TUNING_DISABLED);
267 
268 /**
269 * @brief This key defines the tuning data filename to be created/used
270 */
271 DECLARE_CONFIG_KEY(TUNING_FILE);
272 
273 /**
274 * @brief the key for setting desirable log level.
275 * This option should be used with values: PluginConfigParams::LOG_NONE (default),
276 * PluginConfigParams::LOG_WARNING, PluginConfigParams::LOG_INFO, PluginConfigParams::LOG_DEBUG
277 */
278 DECLARE_CONFIG_KEY(LOG_LEVEL);
279 
280 DECLARE_CONFIG_VALUE(LOG_NONE);
281 DECLARE_CONFIG_VALUE(LOG_WARNING);
282 DECLARE_CONFIG_VALUE(LOG_INFO);
283 DECLARE_CONFIG_VALUE(LOG_DEBUG);
284 
285 /**
286 * @brief the key for setting of required device to execute on
287 * values: device id starts from "0" - first device, "1" - second device, etc
288 */
289 DECLARE_CONFIG_KEY(DEVICE_ID);
290 
291 /**
292 * @brief the key for enabling exclusive mode for async requests of different executable networks and the same plugin.
293 * Sometimes it's necessary to avoid oversubscription requests that are sharing the same device in parallel.
294 * E.g. There 2 task executors for CPU device: one - in the Hetero plugin, another - in pure CPU plugin.
295 * Parallel execution both of them might lead to oversubscription and not optimal CPU usage. More efficient
296 * to run the corresponding tasks one by one via single executor.
297 * By default, the option is set to YES for hetero cases, and to NO for conventional (single-plugin) cases
298 * Notice that setting YES disables the CPU streams feature (see another config key in this file)
299 */
300 DECLARE_CONFIG_KEY(EXCLUSIVE_ASYNC_REQUESTS);
301 
302 /**
303  * @brief This key enables dumping of the internal primitive graph.
304  * Should be passed into LoadNetwork method to enable dumping of internal graph of primitives and
305  * corresponding configuration information. Value is a name of output dot file without extension.
306  * Files <dot_file_name>_init.dot and <dot_file_name>_perf.dot will be produced.
307  */
308 DECLARE_CONFIG_KEY(DUMP_EXEC_GRAPH_AS_DOT);
309 
310 } // namespace PluginConfigParams
311 } // namespace InferenceEngine
static constexpr auto YES
generic boolean values
Definition: ie_plugin_config.hpp:173
static constexpr auto CPU_THROUGHPUT_NUMA
Optimize CPU execution to maximize throughput. It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
Definition: ie_plugin_config.hpp:199
Inference Engine API.
Definition: ie_argmax_layer.hpp:11
static constexpr auto GPU_THROUGHPUT_AUTO
Optimize GPU plugin execution to maximize throughput. It is passed to IInferencePlugin::SetConfig(), this option should be used with values:
Definition: ie_plugin_config.hpp:210