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 2021.1
75  * @brief This class is a main plugin interface
76  */
77 class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::Core instead. Will be removed in 2021.1")
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  * This API will be removed in 2021.1 release.
91  * @brief Sets logging callback
92  *
93  * Logging is used to track what is going on inside
94  * @param listener Logging sink
95  */
96  IE_SUPPRESS_DEPRECATED_START
97  INFERENCE_ENGINE_DEPRECATED("IErrorListener is not used anymore. StatusCode is provided in case of unexpected situations")
98  virtual void SetLogCallback(IErrorListener& listener) noexcept = 0;
99  IE_SUPPRESS_DEPRECATED_END
100 
101  /**
102  * @brief Creates an executable network from a network object. User can create as many networks as they need and use
103  * them simultaneously (up to the limitation of the hardware resources)
104  *
105  * @param ret Reference to a shared ptr of the returned network interface
106  * @param network Network object acquired from CNNNetReader
107  * @param config Map of pairs: (config parameter name, config parameter value) relevant only for this load operation
108  * @param resp Pointer to the response message that holds a description of an error if any occurred
109  * @return Status code of the operation. InferenceEngine::OK if succeeded
110  */
111  virtual StatusCode LoadNetwork(IExecutableNetwork::Ptr& ret, const ICNNNetwork& network,
112  const std::map<std::string, std::string>& config, ResponseDesc* resp) noexcept = 0;
113 
114  /**
115  * @brief Creates an executable network from a previously exported network
116  *
117  * @param ret Reference to a shared ptr of the returned network interface
118  * @param modelFileName Path to the location of the exported file
119  * @param config Map of pairs: (config parameter name, config parameter value) relevant only for this load
120  * operation*
121  * @param resp Pointer to the response message that holds a description of an error if any occurred
122  * @return Status code of the operation. InferenceEngine::OK if succeeded
123  */
124  virtual StatusCode ImportNetwork(IExecutableNetwork::Ptr& ret, const std::string& modelFileName,
125  const std::map<std::string, std::string>& config, ResponseDesc* resp) noexcept = 0;
126 
127  /**
128  * @brief Registers extension within the plugin
129  *
130  * @param extension Pointer to already loaded extension
131  * @param resp Pointer to the response message that holds a description of an error if any occurred
132  * @return Status code of the operation. InferenceEngine::OK if succeeded
133  */
134  virtual StatusCode AddExtension(InferenceEngine::IExtensionPtr extension,
135  InferenceEngine::ResponseDesc* resp) noexcept = 0;
136 
137  /**
138  * @brief Sets configuration for plugin, acceptable keys can be found in ie_plugin_config.hpp
139  *
140  * @param config Map of pairs: (config parameter name, config parameter value)
141  * @param resp Pointer to the response message that holds a description of an error if any occurred
142  * @return Status code of the operation. InferenceEngine::OK if succeeded
143  */
144  virtual StatusCode SetConfig(const std::map<std::string, std::string>& config, ResponseDesc* resp) noexcept = 0;
145 
146  /**
147  * @brief Query plugin if it supports specified network with specified configuration
148  *
149  * @param network Network object to query
150  * @param config Map of pairs: (config parameter name, config parameter value)
151  * @param res Reference to query network result
152  */
153  virtual void QueryNetwork(const ICNNNetwork& network, const std::map<std::string, std::string>& config,
154  QueryNetworkResult& res) const noexcept {
155  (void)network;
156  (void)config;
157  res.rc = InferenceEngine::NOT_IMPLEMENTED;
158  }
159 
160  /**
161  * @brief A default virtual destructor
162  */
163  ~IInferencePlugin() override;
164 };
165 
166 /**
167  * @brief Creates the default instance of the interface (per plugin)
168  *
169  * @param plugin Pointer to the plugin
170  * @param resp Pointer to the response message that holds a description of an error if any occurred
171  * @return Status code of the operation. InferenceEngine::OK if succeeded
172  */
173 IE_SUPPRESS_DEPRECATED_START
174 INFERENCE_PLUGIN_API(StatusCode) CreatePluginEngine(IInferencePlugin*& plugin, ResponseDesc* resp) noexcept;
175 IE_SUPPRESS_DEPRECATED_END
176 
177 } // 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:359
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:18
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:153
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