ie_ihetero_plugin.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 that provides interface to register custom hetero functionality
7  * @file ie_ihetero_plugin.hpp
8  */
9 #pragma once
10 #include <map>
11 #include <string>
12 #include <memory>
13 #include <ie_api.h>
14 #include <ie_icnn_network.hpp>
16 #include <ie_plugin.hpp>
17 
18 namespace InferenceEngine {
19 
20 /**
21  * @deprecated Use InferenceEngine::Core to work with HETERO device
22  * @brief This interface describes a mechanism of custom loaders to be used in heterogeneous
23  * plugin during setting of affinity and loading of split sub-network to the plugins
24  * The custom loader can define addition settings for the plugins or network loading
25  * Examples of cases when this interface should be implemented in the application:
26  *
27  * 1. add custom layers to existing plugins if it is not pointed to the heterogeneous plugin
28  * or registration of custom layer is different than supported in available public plugins
29  *
30  * 2. set affinity manually for the same plugin being initialized by different parameters,
31  * e.g different device id
32  * In this case there will be mapping of
33  * Device1 > HeteroDeviceLoaderImpl1
34  * Device2 > HeteroDeviceLoaderImpl2
35  * the affinity should be pointed manually, the implementation of HeteroDeviceLoaderImpl1 and
36  * HeteroDeviceLoaderImpl2 should be in the application, and these device loaders should be registered
37  * through calling of
38  * IHeteroInferencePlugin::SetDeviceLoader("Device1", HeteroDeviceLoaderImpl1)
39  * IHeteroInferencePlugin::SetDeviceLoader("Device2", HeteroDeviceLoaderImpl2)
40 */
41 class INFERENCE_ENGINE_DEPRECATED INFERENCE_ENGINE_API_CLASS(IHeteroDeviceLoader) {
42 public:
43  virtual ~IHeteroDeviceLoader();
44 
45  /**
46  * @deprecated Use InferenceEngine::Core with HETERO device in InferenceEngine::Core::LoadNetwork.
47  * @brief Loads network to the device. The instantiation of plugin should be in the implementation
48  * of the IHeteroDeviceLoader. As well setting of special config option should happen in the
49  * implementation as well
50  * @param device Loading of network should happen for this device
51  * @param ret Reference to a shared ptr of the returned executable network instance
52  * @param network Network object acquired from CNNNetReader
53  * @param config Map of configuration settings relevant only for current load operation
54  * @param resp Pointer to the response message that holds a description of an error if any occurred
55  * @return Status code of the operation. OK if succeeded
56  */
57  INFERENCE_ENGINE_DEPRECATED
58  virtual StatusCode LoadNetwork(
59  const std::string& device,
61  ICNNNetwork &network,
62  const std::map<std::string, std::string> &config,
63  ResponseDesc *resp) noexcept = 0;
64 
65  /**
66  * @deprecated Use the IHeteroDeviceLoader::QueryNetwork
67  * @brief This function calls plugin function QueryNetwork for the plugin being instantiated
68  * in the implementation of IHeteroDeviceLoader
69  * @param device QueryNetwork will be executed for this device
70  * @param network Network object acquired from CNNNetReader
71  * @param res Query network result object
72  */
73  INFERENCE_ENGINE_DEPRECATED
74  virtual void QueryNetwork(const std::string &device,
75  const ICNNNetwork &network,
76  QueryNetworkResult &res) noexcept {
77  IE_SUPPRESS_DEPRECATED_START
78  QueryNetwork(device, network, { }, res);
79  IE_SUPPRESS_DEPRECATED_END
80  }
81 
82  /**
83  * @deprecated Use InferenceEngine::Core with HETERO device in InferenceEngine::Core::QueryNetwork.
84  * @brief This function calls plugin function QueryNetwork for the plugin being instantiated
85  * in the implementation of IHeteroDeviceLoader
86  * @param device QueryNetwork will be executed for this device
87  * @param network Network object acquired from CNNNetReader
88  * @param config Network configuration parameters
89  * @param res Query network result object
90  */
91  INFERENCE_ENGINE_DEPRECATED
92  virtual void QueryNetwork(const std::string &device,
93  const ICNNNetwork &network,
94  const std::map<std::string, std::string>& config,
95  QueryNetworkResult &res) noexcept = 0;
96 
97 
98  /**
99  * @deprecated Use InferenceEngine::Core with HETERO device in InferenceEngine::Core::QueryNetwork.
100  * @brief Sets log callback
101  * @param listener A reference to IErrorListener object
102  */
103  virtual void SetLogCallback(IErrorListener &listener) = 0;
104 
105  IE_SUPPRESS_DEPRECATED_START
106  /**
107  * @brief Shared pointer to IHeteroDeviceLoader instance
108  */
109  using Ptr = std::shared_ptr<IHeteroDeviceLoader>;
110  IE_SUPPRESS_DEPRECATED_END
111 };
112 
113 IE_SUPPRESS_DEPRECATED_START
114 /**
115  * @brief Represents map from device name to device-specific loader
116  */
117 using MapDeviceLoaders = std::map<std::string, InferenceEngine::IHeteroDeviceLoader::Ptr>;
118 IE_SUPPRESS_DEPRECATED_END
119 
120 /**
121  * @deprecated Use InferenceEngine::Core with HETERO mode in LoadNetwork, QueryNetwork, etc
122  * @brief This interface extends regular plugin interface for heterogeneous case. Not all plugins
123  * implements it. The main purpose of this interface - to register loaders and have an ability
124  * to get default settings for affinity on certain devices.
125  */
126 class INFERENCE_ENGINE_DEPRECATED INFERENCE_ENGINE_API_CLASS(IHeteroInferencePlugin) : public IInferencePlugin {
127 public:
128  virtual ~IHeteroInferencePlugin();
129 
130  /**
131  * @deprecated Use InferenceEngine::Core to work with HETERO device
132  * Registers device loader for the device
133  * @param device - the device name being used in CNNNLayer::affinity
134  * @param loader - helper class allowing to analyze if layers are supported and allow
135  * to load network to the plugin being defined in the IHeteroDeviceLoader implementation
136  */
137  IE_SUPPRESS_DEPRECATED_START
138  INFERENCE_ENGINE_DEPRECATED
139  virtual void SetDeviceLoader(const std::string &device, IHeteroDeviceLoader::Ptr loader) noexcept = 0;
140  IE_SUPPRESS_DEPRECATED_END
141 
142  /**
143  * @deprecated Use InferenceEngine::Core::QueryNetwork with HETERO device and QueryNetworkResult::supportedLayersMap
144  * to set affinities to a network
145  * @brief The main goal of this function to set affinity according to the options set for the plugin
146  * implementing IHeteroInferencePlugin.
147  * This function works only if all affinity in the network are empty.
148  * @param network Network object acquired from CNNNetReader
149  * @param config Map of configuration settings
150  * @param resp Pointer to the response message that holds a description of an error if any occurred
151  * @return Status code of the operation. OK if succeeded
152  */
153  INFERENCE_ENGINE_DEPRECATED
154  virtual StatusCode SetAffinity(
155  ICNNNetwork& network,
156  const std::map<std::string, std::string> &config,
157  ResponseDesc *resp) noexcept = 0;
158 };
159 
160 } // namespace InferenceEngine
Inference Engine API.
Definition: ie_argmax_layer.hpp:11
a header file for IExecutableNetwork interface
A header file for Main Inference Engine API.
virtual void QueryNetwork(const std::string &device, const ICNNNetwork &network, QueryNetworkResult &res) noexcept
This function calls plugin function QueryNetwork for the plugin being instantiated in the implementat...
Definition: ie_ihetero_plugin.hpp:74
This is a header file for the ICNNNetwork class.
This interface describes a mechanism of custom loaders to be used in heterogeneous plugin during sett...
Definition: ie_ihetero_plugin.hpp:41
This interface extends regular plugin interface for heterogeneous case. Not all plugins implements it...
Definition: ie_ihetero_plugin.hpp:126
Represents detailed information for an error.
Definition: ie_common.h:230
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:207
std::map< std::string, InferenceEngine::IHeteroDeviceLoader::Ptr > MapDeviceLoaders
Represents map from device name to device-specific loader.
Definition: ie_ihetero_plugin.hpp:117
This class is a main plugin interface.
Definition: ie_plugin.hpp:109
This is the main interface to describe the NN topology.
Definition: ie_icnn_network.hpp:35
The macro defines a symbol import/export mechanism essential for Microsoft Windows(R) OS...
This class represents a custom error listener. Plugin consumers can provide it via InferenceEngine::S...
Definition: ie_error.hpp:16
std::shared_ptr< IExecutableNetwork > Ptr
A smart pointer to the current IExecutableNetwork object.
Definition: ie_iexecutable_network.hpp:38
Responce structure encapsulating information about supported layer.
Definition: ie_plugin.hpp:50
std::shared_ptr< IHeteroDeviceLoader > Ptr
Shared pointer to IHeteroDeviceLoader instance.
Definition: ie_ihetero_plugin.hpp:109