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