ie_iexecutable_network_internal.hpp
1 // Copyright (C) 2018-2021 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #pragma once
6 
7 #include <map>
8 #include <memory>
9 #include <string>
10 #include <vector>
11 
12 #include <ie_parameter.hpp>
13 #include <ie_remote_context.hpp>
14 #include <cpp/ie_cnn_network.h>
15 #include <cpp_interfaces/interface/ie_ivariable_state_internal.hpp>
17 
18 namespace InferenceEngine {
19 
20 class IInferencePlugin;
21 class IInferRequestInternal;
22 class RemoteContext;
23 class IVariableStateInternal;
24 
25 /**
26  * @interface IExecutableNetworkInternal
27  * @brief An internal API of executable network to be implemented by plugin,
28  * @ingroup ie_dev_api_exec_network_api
29  */
30 class INFERENCE_ENGINE_API_CLASS(IExecutableNetworkInternal) : public std::enable_shared_from_this<IExecutableNetworkInternal> {
31 public:
32  /**
33  * @brief A shared pointer to IExecutableNetworkInternal interface
34  */
35  using Ptr = std::shared_ptr<IExecutableNetworkInternal>;
36 
37  /**
38  * @brief Sets the network inputs info.
39  * @param[in] networkInputs The network inputs info
40  */
41  virtual void setNetworkInputs(const InputsDataMap& networkInputs);
42 
43  /**
44  * @brief Sets the network outputs data.
45  * @param[in] networkOutputs The network outputs
46  */
47  virtual void setNetworkOutputs(const OutputsDataMap& networkOutputs);
48 
49  /**
50  * @brief Gets the Executable network output Data node information. The received info is stored in the given Data
51  * node.
52  * @return out Reference to the ConstOutputsDataMap object
53  */
55 
56  /**
57  * @brief Gets the Executable network input Data node information. The received info is stored in the given
58  * InputsDataMap object.
59  * @return inputs Reference to ConstInputsDataMap object.
60  */
62 
63  /**
64  * @brief Create an inference request object used to infer the network
65  * Note: the returned request will have allocated input and output blobs (that can be changed later)
66  * @return shared_ptr for the created request
67  */
68  virtual std::shared_ptr<IInferRequestInternal> CreateInferRequest();
69 
70  /**
71  * @deprecated Use IExecutableNetworkInternal::Export(std::ostream& networkModel)
72  * @brief Export the current created executable network so it can be used later in the Import() main API
73  * @param modelFileName - path to the location of the exported file
74  */
75  virtual void Export(const std::string& modelFileName);
76 
77  /**
78  * @brief Export the current created executable network so it can be used later in the Import() main API
79  * @param networkModel - Reference to network model output stream
80  */
81  virtual void Export(std::ostream& networkModel);
82 
83  /**
84  * @brief Get executable graph information from a device
85  * @return A network object to store executable graph information
86  */
88 
89  /**
90  * @deprecated Need to implement GetVariablesInfo for ExecutableNetwork
91  * @brief Queries memory states.
92  * @return Returns memory states
93  */
94  virtual std::vector<std::shared_ptr<IVariableStateInternal>> QueryState();
95 
96  /**
97  * @brief Sets the pointer to plugin internal.
98  * @param[in] plugin The plugin
99  * @note Needed to correctly handle ownership between objects.
100  */
101  virtual void SetPointerToPlugin(const std::shared_ptr<IInferencePlugin>& plugin);
102 
103  /**
104  * @brief Sets configuration for current executable network
105  * @param config Map of pairs: (config parameter name, config parameter value)
106  */
107  virtual void SetConfig(const std::map<std::string, Parameter>& config);
108 
109  /**
110  * @brief Gets configuration dedicated to plugin behaviour
111  * @param name A config key, can be found in ie_plugin_config.hpp
112  * @return A value of config corresponding to config key
113  */
114  virtual Parameter GetConfig(const std::string& name) const;
115 
116  /**
117  * @brief Gets general runtime metric for dedicated hardware
118  * @param name A metric name to request
119  * @return A metric value corresponding to metric key
120  */
121  virtual Parameter GetMetric(const std::string& name) const;
122 
123  /**
124  * @brief Gets the remote context.
125  * @return A reference to a context
126  */
127  virtual std::shared_ptr<RemoteContext> GetContext() const;
128 
129 protected:
130  ~IExecutableNetworkInternal() = default;
131 
132  /**
133  * @brief Creates an inference request internal implementation.
134  * @note The method is called by IExecutableNetworkInternal::CreateInferRequest as
135  * plugin-specific implementation.
136  * @param[in] networkInputs The network inputs
137  * @param[in] networkOutputs The network outputs
138  * @return A shared pointer to inference request object.
139  */
140  virtual std::shared_ptr<IInferRequestInternal> CreateInferRequestImpl(InputsDataMap networkInputs,
141  OutputsDataMap networkOutputs);
142 
143  InferenceEngine::InputsDataMap _networkInputs; //!< Holds information about network inputs info
144  InferenceEngine::OutputsDataMap _networkOutputs; //!< Holds information about network outputs data
145 
146  /**
147  * @brief A pointer to a IInferencePlugin interface.
148  * @note Needed to correctly handle ownership between objects.
149  */
150  std::shared_ptr<IInferencePlugin> _plugin;
151 };
152 
153 /**
154  * @brief SOPointer to IExecutableNetworkInternal.
155  */
156 using SoExecutableNetworkInternal = details::SOPointer<IExecutableNetworkInternal>;
157 
158 } // namespace InferenceEngine
An internal API of executable network to be implemented by plugin,.
Definition: ie_iexecutable_network_internal.hpp:30
virtual CNNNetwork GetExecGraphInfo()
Get executable graph information from a device.
virtual void Export(const std::string &modelFileName)
Export the current created executable network so it can be used later in the Import() main API.
virtual void SetPointerToPlugin(const std::shared_ptr< IInferencePlugin > &plugin)
Sets the pointer to plugin internal.
virtual ConstInputsDataMap GetInputsInfo() const
Gets the Executable network input Data node information. The received info is stored in the given Inp...
std::shared_ptr< IExecutableNetworkInternal > Ptr
A shared pointer to IExecutableNetworkInternal interface.
Definition: ie_iexecutable_network_internal.hpp:35
virtual void Export(std::ostream &networkModel)
Export the current created executable network so it can be used later in the Import() main API.
virtual std::shared_ptr< RemoteContext > GetContext() const
Gets the remote context.
virtual void setNetworkInputs(const InputsDataMap &networkInputs)
Sets the network inputs info.
virtual void SetConfig(const std::map< std::string, Parameter > &config)
Sets configuration for current executable network.
virtual std::shared_ptr< IInferRequestInternal > CreateInferRequestImpl(InputsDataMap networkInputs, OutputsDataMap networkOutputs)
Creates an inference request internal implementation.
InferenceEngine::OutputsDataMap _networkOutputs
Holds information about network outputs data.
Definition: ie_iexecutable_network_internal.hpp:144
virtual void setNetworkOutputs(const OutputsDataMap &networkOutputs)
Sets the network outputs data.
virtual std::vector< std::shared_ptr< IVariableStateInternal > > QueryState()
Queries memory states.
InferenceEngine::InputsDataMap _networkInputs
Holds information about network inputs info.
Definition: ie_iexecutable_network_internal.hpp:143
virtual Parameter GetConfig(const std::string &name) const
Gets configuration dedicated to plugin behaviour.
std::shared_ptr< IInferencePlugin > _plugin
A pointer to a IInferencePlugin interface.
Definition: ie_iexecutable_network_internal.hpp:150
virtual std::shared_ptr< IInferRequestInternal > CreateInferRequest()
Create an inference request object used to infer the network Note: the returned request will have all...
virtual Parameter GetMetric(const std::string &name) const
Gets general runtime metric for dedicated hardware.
virtual ConstOutputsDataMap GetOutputsInfo() const
Gets the Executable network output Data node information. The received info is stored in the given Da...
Inference Engine Plugin API namespace.
std::map< std::string, InputInfo::Ptr > InputsDataMap
details::SOPointer< IExecutableNetworkInternal > SoExecutableNetworkInternal
SOPointer to IExecutableNetworkInternal.
Definition: ie_iexecutable_network_internal.hpp:156
std::map< std::string, CDataPtr > ConstOutputsDataMap
std::map< std::string, InputInfo::CPtr > ConstInputsDataMap
std::map< std::string, DataPtr > OutputsDataMap