ie_iexecutable_network.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 IExecutableNetwork interface
7  * @file ie_iexecutable_network.hpp
8  */
9 #pragma once
10 
11 #include "ie_common.h"
12 #include "ie_primitive_info.hpp"
13 #include "ie_iinfer_request.hpp"
14 #include "ie_icnn_network.hpp"
15 #include "ie_imemory_state.hpp"
16 #include "ie_input_info.hpp"
17 #include "ie_parameter.hpp"
18 #include <string>
19 #include <vector>
20 #include <memory>
21 #include <map>
22 
23 namespace InferenceEngine {
24 
25 /**
26  * @brief A collection that contains string as key, and const Data smart pointer as value
27  */
28 using ConstOutputsDataMap = std::map<std::string, CDataPtr>;
29 
30 /**
31  * @brief This is an interface of an executable network
32  */
33 class IExecutableNetwork : public details::IRelease {
34 public:
35  /**
36  * @brief A smart pointer to the current IExecutableNetwork object
37  */
38  using Ptr = std::shared_ptr<IExecutableNetwork>;
39 
40  /**
41  * @brief Gets the Executable network output Data node information.
42  *
43  * The received info is stored in the given ::ConstOutputsDataMap node.
44  * This method need to be called to find output names for using them later during filling of a map
45  * of blobs passed to InferenceEngine::IInferencePlugin::Infer()
46  *
47  * @param out Reference to the ::ConstOutputsDataMap object
48  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
49  * @return Status code of the operation: InferenceEngine::OK (0) for success
50  */
51  virtual StatusCode GetOutputsInfo(ConstOutputsDataMap &out, ResponseDesc *resp) const noexcept = 0;
52 
53  /**
54  * @brief Gets the executable network input Data node information.
55  *
56  * The received info is stored in the given ::ConstInputsDataMap object.
57  * This method need to be called to find out input names for using them later during filling of a map
58  * of blobs passed to InferenceEngine::IInferencePlugin::Infer()
59  *
60  * @param inputs Reference to ::ConstInputsDataMap object.
61  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
62  * @return Status code of the operation: InferenceEngine::OK (0) for success
63  */
64  virtual StatusCode GetInputsInfo(ConstInputsDataMap &inputs, ResponseDesc *resp) const noexcept = 0;
65 
66  /**
67  * @brief Creates an inference request object used to infer the network.
68  *
69  * The created request has allocated input and output blobs (that can be changed later).
70  *
71  * @param req Shared pointer to the created request object
72  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
73  * @return Status code of the operation: InferenceEngine::OK (0) for success
74  */
75  virtual StatusCode CreateInferRequest(IInferRequest::Ptr& req, ResponseDesc *resp) noexcept = 0;
76 
77  /**
78  * @brief Exports the current executable network.
79  *
80  * @see Core::ImportNetwork
81  * @see IInferencePlugin::ImportNetwork
82  *
83  * @param modelFileName Full path to the location of the exported file
84  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
85  * @return Status code of the operation: InferenceEngine::OK (0) for success
86  */
87  virtual StatusCode Export(const std::string& modelFileName, ResponseDesc *resp) noexcept = 0;
88 
89  /**
90  * @brief Get the mapping of IR layer names to implemented kernels
91  * @param deployedTopology Map of PrimitiveInfo objects that represent the deployed topology
92  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
93  * @return Status code of the operation: InferenceEngine::OK (0) for success
94  */
95  virtual StatusCode GetMappedTopology(std::map<std::string, std::vector<PrimitiveInfo::Ptr>> &deployedTopology, ResponseDesc *resp) noexcept = 0;
96 
97  /**
98  * @brief Get executable graph information from a device
99  *
100  * @param graphPtr network ptr to store executable graph information
101  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
102  * @return Status code of the operation: InferenceEngine::OK (0) for success
103  */
104  virtual StatusCode GetExecGraphInfo(ICNNNetwork::Ptr &graphPtr, ResponseDesc *resp) noexcept = 0;
105 
106  /**
107  * @brief Gets state control interface for given executable network.
108  *
109  * State control essential for recurrent networks
110  *
111  * @param pState reference to a pointer that receives internal states
112  * @param idx requested index for receiving memory state
113  * @param resp Optional: pointer to an already allocated object to contain information in case of failure
114  * @return Status code of the operation: InferenceEngine::OK (0) for success, OUT_OF_BOUNDS (-6) no memory state for given index
115  */
116  virtual StatusCode QueryState(IMemoryState::Ptr & pState, size_t idx, ResponseDesc *resp) noexcept = 0;
117 
118  /**
119  * @brief Sets configuration for current executable network
120  *
121  * @param config Map of pairs: (config parameter name, config parameter value)
122  * @param resp Pointer to the response message that holds a description of an error if any occurred
123  * @return code of the operation. InferenceEngine::OK if succeeded
124  */
125  virtual StatusCode SetConfig(const std::map<std::string, Parameter> &config, ResponseDesc *resp) noexcept = 0;
126 
127  /** @brief Gets configuration for current executable network.
128  *
129  * The method is responsible to extract information
130  * which affects executable network execution. The list of supported configuration values can be extracted via
131  * ExecutableNetwork::GetMetric with the SUPPORTED_CONFIG_KEYS key, but some of these keys cannot be changed dymanically,
132  * e.g. DEVICE_ID cannot changed if an executable network has already been compiled for particular device.
133  *
134  * @param name config key, can be found in ie_plugin_config.hpp
135  * @param result value of config corresponding to config key
136  * @param resp Pointer to the response message that holds a description of an error if any occurred
137  * @return code of the operation. InferenceEngine::OK if succeeded
138  */
139  virtual StatusCode GetConfig(const std::string &name, Parameter &result, ResponseDesc *resp) const noexcept = 0;
140 
141  /**
142  * @brief Gets general runtime metric for an executable network.
143  *
144  * It can be network name, actual device ID on
145  * which executable network is running or all other properties which cannot be changed dynamically.
146  *
147  * @param name metric name to request
148  * @param result metric value corresponding to metric key
149  * @param resp Pointer to the response message that holds a description of an error if any occurred
150  * @return code of the operation. InferenceEngine::OK if succeeded
151  */
152  virtual StatusCode GetMetric(const std::string &name, Parameter &result, ResponseDesc *resp) const noexcept = 0;
153 };
154 
155 } // namespace InferenceEngine
Inference Engine API.
Definition: ie_argmax_layer.hpp:11
This is a header file for the ICNNNetwork class.
a header file for IInferRequest interface
a header file for IMemoryState interface
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:230
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:28
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:207
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.
virtual StatusCode GetOutputsInfo(ConstOutputsDataMap &out, ResponseDesc *resp) const noexcept=0
Gets the Executable network output Data node information.
virtual StatusCode QueryState(IMemoryState::Ptr &pState, size_t idx, ResponseDesc *resp) noexcept=0
Gets state control interface for given executable network.
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:27
This is an interface of an executable network.
Definition: ie_iexecutable_network.hpp:33
A header file for the PrimitiveInfo struct.
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:203
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:38
virtual StatusCode GetMetric(const std::string &name, Parameter &result, ResponseDesc *resp) const noexcept=0
Gets general runtime metric for an executable network.
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:39