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  * 1. add custom layers to existing plugins if it is not pointed to the heterogeneous plugin
27  * or registration of custom layer is different than supported in available public plugins
28  * 2. set affinity manually for the same plugin being initialized by different parameters,
29  * e.g different device id
30  * In this case there will be mapping of
31  * Device1 > HeteroDeviceLoaderImpl1
32  * Device2 > HeteroDeviceLoaderImpl2
33  * the affinity should be pointed manually, the implementation of HeteroDeviceLoaderImpl1 and
34  * HeteroDeviceLoaderImpl2 should be in the application, and these device loaders should be registered
35  * through calling of
36  * IHeteroInferencePlugin::SetDeviceLoader("Device1", HeteroDeviceLoaderImpl1)
37  * IHeteroInferencePlugin::SetDeviceLoader("Device2", HeteroDeviceLoaderImpl2)
38 */
39 class INFERENCE_ENGINE_DEPRECATED INFERENCE_ENGINE_API_CLASS(IHeteroDeviceLoader) {
40 public:
41  virtual ~IHeteroDeviceLoader();
42 
43  /**
44  * @deprecated Use InferenceEngine::Core with HETERO device in InferenceEngine::Core::LoadNetwork.
45  * @brief Loads network to the device. The instantiation of plugin should be in the implementation
46  * of the IHeteroDeviceLoader. As well setting of special config option should happen in the
47  * implementation as well
48  * @param device Loading of network should happen for this device
49  * @param ret Reference to a shared ptr of the returned executable network instance
50  * @param network Network object acquired from CNNNetReader
51  * @param config Map of configuration settings relevant only for current load operation
52  * @param resp Pointer to the response message that holds a description of an error if any occurred
53  * @return Status code of the operation. OK if succeeded
54  */
55  INFERENCE_ENGINE_DEPRECATED
56  virtual StatusCode LoadNetwork(
57  const std::string& device,
59  ICNNNetwork &network,
60  const std::map<std::string, std::string> &config,
61  ResponseDesc *resp) noexcept = 0;
62 
63  /**
64  * @deprecated Use the IHeteroDeviceLoader::QueryNetwork
65  * @brief This function calls plugin function QueryNetwork for the plugin being instantiated
66  * in the implementation of IHeteroDeviceLoader
67  * @param device QueryNetwork will be executed for this device
68  * @param network Network object acquired from CNNNetReader
69  * @param res Query network result object
70  */
71  INFERENCE_ENGINE_DEPRECATED
72  virtual void QueryNetwork(const std::string &device,
73  const ICNNNetwork &network,
74  QueryNetworkResult &res) noexcept {
75  IE_SUPPRESS_DEPRECATED_START
76  QueryNetwork(device, network, { }, res);
77  IE_SUPPRESS_DEPRECATED_END
78  }
79 
80  /**
81  * @deprecated Use InferenceEngine::Core with HETERO device in InferenceEngine::Core::QueryNetwork.
82  * @brief This function calls plugin function QueryNetwork for the plugin being instantiated
83  * in the implementation of IHeteroDeviceLoader
84  * @param device QueryNetwork will be executed for this device
85  * @param network Network object acquired from CNNNetReader
86  * @param config Network configuration parameters
87  * @param res Query network result object
88  */
89  INFERENCE_ENGINE_DEPRECATED
90  virtual void QueryNetwork(const std::string &device,
91  const ICNNNetwork &network,
92  const std::map<std::string, std::string>& /*config*/,
93  QueryNetworkResult &res) noexcept = 0;
94 
95  INFERENCE_ENGINE_DEPRECATED
96  virtual void SetLogCallback(IErrorListener &listener) = 0;
97 
98  IE_SUPPRESS_DEPRECATED_START
99  using Ptr = std::shared_ptr<IHeteroDeviceLoader>;
100  IE_SUPPRESS_DEPRECATED_END
101 };
102 
103 IE_SUPPRESS_DEPRECATED_START
104 using MapDeviceLoaders = std::map<std::string, InferenceEngine::IHeteroDeviceLoader::Ptr>;
105 IE_SUPPRESS_DEPRECATED_END
106 
107 /**
108  * @deprecated Use InferenceEngine::Core with HETERO mode in LoadNetwork, QueryNetwork, etc
109  * @brief This interface extends regular plugin interface for heterogeneous case. Not all plugins
110  * implements it. The main purpose of this interface - to register loaders and have an ability
111  * to get default settings for affinity on certain devices.
112  */
113 class INFERENCE_ENGINE_DEPRECATED INFERENCE_ENGINE_API_CLASS(IHeteroInferencePlugin) : public IInferencePlugin {
114 public:
115  virtual ~IHeteroInferencePlugin();
116 
117  /**
118  * @deprecated Use InferenceEngine::Core to work with HETERO device
119  * Registers device loader for the device
120  * @param device - the device name being used in CNNNLayer::affinity
121  * @param loader - helper class allowing to analyze if layers are supported and allow
122  * to load network to the plugin being defined in the IHeteroDeviceLoader implementation
123  */
124  IE_SUPPRESS_DEPRECATED_START
125  INFERENCE_ENGINE_DEPRECATED
126  virtual void SetDeviceLoader(const std::string &device, IHeteroDeviceLoader::Ptr loader) noexcept = 0;
127  IE_SUPPRESS_DEPRECATED_END
128 
129  /**
130  * @deprecated Use InferenceEngine::Core::QueryNetwork with HETERO device and QueryNetworkResult::supportedLayersMap
131  * to set affinities to a network
132  * @brief The main goal of this function to set affinity according to the options set for the plugin
133  * implementing IHeteroInferencePlugin.
134  * This function works only if all affinity in the network are empty.
135  * @param network Network object acquired from CNNNetReader
136  * @param config Map of configuration settings
137  * @param resp Pointer to the response message that holds a description of an error if any occurred
138  * @return Status code of the operation. OK if succeeded
139  */
140  INFERENCE_ENGINE_DEPRECATED
141  virtual StatusCode SetAffinity(
142  ICNNNetwork& network,
143  const std::map<std::string, std::string> &config,
144  ResponseDesc *resp) noexcept = 0;
145 };
146 
147 } // namespace InferenceEngine
Definition: ie_argmax_layer.hpp:11
a header file for IExecutableNetwork interface
A header file for Main Inference Engine API.
StatusCode
This enum contains codes for all possible return values of the interface functions.
Definition: ie_common.h:205
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:72
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:39
This interface extends regular plugin interface for heterogeneous case. Not all plugins implements it...
Definition: ie_ihetero_plugin.hpp:113
Represents detailed information for an error.
Definition: ie_common.h:228
This class is a main plugin interface.
Definition: ie_plugin.hpp:103
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:46