Added SetExeNetworkInfo to Plugin API level (#5715)

This commit is contained in:
Ilya Lavrenov
2021-05-20 14:28:01 +03:00
committed by GitHub
parent d98e954f5d
commit a7d95bbfa3
8 changed files with 39 additions and 41 deletions

View File

@@ -140,13 +140,20 @@ public:
/**
* @brief Gets pre-process info for the input
*
* @return A reference to the PreProcessInfo instance that contains pre-process info for this input
*/
PreProcessInfo& getPreProcess() {
return _preProcessInfo;
}
/**
* @brief Gets pre-process info for the input
* @return A reference to the PreProcessInfo instance that contains pre-process info for this input
*/
const PreProcessInfo& getPreProcess() const {
return _preProcessInfo;
}
protected:
/**
* @brief Pre-process info for the input

View File

@@ -8,6 +8,7 @@
#include <vector>
#include <string>
#include <unordered_set>
#include <type_traits>
#include <cpp_interfaces/impl/ie_plugin_internal.hpp>
#include <cpp_interfaces/interface/ie_internal_plugin_config.hpp>
@@ -62,7 +63,14 @@ private:
if (!executableNetwork) {
IE_THROW() << "Failed to load network by AUTO plugin";
}
return std::make_shared<AutoExecutableNetwork>(executableNetwork);
auto impl = std::make_shared<AutoExecutableNetwork>(executableNetwork);
if (std::is_same<std::string, T>::value) {
SetExeNetworkInfo(impl, executableNetwork->GetInputsInfo(),
executableNetwork->GetOutputsInfo());
}
return impl;
}
};

View File

@@ -142,33 +142,10 @@ InferenceEngine::Parameter MultiDeviceInferencePlugin::GetMetric(const std::stri
}
}
void MultiDeviceInferencePlugin::SetExeNetworkInfo(InferenceEngine::ExecutableNetworkInternal::Ptr exeNetwork,
const InferenceEngine::ConstInputsDataMap& devInputs,
const InferenceEngine::ConstOutputsDataMap& devOutputs) {
// Set inputs/outputs and pointer to plugin manually here
InputsDataMap _inputs, clonedInputs;
OutputsDataMap _outputs, clonedOutputs;
for (auto& it : devInputs) {
InputInfo::CPtr devData = it.second;
InputInfo::Ptr data = std::make_shared<InputInfo>(*devData);
_inputs[it.first] = data;
}
for (auto& it : devOutputs) {
CDataPtr devData = it.second;
DataPtr data = std::make_shared<Data>(*devData);
_outputs[it.first] = data;
}
copyInputOutputInfo(_inputs, _outputs, clonedInputs, clonedOutputs);
exeNetwork->setNetworkInputs(clonedInputs);
exeNetwork->setNetworkOutputs(clonedOutputs);
exeNetwork->SetPointerToPlugin(shared_from_this());
}
// Is called only when caching is enabled
IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetwork(const std::string& modelPath,
const std::map<std::string, std::string>& config) {
CNNNetwork network;
return LoadExeNetworkImpl(modelPath, network, config);
return LoadExeNetworkImpl(modelPath, {}, config);
}
ExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(const CNNNetwork &network,

View File

@@ -44,10 +44,6 @@ private:
InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const std::string& modelPath,
InferenceEngine::CNNNetwork network,
const std::map<std::string, std::string>& config);
void SetExeNetworkInfo(InferenceEngine::ExecutableNetworkInternal::Ptr exeNetwork,
const InferenceEngine::ConstInputsDataMap& inputs,
const InferenceEngine::ConstOutputsDataMap& outputs);
};
} // namespace MultiDevicePlugin

View File

@@ -86,7 +86,7 @@ public:
* @param[in] plugin The plugin
* @note Needed to correctly handle ownership between objects.
*/
void SetPointerToPlugin(const IInferencePlugin::Ptr& plugin) {
virtual void SetPointerToPlugin(const IInferencePlugin::Ptr& plugin) {
_plugin = plugin;
}

View File

@@ -54,10 +54,6 @@ public:
IExecutableNetworkInternal::Ptr LoadNetwork(const CNNNetwork& network, const std::map<std::string, std::string>& config,
RemoteContext::Ptr context) override {
InputsDataMap networkInputs = network.getInputsInfo(), networkInputsCloned;
OutputsDataMap networkOutputs = network.getOutputsInfo(), networkOutputsCloned;
copyInputOutputInfo(networkInputs, networkOutputs, networkInputsCloned, networkOutputsCloned);
ExecutableNetworkInternal::Ptr impl;
if (nullptr == context) {
impl = LoadExeNetworkImpl(network, config);
@@ -65,9 +61,7 @@ public:
impl = LoadExeNetworkImpl(network, context, config);
}
impl->setNetworkInputs(networkInputsCloned);
impl->setNetworkOutputs(networkOutputsCloned);
impl->SetPointerToPlugin(shared_from_this());
SetExeNetworkInfo(impl, network.getInputsInfo(), network.getOutputsInfo());
return impl;
}
@@ -216,6 +210,20 @@ protected:
IE_THROW(NotImplemented);
}
template <typename Tinput, typename Toutput>
void SetExeNetworkInfo(const InferenceEngine::ExecutableNetworkInternal::Ptr& exeNetwork,
const std::map<std::string, std::shared_ptr<Tinput> >& inputs,
const std::map<std::string, std::shared_ptr<Toutput> >& outputs) {
// Set inputs/outputs and pointer to plugin manually here
InferenceEngine::InputsDataMap clonedInputs;
InferenceEngine::OutputsDataMap clonedOutputs;
copyInputOutputInfo(inputs, outputs, clonedInputs, clonedOutputs);
exeNetwork->setNetworkInputs(clonedInputs);
exeNetwork->setNetworkOutputs(clonedOutputs);
exeNetwork->SetPointerToPlugin(shared_from_this());
}
std::string _pluginName; //!< A device name that plugins enables
std::map<std::string, std::string> _config; //!< A map config keys -> values
ICore* _core = nullptr; //!< A pointer to ICore interface

View File

@@ -32,7 +32,7 @@ class IExecutableNetworkInternal;
* @param[in] from PreProcessInfo to copy from
* @param to PreProcessInfo to copy to
*/
static void copyPreProcess(const PreProcessInfo& from, PreProcessInfo& to) {
inline void copyPreProcess(const PreProcessInfo& from, PreProcessInfo& to) {
to = from;
if (from.getMeanVariant() == MEAN_IMAGE) {
for (size_t i = 0; i < from.getNumberOfChannels(); i++) {
@@ -54,7 +54,9 @@ static void copyPreProcess(const PreProcessInfo& from, PreProcessInfo& to) {
* @param _networkInputs The network inputs to copy to
* @param _networkOutputs The network outputs to copy to
*/
inline void copyInputOutputInfo(const InputsDataMap & networkInputs, const OutputsDataMap & networkOutputs,
template <typename Tinput, typename Toutput>
inline void copyInputOutputInfo(const std::map<std::string, std::shared_ptr<Tinput> > & networkInputs,
const std::map<std::string, std::shared_ptr<Toutput> > & networkOutputs,
InputsDataMap & _networkInputs, OutputsDataMap & _networkOutputs) {
_networkInputs.clear();
_networkOutputs.clear();

View File

@@ -133,7 +133,7 @@ public:
ExecutableNetworkInternal::Export(networkModel);
}
void SetPointerToPlugin(IInferencePlugin::Ptr plugin) override {
void SetPointerToPlugin(const IInferencePlugin::Ptr& plugin) override {
std::lock_guard<std::mutex> guard(m_pluginMutex);
ExecutableNetworkInternal::SetPointerToPlugin(plugin);
}