ie_plugin.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 file for Main Inference Engine API
7  *
8  * @file ie_plugin.hpp
9  */
10 #pragma once
11 
12 #include <ie_iextension.h>
13 
14 #include <ie_icnn_network.hpp>
15 #include <map>
16 #include <memory>
17 #include <set>
18 #include <string>
19 #include <vector>
20 
21 #include "details/ie_no_copy.hpp"
22 #include "ie_api.h"
23 #include "ie_error.hpp"
25 #include "ie_version.hpp"
26 
27 /**
28  * @def INFERENCE_PLUGIN_API(type)
29  * @brief Defines Inference Engine Plugin API method
30  * @param type A plugin type
31  */
32 
33 #if defined(_WIN32)
34 #ifdef IMPLEMENT_INFERENCE_ENGINE_PLUGIN
35 #define INFERENCE_PLUGIN_API(type) extern "C" __declspec(dllexport) type
36 #else
37 #define INFERENCE_PLUGIN_API(type) extern "C" type
38 #endif
39 #elif (__GNUC__ >= 4) // NOLINT
40 #ifdef IMPLEMENT_INFERENCE_ENGINE_PLUGIN
41 #define INFERENCE_PLUGIN_API(type) extern "C" __attribute__((visibility("default"))) type
42 #else
43 #define INFERENCE_PLUGIN_API(type) extern "C" type
44 #endif
45 #else
46 #define INFERENCE_PLUGIN_API(TYPE) extern "C" TYPE
47 #endif
48 
49 namespace InferenceEngine {
50 
51 /**
52  * @brief Responce structure encapsulating information about supported layer
53  */
55  /**
56  * @brief A map of supported layers:
57  * - key - a layer name
58  * - value - a device name on which layer is assigned
59  */
60  std::map<std::string, std::string> supportedLayersMap;
61 
62  /**
63  * @brief A status code
64  */
65  StatusCode rc = OK;
66 
67  /**
68  * @brief Response mssage
69  */
71 };
72 
73 /**
74  * @deprecated Use InferenceEngine::Core instead. Will be removed in 2020.3
75  * @brief This class is a main plugin interface
76  */
77 class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::Core instead. Will be removed in 2020.3")
78  INFERENCE_ENGINE_API_CLASS(IInferencePlugin)
79  : public details::IRelease {
80 public:
81  /**
82  * @brief Returns plugin version information
83  *
84  * @param versionInfo Pointer to version info. Is set by plugin
85  */
86  virtual void GetVersion(const Version*& versionInfo) noexcept = 0;
87 
88  /**
89  * @deprecated IErrorListener is not used anymore. StatusCode is provided in case of unexpected situations
90  * @brief Sets logging callback
91  *
92  * Logging is used to track what is going on inside
93  * @param listener Logging sink
94  */
95  IE_SUPPRESS_DEPRECATED_START
96  INFERENCE_ENGINE_DEPRECATED("IErrorListener is not used anymore. StatusCode is provided in case of unexpected situations")
97  virtual void SetLogCallback(IErrorListener& listener) noexcept = 0;
98  IE_SUPPRESS_DEPRECATED_END
99 
100  /**
101  * @brief Creates an executable network from a network object. User can create as many networks as they need and use
102  * them simultaneously (up to the limitation of the hardware resources)
103  *
104  * @param ret Reference to a shared ptr of the returned network interface
105  * @param network Network object acquired from CNNNetReader
106  * @param config Map of pairs: (config parameter name, config parameter value) relevant only for this load operation
107  * @param resp Pointer to the response message that holds a description of an error if any occurred
108  * @return Status code of the operation. InferenceEngine::OK if succeeded
109  */
110  virtual StatusCode LoadNetwork(IExecutableNetwork::Ptr& ret, const ICNNNetwork& network,
111  const std::map<std::string, std::string>& config, ResponseDesc* resp) noexcept = 0;
112 
113  /**
114  * @brief Creates an executable network from a previously exported network
115  *
116  * @param ret Reference to a shared ptr of the returned network interface
117  * @param modelFileName Path to the location of the exported file
118  * @param config Map of pairs: (config parameter name, config parameter value) relevant only for this load
119  * operation*
120  * @param resp Pointer to the response message that holds a description of an error if any occurred
121  * @return Status code of the operation. InferenceEngine::OK if succeeded
122  */
123  virtual StatusCode ImportNetwork(IExecutableNetwork::Ptr& ret, const std::string& modelFileName,
124  const std::map<std::string, std::string>& config, ResponseDesc* resp) noexcept = 0;
125 
126  /**
127  * @brief Registers extension within the plugin
128  *
129  * @param extension Pointer to already loaded extension
130  * @param resp Pointer to the response message that holds a description of an error if any occurred
131  * @return Status code of the operation. InferenceEngine::OK if succeeded
132  */
133  virtual StatusCode AddExtension(InferenceEngine::IExtensionPtr extension,
134  InferenceEngine::ResponseDesc* resp) noexcept = 0;
135 
136  /**
137  * @brief Sets configuration for plugin, acceptable keys can be found in ie_plugin_config.hpp
138  *
139  * @param config Map of pairs: (config parameter name, config parameter value)
140  * @param resp Pointer to the response message that holds a description of an error if any occurred
141  * @return Status code of the operation. InferenceEngine::OK if succeeded
142  */
143  virtual StatusCode SetConfig(const std::map<std::string, std::string>& config, ResponseDesc* resp) noexcept = 0;
144 
145  /**
146  * @brief Query plugin if it supports specified network with specified configuration
147  *
148  * @param network Network object to query
149  * @param config Map of pairs: (config parameter name, config parameter value)
150  * @param res Reference to query network result
151  */
152  virtual void QueryNetwork(const ICNNNetwork& network, const std::map<std::string, std::string>& config,
153  QueryNetworkResult& res) const noexcept {
154  (void)network;
155  (void)config;
156  res.rc = InferenceEngine::NOT_IMPLEMENTED;
157  }
158 
159  /**
160  * @brief A default virtual destructor
161  */
162  ~IInferencePlugin() override;
163 };
164 
165 /**
166  * @brief Creates the default instance of the interface (per plugin)
167  *
168  * @param plugin Pointer to the plugin
169  * @param resp Pointer to the response message that holds a description of an error if any occurred
170  * @return Status code of the operation. InferenceEngine::OK if succeeded
171  */
172 IE_SUPPRESS_DEPRECATED_START
173 INFERENCE_PLUGIN_API(StatusCode) CreatePluginEngine(IInferencePlugin*& plugin, ResponseDesc* resp) noexcept;
174 IE_SUPPRESS_DEPRECATED_END
175 
176 } // namespace InferenceEngine
std::map< std::string, std::string > supportedLayersMap
A map of supported layers:
Definition: ie_plugin.hpp:60
This class represents Inference Engine Core entity.
Definition: ie_core.hpp:29
A header file that provides versioning information for the inference engine shared library...
A header file for a plugin logging mechanism.
Inference Engine API.
Definition: ie_argmax_layer.hpp:15
Represents version information that describes plugins and the inference engine runtime library...
Definition: ie_version.hpp:21
a header file for IExecutableNetwork interface
ResponseDesc resp
Response mssage.
Definition: ie_plugin.hpp:70
This is a header file for the ICNNNetwork class.
Represents detailed information for an error.
Definition: ie_common.h:247
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:224
This class is a main plugin interface.
Definition: ie_plugin.hpp:77
This is the main interface to describe the NN topology.
Definition: ie_icnn_network.hpp:43
std::shared_ptr< IExtension > IExtensionPtr
A shared pointer to a IExtension interface.
Definition: ie_iextension.h:344
StatusCode rc
A status code.
Definition: ie_plugin.hpp:65
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
StatusCode CreatePluginEngine(IInferencePlugin *&plugin, ResponseDesc *resp) noexcept
Creates the default instance of the interface (per plugin)
This is a header file for Inference Engine Extension Interface.
This class represents a custom error listener.
Definition: ie_error.hpp:17
header file for no_copy class
virtual void QueryNetwork(const ICNNNetwork &network, const std::map< std::string, std::string > &config, QueryNetworkResult &res) const noexcept
Query plugin if it supports specified network with specified configuration.
Definition: ie_plugin.hpp:152
std::shared_ptr< IExecutableNetwork > Ptr
A smart pointer to the current IExecutableNetwork object.
Definition: ie_iexecutable_network.hpp:41
Responce structure encapsulating information about supported layer.
Definition: ie_plugin.hpp:54