diff --git a/docs/IE_PLUGIN_DG/ExecutableNetwork.md b/docs/IE_PLUGIN_DG/ExecutableNetwork.md index 2685c518a0e..c5bfd889857 100644 --- a/docs/IE_PLUGIN_DG/ExecutableNetwork.md +++ b/docs/IE_PLUGIN_DG/ExecutableNetwork.md @@ -4,8 +4,8 @@ - Compile an InferenceEngine::ICNNNetwork instance to a backend specific graph representation - Create an arbitrary number of `InferRequest` objects - Hold some common resources shared between different instances of `InferRequest`. For example: - - InferenceEngine::ExecutableNetworkInternal::_taskExecutor task executor to implement asynchronous execution - - InferenceEngine::ExecutableNetworkInternal::_callbackExecutor task executor to run an asynchronous inference request callback in a separate thread + - InferenceEngine::IExecutableNetworkInternal::_taskExecutor task executor to implement asynchronous execution + - InferenceEngine::IExecutableNetworkInternal::_callbackExecutor task executor to run an asynchronous inference request callback in a separate thread `ExecutableNetwork` Class ------------------------ diff --git a/docs/IE_PLUGIN_DG/Plugin.md b/docs/IE_PLUGIN_DG/Plugin.md index bb00fb9489a..cadc8660fd3 100644 --- a/docs/IE_PLUGIN_DG/Plugin.md +++ b/docs/IE_PLUGIN_DG/Plugin.md @@ -21,7 +21,7 @@ To build an Inference Engine plugin with the Plugin API, see the [Inference Engi Plugin Class ------------------------ -Inference Engine Plugin API provides the helper InferenceEngine::InferencePluginInternal class recommended to use as a base class for a plugin. +Inference Engine Plugin API provides the helper InferenceEngine::IInferencePlugin class recommended to use as a base class for a plugin. Based on that, declaration of a plugin class can look as follows: @snippet src/template_plugin.hpp plugin:header @@ -56,8 +56,8 @@ A plugin must define a device name enabled via the `_pluginName` field of a base ### `LoadExeNetworkImpl()` -**Implementation details:** The base InferenceEngine::InferencePluginInternal class provides a common implementation -of the public InferenceEngine::InferencePluginInternal::LoadNetwork method that calls plugin-specific `LoadExeNetworkImpl`, which is defined in a derived class. +**Implementation details:** The base InferenceEngine::IInferencePlugin class provides a common implementation +of the public InferenceEngine::IInferencePlugin::LoadNetwork method that calls plugin-specific `LoadExeNetworkImpl`, which is defined in a derived class. This is the most important function of the `Plugin` class and creates an instance of compiled `ExecutableNetwork`, which holds a backend-dependent compiled graph in an internal representation: @@ -166,10 +166,10 @@ using an [ExecutableNetwork](@ref executable_network) object. This functionality backend specific graph compilation takes significant time and/or cannot be done on a target host device due to other reasons. -**Implementation details:** The base plugin class InferenceEngine::InferencePluginInternal implements InferenceEngine::InferencePluginInternal::ImportNetwork -as follows: exports a device type (InferenceEngine::InferencePluginInternal::_pluginName) and then calls `ImportNetworkImpl`, +**Implementation details:** The base plugin class InferenceEngine::IInferencePlugin implements InferenceEngine::IInferencePlugin::ImportNetwork +as follows: exports a device type (InferenceEngine::IInferencePlugin::_pluginName) and then calls `ImportNetworkImpl`, which is implemented in a derived class. -If a plugin cannot use the base implementation InferenceEngine::InferencePluginInternal::ImportNetwork, it can override base +If a plugin cannot use the base implementation InferenceEngine::IInferencePlugin::ImportNetwork, it can override base implementation and define an output blob structure up to its needs. This can be useful if a plugin exports a blob in a special format for integration with other frameworks where a common Inference Engine header from a base class implementation is not appropriate. diff --git a/docs/template_plugin/src/template_executable_network.cpp b/docs/template_plugin/src/template_executable_network.cpp index f0f2a8066e5..e46bd63e5a0 100644 --- a/docs/template_plugin/src/template_executable_network.cpp +++ b/docs/template_plugin/src/template_executable_network.cpp @@ -8,6 +8,7 @@ #include #include +#include "ie_icore.hpp" #include "template/template_config.hpp" #include "template_itt.hpp" #include "template_plugin.hpp" diff --git a/docs/template_plugin/src/template_executable_network.hpp b/docs/template_plugin/src/template_executable_network.hpp index cebfddb3947..ca3bca11ba8 100644 --- a/docs/template_plugin/src/template_executable_network.hpp +++ b/docs/template_plugin/src/template_executable_network.hpp @@ -28,8 +28,6 @@ public: ExecutableNetwork(std::istream& model, const Configuration& cfg, const std::shared_ptr& plugin); - ~ExecutableNetwork() override = default; - // Methods from a base class ExecutableNetworkThreadSafeDefault void ExportImpl(std::ostream& model) override; diff --git a/docs/template_plugin/src/template_plugin.cpp b/docs/template_plugin/src/template_plugin.cpp index beaedb97c5e..c5cefeba93e 100644 --- a/docs/template_plugin/src/template_plugin.cpp +++ b/docs/template_plugin/src/template_plugin.cpp @@ -84,7 +84,7 @@ std::shared_ptr TransformNetwork(const std::shared_ptr& config) { +InferenceEngine::IExecutableNetworkInternal::Ptr Plugin::ImportNetworkImpl(std::istream& modelStream, const std::map& config) { OV_ITT_SCOPED_TASK(itt::domains::TemplatePlugin, "Plugin::ImportNetworkImpl"); auto fullConfig = Configuration {config, _cfg}; @@ -188,7 +188,7 @@ InferenceEngine::QueryNetworkResult Plugin::QueryNetwork(const InferenceEngine:: // ! [plugin:query_network] // ! [plugin:add_extension] -void Plugin::AddExtension(InferenceEngine::IExtensionPtr /*extension*/) { +void Plugin::AddExtension(const InferenceEngine::IExtensionPtr& /*extension*/) { // TODO: add extensions if plugin supports extensions IE_THROW(NotImplemented); } diff --git a/docs/template_plugin/src/template_plugin.hpp b/docs/template_plugin/src/template_plugin.hpp index f065fad04e3..ef2b506d497 100644 --- a/docs/template_plugin/src/template_plugin.hpp +++ b/docs/template_plugin/src/template_plugin.hpp @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "backend.hpp" #include "template_config.hpp" @@ -13,7 +13,7 @@ //! [plugin:header] namespace TemplatePlugin { -class Plugin : public InferenceEngine::InferencePluginInternal { +class Plugin : public InferenceEngine::IInferencePlugin { public: using Ptr = std::shared_ptr; @@ -23,12 +23,12 @@ public: void SetConfig(const std::map& config) override; InferenceEngine::QueryNetworkResult QueryNetwork(const InferenceEngine::CNNNetwork& network, const std::map& config) const override; - InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, - const std::map& config) override; - void AddExtension(InferenceEngine::IExtensionPtr extension) override; + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, + const std::map& config) override; + void AddExtension(const std::shared_ptr& extension) override; InferenceEngine::Parameter GetConfig(const std::string& name, const std::map& options) const override; InferenceEngine::Parameter GetMetric(const std::string& name, const std::map& options) const override; - InferenceEngine::ExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& model, const std::map& config) override; + InferenceEngine::IExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& model, const std::map& config) override; private: friend class ExecutableNetwork; diff --git a/inference-engine/include/ie_parameter.hpp b/inference-engine/include/ie_parameter.hpp index 086556151f7..1343f89db32 100644 --- a/inference-engine/include/ie_parameter.hpp +++ b/inference-engine/include/ie_parameter.hpp @@ -335,6 +335,11 @@ private: Any* ptr = nullptr; }; +/** + * @brief An std::map object containing parameters + */ +using ParamMap = std::map; + #ifdef __ANDROID__ extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData); extern template struct INFERENCE_ENGINE_API_CLASS(InferenceEngine::Parameter::RealData); diff --git a/inference-engine/include/ie_remote_context.hpp b/inference-engine/include/ie_remote_context.hpp index 1fd7d9c7419..376459b4a9d 100644 --- a/inference-engine/include/ie_remote_context.hpp +++ b/inference-engine/include/ie_remote_context.hpp @@ -19,11 +19,6 @@ namespace InferenceEngine { class RemoteContext; -/** - * @brief An std::map object containing low-level object parameters - * of classes that are derived from RemoteBlob or RemoteContext - */ -using ParamMap = std::map; /** * @brief This class represents an Inference Engine abstraction to the memory allocated * on the remote (non-CPU) accelerator device diff --git a/inference-engine/src/auto_plugin/auto_exec_network.cpp b/inference-engine/src/auto_plugin/auto_exec_network.cpp index beeff6f1468..353196a88d4 100644 --- a/inference-engine/src/auto_plugin/auto_exec_network.cpp +++ b/inference-engine/src/auto_plugin/auto_exec_network.cpp @@ -22,7 +22,7 @@ AutoExecutableNetwork::AutoExecutableNetwork(const SoExecutableNetworkInternal& AutoExecutableNetwork::~AutoExecutableNetwork() = default; InferenceEngine::IInferRequestInternal::Ptr AutoExecutableNetwork::CreateInferRequestImpl(InputsDataMap networkInputs, - OutputsDataMap networkOutputs) { + OutputsDataMap networkOutputs) { SoIInferRequestInternal inferRequest = {_network, _network->CreateInferRequest()}; return std::make_shared(_networkInputs, _networkOutputs, inferRequest); } diff --git a/inference-engine/src/auto_plugin/auto_exec_network.hpp b/inference-engine/src/auto_plugin/auto_exec_network.hpp index 0daa9dd6dae..a39478b19a7 100644 --- a/inference-engine/src/auto_plugin/auto_exec_network.hpp +++ b/inference-engine/src/auto_plugin/auto_exec_network.hpp @@ -24,7 +24,7 @@ struct DeviceInformation { std::map config; }; -class AutoExecutableNetwork : public InferenceEngine::ExecutableNetworkInternal { +class AutoExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal { public: using Ptr = std::shared_ptr; @@ -39,7 +39,7 @@ public: InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, InferenceEngine::OutputsDataMap networkOutputs) override; - ~AutoExecutableNetwork() override; + ~AutoExecutableNetwork(); private: InferenceEngine::SoExecutableNetworkInternal _network; diff --git a/inference-engine/src/auto_plugin/auto_plugin.cpp b/inference-engine/src/auto_plugin/auto_plugin.cpp index 3e65075b240..4f8a14e7d8d 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.cpp +++ b/inference-engine/src/auto_plugin/auto_plugin.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include "auto_plugin.hpp" @@ -54,8 +55,8 @@ IE::IExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadNetwork(const std:: return LoadNetworkImpl(fileName, config); } -IE::ExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadExeNetworkImpl(const IE::CNNNetwork& network, - const ConfigType& config) { +IE::IExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadExeNetworkImpl(const IE::CNNNetwork& network, + const ConfigType& config) { if (network.getFunction() == nullptr) { IE_THROW() << "AUTO device supports just ngraph network representation"; } diff --git a/inference-engine/src/auto_plugin/auto_plugin.hpp b/inference-engine/src/auto_plugin/auto_plugin.hpp index 3fbe2bbaa28..507716b9a90 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.hpp +++ b/inference-engine/src/auto_plugin/auto_plugin.hpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include "auto_exec_network.hpp" @@ -18,11 +18,11 @@ namespace AutoPlugin { namespace IE = InferenceEngine; using ConfigType = std::map; -class AutoInferencePlugin : public IE::InferencePluginInternal { +class AutoInferencePlugin : public IE::IInferencePlugin { public: AutoInferencePlugin(); ~AutoInferencePlugin() = default; - IE::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const IE::CNNNetwork& network, const ConfigType& config) override; + IE::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const IE::CNNNetwork& network, const ConfigType& config) override; IE::IExecutableNetworkInternal::Ptr LoadNetwork(const std::string& fileName, const ConfigType& config) override; IE::QueryNetworkResult QueryNetwork(const IE::CNNNetwork& network, const ConfigType& config) const override; IE::Parameter GetMetric(const std::string& name, const std::map& options) const override; diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.cpp b/inference-engine/src/cldnn_engine/cldnn_engine.cpp index 8a66351fbec..e2e7644f7a5 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_engine.cpp @@ -473,8 +473,8 @@ void clDNNEngine::UpdateConfig(CLDNNPlugin::Config& conf, const InferenceEngine: } } -ExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, - const std::map &config) { +IExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, + const std::map &config) { OV_ITT_SCOPED_TASK(itt::domains::CLDNNPlugin, "clDNNEngine::LoadExeNetworkImpl"); // verification of supported input InferenceEngine::InputsDataMap _networkInputs = network.getInputsInfo(); @@ -523,9 +523,9 @@ ExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceEn } } -ExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, - RemoteContext::Ptr context, - const std::map &config) { +IExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, + const RemoteContext::Ptr &context, + const std::map &config) { InferenceEngine::InputsDataMap _networkInputs = network.getInputsInfo(); check_inputs(_networkInputs); diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.h b/inference-engine/src/cldnn_engine/cldnn_engine.h index d57d9e06376..f092bcd488e 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.h +++ b/inference-engine/src/cldnn_engine/cldnn_engine.h @@ -8,14 +8,15 @@ #include #include #include -#include +#include +#include #include "cldnn_remote_context.h" namespace CLDNNPlugin { using CLDNNCustomLayerPtr = std::shared_ptr; -class clDNNEngine : public InferenceEngine::InferencePluginInternal, +class clDNNEngine : public InferenceEngine::IInferencePlugin, public InferenceEngine::gpu::details::param_map_obj_getter { struct impl; std::shared_ptr _impl; @@ -35,12 +36,12 @@ class clDNNEngine : public InferenceEngine::InferencePluginInternal, public: clDNNEngine(); - InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, - const std::map &config) override; + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, + const std::map &config) override; - InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, - InferenceEngine::RemoteContext::Ptr context, - const std::map &config) override; + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, + const InferenceEngine::RemoteContext::Ptr& context, + const std::map &config) override; void SetConfig(const std::map &config) override; InferenceEngine::Parameter GetConfig(const std::string& name, const std::map& options) const override; diff --git a/inference-engine/src/cldnn_engine/cldnn_remote_context.h b/inference-engine/src/cldnn_engine/cldnn_remote_context.h index 99a3093d9e7..a2ce1729bd1 100644 --- a/inference-engine/src/cldnn_engine/cldnn_remote_context.h +++ b/inference-engine/src/cldnn_engine/cldnn_remote_context.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include "cldnn_config.h" #include #include diff --git a/inference-engine/src/gna_plugin/gna_executable_network.hpp b/inference-engine/src/gna_plugin/gna_executable_network.hpp index 9da0c7070a9..40b81ebb84f 100644 --- a/inference-engine/src/gna_plugin/gna_executable_network.hpp +++ b/inference-engine/src/gna_plugin/gna_executable_network.hpp @@ -12,11 +12,11 @@ #include "gna_plugin.hpp" #include #include -#include +#include namespace GNAPluginNS { -class GNAExecutableNetwork : public InferenceEngine::ExecutableNetworkInternal { +class GNAExecutableNetwork : public InferenceEngine::IExecutableNetworkInternal { std::shared_ptr plg; public: @@ -69,8 +69,6 @@ class GNAExecutableNetwork : public InferenceEngine::ExecutableNetworkInternal { plg->Export(modelFileName); } - using ExecutableNetworkInternal::Export; - void Export(std::ostream& modelStream) override { plg->Export(modelStream); } diff --git a/inference-engine/src/gna_plugin/gna_plugin.cpp b/inference-engine/src/gna_plugin/gna_plugin.cpp index 77fb999d45f..586bbf0ff9f 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.cpp +++ b/inference-engine/src/gna_plugin/gna_plugin.cpp @@ -1495,7 +1495,7 @@ Blob::Ptr GNAPlugin::GetInputBlob(const std::string& name, InferenceEngine::Prec return inputBlob; } -std::vector GNAPlugin::QueryState() { +std::vector GNAPlugin::QueryState() { if (memoryStates.size() != graphCompiler.memory_connection.size()) { memoryStates.clear(); for (auto& connection : graphCompiler.memory_connection) { @@ -1659,7 +1659,7 @@ std::map GNAPlugin::Ge } } -void GNAPlugin::AddExtension(InferenceEngine::IExtensionPtr extension) {} +void GNAPlugin::AddExtension(const InferenceEngine::IExtensionPtr& extension) {} void GNAPlugin::SetConfig(const std::map &config_map) { config.UpdateFromMap(config_map); diff --git a/inference-engine/src/gna_plugin/gna_plugin.hpp b/inference-engine/src/gna_plugin/gna_plugin.hpp index 7ea93642ba1..1b37439eead 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.hpp +++ b/inference-engine/src/gna_plugin/gna_plugin.hpp @@ -14,7 +14,7 @@ #include #include #include -#include "cpp_interfaces/impl/ie_variable_state_internal.hpp" +#include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" #include "descriptions/gna_flags.hpp" #include "descriptions/gna_input_desc.hpp" #include "descriptions/gna_output_desc.hpp" @@ -85,7 +85,7 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin { InferenceEngine::InputsDataMap inputsDataMap; InferenceEngine::OutputsDataMap outputsDataMap; - std::vector memoryStates; + std::vector memoryStates; bool trivialTopology = false; public: @@ -102,19 +102,10 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin { bool Infer(const InferenceEngine::BlobMap &input, InferenceEngine::BlobMap &result); std::map GetPerformanceCounts(); - void AddExtension(InferenceEngine::IExtensionPtr extension) override; + void AddExtension(const InferenceEngine::IExtensionPtr& extension) override; void SetConfig(const std::map &config) override; - InferenceEngine::IExecutableNetworkInternal::Ptr LoadNetwork(const InferenceEngine::CNNNetwork &network, - const std::map &config_map) override { THROW_GNA_EXCEPTION << "Not implemented"; } - InferenceEngine::IExecutableNetworkInternal::Ptr LoadNetwork(const InferenceEngine::CNNNetwork &network, - const std::map &config_map, - InferenceEngine::RemoteContext::Ptr context) override { THROW_GNA_EXCEPTION << "Not implemented"; } - InferenceEngine::IExecutableNetworkInternal::Ptr LoadNetwork(const std::string &modelPath, - const std::map &config_map) override { THROW_GNA_EXCEPTION << "Not implemented"; } bool Infer(const InferenceEngine::Blob &input, InferenceEngine::Blob &result); - void SetCore(InferenceEngine::ICore*) noexcept override {} - InferenceEngine::ICore* GetCore() const noexcept override {return nullptr;} void Reset(); InferenceEngine::QueryNetworkResult QueryNetwork(const InferenceEngine::CNNNetwork &network, const std::map& config) const override; diff --git a/inference-engine/src/gna_plugin/gna_plugin_internal.hpp b/inference-engine/src/gna_plugin/gna_plugin_internal.hpp index 7203382ca52..ba7eaf6e5fa 100644 --- a/inference-engine/src/gna_plugin/gna_plugin_internal.hpp +++ b/inference-engine/src/gna_plugin/gna_plugin_internal.hpp @@ -7,15 +7,15 @@ #include #include #include -#include -#include +#include +#include #include "gna_executable_network.hpp" #include "gna_plugin_config.hpp" #include namespace GNAPluginNS { -class GNAPluginInternal : public InferenceEngine::InferencePluginInternal { +class GNAPluginInternal : public InferenceEngine::IInferencePlugin { private: std::mutex syncCallsToLoadExeNetworkImpl; Config defaultConfig; @@ -30,7 +30,7 @@ private: } public: - InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl( + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl( const InferenceEngine::CNNNetwork &network, const std::map &config) override { std::lock_guard lock{ syncCallsToLoadExeNetworkImpl }; diff --git a/inference-engine/src/gna_plugin/memory/gna_memory_state.cpp b/inference-engine/src/gna_plugin/memory/gna_memory_state.cpp index 19a089e7625..60d3ec175aa 100644 --- a/inference-engine/src/gna_plugin/memory/gna_memory_state.cpp +++ b/inference-engine/src/gna_plugin/memory/gna_memory_state.cpp @@ -12,10 +12,6 @@ namespace GNAPluginNS { namespace memory { - std::string GNAVariableState::GetName() const { - return name; - } - void GNAVariableState::Reset() { state->Reset(); } @@ -43,7 +39,7 @@ namespace memory { return state_precision; } - void GNAVariableState::SetState(InferenceEngine::Blob::Ptr newState) { + void GNAVariableState::SetState(const InferenceEngine::Blob::Ptr& newState) { IE_ASSERT(newState != nullptr); auto data_ptr = newState->cbuffer().as(); diff --git a/inference-engine/src/gna_plugin/memory/gna_memory_state.hpp b/inference-engine/src/gna_plugin/memory/gna_memory_state.hpp index 3ffdb7d7280..6e570daeff3 100644 --- a/inference-engine/src/gna_plugin/memory/gna_memory_state.hpp +++ b/inference-engine/src/gna_plugin/memory/gna_memory_state.hpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include "gna_plugin.hpp" namespace GNAPluginNS { @@ -14,12 +14,11 @@ namespace memory { class GNAVariableState : public InferenceEngine::IVariableStateInternal { public: GNAVariableState(std::string name, std::shared_ptr state) - : name(name), state(state) { IE_ASSERT(state != nullptr); } + : InferenceEngine::IVariableStateInternal{name}, state(state) { IE_ASSERT(state != nullptr); } void Reset() override; - void SetState(InferenceEngine::Blob::Ptr newState) override; + void SetState(const InferenceEngine::Blob::Ptr& newState) override; InferenceEngine::Blob::CPtr GetState() const override; - std::string GetName() const override; float GetScaleFactor() const; private: diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.hpp b/inference-engine/src/hetero_plugin/hetero_executable_network.hpp index fbc4cb93f4a..85fc8d9c19c 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.hpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.hpp @@ -47,8 +47,6 @@ public: const std::map& config, Engine* plugin); - ~HeteroExecutableNetwork() override = default; - InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, InferenceEngine::OutputsDataMap networkOutputs) override; diff --git a/inference-engine/src/hetero_plugin/hetero_plugin.cpp b/inference-engine/src/hetero_plugin/hetero_plugin.cpp index e09f03d7fa7..b194028eb5f 100644 --- a/inference-engine/src/hetero_plugin/hetero_plugin.cpp +++ b/inference-engine/src/hetero_plugin/hetero_plugin.cpp @@ -38,7 +38,7 @@ Engine::Configs mergeConfigs(Engine::Configs config, const Engine::Configs & loc } // namespace -InferenceEngine::ExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, +InferenceEngine::IExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, const Configs& config) { if (GetCore() == nullptr) { IE_THROW() << "Please, work with HETERO device via InferencEngine::Core object"; @@ -58,7 +58,7 @@ InferenceEngine::ExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl(const return std::make_shared(network, mergeConfigs(_config, config), this); } -InferenceEngine::ExecutableNetworkInternal::Ptr Engine::ImportNetworkImpl(std::istream& heteroModel, const Configs& config) { +InferenceEngine::IExecutableNetworkInternal::Ptr Engine::ImportNetworkImpl(std::istream& heteroModel, const Configs& config) { if (GetCore() == nullptr) { IE_THROW() << "Please, work with HETERO device via InferencEngine::Core object"; } diff --git a/inference-engine/src/hetero_plugin/hetero_plugin.hpp b/inference-engine/src/hetero_plugin/hetero_plugin.hpp index 9b4198aac72..2b5a93b829b 100644 --- a/inference-engine/src/hetero_plugin/hetero_plugin.hpp +++ b/inference-engine/src/hetero_plugin/hetero_plugin.hpp @@ -6,7 +6,7 @@ #include "description_buffer.hpp" #include "ie_icore.hpp" -#include "cpp_interfaces/impl/ie_plugin_internal.hpp" +#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include #include #include @@ -16,14 +16,14 @@ namespace HeteroPlugin { -class Engine : public InferenceEngine::InferencePluginInternal { +class Engine : public InferenceEngine::IInferencePlugin { public: using Configs = std::map; using DeviceMetaInformationMap = std::unordered_map; Engine(); - InferenceEngine::ExecutableNetworkInternal::Ptr + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, const Configs &config) override; void SetConfig(const Configs &config) override; @@ -37,7 +37,7 @@ public: InferenceEngine::Parameter GetConfig(const std::string& name, const std::map & options) const override; - InferenceEngine::ExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& heteroModel, const Configs& config) override; + InferenceEngine::IExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& heteroModel, const Configs& config) override; DeviceMetaInformationMap GetDevicePlugins(const std::string& targetFallback, const Configs & localConfig) const; diff --git a/inference-engine/src/inference_engine/cpp/ie_plugin.hpp b/inference-engine/src/inference_engine/cpp/ie_plugin.hpp index 3496261e1fd..0994633f99b 100644 --- a/inference-engine/src/inference_engine/cpp/ie_plugin.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_plugin.hpp @@ -52,7 +52,7 @@ public: PLUGIN_CALL_STATEMENT(return _ptr->GetVersion()); } - void AddExtension(InferenceEngine::IExtensionPtr extension) { + void AddExtension(const InferenceEngine::IExtensionPtr& extension) { PLUGIN_CALL_STATEMENT(_ptr->AddExtension(extension)); } @@ -64,7 +64,9 @@ public: PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config)}); } - details::SOPointer LoadNetwork(const CNNNetwork& network, RemoteContext::Ptr context, const std::map& config) { + details::SOPointer LoadNetwork(const CNNNetwork& network, + const std::shared_ptr& context, + const std::map& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config, context)}); } @@ -81,7 +83,7 @@ public: } details::SOPointer ImportNetwork(const std::string& modelFileName, - const std::map& config) { + const std::map& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(modelFileName, config)}); } @@ -91,8 +93,8 @@ public: } details::SOPointer ImportNetwork(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config) { + const std::shared_ptr& context, + const std::map& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, context, config)}); } @@ -100,11 +102,11 @@ public: PLUGIN_CALL_STATEMENT(return _ptr->GetMetric(name, options)); } - RemoteContext::Ptr CreateContext(const ParamMap& params) { + std::shared_ptr CreateContext(const ParamMap& params) { PLUGIN_CALL_STATEMENT(return _ptr->CreateContext(params)); } - RemoteContext::Ptr GetDefaultContext(const ParamMap& params) { + std::shared_ptr GetDefaultContext(const ParamMap& params) { PLUGIN_CALL_STATEMENT(return _ptr->GetDefaultContext(params)); } diff --git a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp index 4f0866be7a0..46f99d3fc6c 100644 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp @@ -19,7 +19,7 @@ namespace InferenceEngine { VariableState::VariableState(const details::SharedObjectLoader& so, const IVariableStateInternal::Ptr& impl) : _so(so), _impl(impl) { - IE_ASSERT(_impl != nullptr); + if (_impl == nullptr) IE_THROW() << "VariableState was not initialized."; } IE_SUPPRESS_DEPRECATED_START diff --git a/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp b/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp index cd48f7b58d8..2481ca67852 100644 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_variable_state_base.hpp @@ -7,7 +7,7 @@ #include #include "cpp/exception2status.hpp" -#include "cpp_interfaces/impl/ie_variable_state_internal.hpp" +#include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" #include "ie_imemory_state.hpp" namespace InferenceEngine { diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp new file mode 100644 index 00000000000..bf3086551c1 --- /dev/null +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp @@ -0,0 +1,103 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include + +namespace InferenceEngine { + +void IExecutableNetworkInternal::setNetworkInputs(const InputsDataMap& networkInputs) { + _networkInputs = networkInputs; +} + +void IExecutableNetworkInternal::setNetworkOutputs(const OutputsDataMap& networkOutputs) { + _networkOutputs = networkOutputs; +} + +ConstOutputsDataMap IExecutableNetworkInternal::GetOutputsInfo() const { + ConstOutputsDataMap outputMap; + for (const auto& output : _networkOutputs) { + outputMap.emplace(output.first, output.second); + } + return outputMap; +} + +ConstInputsDataMap IExecutableNetworkInternal::GetInputsInfo() const { + ConstInputsDataMap inputMap; + for (const auto& input : _networkInputs) { + inputMap.emplace(input.first, input.second); + } + return inputMap; +} + +std::shared_ptr IExecutableNetworkInternal::CreateInferRequest() { + auto asyncRequestImpl = CreateInferRequestImpl(_networkInputs, _networkOutputs); + asyncRequestImpl->setPointerToExecutableNetworkInternal(shared_from_this()); + return asyncRequestImpl; +} + +void IExecutableNetworkInternal::Export(const std::string& modelFileName) { + // we need to write to stringstream first + // because in case of exception in ExportImpl the file is not created + std::stringstream strm; + ExportImpl(strm); + std::ofstream(modelFileName.c_str()) << strm.rdbuf(); +} + +void IExecutableNetworkInternal::Export(std::ostream& networkModel) { + std::stringstream strm; + strm.write(exportMagic.data(), exportMagic.size()); + strm << _plugin->GetName() << std::endl; + ExportImpl(strm); + networkModel << strm.rdbuf(); +} + +CNNNetwork IExecutableNetworkInternal::GetExecGraphInfo() { + IE_THROW(NotImplemented); +} + +std::vector> IExecutableNetworkInternal::QueryState() { + IE_THROW(NotImplemented); +} + +void IExecutableNetworkInternal::SetPointerToPlugin(const std::shared_ptr& plugin) { + _plugin = plugin; +} + +void IExecutableNetworkInternal::SetConfig(const std::map&) { + IE_THROW(NotImplemented); +} + +Parameter IExecutableNetworkInternal::GetConfig(const std::string&) const { + IE_THROW(NotImplemented); +} + +Parameter IExecutableNetworkInternal::GetMetric(const std::string&) const { + IE_THROW(NotImplemented); +} + +std::shared_ptr IExecutableNetworkInternal::GetContext() const { + IE_THROW(NotImplemented); +} + +std::shared_ptr IExecutableNetworkInternal::CreateInferRequestImpl(InputsDataMap networkInputs, + OutputsDataMap networkOutputs) { + IE_THROW(NotImplemented); +} + +void IExecutableNetworkInternal::ExportImpl(std::ostream&) { + IE_THROW(NotImplemented); +} +} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iinfer_request_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iinfer_request_internal.cpp index 29f683a0756..fc77b834b69 100644 --- a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iinfer_request_internal.cpp +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iinfer_request_internal.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -21,9 +22,10 @@ namespace InferenceEngine { IInferRequestInternal::~IInferRequestInternal() {} -IInferRequestInternal::IInferRequestInternal(const InputsDataMap& networkInputs, const OutputsDataMap& networkOutputs) { +IInferRequestInternal::IInferRequestInternal(const InputsDataMap& networkInputs, const OutputsDataMap& networkOutputs) : // We should copy maps since they can be overriden in SetBlob with preprocess - copyInputOutputInfo(networkInputs, networkOutputs, _networkInputs, _networkOutputs); + _networkInputs{copyInfo(networkInputs)}, + _networkOutputs{copyInfo(networkOutputs)} { } void IInferRequestInternal::Infer() { @@ -145,7 +147,7 @@ void IInferRequestInternal::SetBlob(const std::string& name, const Blob::Ptr& da InputInfo::Ptr foundInput; DataPtr foundOutput; if (findInputAndOutputBlobByName(name, foundInput, foundOutput)) { - copyPreProcess(info, foundInput->getPreProcess()); + foundInput->getPreProcess() = copyPreProcess(info); } else { IE_THROW() << "Pre-process can't be set to output blob"; } diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp new file mode 100644 index 00000000000..5637701754e --- /dev/null +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_iplugin_internal.cpp @@ -0,0 +1,237 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief Inference Engine plugin API wrapper, to be used by particular implementors + * @file ie_iplugin_internal.hpp + */ + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include + +namespace InferenceEngine { +namespace { +void parsePluginName(std::istream& networkModel) { + ExportMagic magic = {}; + auto currentPos = networkModel.tellg(); + networkModel.read(magic.data(), magic.size()); + auto exportedWithName = (exportMagic == magic); + if (exportedWithName) { + networkModel.ignore(std::numeric_limits::max(), '\n'); + } else { + networkModel.seekg(currentPos, networkModel.beg); + } +} +} // namespace + +PreProcessInfo copyPreProcess(const PreProcessInfo& from) { + PreProcessInfo to = from; + if (from.getMeanVariant() == MEAN_IMAGE) { + for (size_t i = 0; i < from.getNumberOfChannels(); i++) { + auto& from_blob = from[i]->meanData; + auto to_blob = make_blob_with_precision(from[i]->meanData->getTensorDesc()); + to_blob->allocate(); + ie_memcpy(to_blob->buffer(), to_blob->byteSize(), from_blob->cbuffer(), from_blob->byteSize()); + + to.setMeanImageForChannel(to_blob, i); + } + } + return to; +} + +InputsDataMap copyInfo(const InputsDataMap& networkInputs) { + InputsDataMap _networkInputs; + for (const auto& it : networkInputs) { + InputInfo::Ptr newPtr; + if (it.second) { + newPtr = std::make_shared(); + newPtr->getPreProcess() = it.second->getPreProcess(); + newPtr->setInputData(std::make_shared(*it.second->getInputData())); + } + _networkInputs.emplace(it.first, newPtr); + } + return _networkInputs; +} + +OutputsDataMap copyInfo(const OutputsDataMap& networkOutputs) { + OutputsDataMap _networkOutputs; + for (const auto& it : networkOutputs) { + DataPtr newData; + if (it.second) { + newData = std::make_shared(*it.second); + } + _networkOutputs.emplace(it.first, newData); + } + return _networkOutputs; +} + +void IInferencePlugin::VersionStore::copyFrom(const Version& v) { + _dsc = v.description; + _buildNumber = v.buildNumber; + description = _dsc.c_str(); + buildNumber = _buildNumber.c_str(); + apiVersion = v.apiVersion; +} + +IInferencePlugin::VersionStore::VersionStore(const Version& v) { + copyFrom(v); +} + +IInferencePlugin::VersionStore& IInferencePlugin::VersionStore::operator=(const VersionStore& v) { + if (&v != this) { + copyFrom(v); + } + return *this; +} + +void IInferencePlugin::SetVersion(const Version& version) { + _version = VersionStore(version); +} + +const Version& IInferencePlugin::GetVersion() const { + return _version; +} + +std::string IInferencePlugin::GetName() const noexcept { + return _pluginName; +} + +void IInferencePlugin::SetName(const std::string& pluginName) noexcept { + _pluginName = pluginName; +} + +std::shared_ptr IInferencePlugin::LoadNetwork(const CNNNetwork& network, + const std::map& config) { + return LoadNetwork(network, config, nullptr); +} + +template +std::map> const_map_cast(const std::map>& map) { + std::map> res; + for (auto&& v : map) res.emplace(v.first, std::const_pointer_cast(v.second)); + return res; +} + +std::shared_ptr IInferencePlugin::LoadNetwork(const CNNNetwork& network, + const std::map& config, + const std::shared_ptr& context) { + std::shared_ptr impl; + if (nullptr == context) { + impl = LoadExeNetworkImpl(network, config); + } else { + impl = LoadExeNetworkImpl(network, context, config); + } + + SetExeNetworkInfo(impl, const_map_cast(network.getInputsInfo()), const_map_cast(network.getOutputsInfo())); + + return impl; +} + +std::shared_ptr IInferencePlugin::LoadNetwork(const std::string& modelPath, + const std::map& config) { + auto cnnNet = GetCore()->ReadNetwork(modelPath, std::string()); + return GetCore()->LoadNetwork(cnnNet, GetName(), config); +} + +void IInferencePlugin::AddExtension(const std::shared_ptr&) { + IE_THROW(NotImplemented); +} + +void IInferencePlugin::SetConfig(const std::map&) { + IE_THROW(NotImplemented); +} + +Parameter IInferencePlugin::GetConfig(const std::string&, + const std::map&) const { + IE_THROW(NotImplemented); +} + +Parameter IInferencePlugin::GetMetric(const std::string&, + const std::map&) const { + IE_THROW(NotImplemented); +} + +RemoteContext::Ptr IInferencePlugin::CreateContext(const ParamMap&) { + IE_THROW(NotImplemented); +} + +RemoteContext::Ptr IInferencePlugin::GetDefaultContext(const ParamMap&) { + IE_THROW(NotImplemented); +} + +std::shared_ptr IInferencePlugin::ImportNetwork(const std::string&, + const std::map&) { + IE_THROW(NotImplemented); +} + +std::shared_ptr IInferencePlugin::ImportNetwork(std::istream& networkModel, + const std::map& config) { + parsePluginName(networkModel); + return ImportNetworkImpl(networkModel, config); +} + +std::shared_ptr IInferencePlugin::ImportNetwork(std::istream& networkModel, + const std::shared_ptr& context, + const std::map& config) { + parsePluginName(networkModel); + return ImportNetworkImpl(networkModel, context, config); +} + +void IInferencePlugin::SetCore(ICore* core) { + IE_ASSERT(core != nullptr); + _core = core; +} + +ICore* IInferencePlugin::GetCore() const noexcept { + return _core; +} + +QueryNetworkResult IInferencePlugin::QueryNetwork(const CNNNetwork& network, + const std::map& config) const { + IE_THROW(NotImplemented); +} + +std::shared_ptr IInferencePlugin::LoadExeNetworkImpl(const CNNNetwork&, + const std::map&) { + IE_THROW(NotImplemented); +} + +std::shared_ptr IInferencePlugin::LoadExeNetworkImpl(const CNNNetwork&, + const std::shared_ptr&, + const std::map&) { + IE_THROW(NotImplemented); +} + +std::shared_ptr IInferencePlugin::ImportNetworkImpl(std::istream&, + const std::map&) { + IE_THROW(NotImplemented); +} + +std::shared_ptr IInferencePlugin::ImportNetworkImpl(std::istream&, + const std::shared_ptr&, + const std::map&) { + IE_THROW(NotImplemented); +} + +void IInferencePlugin::SetExeNetworkInfo(const std::shared_ptr& exeNetwork, + const ConstInputsDataMap& inputs, + const ConstOutputsDataMap& outputs) { + IE_ASSERT(exeNetwork != nullptr); + // Set inputs/outputs and pointer to plugin manually here + exeNetwork->setNetworkInputs(copyInfo(constMapCast(inputs))); + exeNetwork->setNetworkOutputs(copyInfo(constMapCast(outputs))); + exeNetwork->SetPointerToPlugin(shared_from_this()); +} + +} // namespace InferenceEngine \ No newline at end of file diff --git a/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp new file mode 100644 index 00000000000..0171292d36b --- /dev/null +++ b/inference-engine/src/inference_engine/cpp_interfaces/interface/ie_ivariable_state_internal.cpp @@ -0,0 +1,29 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include + +namespace InferenceEngine { +IVariableStateInternal::IVariableStateInternal(const std::string& name_) : name{name_} {} + +std::string IVariableStateInternal::GetName() const { + return name; +} + +void IVariableStateInternal::Reset() { + IE_THROW(NotImplemented); +} + +void IVariableStateInternal::SetState(const Blob::Ptr& newState) { + state = newState; +} + +Blob::CPtr IVariableStateInternal::GetState() const { + return state; +} + +Blob::CPtr IVariableStateInternal::GetLastState() const { + return GetState(); +} +} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index d9bd58e14e8..cf769aa6978 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -11,6 +11,7 @@ #include #include +#include #include #include #include @@ -487,7 +488,8 @@ public: return res; } - SoExecutableNetworkInternal LoadNetwork(const CNNNetwork& network, const std::string& deviceName, + SoExecutableNetworkInternal LoadNetwork(const CNNNetwork& network, + const std::string& deviceName, const std::map& config) override { OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::IE_LT, "Core::LoadNetwork::CNN"); bool forceDisableCache = config.count(CONFIG_KEY_INTERNAL(FORCE_DISABLE_CACHE)) > 0; @@ -513,7 +515,8 @@ public: return res; } - SoExecutableNetworkInternal LoadNetwork(const std::string& modelPath, const std::string& deviceName, + SoExecutableNetworkInternal LoadNetwork(const std::string& modelPath, + const std::string& deviceName, const std::map& config) override { OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::IE_LT, "Core::LoadNetwork::Path"); auto parsed = parseDeviceNameIntoConfig(deviceName, config); diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h index 5c9b7edad27..22ed83c9401 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_exec_network.h @@ -4,6 +4,7 @@ #pragma once +#include #include #include "mkldnn_graph.h" @@ -22,17 +23,15 @@ class MKLDNNExecNetwork: public InferenceEngine::ExecutableNetworkThreadSafeDefa public: typedef std::shared_ptr Ptr; - InferenceEngine::IInferRequestInternal::Ptr + std::shared_ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, - InferenceEngine::OutputsDataMap networkOutputs) override; + InferenceEngine::OutputsDataMap networkOutputs) override; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override; MKLDNNExecNetwork(const InferenceEngine::CNNNetwork &network, const Config &cfg, const MKLDNNExtensionManager::Ptr &extMgr, NumaNodesWeights &weightsSharing); - ~MKLDNNExecNetwork() override = default; - void setProperty(const std::map &properties); InferenceEngine::Parameter GetConfig(const std::string &name) const override; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp index bd5fa6456ea..2170d05d07e 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp @@ -11,7 +11,7 @@ using namespace MKLDNNPlugin; using namespace InferenceEngine; -void MKLDNNExtensionManager::AddExtension(IExtensionPtr extension) { +void MKLDNNExtensionManager::AddExtension(const IExtensionPtr& extension) { _extensions.push_back(extension); } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.h b/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.h index 83ddfc3ffe1..784f5ea5266 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.h @@ -18,7 +18,7 @@ public: MKLDNNExtensionManager() = default; InferenceEngine::ILayerImpl::Ptr CreateImplementation(const std::shared_ptr& op); std::shared_ptr CreateExtensionFactory(const std::shared_ptr& op); - void AddExtension(InferenceEngine::IExtensionPtr extension); + void AddExtension(const InferenceEngine::IExtensionPtr& extension); private: std::vector _extensions; diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.cpp index 129c6209c10..9ec272be9eb 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.cpp @@ -10,20 +10,8 @@ using namespace InferenceEngine; namespace MKLDNNPlugin { -std::string MKLDNNVariableState::GetName() const { - return name; -} - void MKLDNNVariableState::Reset() { - std::memset(this->storage->buffer(), 0, storage->byteSize()); -} - -void MKLDNNVariableState::SetState(Blob::Ptr newState) { - storage = newState; -} - -InferenceEngine::Blob::CPtr MKLDNNVariableState::GetState() const { - return storage; + std::memset(state->buffer(), 0, state->byteSize()); } } // namespace MKLDNNPlugin diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.h b/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.h index 2fdac8c64b3..aaddd7e4575 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_memory_state.h @@ -4,7 +4,7 @@ #pragma once -#include "cpp_interfaces/impl/ie_variable_state_internal.hpp" +#include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" #include "blob_factory.hpp" #include "mkldnn_memory.h" #include "nodes/common/cpu_memcpy.h" @@ -16,20 +16,13 @@ namespace MKLDNNPlugin { class MKLDNNVariableState : public InferenceEngine::IVariableStateInternal { public: MKLDNNVariableState(std::string name, MKLDNNMemoryPtr storage) : - name(name) { - this->storage = make_blob_with_precision(MKLDNNMemoryDesc(storage->GetDescriptor())); - this->storage->allocate(); - cpu_memcpy(this->storage->buffer(), storage->GetData(), storage->GetSize()); + InferenceEngine::IVariableStateInternal{name} { + state = make_blob_with_precision(MKLDNNMemoryDesc(storage->GetDescriptor())); + state->allocate(); + cpu_memcpy(state->buffer(), storage->GetData(), storage->GetSize()); } - std::string GetName() const override; void Reset() override; - void SetState(InferenceEngine::Blob::Ptr newState) override; - InferenceEngine::Blob::CPtr GetState() const override; - -private: - std::string name; - InferenceEngine::Blob::Ptr storage; }; } // namespace MKLDNNPlugin \ No newline at end of file diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp index 644682a9e28..3f53db150ce 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.cpp @@ -369,7 +369,7 @@ static void Transformation(CNNNetwork& clonedNetwork, const Config& conf) { ConvertToCPUSpecificOpset(nGraphFunc); } -InferenceEngine::ExecutableNetworkInternal::Ptr +InferenceEngine::IExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, const std::map &config) { OV_ITT_SCOPED_TASK(itt::domains::MKLDNNPlugin, "Engine::LoadExeNetworkImpl"); @@ -500,7 +500,7 @@ Parameter Engine::GetMetric(const std::string& name, const std::mapAddExtension(extension); } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.h b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.h index 228a495a0bb..d0cf39e32a0 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_plugin.h +++ b/inference-engine/src/mkldnn_plugin/mkldnn_plugin.h @@ -4,7 +4,7 @@ #pragma once -#include +#include #include "mkldnn_exec_network.h" #include @@ -16,16 +16,16 @@ namespace MKLDNNPlugin { -class Engine : public InferenceEngine::InferencePluginInternal { +class Engine : public InferenceEngine::IInferencePlugin { public: Engine(); ~Engine(); - InferenceEngine::ExecutableNetworkInternal::Ptr + std::shared_ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, const std::map &config) override; - void AddExtension(InferenceEngine::IExtensionPtr extension) override; + void AddExtension(const InferenceEngine::IExtensionPtr& extension) override; void SetConfig(const std::map &config) override; diff --git a/inference-engine/src/multi_device/multi_device_plugin.cpp b/inference-engine/src/multi_device/multi_device_plugin.cpp index 57c4cd2df1d..b24ed374400 100644 --- a/inference-engine/src/multi_device/multi_device_plugin.cpp +++ b/inference-engine/src/multi_device/multi_device_plugin.cpp @@ -16,6 +16,7 @@ #include #include "multi_device_plugin.hpp" #include +#include // ------------------------------MultiDeviceInferencePlugin---------------------------- namespace MultiDevicePlugin { @@ -148,12 +149,12 @@ IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadNetwork(const st return LoadExeNetworkImpl(modelPath, {}, config); } -ExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(const CNNNetwork &network, - const std::map& config) { +IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(const CNNNetwork &network, + const std::map& config) { return LoadExeNetworkImpl({}, network, config); } -ExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(const std::string& modelPath, +IExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(const std::string& modelPath, CNNNetwork network, const std::map& config) { if (GetCore() == nullptr) { diff --git a/inference-engine/src/multi_device/multi_device_plugin.hpp b/inference-engine/src/multi_device/multi_device_plugin.hpp index bd07b5801f6..c900c0d8565 100644 --- a/inference-engine/src/multi_device/multi_device_plugin.hpp +++ b/inference-engine/src/multi_device/multi_device_plugin.hpp @@ -9,18 +9,18 @@ #include #include -#include +#include #include #include "multi_device_exec_network.hpp" namespace MultiDevicePlugin { -class MultiDeviceInferencePlugin : public InferenceEngine::InferencePluginInternal { +class MultiDeviceInferencePlugin : public InferenceEngine::IInferencePlugin { public: MultiDeviceInferencePlugin(); ~MultiDeviceInferencePlugin() = default; - InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, const std::map& config) override; InferenceEngine::IExecutableNetworkInternal::Ptr LoadNetwork(const std::string& modelPath, @@ -41,7 +41,7 @@ protected: const MultiDevicePlugin::DeviceName & deviceName) const; private: - InferenceEngine::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const std::string& modelPath, + InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const std::string& modelPath, InferenceEngine::CNNNetwork network, const std::map& config); }; diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_internal.hpp deleted file mode 100644 index f7dab9f2a25..00000000000 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_internal.hpp +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include -#include -#include -#include - -#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" -#include "cpp_interfaces/interface/ie_iinfer_request_internal.hpp" -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" - -namespace InferenceEngine { - -/** - * @brief Minimum implementation of IExecutableNetworkInternal interface. Must not be used as a base class in plugins - * As base classes, use ExecutableNetworkThreadSafeDefault or ExecutableNetworkThreadSafeAsyncOnly - * @ingroup ie_dev_api_exec_network_api - */ -class ExecutableNetworkInternal : public IExecutableNetworkInternal { -public: - /** - * @brief A shared pointer to ExecutableNetworkInternal object - */ - typedef std::shared_ptr Ptr; - - /** - * @brief Sets the network inputs info. - * @param[in] networkInputs The network inputs info - */ - virtual void setNetworkInputs(const InferenceEngine::InputsDataMap networkInputs) { - _networkInputs = networkInputs; - } - - /** - * @brief Sets the network outputs data. - * @param[in] networkOutputs The network outputs - */ - virtual void setNetworkOutputs(const InferenceEngine::OutputsDataMap networkOutputs) { - _networkOutputs = networkOutputs; - } - - ConstOutputsDataMap GetOutputsInfo() const override { - ConstOutputsDataMap outputMap; - for (const auto& output : _networkOutputs) { - outputMap[output.first] = output.second; - } - return outputMap; - } - - ConstInputsDataMap GetInputsInfo() const override { - ConstInputsDataMap inputMap; - for (const auto& input : _networkInputs) { - inputMap[input.first] = input.second; - } - return inputMap; - } - - void Export(const std::string& modelFileName) override { - // we need to write to stringstream first - // because in case of exception in ExportImpl the file is not created - std::stringstream strm; - ExportImpl(strm); - std::ofstream(modelFileName.c_str()) << strm.rdbuf(); - } - - void Export(std::ostream& networkModel) override { - std::stringstream strm; - strm.write(exportMagic.data(), exportMagic.size()); - strm << _plugin->GetName() << std::endl; - ExportImpl(strm); - networkModel << strm.rdbuf(); - } - - CNNNetwork GetExecGraphInfo() override { - IE_THROW(NotImplemented); - } - - /** - * @brief Sets the pointer to plugin internal. - * @param[in] plugin The plugin - * @note Needed to correctly handle ownership between objects. - */ - virtual void SetPointerToPlugin(const IInferencePlugin::Ptr& plugin) { - _plugin = plugin; - } - - std::vector QueryState() override { - IE_THROW(NotImplemented); - } - - void SetConfig(const std::map& config) override { - if (config.empty()) { - IE_THROW() << "The list of configuration values is empty"; - } - IE_THROW() << "The following config value cannot be changed dynamically for ExecutableNetwork: " - << config.begin()->first; - } - - Parameter GetConfig(const std::string& name) const override { - (void)name; - IE_THROW() << "GetConfig for executable network is not supported by this device"; - } - - Parameter GetMetric(const std::string& name) const override { - (void)name; - IE_THROW(NotImplemented); - } - - RemoteContext::Ptr GetContext() const override { - IE_THROW(NotImplemented); - } - - /** - * @brief Creates an inference request public implementation. - * @return The request public implementation - */ - IInferRequestInternal::Ptr CreateInferRequest() override { - auto asyncRequestImpl = this->CreateInferRequestImpl(_networkInputs, _networkOutputs); - asyncRequestImpl->setPointerToExecutableNetworkInternal(shared_from_this()); - return asyncRequestImpl; - } - -protected: - /** - * @brief Creates an asynchronous inference request internal implementation. - * @note The method is called by ExecutableNetworkInternal::CreateInferRequest as - * plugin-specific implementation. - * @param[in] networkInputs The network inputs - * @param[in] networkOutputs The network outputs - * @return A shared pointer to asynchnous inference request object. - */ - virtual IInferRequestInternal::Ptr CreateInferRequestImpl(InputsDataMap networkInputs, - OutputsDataMap networkOutputs) = 0; - - /** - * @brief Exports an internal hardware-dependent model to a stream. - * @note The function is called from ExecutableNetworkInternal::Export(std::ostream&), - * which performs common export first and calls this plugin-dependent implementation after. - * @param networkModel A stream to export network to. - */ - virtual void ExportImpl(std::ostream& networkModel) { - (void)networkModel; - IE_THROW(NotImplemented); - } - - InferenceEngine::InputsDataMap _networkInputs; //!< Holds information about network inputs info - InferenceEngine::OutputsDataMap _networkOutputs; //!< Holds information about network outputs data - - /** - * @brief A pointer to a IInferencePlugin interface. - * @note Needed to correctly handle ownership between objects. - */ - IInferencePlugin::Ptr _plugin; -}; - -} // namespace InferenceEngine diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_thread_safe_default.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_thread_safe_default.hpp index d209b2061a7..594d596a072 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_thread_safe_default.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_executable_network_thread_safe_default.hpp @@ -9,7 +9,7 @@ #include #include -#include "cpp_interfaces/impl/ie_executable_network_internal.hpp" +#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" #include "cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp" #include "threading/ie_cpu_streams_executor.hpp" @@ -20,7 +20,7 @@ namespace InferenceEngine { * The class is recommended to be used as a base class for Executable Network impleentation during plugin development. * @ingroup ie_dev_api_exec_network_api */ -class ExecutableNetworkThreadSafeDefault : public ExecutableNetworkInternal { +class ExecutableNetworkThreadSafeDefault : public IExecutableNetworkInternal { public: /** * @brief A shared pointer to a ExecutableNetworkThreadSafeDefault object diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_plugin_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_plugin_internal.hpp deleted file mode 100644 index 26ad8073706..00000000000 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_plugin_internal.hpp +++ /dev/null @@ -1,232 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief Inference Engine plugin API wrapper, to be used by particular implementors - * @file ie_plugin_internal.hpp - */ - -#pragma once - -#include - -#include -#include -#include -#include - -#include "cpp_interfaces/impl/ie_executable_network_internal.hpp" -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" -#include "cpp_interfaces/plugin_itt.hpp" - -namespace InferenceEngine { - -namespace { - -/** - * @private - */ -static inline void parsePluginName(std::istream& networkModel) { - ExportMagic magic = {}; - auto currentPos = networkModel.tellg(); - networkModel.read(magic.data(), magic.size()); - auto exportedWithName = (exportMagic == magic); - if (exportedWithName) { - networkModel.ignore(std::numeric_limits::max(), '\n'); - } else { - networkModel.seekg(currentPos, networkModel.beg); - } -} - -} // namespace - -/** - * @brief Optimal implementation of IInferencePlugin interface to avoid duplication in all plugins - * @ingroup ie_dev_api_plugin_api - */ -class InferencePluginInternal : public IInferencePlugin { -public: - IExecutableNetworkInternal::Ptr LoadNetwork(const CNNNetwork& network, - const std::map& config) override { - return LoadNetwork(network, config, nullptr); - } - - IExecutableNetworkInternal::Ptr LoadNetwork(const CNNNetwork& network, const std::map& config, - RemoteContext::Ptr context) override { - ExecutableNetworkInternal::Ptr impl; - if (nullptr == context) { - impl = LoadExeNetworkImpl(network, config); - } else { - impl = LoadExeNetworkImpl(network, context, config); - } - - SetExeNetworkInfo(impl, network.getInputsInfo(), network.getOutputsInfo()); - - return impl; - } - - // NOTE: - // In case of overloading this method, make sure that executable network - // has correctly setNetworkInputs/setNetworkOutputs/SetPointerToPlugin - // Base implementation does this via GetCore()->LoadNetwork(cnnNet) - IExecutableNetworkInternal::Ptr LoadNetwork(const std::string& modelPath, - const std::map& config) override { - auto cnnNet = GetCore()->ReadNetwork(modelPath, std::string()); - return GetCore()->LoadNetwork(cnnNet, GetName(), config); - } - - IExecutableNetworkInternal::Ptr ImportNetwork(const std::string& modelFileName, - const std::map& config) override { - (void)modelFileName; - (void)config; - IE_THROW(NotImplemented); - } - - IExecutableNetworkInternal::Ptr ImportNetwork(std::istream& networkModel, - const std::map& config) override { - parsePluginName(networkModel); - return ImportNetworkImpl(networkModel, config); - } - - IExecutableNetworkInternal::Ptr ImportNetwork(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config) override { - parsePluginName(networkModel); - return ImportNetworkImpl(networkModel, context, config); - } - - void SetConfig(const std::map& config) override { - (void)config; - IE_THROW(NotImplemented); - } - - void SetCore(ICore* core) noexcept override { - assert(nullptr != core); - _core = core; - } - - ICore* GetCore() const noexcept override { - return _core; - } - - void AddExtension(InferenceEngine::IExtensionPtr /*extension*/) override { - IE_THROW(NotImplemented); - } - - QueryNetworkResult QueryNetwork(const CNNNetwork& /*network*/, const std::map& /*config*/) const override { - IE_THROW(NotImplemented); - } - - void SetName(const std::string& pluginName) noexcept override { - _pluginName = pluginName; - } - - std::string GetName() const noexcept override { - return _pluginName; - } - - Parameter GetConfig(const std::string& /*name*/, - const std::map& /*options*/) const override { - IE_THROW(NotImplemented); - } - - Parameter GetMetric(const std::string& /*name*/, - const std::map& /*options*/) const override { - IE_THROW(NotImplemented); - } - - RemoteContext::Ptr CreateContext(const ParamMap& /*params*/) override { - IE_THROW(NotImplemented); - } - - RemoteContext::Ptr GetDefaultContext(const ParamMap& /*params*/) override { - IE_THROW(NotImplemented); - } - -protected: - /** - * @brief Creates an executable network from a parsed network object, users can create as many networks as they need - * and use them simultaneously (up to the limitation of the HW resources) - * @note The function is used in - * InferencePluginInternal::LoadNetwork(const CNNNetwork&, const std::map&) - * which performs common steps first and calls this plugin-dependent method implementation after. - * @param network A network object - * @param config string-string map of config parameters relevant only for this load operation - * @return Shared pointer to the ExecutableNetwork object - */ - virtual ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const CNNNetwork& network, - const std::map& config) = 0; - - /** - * @brief Creates an executable network using remote context from a parsed network object, - * users can create as many networks as they need and use them simultaneously (up to the limitation of the HW resources) - * @note The function is used in - * InferencePluginInternal::LoadNetwork(const CNNNetwork&, const std::map&, RemoteContext::Ptr) - * which performs common steps first and calls this plugin-dependent method implementation after. - * @param network A network object - * @param context A remote context - * @param config string-string map of config parameters relevant only for this load operation - * @return Shared pointer to the ExecutableNetwork object - */ - virtual ExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const CNNNetwork& network, RemoteContext::Ptr context, - const std::map& config) { - (void)network; - (void)context; - (void)config; - IE_THROW(NotImplemented); - } - - /** - * @brief Creates an executable network from an previously exported network - * @note The function is called from - * IInferencePlugin::ImportNetwork(std::istream&, const RemoteContext::Ptr&, const std::map&) - * performs common steps first and calls this plugin-dependent implementation after. - * @param networkModel Reference to network model output stream - * @param config A string -> string map of parameters - * @return An Executable network - */ - virtual ExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& networkModel, - const std::map& config) { - (void)networkModel; - (void)config; - IE_THROW(NotImplemented); - } - - /** - * @brief Imports network wit RemoteContext - * @param networkModel Reference to network model output stream - * @param context - a pointer to plugin context derived from RemoteContext class used to - * execute the network - * @param config A string -> string map of parameters - * @return An Executable network - */ - virtual ExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config) { - (void)networkModel; - (void)context; - (void)config; - IE_THROW(NotImplemented); - } - - template - void SetExeNetworkInfo(const InferenceEngine::ExecutableNetworkInternal::Ptr& exeNetwork, - const std::map >& inputs, - const std::map >& 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 _config; //!< A map config keys -> values - ICore* _core = nullptr; //!< A pointer to ICore interface -}; - -} // namespace InferenceEngine diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_variable_state_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_variable_state_internal.hpp deleted file mode 100644 index b993e5db61c..00000000000 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_variable_state_internal.hpp +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include - -namespace InferenceEngine { - -/** - * @brief Minimal interface for variable state implementation - * @ingroup ie_dev_api_variable_state_api - */ -class VariableStateInternal : public IVariableStateInternal { - std::string name; - Blob::Ptr state; - -public: - /** - * @brief Constructs a variable state with a given name - * @param name A name of variable state - */ - explicit VariableStateInternal(std::string name) : name(name) {} - - /** - * @brief Gets a variable state name - * @return A string representing variable state name - */ - std::string GetName() const override { - return name; - } - - /** - * @brief Sets the new state for the next inference - * @param newState A new state - */ - void SetState(Blob::Ptr newState) override { - state = newState; - } - - /** - * @brief Returns the value of the variable state. - * @return The value of the variable state - */ - Blob::CPtr GetState() const override { - return state; - } -}; - -/** - * @brief For compatibility reasons. - */ -using MemoryStateInternal = VariableStateInternal; - -} // namespace InferenceEngine diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp index da55b2896c2..58951410383 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iexecutable_network_internal.hpp @@ -17,99 +17,145 @@ namespace InferenceEngine { +class IInferencePlugin; class IInferRequestInternal; +class RemoteContext; +class IVariableStateInternal; /** * @interface IExecutableNetworkInternal * @brief An internal API of executable network to be implemented by plugin, * @ingroup ie_dev_api_exec_network_api */ -class IExecutableNetworkInternal : public std::enable_shared_from_this { +class INFERENCE_ENGINE_API_CLASS(IExecutableNetworkInternal) : public std::enable_shared_from_this { public: /** * @brief A shared pointer to IExecutableNetworkInternal interface */ - typedef std::shared_ptr Ptr; + using Ptr = std::shared_ptr; /** - * @brief Destroys the object. + * @brief Sets the network inputs info. + * @param[in] networkInputs The network inputs info */ - virtual ~IExecutableNetworkInternal() = default; + virtual void setNetworkInputs(const InputsDataMap& networkInputs); + + /** + * @brief Sets the network outputs data. + * @param[in] networkOutputs The network outputs + */ + virtual void setNetworkOutputs(const OutputsDataMap& networkOutputs); /** * @brief Gets the Executable network output Data node information. The received info is stored in the given Data - * node. This method need to be called to find output names for using them later during filling of a map of blobs - * passed later to InferenceEngine::IInferencePlugin::Infer() + * node. * @return out Reference to the ConstOutputsDataMap object */ - virtual ConstOutputsDataMap GetOutputsInfo() const = 0; + virtual ConstOutputsDataMap GetOutputsInfo() const; /** * @brief Gets the Executable network input Data node information. The received info is stored in the given - * InputsDataMap object. This method need to be called to find out input names for using them later during filling - * of a map of blobs passed later to InferenceEngine::IInferencePlugin::Infer() + * InputsDataMap object. * @return inputs Reference to ConstInputsDataMap object. */ - virtual ConstInputsDataMap GetInputsInfo() const = 0; + virtual ConstInputsDataMap GetInputsInfo() const; /** * @brief Create an inference request object used to infer the network * Note: the returned request will have allocated input and output blobs (that can be changed later) * @return shared_ptr for the created request */ - virtual std::shared_ptr CreateInferRequest() = 0; + virtual std::shared_ptr CreateInferRequest(); /** * @deprecated Use IExecutableNetworkInternal::Export(std::ostream& networkModel) * @brief Export the current created executable network so it can be used later in the Import() main API * @param modelFileName - path to the location of the exported file */ - virtual void Export(const std::string& modelFileName) = 0; + virtual void Export(const std::string& modelFileName); /** * @brief Export the current created executable network so it can be used later in the Import() main API * @param networkModel - Reference to network model output stream */ - virtual void Export(std::ostream& networkModel) = 0; + virtual void Export(std::ostream& networkModel); /** * @brief Get executable graph information from a device * @return A network object to store executable graph information */ - virtual CNNNetwork GetExecGraphInfo() = 0; + virtual CNNNetwork GetExecGraphInfo(); /** * @deprecated Need to implement GetVariablesInfo for ExecutableNetwork * @brief Queries memory states. * @return Returns memory states */ - virtual std::vector QueryState() = 0; + virtual std::vector> QueryState(); + + /** + * @brief Sets the pointer to plugin internal. + * @param[in] plugin The plugin + * @note Needed to correctly handle ownership between objects. + */ + virtual void SetPointerToPlugin(const std::shared_ptr& plugin); /** * @brief Sets configuration for current executable network * @param config Map of pairs: (config parameter name, config parameter value) */ - virtual void SetConfig(const std::map& config) = 0; + virtual void SetConfig(const std::map& config); /** * @brief Gets configuration dedicated to plugin behaviour * @param name A config key, can be found in ie_plugin_config.hpp * @return A value of config corresponding to config key */ - virtual Parameter GetConfig(const std::string& name) const = 0; + virtual Parameter GetConfig(const std::string& name) const; /** * @brief Gets general runtime metric for dedicated hardware * @param name A metric name to request * @return A metric value corresponding to metric key */ - virtual Parameter GetMetric(const std::string& name) const = 0; + virtual Parameter GetMetric(const std::string& name) const; /** * @brief Gets the remote context. * @return A reference to a context */ - virtual RemoteContext::Ptr GetContext() const = 0; + virtual std::shared_ptr GetContext() const; + +protected: + ~IExecutableNetworkInternal() = default; + + /** + * @brief Creates an inference request internal implementation. + * @note The method is called by IExecutableNetworkInternal::CreateInferRequest as + * plugin-specific implementation. + * @param[in] networkInputs The network inputs + * @param[in] networkOutputs The network outputs + * @return A shared pointer to inference request object. + */ + virtual std::shared_ptr CreateInferRequestImpl(InputsDataMap networkInputs, + OutputsDataMap networkOutputs); + + /** + * @brief Exports an internal hardware-dependent model to a stream. + * @note The function is called from IExecutableNetworkInternal::Export(std::ostream&), + * which performs common export first and calls this plugin-dependent implementation after. + * @param networkModel A stream to export network to. + */ + virtual void ExportImpl(std::ostream& networkModel); + + InferenceEngine::InputsDataMap _networkInputs; //!< Holds information about network inputs info + InferenceEngine::OutputsDataMap _networkOutputs; //!< Holds information about network outputs data + + /** + * @brief A pointer to a IInferencePlugin interface. + * @note Needed to correctly handle ownership between objects. + */ + std::shared_ptr _plugin; }; /** diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp index 9bf6c64e349..22c2f7e1c08 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iplugin_internal.hpp @@ -11,9 +11,8 @@ #include #include -#include #include -#include +#include #include @@ -24,93 +23,79 @@ namespace InferenceEngine { +class ICore; class IExecutableNetworkInternal; +class RemoteContext; +class IExtension; /** * @brief Copies preprocess info * * @param[in] from PreProcessInfo to copy from - * @param to PreProcessInfo to copy to + * @return copy of preprocess info */ -inline void copyPreProcess(const PreProcessInfo& from, PreProcessInfo& to) { - to = from; - if (from.getMeanVariant() == MEAN_IMAGE) { - for (size_t i = 0; i < from.getNumberOfChannels(); i++) { - auto& from_blob = from[i]->meanData; - auto to_blob = make_blob_with_precision(from[i]->meanData->getTensorDesc()); - to_blob->allocate(); - ie_memcpy(to_blob->buffer(), to_blob->byteSize(), from_blob->cbuffer(), from_blob->byteSize()); +INFERENCE_ENGINE_API_CPP(PreProcessInfo) copyPreProcess(const PreProcessInfo& from); - to.setMeanImageForChannel(to_blob, i); - } - } +/** + * @brief Copies the values of `std::string` indexed map and apply const cast + * + * @param[in] map map to copy + * @return map that contains pointers to constant values + */ +template +std::map> constMapCast(const std::map>& map) { + std::map> res; + for (auto&& v : map) res.emplace(v.first, std::const_pointer_cast(v.second)); + return res; } /** - * @brief Copies InputInfo and output Data + * @brief Copies the values of `std::string` indexed map and apply const cast + * + * @param[in] map map to copy + * @return map that contains pointers to values + */ +template +std::map> constMapCast(const std::map>& map) { + std::map> res; + for (auto&& v : map) res.emplace(v.first, std::const_pointer_cast(v.second)); + return res; +} + +/** + * @brief Copies InputInfo * * @param[in] networkInputs The network inputs to copy from - * @param[in] networkOutputs The network outputs to copy from - * @param _networkInputs The network inputs to copy to - * @param _networkOutputs The network outputs to copy to + * @return copy of network inputs */ -template -inline void copyInputOutputInfo(const std::map > & networkInputs, - const std::map > & networkOutputs, - InputsDataMap & _networkInputs, OutputsDataMap & _networkOutputs) { - _networkInputs.clear(); - _networkOutputs.clear(); +INFERENCE_ENGINE_API_CPP(InputsDataMap) copyInfo(const InputsDataMap& networkInputs); - for (const auto& it : networkInputs) { - InputInfo::Ptr newPtr; - if (it.second) { - newPtr.reset(new InputInfo()); - copyPreProcess(it.second->getPreProcess(), newPtr->getPreProcess()); - DataPtr newData(new Data(*it.second->getInputData())); - newPtr->setInputData(newData); - } - _networkInputs[it.first] = newPtr; - } - for (const auto& it : networkOutputs) { - DataPtr newData; - if (it.second) { - newData.reset(new Data(*it.second)); - } - _networkOutputs[it.first] = newData; - } -} +/** + * @brief Copies OutputsData + * + * @param[in] networkInputs network outputs to copy from + * @return copy of network outputs + */ +INFERENCE_ENGINE_API_CPP(OutputsDataMap) copyInfo(const OutputsDataMap& networkOutputs); /** * @interface IInferencePlugin * @brief An API of plugin to be implemented by a plugin * @ingroup ie_dev_api_plugin_api */ -class IInferencePlugin : public std::enable_shared_from_this { +class INFERENCE_ENGINE_API_CLASS(IInferencePlugin) : public std::enable_shared_from_this { class VersionStore : public Version { std::string _dsc; std::string _buildNumber; - void copyFrom(const Version & v) { - _dsc = v.description; - _buildNumber = v.buildNumber; - description = _dsc.c_str(); - buildNumber = _buildNumber.c_str(); - apiVersion = v.apiVersion; - } + void copyFrom(const Version& v); public: VersionStore() = default; - explicit VersionStore(const Version& v) { - copyFrom(v); - } + explicit VersionStore(const Version& v); - VersionStore & operator = (const VersionStore & v) { - if (&v != this) { - copyFrom(v); - } - return *this; - } + VersionStore& operator=(const VersionStore& v); } _version; public: @@ -123,29 +108,25 @@ public: * @brief Sets a plugin version * @param version A version to set */ - void SetVersion(const Version & version) { - _version = VersionStore(version); - } + void SetVersion(const Version & version); /** * @brief Gets a plugin version * @return A const InferenceEngine::Version object */ - Version GetVersion() const { - return _version; - } + const Version& GetVersion() const; /** * @brief Provides a name of a plugin * @return The name. */ - virtual std::string GetName() const noexcept = 0; + virtual std::string GetName() const noexcept; /** - * @brief Sets a name for a plugin + * @brief Sets a name for a plugin * @param[in] name The name */ - virtual void SetName(const std::string& name) noexcept = 0; + virtual void SetName(const std::string& name) noexcept; /** * @brief Creates an executable network from an pares network object, users can create as many networks as they need @@ -155,7 +136,7 @@ public: * @return Created Executable Network object */ virtual std::shared_ptr LoadNetwork(const CNNNetwork& network, - const std::map& config) = 0; + const std::map& config); /** * @brief Creates an executable network from network object, on specified remote context @@ -167,7 +148,7 @@ public: */ virtual std::shared_ptr LoadNetwork(const CNNNetwork& network, const std::map& config, - RemoteContext::Ptr context) = 0; + const std::shared_ptr& context); /** * @brief Creates an executable network from model file path @@ -176,19 +157,19 @@ public: * @return Created Executable Network object */ virtual std::shared_ptr LoadNetwork(const std::string& modelPath, - const std::map& config) = 0; + const std::map& config); /** * @brief Registers extension within plugin * @param extension - pointer to already loaded extension */ - virtual void AddExtension(InferenceEngine::IExtensionPtr extension) = 0; + virtual void AddExtension(const std::shared_ptr& extension); /** * @brief Sets configuration for plugin, acceptable keys can be found in ie_plugin_config.hpp * @param config string-string map of config parameters */ - virtual void SetConfig(const std::map& config) = 0; + virtual void SetConfig(const std::map& config); /** * @brief Gets configuration dedicated to plugin behaviour @@ -196,7 +177,7 @@ public: * @param options - configuration details for config * @return Value of config corresponding to config key */ - virtual Parameter GetConfig(const std::string& name, const std::map& options) const = 0; + virtual Parameter GetConfig(const std::string& name, const std::map& options) const; /** * @brief Gets general runtime metric for dedicated hardware @@ -204,21 +185,21 @@ public: * @param options - configuration details for metric * @return Metric value corresponding to metric key */ - virtual Parameter GetMetric(const std::string& name, const std::map& options) const = 0; + virtual Parameter GetMetric(const std::string& name, const std::map& options) const; /** * @brief Creates a remote context instance based on a map of parameters * @param[in] params The map of parameters * @return A remote context object */ - virtual RemoteContext::Ptr CreateContext(const ParamMap& params) = 0; + virtual std::shared_ptr CreateContext(const ParamMap& params); /** * @brief Provides a default remote context instance if supported by a plugin * @param[in] params The map of parameters * @return The default context. */ - virtual RemoteContext::Ptr GetDefaultContext(const ParamMap& params) = 0; + virtual std::shared_ptr GetDefaultContext(const ParamMap& params); /** * @deprecated Use ImportNetwork(std::istream& networkModel, const std::map& config) @@ -228,7 +209,7 @@ public: * @return An Executable network */ virtual std::shared_ptr ImportNetwork(const std::string& modelFileName, - const std::map& config) = 0; + const std::map& config); /** * @brief Creates an executable network from an previously exported network using plugin implementation @@ -238,7 +219,7 @@ public: * @return An Executable network */ virtual std::shared_ptr ImportNetwork(std::istream& networkModel, - const std::map& config) = 0; + const std::map& config); /** * @brief Creates an executable network from an previously exported network using plugin implementation @@ -250,20 +231,20 @@ public: * @return An Executable network */ virtual std::shared_ptr ImportNetwork(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config) = 0; + const std::shared_ptr& context, + const std::map& config); /** * @brief Sets pointer to ICore interface * @param core Pointer to Core interface */ - virtual void SetCore(ICore* core) noexcept = 0; + virtual void SetCore(ICore* core); /** * @brief Gets reference to ICore interface * @return Reference to ICore interface */ - virtual ICore* GetCore() const noexcept = 0; + virtual ICore* GetCore() const noexcept; /** * @brief Queries a plugin about supported layers in network @@ -271,10 +252,70 @@ public: * @param[in] config The map of configuration parameters * @return The result of query operator containing supported layers map */ - virtual QueryNetworkResult QueryNetwork(const CNNNetwork& network, const std::map& config) const = 0; + virtual QueryNetworkResult QueryNetwork(const CNNNetwork& network, const std::map& config) const; protected: ~IInferencePlugin() = default; + + /** + * @brief Creates an executable network from a parsed network object, users can create as many networks as they need + * and use them simultaneously (up to the limitation of the HW resources) + * @note The function is used in + * InferencePluginInternal::LoadNetwork(const CNNNetwork&, const std::map&) + * which performs common steps first and calls this plugin-dependent method implementation after. + * @param network A network object + * @param config string-string map of config parameters relevant only for this load operation + * @return Shared pointer to the ExecutableNetwork object + */ + virtual std::shared_ptr LoadExeNetworkImpl(const CNNNetwork& network, + const std::map& config); + + /** + * @brief Creates an executable network using remote context from a parsed network object, + * users can create as many networks as they need and use them simultaneously (up to the limitation of the HW resources) + * @note The function is used in + * InferencePluginInternal::LoadNetwork(const CNNNetwork&, const std::map&, RemoteContext::Ptr) + * which performs common steps first and calls this plugin-dependent method implementation after. + * @param network A network object + * @param context A remote context + * @param config string-string map of config parameters relevant only for this load operation + * @return Shared pointer to the ExecutableNetwork object + */ + virtual std::shared_ptr LoadExeNetworkImpl(const CNNNetwork& network, + const std::shared_ptr& context, + const std::map& config); + + /** + * @brief Creates an executable network from an previously exported network + * @note The function is called from + * IInferencePlugin::ImportNetwork(std::istream&, const RemoteContext::Ptr&, const std::map&) + * performs common steps first and calls this plugin-dependent implementation after. + * @param networkModel Reference to network model output stream + * @param config A string -> string map of parameters + * @return An Executable network + */ + virtual std::shared_ptr ImportNetworkImpl(std::istream& networkModel, + const std::map& config); + + /** + * @brief Imports network wit RemoteContext + * @param networkModel Reference to network model output stream + * @param context - a pointer to plugin context derived from RemoteContext class used to + * execute the network + * @param config A string -> string map of parameters + * @return An Executable network + */ + virtual std::shared_ptr ImportNetworkImpl(std::istream& networkModel, + const std::shared_ptr& context, + const std::map& config); + + void SetExeNetworkInfo(const std::shared_ptr& exeNetwork, + const ConstInputsDataMap& inputs, + const ConstOutputsDataMap& outputs); + + std::string _pluginName; //!< A device name that plugins enables + std::map _config; //!< A map config keys -> values + ICore* _core = nullptr; //!< A pointer to ICore interface }; namespace details { @@ -299,9 +340,9 @@ public: } catch (const InferenceEngine::Exception&) { \ throw; \ } catch (const std::exception& ex) { \ - IE_THROW() << ex.what(); \ + IE_THROW() << ex.what(); \ } catch (...) { \ - IE_THROW(Unexpected); \ + IE_THROW(Unexpected); \ } \ plugin->SetVersion(version); \ } diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp index 279ae854f73..f92fd556f00 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_ivariable_state_internal.hpp @@ -17,41 +17,38 @@ namespace InferenceEngine { * @brief Minimal interface for variable state implementation * @ingroup ie_dev_api_variable_state_api */ -class IVariableStateInternal { +class INFERENCE_ENGINE_API_CLASS(IVariableStateInternal) : public std::enable_shared_from_this { public: /** * @brief A shared pointer to a IVariableStateInternal interface */ using Ptr = std::shared_ptr; - /** - * @brief A default virtual dtor - */ - virtual ~IVariableStateInternal() = default; + explicit IVariableStateInternal(const std::string& name); /** * @brief Gets a variable state name * @return A string representing variable state name */ - virtual std::string GetName() const = 0; + virtual std::string GetName() const; /** * @brief Reset internal variable state for relevant infer request, to a value specified as * default for according `ReadValue` node */ - virtual void Reset() = 0; + virtual void Reset(); /** * @brief Sets the new state for the next inference * @param newState A new state */ - virtual void SetState(Blob::Ptr newState) = 0; + virtual void SetState(const Blob::Ptr& newState); /** * @brief Returns the value of the variable state. * @return The value of the variable state */ - virtual Blob::CPtr GetState() const = 0; + virtual Blob::CPtr GetState() const; /** * @deprecated Use IVariableStateInternal::GetState method instead @@ -59,9 +56,16 @@ public: * @return The value of the variable state */ INFERENCE_ENGINE_DEPRECATED("Use IVariableStateInternal::GetState method instead") - virtual Blob::CPtr GetLastState() const { - return GetState(); - } + virtual Blob::CPtr GetLastState() const; + +protected: + /** + * @brief A default dtor + */ + ~IVariableStateInternal() = default; + + std::string name; + Blob::Ptr state; }; /** @@ -74,4 +78,9 @@ using IMemoryStateInternal = IVariableStateInternal; */ using SoIVariableStateInternal = details::SOPointer; +/** + * @brief For compatibility reasons. + */ +using MemoryStateInternal = IVariableStateInternal; + } // namespace InferenceEngine diff --git a/inference-engine/src/plugin_api/ie_icore.hpp b/inference-engine/src/plugin_api/ie_icore.hpp index 02b941dcbf4..70d7aaff3a5 100644 --- a/inference-engine/src/plugin_api/ie_icore.hpp +++ b/inference-engine/src/plugin_api/ie_icore.hpp @@ -63,7 +63,8 @@ public: * operation * @return An executable network reference */ - virtual SoExecutableNetworkInternal LoadNetwork(const CNNNetwork& network, const std::string& deviceName, + virtual SoExecutableNetworkInternal LoadNetwork(const CNNNetwork& network, + const std::string& deviceName, const std::map& config = {}) = 0; /** @@ -78,7 +79,8 @@ public: * operation * @return An executable network reference */ - virtual SoExecutableNetworkInternal LoadNetwork(const std::string& modelPath, const std::string& deviceName, + virtual SoExecutableNetworkInternal LoadNetwork(const std::string& modelPath, + const std::string& deviceName, const std::map& config) = 0; /** @@ -89,7 +91,8 @@ public: * operation* * @return An executable network reference */ - virtual SoExecutableNetworkInternal ImportNetwork(std::istream& networkModel, const std::string& deviceName = {}, + virtual SoExecutableNetworkInternal ImportNetwork(std::istream& networkModel, + const std::string& deviceName = {}, const std::map& config = {}) = 0; /** diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp index b143e78c121..020a3d9e580 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h index 4055c64033e..667b93b6aae 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_infer_request.h @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp index 0f9d27fb28e..f61b9fbf7fb 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -29,7 +29,7 @@ using namespace InferenceEngine::VPUConfigParams; using namespace vpu::MyriadPlugin; -ExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl( +IExecutableNetworkInternal::Ptr Engine::LoadExeNetworkImpl( const CNNNetwork& network, const std::map& config) { VPU_PROFILE(LoadExeNetworkImpl); diff --git a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h index 3fb619a8a1b..07349f637e2 100644 --- a/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h +++ b/inference-engine/src/vpu/myriad_plugin/myriad_plugin.h @@ -12,12 +12,12 @@ #include #include #include -#include +#include namespace vpu { namespace MyriadPlugin { -class Engine : public ie::InferencePluginInternal { +class Engine : public ie::IInferencePlugin { public: explicit Engine(std::shared_ptr mvnc); @@ -27,7 +27,7 @@ public: void SetConfig(const std::map& config) override; - ie::ExecutableNetworkInternal::Ptr LoadExeNetworkImpl( + ie::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl( const ie::CNNNetwork& network, const std::map& config) override; @@ -35,7 +35,7 @@ public: const ie::CNNNetwork& network, const std::map& config) const override; - using ie::InferencePluginInternal::ImportNetwork; + using ie::IInferencePlugin::ImportNetwork; ie::IExecutableNetworkInternal::Ptr ImportNetwork( const std::string& modelFileName, diff --git a/inference-engine/tests/functional/inference_engine/caching_test.cpp b/inference-engine/tests/functional/inference_engine/caching_test.cpp index cdd5d2efa53..8aefaec7d22 100644 --- a/inference-engine/tests/functional/inference_engine/caching_test.cpp +++ b/inference-engine/tests/functional/inference_engine/caching_test.cpp @@ -17,8 +17,8 @@ #include "details/ie_so_loader.h" #include "ie_metric_helpers.hpp" -#include "cpp_interfaces/impl/ie_executable_network_internal.hpp" -#include "cpp_interfaces/impl/ie_plugin_internal.hpp" +#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" +#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" #include "common_test_utils/unicode_utils.hpp" #include "common_test_utils/file_utils.hpp" @@ -69,7 +69,7 @@ public: MOCK_QUALIFIED_METHOD0(getParams, const, ParamMap()); }; -class MockCachingInferencePluginBase : public InferenceEngine::InferencePluginInternal { +class MockCachingInferencePluginBase : public InferenceEngine::IInferencePlugin { public: MockCachingInferencePluginBase() = default; ~MockCachingInferencePluginBase() = default; @@ -80,7 +80,7 @@ public: // Thus, we define a proxy callback and will use // EXPECT_CALL(OnLoadNetworkFromFile) instead of EXPECT_CALL(LoadNetwork) OnLoadNetworkFromFile(); - return InferenceEngine::InferencePluginInternal::LoadNetwork(modelPath, config); + return InferenceEngine::IInferencePlugin::LoadNetwork(modelPath, config); } virtual void OnLoadNetworkFromFile() const {} @@ -91,29 +91,30 @@ public: MockCachingInferencePlugin() = default; ~MockCachingInferencePlugin() = default; - MOCK_METHOD2(LoadExeNetworkImpl, ExecutableNetworkInternal::Ptr(const CNNNetwork& network, - const std::map& config)); + MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr(const CNNNetwork& network, + const std::map& config)); - MOCK_METHOD3(LoadExeNetworkImpl, ExecutableNetworkInternal::Ptr(const CNNNetwork& network, RemoteContext::Ptr context, - const std::map& config)); + MOCK_METHOD3(LoadExeNetworkImpl, std::shared_ptr(const CNNNetwork& network, + const RemoteContext::Ptr& context, + const std::map& config)); MOCK_CONST_METHOD0(OnLoadNetworkFromFile, void(void)); - MOCK_METHOD2(ImportNetworkImpl, ExecutableNetworkInternal::Ptr(std::istream& networkModel, - const std::map& config)); + MOCK_METHOD2(ImportNetworkImpl, std::shared_ptr(std::istream& networkModel, + const std::map& config)); - MOCK_METHOD3(ImportNetworkImpl, ExecutableNetworkInternal::Ptr(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config)); + MOCK_METHOD3(ImportNetworkImpl, std::shared_ptr(std::istream& networkModel, + const RemoteContext::Ptr& context, + const std::map& config)); MOCK_CONST_METHOD2(QueryNetwork, QueryNetworkResult(const CNNNetwork& network, - const std::map& config)); + const std::map& config)); MOCK_CONST_METHOD2(GetMetric, Parameter(const std::string& name, const std::map& options)); MOCK_METHOD1(GetDefaultContext, RemoteContext::Ptr(const ParamMap& params)); }; -class MockExecutableNetwork : public ExecutableNetworkInternal { +class MockExecutableNetwork : public IExecutableNetworkInternal { std::mutex m_pluginMutex; public: @@ -125,17 +126,17 @@ public: MOCK_CONST_METHOD1(GetConfig, Parameter(const std::string& name)); MOCK_CONST_METHOD1(GetMetric, Parameter(const std::string& name)); MOCK_METHOD2(CreateInferRequestImpl, IInferRequestInternal::Ptr(InputsDataMap, OutputsDataMap)); - MOCK_METHOD1(setNetworkInputs, void(const InputsDataMap networkInputs)); - MOCK_METHOD1(setNetworkOutputs, void(const OutputsDataMap networkOutputs)); + MOCK_METHOD1(setNetworkInputs, void(const InputsDataMap& networkInputs)); + MOCK_METHOD1(setNetworkOutputs, void(const OutputsDataMap& networkOutputs)); void Export(std::ostream& networkModel) override { std::lock_guard guard(m_pluginMutex); - ExecutableNetworkInternal::Export(networkModel); + IExecutableNetworkInternal::Export(networkModel); } void SetPointerToPlugin(const IInferencePlugin::Ptr& plugin) override { std::lock_guard guard(m_pluginMutex); - ExecutableNetworkInternal::SetPointerToPlugin(plugin); + IExecutableNetworkInternal::SetPointerToPlugin(plugin); } }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp index d437fa536af..676bf59b340 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mock.cpp @@ -12,7 +12,6 @@ #include "unit_test_utils/mocks/cpp_interfaces/mock_task_executor.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_async_infer_request_default.hpp" -#include "unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_network_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_network_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_network_internal.hpp deleted file mode 100644 index a605d65c551..00000000000 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_network_internal.hpp +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#pragma once - -#include -#include -#include - -#include "ie_input_info.hpp" -#include "cpp/ie_cnn_network.h" - -#include - -#include - -#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" - -using namespace InferenceEngine; - -class MockExecutableNetworkInternal : public ExecutableNetworkInternal { -public: - MOCK_METHOD1(setNetworkInputs, void(InputsDataMap)); - MOCK_METHOD1(setNetworkOutputs, void(OutputsDataMap)); - MOCK_METHOD0(CreateInferRequest, IInferRequestInternal::Ptr(void)); - MOCK_METHOD1(Export, void(const std::string &)); - MOCK_METHOD0(GetExecGraphInfo, CNNNetwork(void)); - void WrapOstreamExport(std::ostream& networkModel) { - ExecutableNetworkInternal::Export(networkModel); - } - const std::string exportString = "MockExecutableNetworkInternal"; - void ExportImpl(std::ostream& networkModel) override { - networkModel << exportString << std::endl; - } - MOCK_METHOD2(CreateInferRequestImpl, IInferRequestInternal::Ptr(InputsDataMap, OutputsDataMap)); -}; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp index 0e7fbac7a25..2a68e96c19e 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp @@ -7,17 +7,16 @@ #include #include -#include "mock_executable_network_internal.hpp" #include "ie_icore.hpp" #include #include #include -#include -#include +#include +#include -class MockInferencePluginInternal2 : public InferenceEngine::InferencePluginInternal { +class MockInferencePluginInternal2 : public InferenceEngine::IInferencePlugin { public: - MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( + MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( const InferenceEngine::CNNNetwork &, const std::map &)); MOCK_METHOD2(LoadNetwork, std::shared_ptr( const InferenceEngine::CNNNetwork &, @@ -26,16 +25,17 @@ public: MOCK_METHOD1(SetConfig, void(const std::map &)); }; -class MockInferencePluginInternal : public InferenceEngine::InferencePluginInternal { +class MockInferencePluginInternal : public InferenceEngine::IInferencePlugin { public: - MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( + MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( const InferenceEngine::CNNNetwork &, const std::map &)); MOCK_METHOD1(AddExtension, void(InferenceEngine::IExtensionPtr ext_ptr)); MOCK_METHOD1(SetConfig, void(const std::map &)); - using InferenceEngine::InferencePluginInternal::ImportNetwork; + using InferenceEngine::IInferencePlugin::ImportNetwork; - ExecutableNetworkInternal::Ptr ImportNetworkImpl(std::istream& stream, const std::map &) { + std::shared_ptr ImportNetworkImpl(std::istream& stream, + const std::map &) { std::getline(stream, importedString); return {}; } @@ -43,9 +43,9 @@ public: std::string importedString; }; -class MockInferencePluginInternal3 : public InferenceEngine::InferencePluginInternal { +class MockInferencePluginInternal3 : public InferenceEngine::IInferencePlugin { public: - MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( + MOCK_METHOD2(LoadExeNetworkImpl, std::shared_ptr( const InferenceEngine::CNNNetwork &, const std::map &)); MOCK_METHOD1(AddExtension, void(InferenceEngine::IExtensionPtr ext_ptr)); MOCK_METHOD1(SetConfig, void(const std::map &)); diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp index 32cd3485bd0..4e221be90f7 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp @@ -11,7 +11,7 @@ #include #include "ie_input_info.hpp" -#include +#include #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" @@ -31,4 +31,11 @@ public: MOCK_CONST_METHOD1(GetConfig, Parameter(const std::string &name)); MOCK_CONST_METHOD1(GetMetric, Parameter(const std::string &name)); MOCK_CONST_METHOD0(GetContext, RemoteContext::Ptr(void)); + void WrapOstreamExport(std::ostream& networkModel) { + IExecutableNetworkInternal::Export(networkModel); + } + const std::string exportString = "MockExecutableNetworkInternal"; + void ExportImpl(std::ostream& networkModel) override { + networkModel << exportString << std::endl; + } }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp index a5c1ada89d5..c31d1d1b5b6 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp @@ -10,7 +10,8 @@ #include #include -#include +#include +#include class MockIInferRequestInternal : public InferenceEngine::IInferRequestInternal { public: diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp index 98800d53dc9..f50238bdfe1 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp @@ -12,9 +12,10 @@ #include class MockIVariableStateInternal : public InferenceEngine::IVariableStateInternal { - public: +public: + MockIVariableStateInternal() : InferenceEngine::IVariableStateInternal{"MockIVariableStateInternal"} {} MOCK_CONST_METHOD0(GetName, std::string()); MOCK_METHOD0(Reset, void()); - MOCK_METHOD1(SetState, void(InferenceEngine::Blob::Ptr)); + MOCK_METHOD1(SetState, void(const InferenceEngine::Blob::Ptr&)); MOCK_CONST_METHOD0(GetState, InferenceEngine::Blob::CPtr()); }; diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp index a0d5b13dff8..a2b845b0c4a 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp @@ -40,8 +40,9 @@ MockPlugin::LoadNetwork(const CNNNetwork &network, } std::shared_ptr -MockPlugin::LoadNetwork(const CNNNetwork& network, const std::map& config, - RemoteContext::Ptr context) { +MockPlugin::LoadNetwork(const CNNNetwork& network, + const std::map& config, + const std::shared_ptr& context) { if (_target) { return _target->LoadNetwork(network, config, context); } else { @@ -49,44 +50,44 @@ MockPlugin::LoadNetwork(const CNNNetwork& network, const std::map MockPlugin::LoadNetwork(const std::string &modelPath, const std::map &config) { if (_target) { return _target->LoadNetwork(modelPath, config); } else { - return InferenceEngine::InferencePluginInternal::LoadNetwork(modelPath, config); + return InferenceEngine::IInferencePlugin::LoadNetwork(modelPath, config); } } -ExecutableNetworkInternal::Ptr +std::shared_ptr MockPlugin::LoadExeNetworkImpl(const CNNNetwork& network, const std::map& config) { return {}; } -InferenceEngine::ExecutableNetworkInternal::Ptr +std::shared_ptr MockPlugin::ImportNetworkImpl(std::istream& networkModel, const std::map& config) { if (_target) { - return std::static_pointer_cast(_target->ImportNetwork(networkModel, config)); + return _target->ImportNetwork(networkModel, config); } else { IE_THROW(NotImplemented); } } -InferenceEngine::ExecutableNetworkInternal::Ptr +std::shared_ptr MockPlugin::ImportNetworkImpl(std::istream& networkModel, - const InferenceEngine::RemoteContext::Ptr& context, + const std::shared_ptr& context, const std::map& config) { if (_target) { - return std::static_pointer_cast(_target->ImportNetwork(networkModel, context, config)); + return _target->ImportNetwork(networkModel, context, config); } else { IE_THROW(NotImplemented); } } -InferenceEngine::RemoteContext::Ptr MockPlugin::GetDefaultContext(const InferenceEngine::ParamMap& params) { +std::shared_ptr MockPlugin::GetDefaultContext(const InferenceEngine::ParamMap& params) { if (_target) { return _target->GetDefaultContext(params); } else { @@ -108,21 +109,21 @@ void MockPlugin::SetCore(InferenceEngine::ICore* core) noexcept { if (_target) { _target->SetCore(core); } - InferenceEngine::InferencePluginInternal::SetCore(core); + InferenceEngine::IInferencePlugin::SetCore(core); } void MockPlugin::SetName(const std::string& name) noexcept { if (_target) { _target->SetName(name); } - InferenceEngine::InferencePluginInternal::SetName(name); + InferenceEngine::IInferencePlugin::SetName(name); } std::string MockPlugin::GetName() const noexcept { if (_target) { return _target->GetName(); } - return InferenceEngine::InferencePluginInternal::GetName(); + return InferenceEngine::IInferencePlugin::GetName(); } diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp index 9401a9bd39b..c01a8a8d175 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp @@ -7,9 +7,9 @@ #include #include -#include +#include -class MockPlugin : public InferenceEngine::InferencePluginInternal { +class MockPlugin : public InferenceEngine::IInferencePlugin { InferenceEngine::IInferencePlugin * _target = nullptr; public: @@ -24,29 +24,29 @@ public: std::shared_ptr LoadNetwork(const InferenceEngine::CNNNetwork& network, const std::map& config, - InferenceEngine::RemoteContext::Ptr context) override; + const std::shared_ptr& context) override; - std::shared_ptr + std::shared_ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, const std::map& config) override; - InferenceEngine::IExecutableNetworkInternal::Ptr + std::shared_ptr LoadNetwork(const std::string &modelPath, const std::map &config) override; - std::shared_ptr + std::shared_ptr ImportNetworkImpl(std::istream& networkModel, const std::map& config) override; - std::shared_ptr + std::shared_ptr ImportNetworkImpl(std::istream& networkModel, - const InferenceEngine::RemoteContext::Ptr& context, - const std::map& config) override; + const std::shared_ptr& context, + const std::map& config) override; InferenceEngine::Parameter GetMetric(const std::string& name, const std::map& options) const override; - InferenceEngine::RemoteContext::Ptr GetDefaultContext(const InferenceEngine::ParamMap& params) override; + std::shared_ptr GetDefaultContext(const InferenceEngine::ParamMap& params) override; InferenceEngine::QueryNetworkResult QueryNetwork(const InferenceEngine::CNNNetwork& network, const std::map& config) const override; diff --git a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp index 6867cb92b26..83712bf6fd5 100644 --- a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp +++ b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_memory_state_internal_test.cpp @@ -202,19 +202,20 @@ TEST_F(VariableStateTests, VariableStateCanPropagateGetLastState) { IE_SUPPRESS_DEPRECATED_END } -class VariableStateInternalMockImpl : public VariableStateInternal { +class VariableStateInternalMockImpl : public IVariableStateInternal { public: - using VariableStateInternal::VariableStateInternal; + VariableStateInternalMockImpl(const char* name) : IVariableStateInternal(name) {} MOCK_METHOD0(Reset, void()); }; + TEST_F(VariableStateTests, VariableStateInternalCanSaveName) { - IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("name")); - ASSERT_STREQ(pState->GetName().c_str(), "name"); + IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("VariableStateInternalMockImpl")); + ASSERT_STREQ(pState->GetName().c_str(), "VariableStateInternalMockImpl"); } TEST_F(VariableStateTests, VariableStateInternalCanSaveState) { - IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("name")); + IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("VariableStateInternalMockImpl")); float data[] = {123, 124, 125}; auto stateBlob = make_shared_blob({ Precision::FP32, {3}, C }, data, sizeof(data) / sizeof(*data)); @@ -228,7 +229,7 @@ TEST_F(VariableStateTests, VariableStateInternalCanSaveState) { TEST_F(VariableStateTests, VariableStateInternalCanSaveStateByReference) { - IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("name")); + IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("VariableStateInternalMockImpl")); float data[] = {123, 124, 125}; auto stateBlob = make_shared_blob({ Precision::FP32, {3}, C }, data, sizeof(data) / sizeof(*data)); diff --git a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp index c53d9d9307d..0945510d7a0 100644 --- a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp +++ b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_plugin_test.cpp @@ -15,6 +15,7 @@ #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/impl/mock_executable_thread_safe_default.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinfer_request_internal.hpp" +#include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" using namespace ::testing; using namespace std; @@ -25,7 +26,7 @@ class InferenceEnginePluginInternalTest : public ::testing::Test { protected: shared_ptr plugin; shared_ptr mock_plugin_impl; - shared_ptr mockExeNetworkInternal; + shared_ptr mockIExeNetworkInternal; shared_ptr mockExeNetworkTS; shared_ptr mockInferRequestInternal; std::shared_ptr mockNotEmptyNet = std::make_shared(); @@ -36,7 +37,7 @@ protected: virtual void TearDown() { EXPECT_TRUE(Mock::VerifyAndClearExpectations(mock_plugin_impl.get())); - EXPECT_TRUE(Mock::VerifyAndClearExpectations(mockExeNetworkInternal.get())); + EXPECT_TRUE(Mock::VerifyAndClearExpectations(mockIExeNetworkInternal.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(mockExeNetworkTS.get())); EXPECT_TRUE(Mock::VerifyAndClearExpectations(mockInferRequestInternal.get())); } @@ -46,8 +47,8 @@ protected: mock_plugin_impl.reset(new MockInferencePluginInternal()); mock_plugin_impl->SetName(pluginId); plugin = std::static_pointer_cast(mock_plugin_impl); - mockExeNetworkInternal = make_shared(); - mockExeNetworkInternal->SetPointerToPlugin(mock_plugin_impl); + mockIExeNetworkInternal = make_shared(); + mockIExeNetworkInternal->SetPointerToPlugin(mock_plugin_impl); } void getInferRequestWithMockImplInside(IInferRequestInternal::Ptr &request) { @@ -150,7 +151,7 @@ TEST_F(InferenceEnginePluginInternalTest, failToSetNotAllocatedBlob) { TEST_F(InferenceEnginePluginInternalTest, executableNetworkInternalExportsMagicAndName) { std::stringstream strm; - ASSERT_NO_THROW(mockExeNetworkInternal->WrapOstreamExport(strm)); + ASSERT_NO_THROW(mockIExeNetworkInternal->WrapOstreamExport(strm)); ExportMagic actualMagic = {}; strm.read(actualMagic.data(), actualMagic.size()); ASSERT_EQ(exportMagic, actualMagic); @@ -159,14 +160,14 @@ TEST_F(InferenceEnginePluginInternalTest, executableNetworkInternalExportsMagicA ASSERT_EQ(pluginId, pluginName); std::string exportedString; std::getline(strm, exportedString); - ASSERT_EQ(mockExeNetworkInternal->exportString, exportedString); + ASSERT_EQ(mockIExeNetworkInternal->exportString, exportedString); } TEST_F(InferenceEnginePluginInternalTest, pluginInternalEraseMagicAndNameWhenImports) { std::stringstream strm; - ASSERT_NO_THROW(mockExeNetworkInternal->WrapOstreamExport(strm)); + ASSERT_NO_THROW(mockIExeNetworkInternal->WrapOstreamExport(strm)); ASSERT_NO_THROW(mock_plugin_impl->ImportNetwork(strm, {})); - ASSERT_EQ(mockExeNetworkInternal->exportString, mock_plugin_impl->importedString); + ASSERT_EQ(mockIExeNetworkInternal->exportString, mock_plugin_impl->importedString); mock_plugin_impl->importedString = {}; }