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