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