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