From 5e6896d03a9ba3e50b7927d027d78dd41b4c8aef Mon Sep 17 00:00:00 2001 From: Anton Pankratv Date: Tue, 14 Sep 2021 12:49:24 +0300 Subject: [PATCH] Reverted to Remote Context (#7453) --- .../src/cldnn_engine/cldnn_engine.cpp | 6 +- .../src/cldnn_engine/cldnn_engine.h | 6 +- .../cldnn_engine/cldnn_executable_network.cpp | 4 +- .../cldnn_engine/cldnn_executable_network.h | 4 +- .../src/cldnn_engine/cldnn_remote_context.cpp | 2 +- .../src/cldnn_engine/cldnn_remote_context.h | 4 +- .../src/gna_plugin/gna_plugin.hpp | 6 +- .../include/ie/gpu/gpu_context_api_ocl.hpp | 4 +- .../include/ie/ie_remote_context.hpp | 2 +- .../openvino/runtime/remote_context.hpp | 5 +- .../src/cpp/ie_executable_network.cpp | 2 +- .../src/cpp/ie_executable_network_base.hpp | 2 +- .../inference_engine/src/cpp/ie_plugin.hpp | 16 ++--- .../ie_iexecutable_network_internal.cpp | 2 +- .../interface/ie_iplugin_internal.cpp | 10 +-- .../interface/ie_iremote_context.cpp | 19 ------ .../src/inference_engine/src/ie_core.cpp | 32 ++++----- .../inference_engine/src/remote_context.cpp | 4 +- .../multi_device_exec_network.cpp | 2 +- .../multi_device_exec_network.hpp | 2 +- .../ie_iexecutable_network_internal.hpp | 4 +- .../interface/ie_iplugin_internal.hpp | 16 ++--- .../interface/ie_iremote_context.hpp | 67 ------------------- .../inference_engine/caching_test.cpp | 16 ++--- .../cpp_interfaces/interface/mock_icore.hpp | 4 +- .../mock_iexecutable_network_internal.hpp | 2 +- .../interface/mock_iinference_plugin.hpp | 8 +-- .../mocks/mock_engine/mock_plugin.cpp | 6 +- .../mocks/mock_engine/mock_plugin.hpp | 6 +- 29 files changed, 88 insertions(+), 175 deletions(-) delete mode 100644 inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iremote_context.cpp delete mode 100644 inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iremote_context.hpp diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.cpp b/inference-engine/src/cldnn_engine/cldnn_engine.cpp index e488d1ff020..67204de6a48 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_engine.cpp @@ -631,7 +631,7 @@ IExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceE } IExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, - const IRemoteContext::Ptr &context, + const RemoteContext::Ptr &context, const std::map &orig_config) { InferenceEngine::InputsDataMap _networkInputs = network.getInputsInfo(); check_inputs(_networkInputs); @@ -649,7 +649,7 @@ IExecutableNetworkInternal::Ptr clDNNEngine::LoadExeNetworkImpl(const InferenceE return std::make_shared(transformedNetwork, casted, conf); } -IRemoteContext::Ptr clDNNEngine::CreateContext(const ParamMap& params) { +RemoteContext::Ptr clDNNEngine::CreateContext(const ParamMap& params) { // parameter map is non-empty std::string contextTypeStr = _StrFromParams(params, GPU_PARAM_KEY(CONTEXT_TYPE)); @@ -666,7 +666,7 @@ IRemoteContext::Ptr clDNNEngine::CreateContext(const ParamMap& params) { } } -IRemoteContext::Ptr clDNNEngine::GetDefaultContext(const ParamMap& params) { +RemoteContext::Ptr clDNNEngine::GetDefaultContext(const ParamMap& params) { if (nullptr == m_defaultContext) { m_defaultContext.reset(new CLDNNRemoteCLContext(shared_from_this(), params, _impl->m_config)); } diff --git a/inference-engine/src/cldnn_engine/cldnn_engine.h b/inference-engine/src/cldnn_engine/cldnn_engine.h index b40e30be2db..0afcc5db6ad 100644 --- a/inference-engine/src/cldnn_engine/cldnn_engine.h +++ b/inference-engine/src/cldnn_engine/cldnn_engine.h @@ -44,7 +44,7 @@ public: const std::map &config) override; InferenceEngine::IExecutableNetworkInternal::Ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork &network, - const std::shared_ptr &context, + const std::shared_ptr &context, const std::map &config) override; void SetConfig(const std::map &config) override; @@ -53,8 +53,8 @@ public: InferenceEngine::QueryNetworkResult QueryNetwork(const InferenceEngine::CNNNetwork& network, const std::map& config) const override; - std::shared_ptr CreateContext(const InferenceEngine::ParamMap& params) override; - std::shared_ptr GetDefaultContext(const InferenceEngine::ParamMap& params) override; + std::shared_ptr CreateContext(const InferenceEngine::ParamMap& params) override; + std::shared_ptr GetDefaultContext(const InferenceEngine::ParamMap& params) override; }; }; // namespace CLDNNPlugin diff --git a/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp b/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp index 1f5024a6a56..2b125856631 100644 --- a/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_executable_network.cpp @@ -32,7 +32,7 @@ using namespace InferenceEngine::details; namespace CLDNNPlugin { -CLDNNExecNetwork::CLDNNExecNetwork(InferenceEngine::CNNNetwork &network, std::shared_ptr context, Config config) : +CLDNNExecNetwork::CLDNNExecNetwork(InferenceEngine::CNNNetwork &network, std::shared_ptr context, Config config) : InferenceEngine::ExecutableNetworkThreadSafeDefault{[&]()->InferenceEngine::ITaskExecutor::Ptr { if (config.exclusiveAsyncRequests) { //exclusiveAsyncRequests essentially disables the streams (and hence should be checked first) => aligned with the CPU behavior @@ -136,7 +136,7 @@ InferenceEngine::Parameter CLDNNExecNetwork::GetMetric(const std::string &name) } } -std::shared_ptr CLDNNExecNetwork::GetContext() const { +std::shared_ptr CLDNNExecNetwork::GetContext() const { return m_context; } diff --git a/inference-engine/src/cldnn_engine/cldnn_executable_network.h b/inference-engine/src/cldnn_engine/cldnn_executable_network.h index 88267797d71..689c12fcc23 100644 --- a/inference-engine/src/cldnn_engine/cldnn_executable_network.h +++ b/inference-engine/src/cldnn_engine/cldnn_executable_network.h @@ -23,7 +23,7 @@ class CLDNNExecNetwork : public InferenceEngine::ExecutableNetworkThreadSafeDefa public: typedef std::shared_ptr Ptr; - CLDNNExecNetwork(InferenceEngine::CNNNetwork &network, std::shared_ptr context, Config config); + CLDNNExecNetwork(InferenceEngine::CNNNetwork &network, std::shared_ptr context, Config config); std::shared_ptr GetExecGraphInfo() override; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override; @@ -32,7 +32,7 @@ public: InferenceEngine::Parameter GetMetric(const std::string &name) const override; InferenceEngine::Parameter GetConfig(const std::string &name) const override; - std::shared_ptr GetContext() const override; + std::shared_ptr GetContext() const override; std::vector> m_graphs; InferenceEngine::gpu::ClContext::Ptr m_context; diff --git a/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp b/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp index 5e2519cc9ba..e816449b461 100644 --- a/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp +++ b/inference-engine/src/cldnn_engine/cldnn_remote_context.cpp @@ -134,7 +134,7 @@ std::string CLDNNRemoteBlobImpl::getDeviceName() const noexcept { return getContextImpl(m_context.lock())->getDeviceName(); }; -std::shared_ptr CLDNNRemoteBlobImpl::getContext() const noexcept { +std::shared_ptr CLDNNRemoteBlobImpl::getContext() const noexcept { return m_context.lock(); } diff --git a/inference-engine/src/cldnn_engine/cldnn_remote_context.h b/inference-engine/src/cldnn_engine/cldnn_remote_context.h index d35cd7c0410..f93193a1543 100644 --- a/inference-engine/src/cldnn_engine/cldnn_remote_context.h +++ b/inference-engine/src/cldnn_engine/cldnn_remote_context.h @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include "cldnn_config.h" #include "cldnn_common_utils.h" @@ -54,7 +54,7 @@ public: bool deallocate() noexcept; InferenceEngine::ParamMap getParams() const; std::string getDeviceName() const noexcept; - std::shared_ptr getContext() const noexcept; + std::shared_ptr getContext() const noexcept; InferenceEngine::LockedMemory buffer() noexcept; InferenceEngine::LockedMemory cbuffer() const noexcept; InferenceEngine::LockedMemory rwmap()noexcept; diff --git a/inference-engine/src/gna_plugin/gna_plugin.hpp b/inference-engine/src/gna_plugin/gna_plugin.hpp index 476106f558e..eb9d71f875e 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.hpp +++ b/inference-engine/src/gna_plugin/gna_plugin.hpp @@ -114,10 +114,10 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin { const std::map & options) const override; InferenceEngine::Parameter GetMetric(const std::string& name, const std::map & options) const override; - std::shared_ptr CreateContext(const InferenceEngine::ParamMap& params) override { + std::shared_ptr CreateContext(const InferenceEngine::ParamMap& params) override { THROW_GNA_EXCEPTION << "Not implemented"; } - std::shared_ptr GetDefaultContext(const InferenceEngine::ParamMap&) override { + std::shared_ptr GetDefaultContext(const InferenceEngine::ParamMap&) override { THROW_GNA_EXCEPTION << "Not implemented"; } @@ -130,7 +130,7 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin { THROW_GNA_EXCEPTION << "Not implemented"; } InferenceEngine::IExecutableNetworkInternal::Ptr ImportNetwork(std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map &config) override { THROW_GNA_EXCEPTION << "Not implemented"; } diff --git a/inference-engine/src/inference_engine/include/ie/gpu/gpu_context_api_ocl.hpp b/inference-engine/src/inference_engine/include/ie/gpu/gpu_context_api_ocl.hpp index 27a1c0f1a80..8b59db7e978 100644 --- a/inference-engine/src/inference_engine/include/ie/gpu/gpu_context_api_ocl.hpp +++ b/inference-engine/src/inference_engine/include/ie/gpu/gpu_context_api_ocl.hpp @@ -10,7 +10,7 @@ */ #pragma once -#include +#include #include #include @@ -29,7 +29,7 @@ namespace gpu { * The plugin object derived from this class can be obtained either with * GetContext() method of Executable network or using CreateContext() Core call. */ -class ClContext : public IRemoteContext, public details::param_map_obj_getter { +class ClContext : public RemoteContext, public details::param_map_obj_getter { public: /** * @brief A smart pointer to the ClContext object diff --git a/inference-engine/src/inference_engine/include/ie/ie_remote_context.hpp b/inference-engine/src/inference_engine/include/ie/ie_remote_context.hpp index 86baaf22884..0fee1c86808 100644 --- a/inference-engine/src/inference_engine/include/ie/ie_remote_context.hpp +++ b/inference-engine/src/inference_engine/include/ie/ie_remote_context.hpp @@ -23,7 +23,7 @@ namespace InferenceEngine { * Such context represents a scope on the device within which executable * networks and remote memory blobs can exist, function and exchange data. */ -class RemoteContext { +class RemoteContext : public std::enable_shared_from_this { public: /** * @brief A smart pointer to the RemoteContext object diff --git a/inference-engine/src/inference_engine/include/openvino/runtime/remote_context.hpp b/inference-engine/src/inference_engine/include/openvino/runtime/remote_context.hpp index 31986de3e2e..d174b6a6d5d 100644 --- a/inference-engine/src/inference_engine/include/openvino/runtime/remote_context.hpp +++ b/inference-engine/src/inference_engine/include/openvino/runtime/remote_context.hpp @@ -19,7 +19,6 @@ #include "ie_remote_context.hpp" namespace InferenceEngine { -class IRemoteContext; class RemoteBlob; } // namespace InferenceEngine @@ -36,7 +35,7 @@ class Core; */ class INFERENCE_ENGINE_API_CLASS(RemoteContext) { std::shared_ptr _so; - std::shared_ptr _impl; + std::shared_ptr _impl; /** * @brief Constructs RemoteContext from the initialized std::shared_ptr @@ -44,7 +43,7 @@ class INFERENCE_ENGINE_API_CLASS(RemoteContext) { * object is destroyed. * @param impl Initialized shared pointer */ - RemoteContext(const std::shared_ptr& so, const std::shared_ptr& impl); + RemoteContext(const std::shared_ptr& so, const std::shared_ptr& impl); friend class Core; public: diff --git a/inference-engine/src/inference_engine/src/cpp/ie_executable_network.cpp b/inference-engine/src/inference_engine/src/cpp/ie_executable_network.cpp index 4b2977066c3..dde888a82f7 100644 --- a/inference-engine/src/inference_engine/src/cpp/ie_executable_network.cpp +++ b/inference-engine/src/inference_engine/src/cpp/ie_executable_network.cpp @@ -6,9 +6,9 @@ #include "cpp/exception2status.hpp" #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" -#include "cpp_interfaces/interface/ie_iremote_context.hpp" #include "ie_common.h" #include "ie_executable_network_base.hpp" +#include "ie_remote_context.hpp" #include "openvino/runtime/executable_network.hpp" namespace InferenceEngine { diff --git a/inference-engine/src/inference_engine/src/cpp/ie_executable_network_base.hpp b/inference-engine/src/inference_engine/src/cpp/ie_executable_network_base.hpp index 559fe1ace6d..7aac9444d4a 100644 --- a/inference-engine/src/inference_engine/src/cpp/ie_executable_network_base.hpp +++ b/inference-engine/src/inference_engine/src/cpp/ie_executable_network_base.hpp @@ -17,7 +17,7 @@ #include "cpp/exception2status.hpp" #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" #include "cpp_interfaces/interface/ie_ivariable_state_internal.hpp" -#include "cpp_interfaces/interface/ie_iremote_context.hpp" +#include "ie_remote_context.hpp" #include "ie_iexecutable_network.hpp" #include "ie_infer_async_request_base.hpp" diff --git a/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp b/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp index 2e04ac8881c..1b74aea1ce5 100644 --- a/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp +++ b/inference-engine/src/inference_engine/src/cpp/ie_plugin.hpp @@ -67,7 +67,7 @@ public: } details::SOPointer LoadNetwork(const CNNNetwork& network, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config, context)}); } @@ -95,7 +95,7 @@ public: } details::SOPointer ImportNetwork(std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, context, config)}); } @@ -104,11 +104,11 @@ public: PLUGIN_CALL_STATEMENT(return _ptr->GetMetric(name, options)); } - details::SOPointer CreateContext(const ParamMap& params) { + details::SOPointer CreateContext(const ParamMap& params) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->CreateContext(params)}); } - details::SOPointer GetDefaultContext(const ParamMap& params) { + details::SOPointer GetDefaultContext(const ParamMap& params) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->GetDefaultContext(params)}); } @@ -166,7 +166,7 @@ struct InferencePlugin { } SoPtr load_model(const ie::CNNNetwork& network, - const std::shared_ptr& context, + const std::shared_ptr& context, const ConfigMap& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config, context)}); } @@ -194,7 +194,7 @@ struct InferencePlugin { } SoPtr import_model(std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const ConfigMap& config) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, context, config)}); } @@ -203,11 +203,11 @@ struct InferencePlugin { PLUGIN_CALL_STATEMENT(return _ptr->GetMetric(name, options)); } - SoPtr create_context(const ie::ParamMap& params) { + SoPtr create_context(const ie::ParamMap& params) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->CreateContext(params)}); } - SoPtr get_default_context(const ie::ParamMap& params) { + SoPtr get_default_context(const ie::ParamMap& params) { PLUGIN_CALL_STATEMENT(return {_so, _ptr->GetDefaultContext(params)}); } diff --git a/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp b/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp index abd12226ce4..f53cde11ed1 100644 --- a/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp +++ b/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iexecutable_network_internal.cpp @@ -90,7 +90,7 @@ Parameter IExecutableNetworkInternal::GetMetric(const std::string&) const { IE_THROW(NotImplemented); } -std::shared_ptr IExecutableNetworkInternal::GetContext() const { +std::shared_ptr IExecutableNetworkInternal::GetContext() const { IE_THROW(NotImplemented); } diff --git a/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iplugin_internal.cpp b/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iplugin_internal.cpp index 3b08dba7a6e..17487acb64e 100644 --- a/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iplugin_internal.cpp +++ b/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iplugin_internal.cpp @@ -118,7 +118,7 @@ std::map> const_map_cast(const std::map IInferencePlugin::LoadNetwork( const CNNNetwork& network, const std::map& config, - const std::shared_ptr& context) { + const std::shared_ptr& context) { std::shared_ptr impl; if (nullptr == context) { impl = LoadExeNetworkImpl(network, config); @@ -158,11 +158,11 @@ Parameter IInferencePlugin::GetMetric(const std::string&, const std::map IInferencePlugin::CreateContext(const ParamMap&) { +std::shared_ptr IInferencePlugin::CreateContext(const ParamMap&) { IE_THROW(NotImplemented); } -std::shared_ptr IInferencePlugin::GetDefaultContext(const ParamMap&) { +std::shared_ptr IInferencePlugin::GetDefaultContext(const ParamMap&) { IE_THROW(NotImplemented); } @@ -186,7 +186,7 @@ std::shared_ptr IInferencePlugin::ImportNetwork( std::shared_ptr IInferencePlugin::ImportNetwork( std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config) { IE_THROW(NotImplemented); } @@ -213,7 +213,7 @@ std::shared_ptr IInferencePlugin::LoadExeNetworkImpl std::shared_ptr IInferencePlugin::LoadExeNetworkImpl( const CNNNetwork&, - const std::shared_ptr&, + const std::shared_ptr&, const std::map&) { IE_THROW(NotImplemented); } diff --git a/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iremote_context.cpp b/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iremote_context.cpp deleted file mode 100644 index 8ad2777a007..00000000000 --- a/inference-engine/src/inference_engine/src/cpp_interfaces/interface/ie_iremote_context.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -#include - -namespace InferenceEngine { -std::string IRemoteContext::getDeviceName() const noexcept { - return {}; -} - -RemoteBlob::Ptr IRemoteContext::CreateBlob(const TensorDesc&, const ParamMap&) { - IE_THROW(NotImplemented); -} - -ParamMap IRemoteContext::getParams() const { - IE_THROW(NotImplemented); -} -} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/src/ie_core.cpp b/inference-engine/src/inference_engine/src/ie_core.cpp index 7de97146466..815bcbbc1e2 100644 --- a/inference-engine/src/inference_engine/src/ie_core.cpp +++ b/inference-engine/src/inference_engine/src/ie_core.cpp @@ -16,7 +16,6 @@ #include "cpp/ie_plugin.hpp" #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" #include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" -#include "cpp_interfaces/interface/ie_iremote_context.hpp" #include "file_utils.h" #include "ie_cache_guard.hpp" #include "ie_cache_manager.hpp" @@ -24,6 +23,7 @@ #include "ie_itt.hpp" #include "ie_network_reader.hpp" #include "ie_plugin_config.hpp" +#include "ie_remote_context.hpp" #include "ngraph/graph_util.hpp" #include "ngraph/ngraph.hpp" #include "ngraph/opsets/opset.hpp" @@ -209,15 +209,15 @@ class CoreImpl : public ie::ICore, public std::enable_shared_from_this LoadNetworkImpl( - const ie::CNNNetwork& network, - ov::runtime::InferencePlugin& plugin, + ov::runtime::SoPtr load_model_impl( + const InferenceEngine::CNNNetwork& network, + InferencePlugin& plugin, const std::map& parsedConfig, - const ie::IRemoteContext::Ptr& context, + const ie::RemoteContext::Ptr& context, const std::string& blobID, const std::string& modelPath = std::string(), bool forceDisableCache = false) { - OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "CoreImpl::LoadNetworkImpl"); + OV_ITT_SCOPED_TASK(ov::itt::domains::IE, "CoreImpl::load_model_impl"); ov::runtime::SoPtr execNetwork; execNetwork = context ? plugin.load_model(network, context, parsedConfig) : plugin.load_model(network, parsedConfig); @@ -245,7 +245,7 @@ class CoreImpl : public ie::ICore, public std::enable_shared_from_this& config, - const std::shared_ptr& context, + const std::shared_ptr& context, bool& networkIsImported, const std::string& modelPath = std::string()) { ov::runtime::SoPtr execNetwork; @@ -443,7 +443,7 @@ public: // TODO: In future this method can be added to ICore interface ov::runtime::SoPtr LoadNetwork(const ie::CNNNetwork& network, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config) { OV_ITT_SCOPE(FIRST_INFERENCE, ie::itt::domains::IE_LT, "Core::LoadNetwork::RemoteContext"); if (context == nullptr) { @@ -459,10 +459,10 @@ public: auto lock = cacheGuard.getHashLock(hash); res = LoadNetworkFromCache(cacheManager, hash, plugin, parsed._config, context, loadedFromCache); if (!loadedFromCache) { - res = LoadNetworkImpl(network, plugin, parsed._config, context, hash); + res = load_model_impl(network, plugin, parsed._config, context, hash); } } else { - res = LoadNetworkImpl(network, plugin, parsed._config, context, {}); + res = load_model_impl(network, plugin, parsed._config, context, {}); } return res; } @@ -486,10 +486,10 @@ public: auto lock = cacheGuard.getHashLock(hash); res = LoadNetworkFromCache(cacheManager, hash, plugin, parsed._config, nullptr, loadedFromCache); if (!loadedFromCache) { - res = LoadNetworkImpl(network, plugin, parsed._config, nullptr, hash, {}, forceDisableCache); + res = load_model_impl(network, plugin, parsed._config, nullptr, hash, {}, forceDisableCache); } } else { - res = LoadNetworkImpl(network, plugin, parsed._config, nullptr, {}, {}, forceDisableCache); + res = load_model_impl(network, plugin, parsed._config, nullptr, {}, {}, forceDisableCache); } return {{res._so}, res._ptr}; } @@ -509,13 +509,13 @@ public: res = LoadNetworkFromCache(cacheManager, hash, plugin, parsed._config, nullptr, loadedFromCache, modelPath); if (!loadedFromCache) { auto cnnNetwork = ReadNetwork(modelPath, std::string()); - res = LoadNetworkImpl(cnnNetwork, plugin, parsed._config, nullptr, hash, modelPath); + res = load_model_impl(cnnNetwork, plugin, parsed._config, nullptr, hash, modelPath); } } else if (cacheManager) { res = plugin.load_model(modelPath, parsed._config); } else { auto cnnNetwork = ReadNetwork(modelPath, std::string()); - res = LoadNetworkImpl(cnnNetwork, plugin, parsed._config, nullptr, {}, modelPath); + res = load_model_impl(cnnNetwork, plugin, parsed._config, nullptr, {}, modelPath); } return {{res._so}, res._ptr}; } @@ -985,7 +985,7 @@ ExecutableNetwork Core::LoadNetwork(const CNNNetwork& network, ExecutableNetwork Core::LoadNetwork(const CNNNetwork& network, RemoteContext::Ptr context, const std::map& config) { - auto exec = _impl->LoadNetwork(network, std::dynamic_pointer_cast(context), config); + auto exec = _impl->LoadNetwork(network, std::dynamic_pointer_cast(context), config); return {{exec._so}, exec._ptr}; } @@ -1098,7 +1098,7 @@ ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, auto parsed = ov::runtime::parseDeviceNameIntoConfig(deviceName, config); auto exec = _impl->GetCPPPluginByName(deviceName) - .import_model(networkModel, std::dynamic_pointer_cast(context), parsed._config); + .import_model(networkModel, std::dynamic_pointer_cast(context), parsed._config); return {{exec._so}, exec._ptr}; } diff --git a/inference-engine/src/inference_engine/src/remote_context.cpp b/inference-engine/src/inference_engine/src/remote_context.cpp index edee07899b5..62913b54537 100644 --- a/inference-engine/src/inference_engine/src/remote_context.cpp +++ b/inference-engine/src/inference_engine/src/remote_context.cpp @@ -4,8 +4,8 @@ #include "openvino/runtime/remote_context.hpp" -#include "cpp_interfaces/interface/ie_iremote_context.hpp" #include "ie_remote_blob.hpp" +#include "ie_remote_context.hpp" #define REMOTE_CONTEXT_STATEMENT(...) \ if (_impl == nullptr) \ @@ -19,7 +19,7 @@ namespace ov { namespace runtime { -RemoteContext::RemoteContext(const std::shared_ptr& so, const ie::IRemoteContext::Ptr& impl) +RemoteContext::RemoteContext(const std::shared_ptr& so, const ie::RemoteContext::Ptr& impl) : _so(so), _impl(impl) { if (_impl == nullptr) diff --git a/inference-engine/src/multi_device/multi_device_exec_network.cpp b/inference-engine/src/multi_device/multi_device_exec_network.cpp index bd0edeeed32..b569a0cf40d 100644 --- a/inference-engine/src/multi_device/multi_device_exec_network.cpp +++ b/inference-engine/src/multi_device/multi_device_exec_network.cpp @@ -154,7 +154,7 @@ MultiDeviceExecutableNetwork::~MultiDeviceExecutableNetwork() { _workerRequests.clear(); } -std::shared_ptr MultiDeviceExecutableNetwork::GetContext() const { +std::shared_ptr MultiDeviceExecutableNetwork::GetContext() const { auto devices = [&] { std::lock_guard lock(_mutex); return _devicePriorities; diff --git a/inference-engine/src/multi_device/multi_device_exec_network.hpp b/inference-engine/src/multi_device/multi_device_exec_network.hpp index a771ec2531c..2fb6e9462a7 100644 --- a/inference-engine/src/multi_device/multi_device_exec_network.hpp +++ b/inference-engine/src/multi_device/multi_device_exec_network.hpp @@ -117,7 +117,7 @@ public: InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, InferenceEngine::OutputsDataMap networkOutputs) override; - std::shared_ptr GetContext() const override; + std::shared_ptr GetContext() const override; ~MultiDeviceExecutableNetwork() override; void ScheduleToWorkerInferRequest(InferenceEngine::Task, DeviceName preferred_device = ""); 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 adf48cc8f9b..695f3dc5a99 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 @@ -22,7 +22,7 @@ namespace InferenceEngine { class IInferencePlugin; class IInferRequestInternal; -class IRemoteContext; +class RemoteContext; class IVariableStateInternal; /** @@ -134,7 +134,7 @@ public: * @brief Gets the remote context. * @return A reference to a context */ - virtual std::shared_ptr GetContext() const; + virtual std::shared_ptr GetContext() const; protected: ~IExecutableNetworkInternal() = default; 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 32d860ffab8..b82ae2de2e6 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 @@ -28,7 +28,7 @@ namespace InferenceEngine { class ICore; class IExecutableNetworkInternal; -class IRemoteContext; +class RemoteContext; class IExtension; /** @@ -147,13 +147,13 @@ public: * @brief Creates an executable network from network object, on specified remote context * @param network A network object acquired from InferenceEngine::Core::ReadNetwork * @param config string-string map of config parameters relevant only for this load operation - * @param context A pointer to plugin context derived from IRemoteContext class used to + * @param context A pointer to plugin context derived from RemoteContext class used to * execute the network * @return Created Executable Network object */ virtual std::shared_ptr LoadNetwork(const CNNNetwork& network, const std::map& config, - const std::shared_ptr& context); + const std::shared_ptr& context); /** * @brief Creates an executable network from model file path @@ -197,14 +197,14 @@ public: * @param[in] params The map of parameters * @return A remote context object */ - virtual std::shared_ptr CreateContext(const ParamMap& params); + 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 std::shared_ptr GetDefaultContext(const ParamMap& params); + virtual std::shared_ptr GetDefaultContext(const ParamMap& params); /** * @deprecated Use ImportNetwork(std::istream& networkModel, const std::map& config) @@ -236,7 +236,7 @@ public: * @return An Executable network */ virtual std::shared_ptr ImportNetwork(std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config); /** @@ -283,7 +283,7 @@ protected: * resources) * @note The function is used in * InferencePluginInternal::LoadNetwork(const CNNNetwork&, const std::map&, - * IRemoteContext::Ptr) which performs common steps first and calls this plugin-dependent method implementation + * 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 @@ -292,7 +292,7 @@ protected: */ virtual std::shared_ptr LoadExeNetworkImpl( const CNNNetwork& network, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config); /** diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iremote_context.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iremote_context.hpp deleted file mode 100644 index 361ff67af97..00000000000 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iremote_context.hpp +++ /dev/null @@ -1,67 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief This is a header file for the IE RemoteContext and RemoteBlob classes - * - * @file ie_remote_context.hpp - */ -#pragma once - -#include -#include - -#include "ie_parameter.hpp" -#include "ie_remote_context.hpp" - -namespace InferenceEngine { - -class RemoteBlob; - -class INFERENCE_ENGINE_API_CLASS(IRemoteContext) - : public RemoteContext, - public std::enable_shared_from_this { -public: - /** - * @brief A smart pointer to the IRemoteContext object - */ - using Ptr = std::shared_ptr; - - /** - * @brief Returns name of the device on which underlying object is allocated. - * Abstract method. - * @return A device name string in the same format as that in plugin metric. - */ - std::string getDeviceName() const noexcept override; - - /** - * @brief Allocates memory blob in device memory or wraps user-supplied memory handle - * using the specified tensor description and low-level device-specific parameters. - * Returns a pointer to the object which implements RemoteBlob interface. - * @param tensorDesc Defines the layout and dims of the blob - * @param params Map of the low-level blob object parameters. - * Abstract method. - * @return A pointer to plugin object that implements RemoteBlob interface. - */ - std::shared_ptr CreateBlob(const TensorDesc& tensorDesc, const ParamMap& params = {}) override; - - /** - * @brief Returns a map of device-specific parameters required for low-level - * operations with underlying object. - * Parameters include device/context handles, access flags, - * etc. Contents of the map returned depend on remote execution context that is - * currently set on the device (working scenario). - * Abstract method. - * @return A map of name/parameter elements. - */ - ParamMap getParams() const override; - -protected: - /** - * @brief IRemoteContext destructor - */ - ~IRemoteContext() = default; -}; - -} // namespace InferenceEngine diff --git a/inference-engine/tests/functional/inference_engine/caching_test.cpp b/inference-engine/tests/functional/inference_engine/caching_test.cpp index a1714c6e51a..a24c6f18d96 100644 --- a/inference-engine/tests/functional/inference_engine/caching_test.cpp +++ b/inference-engine/tests/functional/inference_engine/caching_test.cpp @@ -17,7 +17,7 @@ #include "details/ie_so_loader.h" #include "ie_metric_helpers.hpp" -#include "cpp_interfaces/interface/ie_iremote_context.hpp" +#include "ie_remote_context.hpp" #include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" #include "cpp_interfaces/interface/ie_iplugin_internal.hpp" @@ -62,7 +62,7 @@ std::string getTestCaseName(const testing::TestParamInfo(std::get<0>(obj.param)) + "_" + std::get<1>(obj.param); } -class MockRemoteContext : public IRemoteContext { +class MockRemoteContext : public RemoteContext { std::string m_name; public: MockRemoteContext(std::string name): m_name(std::move(name)) {} @@ -97,7 +97,7 @@ public: const std::map& config)); MOCK_METHOD3(LoadExeNetworkImpl, std::shared_ptr(const CNNNetwork& network, - const IRemoteContext::Ptr& context, + const RemoteContext::Ptr& context, const std::map& config)); MOCK_CONST_METHOD0(OnLoadNetworkFromFile, void(void)); @@ -106,7 +106,7 @@ public: const std::map& config)); MOCK_METHOD3(ImportNetwork, IExecutableNetworkInternal::Ptr(std::istream& networkModel, - const IRemoteContext::Ptr& context, + const RemoteContext::Ptr& context, const std::map& config)); MOCK_CONST_METHOD2(QueryNetwork, QueryNetworkResult(const CNNNetwork& network, @@ -114,7 +114,7 @@ public: MOCK_CONST_METHOD2(GetMetric, Parameter(const std::string& name, const std::map& options)); MOCK_METHOD1(SetConfig, void(const std::map& options)); - MOCK_METHOD1(GetDefaultContext, std::shared_ptr(const ParamMap& params)); + MOCK_METHOD1(GetDefaultContext, std::shared_ptr(const ParamMap& params)); }; class MockExecutableNetwork : public IExecutableNetworkInternal { @@ -336,7 +336,7 @@ private: WillByDefault(Return("mock")); ON_CALL(plugin, ImportNetwork(_, _, _)). - WillByDefault(Invoke([&](std::istream &istr, const IRemoteContext::Ptr&, + WillByDefault(Invoke([&](std::istream &istr, const RemoteContext::Ptr&, const std::map &) { return createMockIExecutableNet(); })); @@ -347,7 +347,7 @@ private: })); ON_CALL(plugin, LoadExeNetworkImpl(_, _, _)). - WillByDefault(Invoke([&](const CNNNetwork &, const IRemoteContext::Ptr&, + WillByDefault(Invoke([&](const CNNNetwork &, const RemoteContext::Ptr&, const std::map &) { return net; })); @@ -443,7 +443,7 @@ TEST_P(CachingTest, TestLoadCustomImportExport) { EXPECT_CALL(*mockPlugin, GetMetric(METRIC_KEY(IMPORT_EXPORT_SUPPORT), _)).Times(AnyNumber()); EXPECT_CALL(*mockPlugin, GetMetric(METRIC_KEY(DEVICE_ARCHITECTURE), _)).Times(AnyNumber()); ON_CALL(*mockPlugin, ImportNetwork(_, _, _)). - WillByDefault(Invoke([&](std::istream& s, IRemoteContext::Ptr, + WillByDefault(Invoke([&](std::istream& s, RemoteContext::Ptr, const std::map &) { char a[sizeof(customData)]; s.read(a, sizeof(customData)); diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp index 38fc58dacd5..009cdb22595 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_icore.hpp @@ -17,14 +17,14 @@ public: MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( const InferenceEngine::CNNNetwork&, const std::string&, const std::map&)); MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( - const InferenceEngine::CNNNetwork&, const std::shared_ptr &, const std::map&)); + const InferenceEngine::CNNNetwork&, const std::shared_ptr &, const std::map&)); MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( const std::string &, const std::string &, const std::map&)); MOCK_METHOD3(ImportNetwork, InferenceEngine::SoExecutableNetworkInternal( std::istream&, const std::string&, const std::map&)); MOCK_METHOD3(ImportNetwork, InferenceEngine::SoExecutableNetworkInternal( - std::istream&, const std::shared_ptr&, const std::map&)); + std::istream&, const std::shared_ptr&, const std::map&)); MOCK_CONST_METHOD3(QueryNetwork, InferenceEngine::QueryNetworkResult( const InferenceEngine::CNNNetwork&, const std::string&, 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 4ceb8f728fe..805df1d61dc 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 @@ -30,7 +30,7 @@ public: MOCK_METHOD1(SetConfig, void(const std::map &config)); MOCK_CONST_METHOD1(GetConfig, Parameter(const std::string &name)); MOCK_CONST_METHOD1(GetMetric, Parameter(const std::string &name)); - MOCK_CONST_METHOD0(GetContext, std::shared_ptr(void)); + MOCK_CONST_METHOD0(GetContext, std::shared_ptr(void)); void WrapOstreamExport(std::ostream& networkModel) { IExecutableNetworkInternal::Export(networkModel); } diff --git a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp index 0c45de9b995..4cc853e5fd3 100644 --- a/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp +++ b/inference-engine/tests/ie_test_utils/unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp @@ -30,15 +30,15 @@ public: MOCK_CONST_METHOD2(GetMetric, InferenceEngine::Parameter( const std::string&, const std::map&)); MOCK_METHOD1(CreateContext, - std::shared_ptr(const InferenceEngine::ParamMap&)); - MOCK_METHOD1(GetDefaultContext, std::shared_ptr(const InferenceEngine::ParamMap&)); + std::shared_ptr(const InferenceEngine::ParamMap&)); + MOCK_METHOD1(GetDefaultContext, std::shared_ptr(const InferenceEngine::ParamMap&)); MOCK_METHOD3(LoadNetwork, std::shared_ptr( const InferenceEngine::CNNNetwork&, const std::map&, - std::shared_ptr)); + std::shared_ptr)); MOCK_METHOD2(ImportNetwork, std::shared_ptr( std::istream&, const std::map&)); MOCK_METHOD3(ImportNetwork, std::shared_ptr( - std::istream&, const std::shared_ptr&, + std::istream&, const std::shared_ptr&, const std::map&)); MOCK_CONST_METHOD2(QueryNetwork, InferenceEngine::QueryNetworkResult(const InferenceEngine::CNNNetwork&, 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 2cfa6330ab5..e6cefc75ea2 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 @@ -45,7 +45,7 @@ MockPlugin::LoadNetwork(const CNNNetwork &network, std::shared_ptr MockPlugin::LoadNetwork(const CNNNetwork& network, const std::map& config, - const std::shared_ptr& context) { + const std::shared_ptr& context) { if (_target) { return _target->LoadNetwork(network, config, context); } else { @@ -81,7 +81,7 @@ MockPlugin::ImportNetwork(std::istream& networkModel, std::shared_ptr MockPlugin::ImportNetwork(std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config) { if (_target) { return _target->ImportNetwork(networkModel, context, config); @@ -90,7 +90,7 @@ MockPlugin::ImportNetwork(std::istream& networkModel, } } -std::shared_ptr MockPlugin::GetDefaultContext(const InferenceEngine::ParamMap& params) { +std::shared_ptr MockPlugin::GetDefaultContext(const InferenceEngine::ParamMap& params) { if (_target) { return _target->GetDefaultContext(params); } else { 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 8514bf28c80..05becce1fcd 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 @@ -24,7 +24,7 @@ public: std::shared_ptr LoadNetwork(const InferenceEngine::CNNNetwork& network, const std::map& config, - const std::shared_ptr& context) override; + const std::shared_ptr& context) override; std::shared_ptr LoadExeNetworkImpl(const InferenceEngine::CNNNetwork& network, @@ -40,13 +40,13 @@ public: std::shared_ptr ImportNetwork(std::istream& networkModel, - const std::shared_ptr& context, + const std::shared_ptr& context, const std::map& config) override; InferenceEngine::Parameter GetMetric(const std::string& name, const std::map& options) const override; - std::shared_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;