ie_plugin_cpp.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 This is a header file for the Inference Engine plugin C++ API
7  * @file ie_plugin_cpp.hpp
8  */
9 #pragma once
10 
11 #include <map>
12 #include <memory>
13 #include <string>
14 
17 #include "ie_cnn_network.h"
18 #include "ie_plugin.hpp"
19 #include "ie_plugin_ptr.hpp"
20 
21 namespace InferenceEngine {
22 
23 /**
24  * @deprecated Use InferenceEngine::Core instead.
25  * @brief This class is a C++ API wrapper for IInferencePlugin.
26  * It can throw exceptions safely for the application, where it is properly handled.
27  */
28 class INFERENCE_ENGINE_DEPRECATED("Use InferenceEngine::Core instead. Will be removed in 2020 R2") InferencePlugin {
29  IE_SUPPRESS_DEPRECATED_START
31 
32 public:
33  /** @brief A default constructor */
34  InferencePlugin() = default;
35 
36  /**
37  * @brief Constructs a plugin instance from the given pointer.
38  * @param pointer Initialized Plugin pointer
39  */
40  explicit InferencePlugin(const InferenceEnginePluginPtr& pointer): actual(pointer) {}
41 
42  IE_SUPPRESS_DEPRECATED_END
43 
44  /**
45  * @brief Wraps original method
46  * IInferencePlugin::GetVersion
47  */
48  const Version* GetVersion() {
49  const Version* versionInfo = nullptr;
50  IE_SUPPRESS_DEPRECATED_START
51  actual->GetVersion(versionInfo);
52  IE_SUPPRESS_DEPRECATED_END
53  if (versionInfo == nullptr) {
54  THROW_IE_EXCEPTION << "Unknown device is used";
55  }
56  return versionInfo;
57  }
58 
59  /**
60  * @brief Wraps original method
61  * IInferencePlugin::LoadNetwork(IExecutableNetwork::Ptr&, ICNNNetwork&, const std::map<std::string, std::string> &,
62  * ResponseDesc*).
63  * @param network A network object to load
64  * @param config A map of configuration options
65  * @return Created Executable Network object
66  */
67  ExecutableNetwork LoadNetwork(ICNNNetwork& network, const std::map<std::string, std::string>& config) {
69  IE_SUPPRESS_DEPRECATED_START
70  CALL_STATUS_FNC(LoadNetwork, ret, network, config);
71  IE_SUPPRESS_DEPRECATED_END
72  return ExecutableNetwork(ret, actual);
73  }
74 
75  /**
76  * @brief Wraps original method
77  * IInferencePlugin::LoadNetwork(IExecutableNetwork::Ptr&, ICNNNetwork&, const std::map<std::string, std::string> &,
78  * ResponseDesc*).
79  * @param network A network object to load
80  * @param config A map of configuration options
81  * @return Created Executable Network object
82  */
83  ExecutableNetwork LoadNetwork(CNNNetwork network, const std::map<std::string, std::string>& config) {
85  IE_SUPPRESS_DEPRECATED_START
86  CALL_STATUS_FNC(LoadNetwork, ret, network, config);
87  IE_SUPPRESS_DEPRECATED_END
88  if (ret.get() == nullptr) THROW_IE_EXCEPTION << "Internal error: pointer to executable network is null";
89  return ExecutableNetwork(ret, actual);
90  }
91 
92  /**
93  * @brief Wraps original method
94  * IInferencePlugin::AddExtension
95  * @param extension Pointer to loaded Extension
96  */
97  void AddExtension(InferenceEngine::IExtensionPtr extension) {
98  IE_SUPPRESS_DEPRECATED_START
99  CALL_STATUS_FNC(AddExtension, extension);
100  IE_SUPPRESS_DEPRECATED_END
101  }
102 
103  /**
104  * @brief Wraps original method
105  * IInferencePlugin::SetConfig
106  * @param config A configuration map
107  */
108  void SetConfig(const std::map<std::string, std::string>& config) {
109  IE_SUPPRESS_DEPRECATED_START
110  CALL_STATUS_FNC(SetConfig, config);
111  IE_SUPPRESS_DEPRECATED_END
112  }
113 
114  /**
115  * @brief Wraps original method
116  * IInferencePlugin::ImportNetwork
117  * @param modelFileName A path to the imported network
118  * @param config A configuration map
119  * @return Created Executable Network object
120  */
121  ExecutableNetwork ImportNetwork(const std::string& modelFileName,
122  const std::map<std::string, std::string>& config) {
124  IE_SUPPRESS_DEPRECATED_START
125  CALL_STATUS_FNC(ImportNetwork, ret, modelFileName, config);
126  IE_SUPPRESS_DEPRECATED_END
127  return ExecutableNetwork(ret, actual);
128  }
129 
130  /**
131  * @brief Wraps original method
132  * IInferencePlugin::QueryNetwork(const ICNNNetwork&, const std::map<std::string, std::string> &,
133  * QueryNetworkResult&) const
134  * @param network A network object to query
135  * @param config A configuration map
136  * @param res Query results
137  */
138  void QueryNetwork(const ICNNNetwork& network, const std::map<std::string, std::string>& config,
139  QueryNetworkResult& res) const {
140  IE_SUPPRESS_DEPRECATED_START
141  actual->QueryNetwork(network, config, res);
142  IE_SUPPRESS_DEPRECATED_END
143  if (res.rc != OK) THROW_IE_EXCEPTION << res.resp.msg;
144  }
145 
146  IE_SUPPRESS_DEPRECATED_START
147 
148  /**
149  * @brief Converts InferenceEngine to InferenceEnginePluginPtr pointer
150  * @return Wrapped object
151  */
153  return actual;
154  }
155 
156  /**
157  * @brief Shared pointer on InferencePlugin object
158  */
159  using Ptr = std::shared_ptr<InferencePlugin>;
160 
161  IE_SUPPRESS_DEPRECATED_END
162 };
163 } // namespace InferenceEngine
#define THROW_IE_EXCEPTION
A macro used to throw the exception with a notable description.
Definition: ie_exception.hpp:24
A header file that provides wrapper classes for IExecutableNetwork.
A header file that provides wrapper for ICNNNetwork object.
This class represents Inference Engine Core entity. It can throw exceptions safely for the applicatio...
Definition: ie_core.hpp:25
InferenceEngine::details::SOPointer< IInferencePlugin > InferenceEnginePluginPtr
A C++ helper to work with objects created by the plugin. Implements different interfaces.
Definition: ie_plugin_ptr.hpp:41
ExecutableNetwork ImportNetwork(const std::string &modelFileName, const std::map< std::string, std::string > &config)
Wraps original method IInferencePlugin::ImportNetwork.
Definition: ie_plugin_cpp.hpp:121
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 Main Inference Engine API.
A header file that provides macros to handle no exception methods.
ResponseDesc resp
Response mssage.
Definition: ie_plugin.hpp:68
A header file contains a wrapper class for handling plugin instantiation and releasing resources...
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
void SetConfig(const std::map< std::string, std::string > &config)
Wraps original method IInferencePlugin::SetConfig.
Definition: ie_plugin_cpp.hpp:108
ExecutableNetwork LoadNetwork(CNNNetwork network, const std::map< std::string, std::string > &config)
Wraps original method IInferencePlugin::LoadNetwork(IExecutableNetwork::Ptr&, ICNNNetwork&, const std::map<std::string, std::string> &, ResponseDesc*).
Definition: ie_plugin_cpp.hpp:83
void QueryNetwork(const ICNNNetwork &network, const std::map< std::string, std::string > &config, QueryNetworkResult &res) const
Wraps original method IInferencePlugin::QueryNetwork(const ICNNNetwork&, const std::map<std::string, std::string> &, QueryNetworkResult&) const.
Definition: ie_plugin_cpp.hpp:138
std::shared_ptr< InferencePlugin > Ptr
Shared pointer on InferencePlugin object.
Definition: ie_plugin_cpp.hpp:159
This is the main interface to describe the NN topology.
Definition: ie_icnn_network.hpp:41
wrapper over IExecutableNetwork
Definition: ie_executable_network.hpp:29
This class contains all the information about the Neural Network and the related binary information...
Definition: ie_cnn_network.h:37
StatusCode rc
A status code.
Definition: ie_plugin.hpp:63
ExecutableNetwork LoadNetwork(ICNNNetwork &network, const std::map< std::string, std::string > &config)
Wraps original method IInferencePlugin::LoadNetwork(IExecutableNetwork::Ptr&, ICNNNetwork&, const std::map<std::string, std::string> &, ResponseDesc*).
Definition: ie_plugin_cpp.hpp:67
const Version * GetVersion()
Wraps original method IInferencePlugin::GetVersion.
Definition: ie_plugin_cpp.hpp:48
char msg[256]
A character buffer that holds the detailed information for an error.
Definition: ie_common.h:239
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
InferencePlugin(const InferenceEnginePluginPtr &pointer)
Constructs a plugin instance from the given pointer.
Definition: ie_plugin_cpp.hpp:40
void AddExtension(InferenceEngine::IExtensionPtr extension)
Wraps original method IInferencePlugin::AddExtension.
Definition: ie_plugin_cpp.hpp:97