ie_iexecutable_network.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 IExecutableNetwork interface
7  *
8  * @file ie_iexecutable_network.hpp
9  */
10 #pragma once
11 
12 #include <map>
13 #include <memory>
14 #include <string>
15 #include <vector>
16 
17 #include "ie_common.h"
18 #include "ie_icnn_network.hpp"
19 #include "ie_iinfer_request.hpp"
20 #include "ie_imemory_state.hpp"
21 #include "ie_input_info.hpp"
22 #include "ie_parameter.hpp"
23 #include "ie_primitive_info.hpp"
24 #include "ie_remote_context.hpp"
25 
26 namespace InferenceEngine {
27 
28 /**
29  * @brief A collection that contains string as key, and const Data smart pointer as value
30  */
31 using ConstOutputsDataMap = std::map<std::string, CDataPtr>;
32 
33 /**
34  * @brief This is an interface of an executable network
35  */
36 class IExecutableNetwork : public details::IRelease {
37 public:
38  /**
39  * @brief A smart pointer to the current IExecutableNetwork object
40  */
41  using Ptr = std::shared_ptr<IExecutableNetwork>;
42 
43  /**
44  * @brief Gets the Executable network output Data node information.
45  *
46  * The received info is stored in the given InferenceEngine::ConstOutputsDataMap node.
47  * This method need to be called to find output names for using them later
48  * when calling InferenceEngine::InferRequest::GetBlob or InferenceEngine::InferRequest::SetBlob
49  *
50  * @param out Reference to the ::ConstOutputsDataMap object
51  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
52  * @return Status code of the operation: InferenceEngine::OK (0) for success
53  */
54  virtual StatusCode GetOutputsInfo(ConstOutputsDataMap& out, ResponseDesc* resp) const noexcept = 0;
55 
56  /**
57  * @brief Gets the executable network input Data node information.
58  *
59  * The received info is stored in the given ::ConstInputsDataMap object.
60  * This method need to be called to find out input names for using them later
61  * when calling InferenceEngine::InferRequest::SetBlob
62  *
63  * @param inputs Reference to ::ConstInputsDataMap object.
64  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
65  * @return Status code of the operation: InferenceEngine::OK (0) for success
66  */
67  virtual StatusCode GetInputsInfo(ConstInputsDataMap& inputs, ResponseDesc* resp) const noexcept = 0;
68 
69  /**
70  * @brief Creates an inference request object used to infer the network.
71  *
72  * The created request has allocated input and output blobs (that can be changed later).
73  *
74  * @param req Shared pointer to the created request object
75  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
76  * @return Status code of the operation: InferenceEngine::OK (0) for success
77  */
78  virtual StatusCode CreateInferRequest(IInferRequest::Ptr& req, ResponseDesc* resp) noexcept = 0;
79 
80  /**
81  * @brief Exports the current executable network.
82  *
83  * @see Core::ImportNetwork
84  *
85  * @param modelFileName Full path to the location of the exported file
86  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
87  * @return Status code of the operation: InferenceEngine::OK (0) for success
88  */
89  virtual StatusCode Export(const std::string& modelFileName, ResponseDesc* resp) noexcept = 0;
90 
91  /**
92  * @brief Exports the current executable network.
93  *
94  * @see Core::ImportNetwork
95  *
96  * @param networkModel Network model output stream
97  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
98  * @return Status code of the operation: InferenceEngine::OK (0) for success
99  */
100  virtual StatusCode Export(std::ostream& networkModel, ResponseDesc* resp) noexcept = 0;
101 
102  /**
103  * @deprecated Use ExecutableNetwork::GetExecGraphInfo to get information about an internal graph.
104  * The method will be removed in 2021.1 release.
105  * @brief Get the mapping of IR layer names to implemented kernels
106  *
107  * @param deployedTopology Map of PrimitiveInfo objects that represent the deployed topology
108  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
109  * @return Status code of the operation: InferenceEngine::OK (0) for success
110  */
111  IE_SUPPRESS_DEPRECATED_START_WIN
112  INFERENCE_ENGINE_DEPRECATED("Use ExecutableNetwork::GetExecGraphInfo to get information about an internal graph")
113  virtual StatusCode GetMappedTopology(std::map<std::string, std::vector<PrimitiveInfo::Ptr>>& deployedTopology,
114  ResponseDesc* resp) noexcept = 0;
115  IE_SUPPRESS_DEPRECATED_END_WIN
116 
117  /**
118  * @brief Get executable graph information from a device
119  *
120  * @param graphPtr network ptr to store executable graph information
121  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
122  * @return Status code of the operation: InferenceEngine::OK (0) for success
123  */
124  virtual StatusCode GetExecGraphInfo(ICNNNetwork::Ptr& graphPtr, ResponseDesc* resp) noexcept = 0;
125 
126  /**
127  * @brief Gets state control interface for given executable network.
128  *
129  * State control essential for recurrent networks
130  *
131  * @param pState reference to a pointer that receives internal states
132  * @param idx requested index for receiving memory state
133  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
134  * @return Status code of the operation: InferenceEngine::OK (0) for success, OUT_OF_BOUNDS (-6) no memory state for
135  * given index
136  */
137  virtual StatusCode QueryState(IMemoryState::Ptr& pState, size_t idx, ResponseDesc* resp) noexcept = 0;
138 
139  /**
140  * @brief Sets configuration for current executable network
141  *
142  * @param config Map of pairs: (config parameter name, config parameter value)
143  * @param resp Pointer to the response message that holds a description of an error if any occurred
144  * @return code of the operation. InferenceEngine::OK if succeeded
145  */
146  virtual StatusCode SetConfig(const std::map<std::string, Parameter>& config, ResponseDesc* resp) noexcept = 0;
147 
148  /** @brief Gets configuration for current executable network.
149  *
150  * The method is responsible to extract information
151  * which affects executable network execution. The list of supported configuration values can be extracted via
152  * ExecutableNetwork::GetMetric with the SUPPORTED_CONFIG_KEYS key, but some of these keys cannot be changed
153  * dymanically, e.g. DEVICE_ID cannot changed if an executable network has already been compiled for particular
154  * device.
155  *
156  * @param name config key, can be found in ie_plugin_config.hpp
157  * @param result value of config corresponding to config key
158  * @param resp Pointer to the response message that holds a description of an error if any occurred
159  * @return code of the operation. InferenceEngine::OK if succeeded
160  */
161  virtual StatusCode GetConfig(const std::string& name, Parameter& result, ResponseDesc* resp) const noexcept = 0;
162 
163  /**
164  * @brief Gets general runtime metric for an executable network.
165  *
166  * It can be network name, actual device ID on
167  * which executable network is running or all other properties which cannot be changed dynamically.
168  *
169  * @param name metric name to request
170  * @param result metric value corresponding to metric key
171  * @param resp Pointer to the response message that holds a description of an error if any occurred
172  * @return code of the operation. InferenceEngine::OK if succeeded
173  */
174  virtual StatusCode GetMetric(const std::string& name, Parameter& result, ResponseDesc* resp) const noexcept = 0;
175 
176  /**
177  * @brief Gets shared context used to create an executable network.
178  *
179  * @param pContext Refernce to a pointer that will receive resulting shared context object ptr
180  * @param resp Pointer to the response message that holds a description of an error if any occurred
181  * @return code of the operation. InferenceEngine::OK if succeeded
182  */
183  virtual StatusCode GetContext(RemoteContext::Ptr& pContext, ResponseDesc* resp) const noexcept = 0;
184 };
185 
186 } // namespace InferenceEngine
Definition: cldnn_config.hpp:16
manages data for reset operations
Definition: ie_imemory_state.hpp:24
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:224
This is a header file for the ICNNNetwork class.
a header file for IInferRequest interface
This is a header file for the IE RemoteContext and RemoteBlob classes.
a header file for IMemoryState interface
std::map< std::string, CDataPtr > ConstOutputsDataMap
A collection that contains string as key, and const Data smart pointer as value.
Definition: ie_iexecutable_network.hpp:31
virtual StatusCode Export(const std::string &modelFileName, ResponseDesc *resp) noexcept=0
Exports the current executable network.
virtual StatusCode GetExecGraphInfo(ICNNNetwork::Ptr &graphPtr, ResponseDesc *resp) noexcept=0
Get executable graph information from a device.
Represents detailed information for an error.
Definition: ie_common.h:247
virtual StatusCode SetConfig(const std::map< std::string, Parameter > &config, ResponseDesc *resp) noexcept=0
Sets configuration for current executable network.
virtual StatusCode GetMappedTopology(std::map< std::string, std::vector< PrimitiveInfo::Ptr >> &deployedTopology, ResponseDesc *resp) noexcept=0
Get the mapping of IR layer names to implemented kernels.
std::map< std::string, InputInfo::CPtr > ConstInputsDataMap
A collection that contains string as key, and const InputInfo smart pointer as value.
Definition: ie_input_info.hpp:165
This is the main interface to describe the NN topology.
Definition: ie_icnn_network.hpp:43
virtual StatusCode GetOutputsInfo(ConstOutputsDataMap &out, ResponseDesc *resp) const noexcept=0
Gets the Executable network output Data node information.
A header file for the Parameter class.
virtual StatusCode QueryState(IMemoryState::Ptr &pState, size_t idx, ResponseDesc *resp) noexcept=0
Gets state control interface for given executable network.
This class represents an Inference Engine abstraction for remote (non-CPU) accelerator device-specifi...
Definition: ie_remote_context.hpp:94
virtual StatusCode GetInputsInfo(ConstInputsDataMap &inputs, ResponseDesc *resp) const noexcept=0
Gets the executable network input Data node information.
virtual StatusCode CreateInferRequest(IInferRequest::Ptr &req, ResponseDesc *resp) noexcept=0
Creates an inference request object used to infer the network.
This class represents an object to work with different parameters.
Definition: ie_parameter.hpp:38
This is an interface of an executable network.
Definition: ie_iexecutable_network.hpp:36
virtual StatusCode GetContext(RemoteContext::Ptr &pContext, ResponseDesc *resp) const noexcept=0
Gets shared context used to create an executable network.
A header file for the PrimitiveInfo struct.
virtual StatusCode GetConfig(const std::string &name, Parameter &result, ResponseDesc *resp) const noexcept=0
Gets configuration for current executable network.
a header file for InputInfo class
std::shared_ptr< IExecutableNetwork > Ptr
A smart pointer to the current IExecutableNetwork object.
Definition: ie_iexecutable_network.hpp:41
virtual StatusCode GetMetric(const std::string &name, Parameter &result, ResponseDesc *resp) const noexcept=0
Gets general runtime metric for an executable network.
Structure with information about Primitive.
Definition: ie_primitive_info.hpp:27
This is a header file with common inference engine definitions.
std::shared_ptr< IInferRequest > Ptr
A shared pointer to the IInferRequest object.
Definition: ie_iinfer_request.hpp:44