diff --git a/docs/template_plugin/src/transformations/preprocessing/preprocessing.cpp b/docs/template_plugin/src/transformations/preprocessing/preprocessing.cpp index a7e6d8bc718202..4f68deb3f93cd8 100644 --- a/docs/template_plugin/src/transformations/preprocessing/preprocessing.cpp +++ b/docs/template_plugin/src/transformations/preprocessing/preprocessing.cpp @@ -42,6 +42,7 @@ bool ngraph::pass::AddPreprocessing::run_on_function(std::shared_ptrgetTensorDesc().getPrecision() == InferenceEngine::Precision::FP32, "Only InferenceEngine::Precision::FP32 precision is supported for PreProcessChannel::meanData"); } else { + NGRAPH_CHECK(pInfo[c]->meanData != nullptr, "pInfo[c]->meanData is nullptr"); NGRAPH_CHECK(meanImage->getTensorDesc() == pInfo[c]->meanData->getTensorDesc(), "TensorDesc for PreProcessChannel::meanData must be equal"); } diff --git a/inference-engine/include/cpp/ie_executable_network.hpp b/inference-engine/include/cpp/ie_executable_network.hpp index 1001e65903df0d..4200d160c5d94c 100644 --- a/inference-engine/include/cpp/ie_executable_network.hpp +++ b/inference-engine/include/cpp/ie_executable_network.hpp @@ -16,15 +16,13 @@ #include #include +#include "ie_parameter.hpp" +#include "ie_remote_context.hpp" #include "cpp/ie_cnn_network.h" #include "cpp/ie_infer_request.hpp" +#include "details/ie_so_loader.h" namespace InferenceEngine { - -namespace details { -class SharedObjectLoader; -} - class IExecutableNetworkInternal; class IExecutableNetwork; @@ -32,24 +30,23 @@ class IExecutableNetwork; * @brief This is an interface of an executable network */ class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) { - std::shared_ptr _impl; - std::shared_ptr _so; - - ExecutableNetwork(const std::shared_ptr& impl, - const std::shared_ptr& so); - - friend class InferencePlugin; + details::SharedObjectLoader _so; + std::shared_ptr _impl; -public: /** - * @brief Default constructor + * @brief Constructs ExecutableNetwork from the initialized std::shared_ptr + * @param so Plugin to use. This is required to ensure that ExecutableNetwork can work properly even if plugin object is destroyed. + * @param impl Initialized shared pointer */ - ExecutableNetwork() = default; + ExecutableNetwork(const details::SharedObjectLoader& so, + const std::shared_ptr& impl); + friend class Core; +public: /** - * @brief Default destructor + * @brief A default constructor. */ - ~ExecutableNetwork(); + ExecutableNetwork() = default; /** * @brief Gets the Executable network output Data node information. diff --git a/inference-engine/include/cpp/ie_infer_request.hpp b/inference-engine/include/cpp/ie_infer_request.hpp index 8ae8f1be3b948a..54c71c410fd7d8 100644 --- a/inference-engine/include/cpp/ie_infer_request.hpp +++ b/inference-engine/include/cpp/ie_infer_request.hpp @@ -13,17 +13,13 @@ #include #include +#include "ie_blob.h" #include "cpp/ie_memory_state.hpp" -#include "ie_remote_context.hpp" #include "ie_iinfer_request.hpp" #include "details/ie_so_loader.h" -#include "ie_blob.h" namespace InferenceEngine { -namespace details { -class SharedObjectLoader; -} class IInferRequestInternal; /** @@ -33,12 +29,16 @@ class IInferRequestInternal; * It can throw exceptions safely for the application, where it is properly handled. */ class INFERENCE_ENGINE_API_CLASS(InferRequest) { - std::shared_ptr _impl; - std::shared_ptr _so; - - InferRequest(const std::shared_ptr& impl, - const std::shared_ptr& so); + details::SharedObjectLoader _so; + std::shared_ptr _impl; + /** + * @brief Constructs InferRequest from the initialized std::shared_ptr + * @param so Plugin to use. This is required to ensure that InferRequest can work properly even if plugin object is destroyed. + * @param impl Initialized shared pointer + */ + InferRequest(const details::SharedObjectLoader& so, + const std::shared_ptr& impl); friend class ExecutableNetwork; public: @@ -63,11 +63,6 @@ class INFERENCE_ENGINE_API_CLASS(InferRequest) { */ InferRequest() = default; - /** - * @brief Destructor - */ - ~InferRequest(); - /** * @brief Sets input/output data to infer * diff --git a/inference-engine/include/cpp/ie_memory_state.hpp b/inference-engine/include/cpp/ie_memory_state.hpp index 6907862efc1048..7e135abcb4721d 100644 --- a/inference-engine/include/cpp/ie_memory_state.hpp +++ b/inference-engine/include/cpp/ie_memory_state.hpp @@ -15,34 +15,35 @@ #include "ie_api.h" #include "ie_blob.h" +#include "details/ie_so_loader.h" namespace InferenceEngine { -namespace details { -class SharedObjectLoader; -} - class IVariableStateInternal; /** * @brief C++ exception based error reporting wrapper of API class IVariableState */ class INFERENCE_ENGINE_API_CLASS(VariableState) { - std::shared_ptr _impl = nullptr; - std::shared_ptr _so = nullptr; + details::SharedObjectLoader _so; + std::shared_ptr _impl; /** * @brief Constructs VariableState from the initialized std::shared_ptr * @param impl Initialized shared pointer * @param so Optional: Plugin to use. This is required to ensure that VariableState can work properly even if plugin object is destroyed. */ - VariableState(const std::shared_ptr& impl, - const std::shared_ptr& so); - + VariableState(const details::SharedObjectLoader& so, + const std::shared_ptr& impl); friend class InferRequest; friend class ExecutableNetwork; public: + /** + * @brief Default constructor + */ + VariableState() = default; + /** * @copybrief IVariableState::Reset * @@ -62,7 +63,7 @@ class INFERENCE_ENGINE_API_CLASS(VariableState) { * @copybrief IVariableState::GetState * * Wraps IVariableState::GetState - * @return A blob representing a state + * @return A blob representing a state */ Blob::CPtr GetState() const; diff --git a/inference-engine/include/details/ie_so_loader.h b/inference-engine/include/details/ie_so_loader.h index aa1a82a2281a6d..dc03b31655a866 100644 --- a/inference-engine/include/details/ie_so_loader.h +++ b/inference-engine/include/details/ie_so_loader.h @@ -4,7 +4,7 @@ /** * @brief A header file for definition of abstraction over platform specific shared objects - * + * * @file ie_so_loader.h */ #pragma once @@ -25,9 +25,9 @@ class INFERENCE_ENGINE_API_CLASS(SharedObjectLoader) { public: /** - * @brief A shared pointer to SharedObjectLoader + * @brief Default constructor */ - using Ptr = std::shared_ptr; + SharedObjectLoader() = default; #ifdef ENABLE_UNICODE_PATH_SUPPORT /** diff --git a/inference-engine/include/details/ie_so_pointer.hpp b/inference-engine/include/details/ie_so_pointer.hpp index b2926ee44ecae7..62abb7bb10e497 100644 --- a/inference-engine/include/details/ie_so_pointer.hpp +++ b/inference-engine/include/details/ie_so_pointer.hpp @@ -36,19 +36,19 @@ using enableIfSupportedChar = typename std::enable_if<(std::is_same::va /** * @brief This class instantiate object using shared library * @tparam T An type of object SOPointer can hold - * @tparam Loader A loader used to load a library */ -template +template class SOPointer { - template + template friend class SOPointer; -IE_SUPPRESS_DEPRECATED_START + + IE_SUPPRESS_DEPRECATED_START struct HasRelease { template static char test(decltype(&C::Release)); template static long test(...); constexpr static const bool value = sizeof(test(nullptr)) == sizeof(char); }; -IE_SUPPRESS_DEPRECATED_END + IE_SUPPRESS_DEPRECATED_END public: /** @@ -62,48 +62,36 @@ IE_SUPPRESS_DEPRECATED_END */ template > - explicit SOPointer(const std::basic_string & name) - : _so_loader(new Loader(name.c_str())) { - Load(std::integral_constant{}); - } - - /** - * @brief The main constructor - * @param name Name of a shared library file - */ - explicit SOPointer(const char * name) - : _so_loader(new Loader(name)) { - Load(std::integral_constant{}); - } + SOPointer(const std::basic_string & name) + : _so(name.c_str()) { + Load(std::integral_constant{}); + } /** * @brief Constructs an object with existing reference - * @param pointedObj Existing reference to wrap + * @brief Constructs an object with existing loader + * @param soLoader Existing pointer to a library loader */ - explicit SOPointer(T* pointedObj): _so_loader(), _pointedObj(pointedObj) { - if (_pointedObj == nullptr) { - IE_THROW() << "Cannot create SOPointer from nullptr"; - } - } + SOPointer(const SharedObjectLoader& so, const std::shared_ptr& ptr) : _so{so}, _ptr{ptr} {} /** * @brief Constructs an object with existing loader - * @param so_loader Existing pointer to a library loader + * @param so Existing pointer to a library loader */ - explicit SOPointer(const std::shared_ptr& so_loader) - : _so_loader(so_loader) { - Load(std::integral_constant{}); - } + explicit SOPointer(const SharedObjectLoader& so) + : _so(so) { + Load(std::integral_constant{}); + } /** * @brief The copy-like constructor, can create So Pointer that dereferenced into child type if T is derived of U * @param that copied SOPointer object */ - template - SOPointer(const SOPointer& that) - : _so_loader(std::dynamic_pointer_cast(that._so_loader)), - _pointedObj(std::dynamic_pointer_cast(that._pointedObj)) { - IE_ASSERT(_pointedObj != nullptr); + template + SOPointer(const SOPointer& that) + : _so(that._so), + _ptr(std::dynamic_pointer_cast(that._ptr)) { + IE_ASSERT(_ptr != nullptr); } /** @@ -111,19 +99,11 @@ IE_SUPPRESS_DEPRECATED_END * @return underlined interface with disabled Release method */ T* operator->() const noexcept { - return _pointedObj.get(); - } - - /** - * @brief Standard dereference operator - * @return underlined interface with disabled Release method - */ - const T* operator*() const noexcept { - return this->operator->(); + return _ptr.get(); } explicit operator bool() const noexcept { - return (nullptr != _pointedObj); + return _ptr != nullptr; } friend bool operator==(std::nullptr_t, const SOPointer& ptr) noexcept { @@ -139,14 +119,12 @@ IE_SUPPRESS_DEPRECATED_END return static_cast(ptr); } - SOPointer& operator=(const SOPointer& pointer) noexcept { - _pointedObj = pointer._pointedObj; - _so_loader = pointer._so_loader; - return *this; + operator const SharedObjectLoader&() const noexcept { + return _so; } - operator const std::shared_ptr&() const noexcept { - return _so_loader; + operator std::shared_ptr& () noexcept { + return _ptr; } protected: @@ -173,10 +151,10 @@ IE_SUPPRESS_DEPRECATED_END try { void* create = nullptr; try { - create = _so_loader->get_symbol((SOCreatorTrait::name + std::string("Shared")).c_str()); + create = _so.get_symbol((SOCreatorTrait::name + std::string("Shared")).c_str()); } catch (const NotFound&) {} if (create == nullptr) { - create = _so_loader->get_symbol(SOCreatorTrait::name); + create = _so.get_symbol(SOCreatorTrait::name); using CreateF = StatusCode(T*&, ResponseDesc*); T* object = nullptr; ResponseDesc desc; @@ -186,11 +164,11 @@ IE_SUPPRESS_DEPRECATED_END InferenceEngine::details::ThrowNow{} <<= std::stringstream{} << IE_LOCATION << desc.msg) } IE_SUPPRESS_DEPRECATED_START - _pointedObj = std::shared_ptr(object, [] (T* ptr){ptr->Release();}); + _ptr = std::shared_ptr(object, [] (T* ptr){ptr->Release();}); IE_SUPPRESS_DEPRECATED_END } else { using CreateF = void(std::shared_ptr&); - reinterpret_cast(create)(_pointedObj); + reinterpret_cast(create)(_ptr); } } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { IE_THROW() << ex.what(); @@ -205,7 +183,7 @@ IE_SUPPRESS_DEPRECATED_END void Load(std::false_type) { try { using CreateF = void(std::shared_ptr&); - reinterpret_cast(_so_loader->get_symbol(SOCreatorTrait::name))(_pointedObj); + reinterpret_cast(_so.get_symbol(SOCreatorTrait::name))(_ptr); } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { IE_THROW() << ex.what(); } catch(...) { @@ -216,14 +194,14 @@ IE_SUPPRESS_DEPRECATED_END #undef CATCH_IE_EXCEPTIONS /** - * @brief Gets a smart pointer to the DLL + * @brief The DLL */ - std::shared_ptr _so_loader; + SharedObjectLoader _so; /** * @brief Gets a smart pointer to the custom object */ - std::shared_ptr _pointedObj; + std::shared_ptr _ptr; }; } // namespace details } // namespace InferenceEngine diff --git a/inference-engine/src/auto_plugin/auto_exec_network.cpp b/inference-engine/src/auto_plugin/auto_exec_network.cpp index 0d691214835701..d6b42a1a8eca05 100644 --- a/inference-engine/src/auto_plugin/auto_exec_network.cpp +++ b/inference-engine/src/auto_plugin/auto_exec_network.cpp @@ -13,11 +13,12 @@ #include "auto_infer_request.hpp" namespace AutoPlugin { - using namespace InferenceEngine; -AutoExecutableNetwork::AutoExecutableNetwork(const ExecutableNetwork& network, - const DeviceInformation& deviceInfo, - const bool needPerfCounters) : +using namespace InferenceEngine; + +AutoExecutableNetwork::AutoExecutableNetwork(const SoExecutableNetworkInternal& network, + const DeviceInformation& deviceInfo, + const bool needPerfCounters) : _deviceInfo(deviceInfo), _network(network), _config(deviceInfo.config.begin(), deviceInfo.config.end()), @@ -28,32 +29,32 @@ AutoExecutableNetwork::~AutoExecutableNetwork() = default; IInferRequestInternal::Ptr AutoExecutableNetwork::CreateInferRequestImpl(InputsDataMap networkInputs, OutputsDataMap networkOutputs) { - auto inferRequest = _network.CreateInferRequest(); + SoIInferRequestInternal inferRequest = { _network, _network->CreateInferRequest() }; return std::make_shared(networkInputs, networkOutputs, inferRequest); } void AutoExecutableNetwork::Export(std::ostream& networkModel) { - _network.Export(networkModel); + _network->Export(networkModel); } RemoteContext::Ptr AutoExecutableNetwork::GetContext() const { - return _network.GetContext(); + return _network->GetContext(); } InferenceEngine::CNNNetwork AutoExecutableNetwork::GetExecGraphInfo() { - return _network.GetExecGraphInfo(); + return _network->GetExecGraphInfo(); } Parameter AutoExecutableNetwork::GetMetric(const std::string &name) const { - return _network.GetMetric(name); + return _network->GetMetric(name); } void AutoExecutableNetwork::SetConfig(const std::map& config) { - _network.SetConfig(config); + _network->SetConfig(config); } Parameter AutoExecutableNetwork::GetConfig(const std::string& name) const { - return _network.GetConfig(name); + return _network->GetConfig(name); } } // namespace AutoPlugin diff --git a/inference-engine/src/auto_plugin/auto_exec_network.hpp b/inference-engine/src/auto_plugin/auto_exec_network.hpp index 635d9573b9da66..0a99ba061336e9 100644 --- a/inference-engine/src/auto_plugin/auto_exec_network.hpp +++ b/inference-engine/src/auto_plugin/auto_exec_network.hpp @@ -28,9 +28,9 @@ class AutoExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSaf public: using Ptr = std::shared_ptr; - AutoExecutableNetwork(const InferenceEngine::ExecutableNetwork& network, - const DeviceInformation& deviceInfo, - const bool needPerfCounters = false); + AutoExecutableNetwork(const InferenceEngine::SoExecutableNetworkInternal& network, + const DeviceInformation& deviceInfo, + const bool needPerfCounters = false); void Export(std::ostream& networkModel) override; InferenceEngine::RemoteContext::Ptr GetContext() const override; @@ -43,7 +43,7 @@ class AutoExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadSaf ~AutoExecutableNetwork() override; DeviceInformation _deviceInfo; - InferenceEngine::ExecutableNetwork _network; + InferenceEngine::SoExecutableNetworkInternal _network; std::unordered_map _config; bool _needPerfCounters = false; }; diff --git a/inference-engine/src/auto_plugin/auto_infer_request.cpp b/inference-engine/src/auto_plugin/auto_infer_request.cpp index 0adc4ba09388b3..bcaf9b2aa5c4c0 100644 --- a/inference-engine/src/auto_plugin/auto_infer_request.cpp +++ b/inference-engine/src/auto_plugin/auto_infer_request.cpp @@ -9,31 +9,31 @@ namespace AutoPlugin { using namespace InferenceEngine; -AutoInferRequest::AutoInferRequest(const InputsDataMap& networkInputs, - const OutputsDataMap& networkOutputs, - const InferRequest& inferRequest) +AutoInferRequest::AutoInferRequest(const InputsDataMap& networkInputs, + const OutputsDataMap& networkOutputs, + const SoIInferRequestInternal& inferRequest) : IInferRequestInternal(networkInputs, networkOutputs) , _inferRequest(inferRequest) { } std::map AutoInferRequest::GetPerformanceCounts() const { - return _inferRequest.GetPerformanceCounts(); + return _inferRequest->GetPerformanceCounts(); } void AutoInferRequest::InferImpl() { - _inferRequest.Infer(); + _inferRequest->Infer(); } void AutoInferRequest::SetBlob(const std::string& name, const InferenceEngine::Blob::Ptr& data) { - _inferRequest.SetBlob(name, data); + _inferRequest->SetBlob(name, data); } Blob::Ptr AutoInferRequest::GetBlob(const std::string& name) { - return _inferRequest.GetBlob(name); + return _inferRequest->GetBlob(name); } void AutoInferRequest::Cancel() { - _inferRequest.Cancel(); + _inferRequest->Cancel(); } } // namespace AutoPlugin diff --git a/inference-engine/src/auto_plugin/auto_infer_request.hpp b/inference-engine/src/auto_plugin/auto_infer_request.hpp index 49da8a117e1779..400a18bf7c6167 100644 --- a/inference-engine/src/auto_plugin/auto_infer_request.hpp +++ b/inference-engine/src/auto_plugin/auto_infer_request.hpp @@ -5,8 +5,6 @@ #pragma once #include -#include -#include #include #include #include @@ -24,9 +22,9 @@ namespace AutoPlugin { class AutoInferRequest : public InferenceEngine::IInferRequestInternal { public: using Ptr = std::shared_ptr; - explicit AutoInferRequest(const InferenceEngine::InputsDataMap& networkInputs, - const InferenceEngine::OutputsDataMap& networkOutputs, - const InferenceEngine::InferRequest& inferRequest); + explicit AutoInferRequest(const InferenceEngine::InputsDataMap& networkInputs, + const InferenceEngine::OutputsDataMap& networkOutputs, + const InferenceEngine::SoIInferRequestInternal& inferRequest); std::map GetPerformanceCounts() const override; void InferImpl() override; void SetBlob(const std::string& name, const InferenceEngine::Blob::Ptr& data) override; @@ -34,7 +32,7 @@ class AutoInferRequest : public InferenceEngine::IInferRequestInternal { void Cancel() override; private: - InferenceEngine::InferRequest _inferRequest; + InferenceEngine::SoIInferRequestInternal _inferRequest; }; } // namespace AutoPlugin diff --git a/inference-engine/src/auto_plugin/auto_plugin.cpp b/inference-engine/src/auto_plugin/auto_plugin.cpp index 692d8955a09424..8035cc74ccfc0a 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.cpp +++ b/inference-engine/src/auto_plugin/auto_plugin.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -38,6 +37,38 @@ AutoInferencePlugin::AutoInferencePlugin() { _pluginName = "AUTO"; } +IE::IExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadNetwork(const std::string& fileName, + const ConfigType& config) { + if (GetCore() == nullptr) { + IE_THROW() << "Please, work with AUTO device via InferencEngine::Core object"; + } + + auto fullConfig = mergeConfigs(_config, config); + auto metaDevices = GetDeviceChoice(fullConfig); + + // FIXME: always select CPU device now + DeviceInformation selectedDevice = SelectDevice(metaDevices); + IE::SoExecutableNetworkInternal executableNetwork; + try { + executableNetwork = GetCore()->LoadNetwork(fileName, selectedDevice.deviceName, selectedDevice.config); + } catch(const IE::Exception &iie) { + IE_THROW() << "Failed to load network to device named " << selectedDevice.deviceName + << " with exception " << iie.what(); + } + + bool enablePerfCounters = false; + try { + enablePerfCounters = + executableNetwork->GetConfig(IE::PluginConfigParams::KEY_PERF_COUNT).as() == + IE::PluginConfigParams::YES; + } catch (...) { + } + + return std::make_shared(executableNetwork, + selectedDevice, + enablePerfCounters); +} + IE::ExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadExeNetworkImpl(const IE::CNNNetwork& network, const ConfigType& config) { if (GetCore() == nullptr) { @@ -53,7 +84,7 @@ IE::ExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadExeNetworkImpl(const // FIXME: always select CPU device now DeviceInformation selectedDevice = SelectDevice(metaDevices); - IE::ExecutableNetwork executableNetwork; + IE::SoExecutableNetworkInternal executableNetwork; try { executableNetwork = GetCore()->LoadNetwork(network, selectedDevice.deviceName, selectedDevice.config); } catch(const IE::Exception &iie) { @@ -64,7 +95,7 @@ IE::ExecutableNetworkInternal::Ptr AutoInferencePlugin::LoadExeNetworkImpl(const bool enablePerfCounters = false; try { enablePerfCounters = - executableNetwork.GetConfig(IE::PluginConfigParams::KEY_PERF_COUNT).as() == + executableNetwork->GetConfig(IE::PluginConfigParams::KEY_PERF_COUNT).as() == IE::PluginConfigParams::YES; } catch (...) { } diff --git a/inference-engine/src/auto_plugin/auto_plugin.hpp b/inference-engine/src/auto_plugin/auto_plugin.hpp index a2a885d4f1fc51..6eefeec5e2ed26 100644 --- a/inference-engine/src/auto_plugin/auto_plugin.hpp +++ b/inference-engine/src/auto_plugin/auto_plugin.hpp @@ -22,6 +22,7 @@ class AutoInferencePlugin : public IE::InferencePluginInternal { AutoInferencePlugin(); ~AutoInferencePlugin() = default; IE::ExecutableNetworkInternal::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; IE::Parameter GetConfig(const std::string& name, const std::map & options) const override; diff --git a/inference-engine/src/gna_plugin/gna_infer_request.hpp b/inference-engine/src/gna_plugin/gna_infer_request.hpp index e0256b32f2b641..2aaf21341c398e 100644 --- a/inference-engine/src/gna_plugin/gna_infer_request.hpp +++ b/inference-engine/src/gna_plugin/gna_infer_request.hpp @@ -9,6 +9,7 @@ #include #include "cpp_interfaces/interface/ie_iinfer_request_internal.hpp" +#include "cpp/ie_infer_request.hpp" #include "gna_plugin.hpp" namespace GNAPluginNS { diff --git a/inference-engine/src/gna_plugin/gna_plugin.hpp b/inference-engine/src/gna_plugin/gna_plugin.hpp index 33df51710ba69e..7ea93642ba1bb6 100644 --- a/inference-engine/src/gna_plugin/gna_plugin.hpp +++ b/inference-engine/src/gna_plugin/gna_plugin.hpp @@ -110,7 +110,7 @@ class GNAPlugin : public InferenceEngine::IInferencePlugin { InferenceEngine::IExecutableNetworkInternal::Ptr LoadNetwork(const InferenceEngine::CNNNetwork &network, const std::map &config_map, InferenceEngine::RemoteContext::Ptr context) override { THROW_GNA_EXCEPTION << "Not implemented"; } - InferenceEngine::ExecutableNetwork LoadNetwork(const std::string &modelPath, + 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 {} diff --git a/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp b/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp index cdd3c54ae17fd4..ce99b0958c9cfc 100644 --- a/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp +++ b/inference-engine/src/hetero_plugin/hetero_async_infer_request.cpp @@ -13,35 +13,31 @@ HeteroAsyncInferRequest::HeteroAsyncInferRequest(const IInferRequestInternal::Pt const ITaskExecutor::Ptr& taskExecutor, const ITaskExecutor::Ptr& callbackExecutor) : AsyncInferRequestThreadSafeDefault(request, taskExecutor, callbackExecutor), - _heteroInferRequest(std::static_pointer_cast(request)), - _statusCodes{_heteroInferRequest->_inferRequests.size(), StatusCode::OK} { + _heteroInferRequest(std::static_pointer_cast(request)) { _pipeline.clear(); for (std::size_t requestId = 0; requestId < _heteroInferRequest->_inferRequests.size(); ++requestId) { struct RequestExecutor : ITaskExecutor { - explicit RequestExecutor(InferRequest & inferRequest) : _inferRequest(inferRequest) { - _inferRequest.SetCompletionCallback>( - [this] (InferRequest, StatusCode sts) mutable { - _status = sts; + explicit RequestExecutor(SoIInferRequestInternal & inferRequest) : _inferRequest(inferRequest) { + _inferRequest->SetCallback( + [this] (std::exception_ptr exceptionPtr) mutable { + _exceptionPtr = exceptionPtr; auto capturedTask = std::move(_task); capturedTask(); }); } void run(Task task) override { _task = std::move(task); - _inferRequest.StartAsync(); + _inferRequest->StartAsync(); }; - InferRequest & _inferRequest; - StatusCode _status = StatusCode::OK; - Task _task; + SoIInferRequestInternal & _inferRequest; + std::exception_ptr _exceptionPtr; + Task _task; }; auto requestExecutor = std::make_shared(_heteroInferRequest->_inferRequests[requestId]._request); _pipeline.emplace_back(requestExecutor, [requestExecutor] { - if (StatusCode::OK != requestExecutor->_status) { - IE_EXCEPTION_SWITCH(requestExecutor->_status, ExceptionType, - InferenceEngine::details::ThrowNow{} - <<= std::stringstream{} << IE_LOCATION - << InferenceEngine::details::ExceptionTraits::string()); + if (nullptr != requestExecutor->_exceptionPtr) { + std::rethrow_exception(requestExecutor->_exceptionPtr); } }); } @@ -58,7 +54,7 @@ StatusCode HeteroAsyncInferRequest::Wait(int64_t millis_timeout) { waitStatus = AsyncInferRequestThreadSafeDefault::Wait(millis_timeout); } catch(...) { for (auto&& requestDesc : _heteroInferRequest->_inferRequests) { - requestDesc._request.Wait(InferRequest::RESULT_READY); + requestDesc._request->Wait(-1); } throw; } diff --git a/inference-engine/src/hetero_plugin/hetero_async_infer_request.hpp b/inference-engine/src/hetero_plugin/hetero_async_infer_request.hpp index 1a36f8724be416..22f8d065432287 100644 --- a/inference-engine/src/hetero_plugin/hetero_async_infer_request.hpp +++ b/inference-engine/src/hetero_plugin/hetero_async_infer_request.hpp @@ -23,7 +23,6 @@ class HeteroAsyncInferRequest : public InferenceEngine::AsyncInferRequestThreadS private: HeteroInferRequest::Ptr _heteroInferRequest; - std::vector _statusCodes; }; } // namespace HeteroPlugin diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp index 83f8a57156cded..bc5ace2160c514 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.cpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.cpp @@ -368,17 +368,17 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(const InferenceEngine::CNNNetwo InputsDataMap externalInputsData = network.getInputsInfo(); OutputsDataMap externalOutputsData = network.getOutputsInfo(); - networks.resize(orderedSubgraphs.size()); + _networks.resize(orderedSubgraphs.size()); std::vector> subFunctions(orderedSubgraphs.size()); int id = 0; for (auto&& subgraph : orderedSubgraphs) { - networks[id]._device = subgraph._affinity; + _networks[id]._device = subgraph._affinity; subFunctions[id] = std::make_shared(subgraph._results, subgraph._parameters, _name + '_' + std::to_string(id)); - networks[id]._clonedNetwork = CNNNetwork{subFunctions[id]}; + _networks[id]._clonedNetwork = CNNNetwork{subFunctions[id]}; // update of pre-processing info - auto clonedInputs = networks[id]._clonedNetwork.getInputsInfo(); + auto clonedInputs = _networks[id]._clonedNetwork.getInputsInfo(); for (auto&& externalInput : externalInputsData) { auto itClonedInput = clonedInputs.find(externalInput.first); if (itClonedInput != clonedInputs.end() && nullptr != itClonedInput->second) { @@ -388,7 +388,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(const InferenceEngine::CNNNetwo } } // update output info - auto clonedOutputs = networks[id]._clonedNetwork.getOutputsInfo(); + auto clonedOutputs = _networks[id]._clonedNetwork.getOutputsInfo(); for (auto&& externalOutput : externalOutputsData) { auto itClonedOutput = clonedOutputs.find(externalOutput.first); if (itClonedOutput != clonedOutputs.end() && nullptr != itClonedOutput->second) { @@ -418,7 +418,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(const InferenceEngine::CNNNetwo } }}.run_on_function(ngraph::clone_function(*function)); } - for (auto&& network : networks) { + for (auto&& network : _networks) { auto metaDevices = _heteroPlugin->GetDevicePlugins(network._device, _config); metaDevices[network._device].emplace(CONFIG_KEY_INTERNAL(FORCE_DISABLE_CACHE), ""); network._network = _heteroPlugin->GetCore()->LoadNetwork(network._clonedNetwork, @@ -481,7 +481,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(std::istream& assert(metaDevices.size() == 1); auto& loadConfig = metaDevices[deviceName]; - InferenceEngine::ExecutableNetwork executableNetwork; + InferenceEngine::SoExecutableNetworkInternal executableNetwork; CNNNetwork cnnnetwork; bool loaded = false; if (ImportExportSupported(deviceName)) { @@ -526,13 +526,13 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(std::istream& } // restore network inputs and outputs - for (auto&& input : executableNetwork.GetInputsInfo()) { + for (auto&& input : executableNetwork->GetInputsInfo()) { if (networkInputs.end() != networkInputs.find(input.first)) { _networkInputs.emplace(input.first, std::make_shared(*input.second)); } } - for (auto&& output : executableNetwork.GetOutputsInfo()) { + for (auto&& output : executableNetwork->GetOutputsInfo()) { if (networkOutputs.end() != networkOutputs.find(output.first)) { _networkOutputs.emplace(output.first, std::make_shared(*output.second)); } @@ -547,7 +547,7 @@ HeteroExecutableNetwork::HeteroExecutableNetwork(std::istream& // save state this->_config = importedConfigs; - this->networks = std::move(descs); + this->_networks = std::move(descs); this->SetPointerToPlugin(_heteroPlugin->shared_from_this()); } @@ -567,7 +567,7 @@ void HeteroExecutableNetwork::ExportImpl(std::ostream& heteroModel) { } auto subnetworksNode = heteroNode.append_child("subnetworks"); - for (auto&& subnetwork : networks) { + for (auto&& subnetwork : _networks) { auto subnet = subnetwork._clonedNetwork; IE_ASSERT(subnet.getFunction() != nullptr); @@ -611,9 +611,9 @@ void HeteroExecutableNetwork::ExportImpl(std::ostream& heteroModel) { doc.reset(); heteroModel << std::endl; - for (auto&& subnetwork : networks) { + for (auto&& subnetwork : _networks) { if (ImportExportSupported(subnetwork._device)) { - subnetwork._network.Export(heteroModel); + subnetwork._network->Export(heteroModel); } else { auto subnet = subnetwork._clonedNetwork; if (!subnet.getFunction()) { @@ -645,7 +645,7 @@ IInferRequestInternal::Ptr HeteroExecutableNetwork::CreateInferRequestImpl( OutputsDataMap networkOutputs) { HeteroInferRequest::SubRequestsList inferRequests; int index = 0; - for (auto&& subnetwork : networks) { + for (auto&& subnetwork : _networks) { HeteroInferRequest::SubRequestDesc desc; desc._network = subnetwork._network; desc._profilingTask = openvino::itt::handle("Infer" + std::to_string(index++)); @@ -677,12 +677,12 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetConfig(const std::string result = it->second == YES ? true : false; } else { // find config key among plugin config keys - for (auto&& desc : networks) { + for (auto&& desc : _networks) { auto execNetwork = desc._network; - auto param = execNetwork.GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); + auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); for (auto && configKey : param.as>()) { if (configKey == name) { - return execNetwork.GetConfig(configKey); + return execNetwork->GetConfig(configKey); } } } @@ -741,12 +741,12 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetMetric(const std::string { std::vector<::Metrics> pluginMetrics; - for (auto&& desc : networks) { + for (auto&& desc : _networks) { auto execNetwork = desc._network; - auto param = execNetwork.GetMetric(METRIC_KEY(SUPPORTED_METRICS)); + auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_METRICS)); ::Metrics metrics; for (auto && metricName : param.as>()) { - metrics[metricName] = execNetwork.GetMetric(metricName); + metrics[metricName] = execNetwork->GetMetric(metricName); } pluginMetrics.push_back(std::move(metrics)); } @@ -764,12 +764,12 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetMetric(const std::string { std::vector<::Metrics> pluginConfigKeys; - for (auto&& desc : networks) { + for (auto&& desc : _networks) { auto execNetwork = desc._network; - auto param = execNetwork.GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); + auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_CONFIG_KEYS)); ::Metrics configKeys; for (auto && metricName : param.as>()) { - configKeys[metricName] = execNetwork.GetConfig(metricName); + configKeys[metricName] = execNetwork->GetConfig(metricName); } pluginConfigKeys.push_back(std::move(configKeys)); } @@ -782,18 +782,18 @@ InferenceEngine::Parameter HeteroExecutableNetwork::GetMetric(const std::string IE_SET_METRIC_RETURN(NETWORK_NAME, _name); } else if (EXEC_NETWORK_METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS) == name) { unsigned int value = 0u; - for (auto&& desc : networks) { - value = std::max(value, desc._network.GetMetric(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)).as()); + for (auto&& desc : _networks) { + value = std::max(value, desc._network->GetMetric(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)).as()); } IE_SET_METRIC_RETURN(OPTIMAL_NUMBER_OF_INFER_REQUESTS, value); } else { // find metric key among plugin metrics - for (auto&& desc : networks) { + for (auto&& desc : _networks) { auto execNetwork = desc._network; - auto param = execNetwork.GetMetric(METRIC_KEY(SUPPORTED_METRICS)); + auto param = execNetwork->GetMetric(METRIC_KEY(SUPPORTED_METRICS)); for (auto && metricKey : param.as>()) { if (metricKey == name) { - return execNetwork.GetMetric(metricKey); + return execNetwork->GetMetric(metricKey); } } } diff --git a/inference-engine/src/hetero_plugin/hetero_executable_network.hpp b/inference-engine/src/hetero_plugin/hetero_executable_network.hpp index 323cafbeb1eb39..9189d965a813af 100644 --- a/inference-engine/src/hetero_plugin/hetero_executable_network.hpp +++ b/inference-engine/src/hetero_plugin/hetero_executable_network.hpp @@ -50,7 +50,7 @@ class HeteroExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadS ~HeteroExecutableNetwork() override = default; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequestImpl(InferenceEngine::InputsDataMap networkInputs, - InferenceEngine::OutputsDataMap networkOutputs) override; + InferenceEngine::OutputsDataMap networkOutputs) override; InferenceEngine::IInferRequestInternal::Ptr CreateInferRequest() override; @@ -66,15 +66,15 @@ class HeteroExecutableNetwork : public InferenceEngine::ExecutableNetworkThreadS bool ImportExportSupported(const std::string& deviceName) const; struct NetworkDesc { - std::string _device; - InferenceEngine::CNNNetwork _clonedNetwork; - InferenceEngine::ExecutableNetwork _network; + std::string _device; + InferenceEngine::CNNNetwork _clonedNetwork; + InferenceEngine::SoExecutableNetworkInternal _network; }; - std::vector networks; - Engine* _heteroPlugin; - std::string _name; - std::map _config; + std::vector _networks; + Engine* _heteroPlugin; + std::string _name; + std::map _config; std::unordered_map _blobNameMap; }; diff --git a/inference-engine/src/hetero_plugin/hetero_infer_request.cpp b/inference-engine/src/hetero_plugin/hetero_infer_request.cpp index e6fb139daa1060..7171363e7830f2 100644 --- a/inference-engine/src/hetero_plugin/hetero_infer_request.cpp +++ b/inference-engine/src/hetero_plugin/hetero_infer_request.cpp @@ -26,7 +26,7 @@ HeteroInferRequest::HeteroInferRequest(InferenceEngine::InputsDataMap networkInp IE_THROW() << "Internal error: no information about network's output/input"; } - auto requestBlob([&](const std::string& blobName, InferenceEngine::InferRequest & r) { + auto requestBlob([&](const std::string& blobName, InferenceEngine::SoIInferRequestInternal& r) { std::string intermediateBlobName = blobName; auto itName = subgraphInputToOutputBlobNames.find(blobName); if (itName != subgraphInputToOutputBlobNames.end()) { @@ -36,29 +36,29 @@ HeteroInferRequest::HeteroInferRequest(InferenceEngine::InputsDataMap networkInp bool emplaced = false; std::tie(itBlob, emplaced) = _blobs.emplace(intermediateBlobName, Blob::Ptr{}); if (emplaced) { - itBlob->second = r.GetBlob(blobName); + itBlob->second = r->GetBlob(blobName); if (InferenceEngine::details::contains(networkInputs, blobName)) { _inputs[blobName] = itBlob->second; } else if (InferenceEngine::details::contains(networkOutputs, blobName)) { _outputs[blobName] = itBlob->second; } } else { - r.SetBlob(blobName, itBlob->second); + r->SetBlob(blobName, itBlob->second); } }); // go over all subnet and create requests for (auto&& desc : _inferRequests) { - desc._request = desc._network.CreateInferRequest(); + desc._request = { desc._network, desc._network->CreateInferRequest() }; // go over all inputs and get blobs from subnet infer requests - for (auto&& outputInfo : desc._network.GetOutputsInfo()) { + for (auto&& outputInfo : desc._network->GetOutputsInfo()) { requestBlob(outputInfo.first, desc._request); } } // go over all outputs and get blobs from subnet infer requests for (auto&& desc : _inferRequests) { - for (auto&& inputInfo : desc._network.GetInputsInfo()) { + for (auto&& inputInfo : desc._network->GetInputsInfo()) { requestBlob(inputInfo.first, desc._request); } } @@ -75,7 +75,7 @@ void HeteroInferRequest::SetBlob(const std::string& name, const InferenceEngine: try { // if `name` is input blob if (findInputAndOutputBlobByName(name, foundInput, foundOutput)) { - r.SetBlob(name, data, foundInput->getPreProcess()); + r->SetBlob(name, data, foundInput->getPreProcess()); } } catch (const InferenceEngine::NotFound& ex) {} } @@ -87,14 +87,14 @@ void HeteroInferRequest::InferImpl() { OV_ITT_SCOPED_TASK(itt::domains::HeteroPlugin, desc._profilingTask); auto &r = desc._request; assert(r); - r.Infer(); + r->Infer(); } } std::map HeteroInferRequest::GetPerformanceCounts() const { std::map perfMap; for (size_t i = 0; i < _inferRequests.size(); i++) { - auto perfMapRequest = _inferRequests[i]._request.GetPerformanceCounts(); + auto perfMapRequest = _inferRequests[i]._request->GetPerformanceCounts(); for (auto &&r : perfMapRequest) { perfMap[std::string("subgraph") + std::to_string(i) + ": " + r.first] = r.second; } @@ -108,30 +108,30 @@ void HeteroInferRequest::updateInOutIfNeeded() { for (auto &&desc : _inferRequests) { auto &r = desc._request; assert(r); - for (auto&& inputInfo : desc._network.GetInputsInfo()) { + for (auto&& inputInfo : desc._network->GetInputsInfo()) { auto& ioname = inputInfo.first; auto iti = _inputs.find(ioname); if (iti != _inputs.end()) { auto it = _preProcData.find(ioname); if (it != _preProcData.end()) { if (it->second->getRoiBlob() != _blobs[ioname]) { - r.SetBlob(ioname.c_str(), it->second->getRoiBlob()); + r->SetBlob(ioname.c_str(), it->second->getRoiBlob()); _blobs[ioname] = iti->second; } } else { if (iti->second != _blobs[ioname]) { - r.SetBlob(ioname.c_str(), iti->second); + r->SetBlob(ioname.c_str(), iti->second); _blobs[ioname] = iti->second; } } } } - for (auto&& outputInfo : desc._network.GetOutputsInfo()) { + for (auto&& outputInfo : desc._network->GetOutputsInfo()) { auto& ioname = outputInfo.first; auto ito = _outputs.find(ioname); if (ito != _outputs.end()) { if (ito->second != _blobs[ioname]) { - r.SetBlob(ioname.c_str(), ito->second); + r->SetBlob(ioname.c_str(), ito->second); _blobs[ioname] = ito->second; } } diff --git a/inference-engine/src/hetero_plugin/hetero_infer_request.hpp b/inference-engine/src/hetero_plugin/hetero_infer_request.hpp index 9f13e57a817eb4..9327d2c410d908 100644 --- a/inference-engine/src/hetero_plugin/hetero_infer_request.hpp +++ b/inference-engine/src/hetero_plugin/hetero_infer_request.hpp @@ -11,9 +11,7 @@ #include #include #include -#include -#include -#include +#include #include namespace HeteroPlugin { @@ -23,9 +21,9 @@ class HeteroInferRequest : public InferenceEngine::IInferRequestInternal { typedef std::shared_ptr Ptr; struct SubRequestDesc { - InferenceEngine::ExecutableNetwork _network; - InferenceEngine::InferRequest _request; - openvino::itt::handle_t _profilingTask; + InferenceEngine::SoExecutableNetworkInternal _network; + InferenceEngine::SoIInferRequestInternal _request; + openvino::itt::handle_t _profilingTask; }; using SubRequestsList = std::vector; diff --git a/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp b/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp index cef73ed9347168..de7a0371718d59 100644 --- a/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_executable_network.cpp @@ -11,7 +11,7 @@ namespace InferenceEngine { #define EXEC_NET_CALL_STATEMENT(...) \ - if (_impl == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; \ + if (_impl == nullptr) IE_THROW() << "ExecutableNetwork was not initialized."; \ try { \ __VA_ARGS__; \ } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { \ @@ -20,16 +20,12 @@ namespace InferenceEngine { IE_THROW(Unexpected); \ } -ExecutableNetwork::ExecutableNetwork(const IExecutableNetworkInternal::Ptr& impl, - const std::shared_ptr& so) - : _impl(impl), _so(so) { +ExecutableNetwork::ExecutableNetwork(const details::SharedObjectLoader& so, + const IExecutableNetworkInternal::Ptr& impl) + : _so(so), _impl(impl) { IE_ASSERT(_impl != nullptr); } -ExecutableNetwork::~ExecutableNetwork() { - _impl = {}; -} - ConstOutputsDataMap ExecutableNetwork::GetOutputsInfo() const { EXEC_NET_CALL_STATEMENT(return _impl->GetOutputsInfo()); } @@ -47,7 +43,7 @@ void ExecutableNetwork::reset(IExecutableNetwork::Ptr newActual) { IE_ASSERT(newBase != nullptr); auto newImpl = newBase->GetImpl(); IE_ASSERT(newImpl != nullptr); - this->_impl.swap(newImpl); + _impl = newImpl; } ExecutableNetwork::operator IExecutableNetwork::Ptr() { @@ -58,7 +54,7 @@ std::vector ExecutableNetwork::QueryState() { std::vector controller; EXEC_NET_CALL_STATEMENT( for (auto&& state : _impl->QueryState()) { - controller.emplace_back(VariableState(state, _so)); + controller.emplace_back(VariableState{ _so, state }); }); return controller; } @@ -66,11 +62,11 @@ std::vector ExecutableNetwork::QueryState() { IE_SUPPRESS_DEPRECATED_END InferRequest ExecutableNetwork::CreateInferRequest() { - EXEC_NET_CALL_STATEMENT(return InferRequest{_impl->CreateInferRequest(), _so}); + EXEC_NET_CALL_STATEMENT(return {_so, _impl->CreateInferRequest()}); } InferRequest::Ptr ExecutableNetwork::CreateInferRequestPtr() { - EXEC_NET_CALL_STATEMENT(return std::make_shared(InferRequest{_impl->CreateInferRequest(), _so})); + EXEC_NET_CALL_STATEMENT(return std::make_shared(CreateInferRequest())); } void ExecutableNetwork::Export(const std::string& modelFileName) { @@ -108,5 +104,4 @@ bool ExecutableNetwork::operator!() const noexcept { ExecutableNetwork::operator bool() const noexcept { return !!_impl; } - } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp b/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp index cb3edc1e23eeac..ffb3a3df69e3ea 100644 --- a/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp +++ b/inference-engine/src/inference_engine/cpp/ie_executable_network_base.hpp @@ -15,7 +15,6 @@ #include #include -#include #include #include #include "cpp/exception2status.hpp" diff --git a/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp b/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp index a3052ecda78896..39ded89d237bec 100644 --- a/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_infer_request.cpp @@ -32,7 +32,7 @@ namespace InferenceEngine { CATCH_IE_EXCEPTION(InferCancelled) #define INFER_REQ_CALL_STATEMENT(...) \ - if (_impl == nullptr) IE_THROW() << "Inference Request is not initialized"; \ + if (_impl == nullptr) IE_THROW() << "Inference Request is not initialized"; \ try { \ __VA_ARGS__ \ } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { \ @@ -41,15 +41,10 @@ namespace InferenceEngine { IE_THROW(Unexpected); \ } -InferRequest::InferRequest(const std::shared_ptr& impl, - const std::shared_ptr& so) : - _impl{impl}, - _so{so} { - if (_impl == nullptr) IE_THROW() << "Inference Requst is not initialized"; -} - -InferRequest::~InferRequest() { - _impl = {}; +InferRequest::InferRequest(const details::SharedObjectLoader& so, + const IInferRequestInternal::Ptr& impl) + : _so(so), _impl(impl) { + IE_ASSERT(_impl != nullptr); } void InferRequest::SetBlob(const std::string& name, const Blob::Ptr& data) { @@ -144,7 +139,7 @@ void InferRequest::SetCompletionCallbackImpl(std::function callback) { void InferRequest::SetCompletionCallbackImpl(std::function callback) { INFER_REQ_CALL_STATEMENT( - auto weakThis = InferRequest{std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}, _so}; + auto weakThis = InferRequest{_so, std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}}; _impl->SetCallback([callback, weakThis] (std::exception_ptr exceptionPtr) { StatusCode statusCode = StatusCode::OK; if (exceptionPtr != nullptr) { @@ -167,7 +162,7 @@ IE_SUPPRESS_DEPRECATED_START void InferRequest::SetCompletionCallbackImpl(IInferRequest::CompletionCallback callback) { INFER_REQ_CALL_STATEMENT( - IInferRequest::Ptr weakThis = InferRequest{std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}, _so}; + IInferRequest::Ptr weakThis = InferRequest{_so, std::shared_ptr{_impl.get(), [](IInferRequestInternal*){}}}; _impl->SetCallback([callback, weakThis] (std::exception_ptr exceptionPtr) { StatusCode statusCode = StatusCode::OK; if (exceptionPtr != nullptr) { @@ -198,7 +193,7 @@ std::vector InferRequest::QueryState() { std::vector controller; INFER_REQ_CALL_STATEMENT( for (auto&& state : _impl->QueryState()) { - controller.emplace_back(VariableState(state, _so)); + controller.emplace_back(VariableState{_so, state}); } ) return controller; diff --git a/inference-engine/src/inference_engine/cpp/ie_plugin.hpp b/inference-engine/src/inference_engine/cpp/ie_plugin.hpp new file mode 100644 index 00000000000000..3c7d4afc000ef5 --- /dev/null +++ b/inference-engine/src/inference_engine/cpp/ie_plugin.hpp @@ -0,0 +1,125 @@ +// Copyright (C) 2018-2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +/** + * @brief This is a header file for the Inference Engine plugin C++ API + * + * @file ie_plugin_cpp.hpp + */ +#pragma once + +#include +#include +#include + +#include "file_utils.h" +#include "cpp/ie_cnn_network.h" +#include "cpp/exception2status.hpp" +#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" + +#if defined __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wreturn-type" +#endif + +#define PLUGIN_CALL_STATEMENT(...) \ + if (!_ptr) IE_THROW() << "Wrapper used in the PLUGIN_CALL_STATEMENT was not initialized."; \ + try { \ + __VA_ARGS__; \ + } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { \ + IE_THROW() << ex.what(); \ + } catch (...) { \ + IE_THROW(Unexpected); \ + } + +namespace InferenceEngine { +/** + * @brief This class is a C++ API wrapper for IInferencePlugin. + * + * It can throw exceptions safely for the application, where it is properly handled. + */ +class InferencePlugin : protected details::SOPointer { + using details::SOPointer::SOPointer; + friend class ICore; + +public: + void SetName(const std::string & deviceName) { + PLUGIN_CALL_STATEMENT(_ptr->SetName(deviceName)); + } + + void SetCore(ICore* core) { + PLUGIN_CALL_STATEMENT(_ptr->SetCore(core)); + } + + const Version GetVersion() const { + PLUGIN_CALL_STATEMENT(return _ptr->GetVersion()); + } + + void AddExtension(InferenceEngine::IExtensionPtr extension) { + PLUGIN_CALL_STATEMENT(_ptr->AddExtension(extension)); + } + + void SetConfig(const std::map& config) { + PLUGIN_CALL_STATEMENT(_ptr->SetConfig(config)); + } + + details::SOPointer LoadNetwork(const CNNNetwork& network, const std::map& config) { + PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config)}); + } + + details::SOPointer LoadNetwork(const CNNNetwork& network, RemoteContext::Ptr context, const std::map& config) { + PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config, context)}); + } + + details::SOPointer LoadNetwork(const std::string& modelPath, const std::map& config) { + PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(modelPath, config)}); + } + + QueryNetworkResult QueryNetwork(const CNNNetwork& network, + const std::map& config) const { + QueryNetworkResult res; + PLUGIN_CALL_STATEMENT(res = _ptr->QueryNetwork(network, config)); + if (res.rc != OK) IE_THROW() << res.resp.msg; + return res; + } + + details::SOPointer ImportNetwork(const std::string& modelFileName, + const std::map& config) { + PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(modelFileName, config)}); + } + + details::SOPointer ImportNetwork(std::istream& networkModel, + const std::map& config) { + PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, config)}); + } + + details::SOPointer ImportNetwork(std::istream& networkModel, + const RemoteContext::Ptr& context, + const std::map& config) { + PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, context, config)}); + } + + Parameter GetMetric(const std::string& name, const std::map& options) const { + PLUGIN_CALL_STATEMENT(return _ptr->GetMetric(name, options)); + } + + RemoteContext::Ptr CreateContext(const ParamMap& params) { + PLUGIN_CALL_STATEMENT(return _ptr->CreateContext(params)); + } + + RemoteContext::Ptr GetDefaultContext(const ParamMap& params) { + PLUGIN_CALL_STATEMENT(return _ptr->GetDefaultContext(params)); + } + + Parameter GetConfig(const std::string& name, const std::map& options) const { + PLUGIN_CALL_STATEMENT(return _ptr->GetConfig(name, options)); + } +}; +} // namespace InferenceEngine + +#undef PLUGIN_CALL_STATEMENT + +#if defined __GNUC__ +# pragma GCC diagnostic pop +#endif 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 5d4a09dcb5d03b..2490b9fe1ad694 100644 --- a/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp +++ b/inference-engine/src/inference_engine/cpp/ie_variable_state.cpp @@ -8,7 +8,7 @@ #include "exception2status.hpp" #define VARIABLE_CALL_STATEMENT(...) \ - if (_impl == nullptr) IE_THROW() << "VariableState was not initialized."; \ + if (_impl == nullptr) IE_THROW() << "VariableState was not initialized."; \ try { \ __VA_ARGS__; \ } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { \ @@ -19,11 +19,10 @@ namespace InferenceEngine { -VariableState::VariableState(const std::shared_ptr& impl, - const std::shared_ptr& so) : _impl(impl), _so(so) { - if (impl == nullptr) { - IE_THROW(NotAllocated) << "VariableState wrapper was not initialized."; - } +VariableState::VariableState(const details::SharedObjectLoader& so, + const IVariableStateInternal::Ptr& impl) + : _so(so), _impl(impl) { + IE_ASSERT(_impl != nullptr); } IE_SUPPRESS_DEPRECATED_START diff --git a/inference-engine/src/inference_engine/ie_core.cpp b/inference-engine/src/inference_engine/ie_core.cpp index 8d9a6bb475cb81..39052af8badd66 100644 --- a/inference-engine/src/inference_engine/ie_core.cpp +++ b/inference-engine/src/inference_engine/ie_core.cpp @@ -17,7 +17,7 @@ #include #include "compilation_context.hpp" -#include "ie_plugin_cpp.hpp" +#include "cpp/ie_plugin.hpp" #include "ie_plugin_config.hpp" #include "ie_cache_manager.hpp" #include "ie_cache_guard.hpp" @@ -26,6 +26,7 @@ #include "ie_network_reader.hpp" #include "xml_parse_utils.h" #include "cpp_interfaces/interface/ie_internal_plugin_config.hpp" +#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" using namespace InferenceEngine::PluginConfigParams; using namespace std::placeholders; @@ -223,15 +224,15 @@ class Core::Impl : public ICore { return supported; } - ExecutableNetwork LoadNetworkImpl(const CNNNetwork& network, - InferencePlugin& plugin, - const std::map& parsedConfig, - const RemoteContext::Ptr& context, - const std::string& blobID, - const std::string& modelPath = std::string(), - bool forceDisableCache = false) { + SoExecutableNetworkInternal LoadNetworkImpl(const CNNNetwork& network, + InferencePlugin& plugin, + const std::map& parsedConfig, + const RemoteContext::Ptr& context, + const std::string& blobID, + const std::string& modelPath = std::string(), + bool forceDisableCache = false) { OV_ITT_SCOPED_TASK(itt::domains::IE, "Core::Impl::LoadNetworkImpl"); - ExecutableNetwork execNetwork; + SoExecutableNetworkInternal execNetwork; execNetwork = context ? plugin.LoadNetwork(network, context, parsedConfig) : plugin.LoadNetwork(network, parsedConfig); auto cacheManager = coreConfig.getCacheConfig()._cacheManager; @@ -242,7 +243,7 @@ class Core::Impl : public ICore { cacheManager->writeCacheEntry(blobID, [&](std::ostream& networkStream) { networkStream << CompiledBlobHeader(GetInferenceEngineVersion()->buildNumber, NetworkCompilationContext::calculateFileInfo(modelPath)); - execNetwork.Export(networkStream); + execNetwork->Export(networkStream); }); } catch (...) { cacheManager->removeCacheEntry(blobID); @@ -252,14 +253,14 @@ class Core::Impl : public ICore { return execNetwork; } - ExecutableNetwork LoadNetworkFromCache(const std::shared_ptr& cacheManager, - const std::string& blobId, - InferencePlugin& plugin, - const std::map& config, - const RemoteContext::Ptr& context, - bool& networkIsImported, - const std::string& modelPath = std::string()) { - ExecutableNetwork execNetwork; + SoExecutableNetworkInternal LoadNetworkFromCache(const std::shared_ptr& cacheManager, + const std::string& blobId, + InferencePlugin& plugin, + const std::map& config, + const RemoteContext::Ptr& context, + bool& networkIsImported, + const std::string& modelPath = std::string()) { + SoExecutableNetworkInternal execNetwork; struct HeaderException {}; IE_ASSERT(cacheManager != nullptr); @@ -446,15 +447,15 @@ class Core::Impl : public ICore { } // TODO: In future this method can be added to ICore interface - ExecutableNetwork LoadNetwork(const CNNNetwork& network, const RemoteContext::Ptr& context, - const std::map& config) { + SoExecutableNetworkInternal LoadNetwork(const CNNNetwork& network, const RemoteContext::Ptr& context, + const std::map& config) { OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::IE_LT, "Core::LoadNetwork::RemoteContext"); if (context == nullptr) { IE_THROW() << "Remote context is null"; } auto parsed = parseDeviceNameIntoConfig(context->getDeviceName(), config); auto plugin = GetCPPPluginByName(parsed._deviceName); - ExecutableNetwork res; + SoExecutableNetworkInternal res; auto cacheManager = coreConfig.getCacheConfig()._cacheManager; if (cacheManager && DeviceSupportsImportExport(plugin)) { auto hash = CalculateNetworkHash(network, parsed._deviceName, plugin, parsed._config); @@ -470,8 +471,8 @@ class Core::Impl : public ICore { return res; } - ExecutableNetwork LoadNetwork(const CNNNetwork& network, const std::string& deviceName, - const std::map& config) override { + 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; auto parsed = parseDeviceNameIntoConfig(deviceName, config); @@ -480,7 +481,7 @@ class Core::Impl : public ICore { parsed._config.erase(CONFIG_KEY_INTERNAL(FORCE_DISABLE_CACHE)); } auto plugin = GetCPPPluginByName(parsed._deviceName); - ExecutableNetwork res; + SoExecutableNetworkInternal res; auto cacheManager = coreConfig.getCacheConfig()._cacheManager; if (!forceDisableCache && cacheManager && DeviceSupportsImportExport(plugin)) { auto hash = CalculateNetworkHash(network, parsed._deviceName, plugin, parsed._config); @@ -496,12 +497,12 @@ class Core::Impl : public ICore { return res; } - ExecutableNetwork LoadNetwork(const std::string& modelPath, const std::string& deviceName, - const std::map& config) override { + 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); auto plugin = GetCPPPluginByName(parsed._deviceName); - ExecutableNetwork res; + SoExecutableNetworkInternal res; auto cacheManager = coreConfig.getCacheConfig()._cacheManager; if (cacheManager && DeviceSupportsImportExport(plugin)) { bool loadedFromCache = false; @@ -522,8 +523,8 @@ class Core::Impl : public ICore { return res; } - ExecutableNetwork ImportNetwork(std::istream& networkModel, const std::string& deviceName, - const std::map& config) override { + SoExecutableNetworkInternal ImportNetwork(std::istream& networkModel, const std::string& deviceName, + const std::map& config) override { auto parsed = parseDeviceNameIntoConfig(deviceName, config); if (parsed._deviceName.empty()) { @@ -661,7 +662,7 @@ class Core::Impl : public ICore { PluginDescriptor desc = it->second; try { - InferencePlugin plugin(desc.libraryLocation); + InferencePlugin plugin{desc.libraryLocation}; { plugin.SetName(deviceName); @@ -901,17 +902,20 @@ CNNNetwork Core::ReadNetwork(const std::string& model, const Blob::CPtr& weights ExecutableNetwork Core::LoadNetwork(const CNNNetwork& network, const std::string& deviceName, const std::map& config) { - return _impl->LoadNetwork(network, deviceName, config); + auto exec = _impl->LoadNetwork(network, deviceName, config); + return { exec, exec }; } ExecutableNetwork Core::LoadNetwork(const CNNNetwork& network, RemoteContext::Ptr context, const std::map& config) { - return _impl->LoadNetwork(network, context, config); + auto exec = _impl->LoadNetwork(network, context, config); + return { exec, exec }; } ExecutableNetwork Core::LoadNetwork(const std::string& modelPath, const std::string& deviceName, const std::map& config) { - return _impl->LoadNetwork(modelPath, deviceName, config); + auto exec = _impl->LoadNetwork(modelPath, deviceName, config); + return { exec, exec }; } RemoteContext::Ptr Core::CreateContext(const std::string& deviceName, const ParamMap& params) { @@ -925,7 +929,6 @@ RemoteContext::Ptr Core::CreateContext(const std::string& deviceName, const Para IE_THROW() << "AUTO device does not support remote context"; } - auto parsed = parseDeviceNameIntoConfig(deviceName, params); return _impl->GetCPPPluginByName(parsed._deviceName).CreateContext(parsed._config); } @@ -982,12 +985,14 @@ ExecutableNetwork Core::ImportNetwork(const std::string& modelFileName, const st } auto parsed = parseDeviceNameIntoConfig(deviceName, config); - return _impl->GetCPPPluginByName(parsed._deviceName).ImportNetwork(modelFileName, parsed._config); + auto exec = _impl->GetCPPPluginByName(parsed._deviceName).ImportNetwork(modelFileName, parsed._config); + return { exec, exec }; } ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, const std::string& deviceName, const std::map& config) { - return _impl->ImportNetwork(networkModel, deviceName, config); + auto exec = _impl->ImportNetwork(networkModel, deviceName, config); + return { exec, exec }; } ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, @@ -1004,7 +1009,8 @@ ExecutableNetwork Core::ImportNetwork(std::istream& networkModel, std::string deviceName = device.getDeviceName(); auto parsed = parseDeviceNameIntoConfig(deviceName, config); - return _impl->GetCPPPluginByName(deviceName).ImportNetwork(networkModel, context, parsed._config); + auto exec = _impl->GetCPPPluginByName(deviceName).ImportNetwork(networkModel, context, parsed._config); + return { exec, exec }; } QueryNetworkResult Core::QueryNetwork(const CNNNetwork& network, const std::string& deviceName, diff --git a/inference-engine/src/inference_engine/ie_network_reader.cpp b/inference-engine/src/inference_engine/ie_network_reader.cpp index 6ffe494203e0fb..6043303712dc02 100644 --- a/inference-engine/src/inference_engine/ie_network_reader.cpp +++ b/inference-engine/src/inference_engine/ie_network_reader.cpp @@ -52,7 +52,7 @@ class Reader: public IReader { << FileUtils::fromFilePath(::FileUtils::makePluginLibraryName({}, libraryName)) << " is in " << getIELibraryPath(); } - ptr = InferenceEngine::details::SOPointer(readersLibraryPath); + ptr = {readersLibraryPath}; }); return ptr; diff --git a/inference-engine/src/inference_engine/ie_plugin_cpp.hpp b/inference-engine/src/inference_engine/ie_plugin_cpp.hpp deleted file mode 100644 index d40bdc478aae1b..00000000000000 --- a/inference-engine/src/inference_engine/ie_plugin_cpp.hpp +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief This is a header file for the Inference Engine plugin C++ API - * - * @file ie_plugin_cpp.hpp - */ -#pragma once - -#include -#include -#include - -#include "file_utils.h" -#include "cpp/ie_executable_network.hpp" -#include "cpp/ie_cnn_network.h" -#include "ie_plugin_ptr.hpp" -#include "cpp/exception2status.hpp" - -#if defined __GNUC__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wreturn-type" -#endif - -#define PLUGIN_CALL_STATEMENT(...) \ - if (!actual) IE_THROW() << "Wrapper used in the PLUGIN_CALL_STATEMENT was not initialized."; \ - try { \ - __VA_ARGS__; \ - } CATCH_IE_EXCEPTIONS catch (const std::exception& ex) { \ - IE_THROW() << ex.what(); \ - } catch (...) { \ - IE_THROW(Unexpected); \ - } - -namespace InferenceEngine { - -/** - * @brief This class is a C++ API wrapper for IInferencePlugin. - * - * It can throw exceptions safely for the application, where it is properly handled. - */ -class InferencePlugin { - InferenceEnginePluginPtr actual; - -public: - InferencePlugin() = default; - - explicit InferencePlugin(const InferenceEnginePluginPtr& pointer): actual(pointer) { - if (actual == nullptr) { - IE_THROW() << "InferencePlugin wrapper was not initialized."; - } - } - - explicit InferencePlugin(const FileUtils::FilePath & libraryLocation) : - actual(libraryLocation) { - if (actual == nullptr) { - IE_THROW() << "InferencePlugin wrapper was not initialized."; - } - } - - void SetName(const std::string & deviceName) { - PLUGIN_CALL_STATEMENT(actual->SetName(deviceName)); - } - - void SetCore(ICore* core) { - PLUGIN_CALL_STATEMENT(actual->SetCore(core)); - } - - const Version GetVersion() const { - PLUGIN_CALL_STATEMENT(return actual->GetVersion()); - } - - void AddExtension(InferenceEngine::IExtensionPtr extension) { - PLUGIN_CALL_STATEMENT(actual->AddExtension(extension)); - } - - void SetConfig(const std::map& config) { - PLUGIN_CALL_STATEMENT(actual->SetConfig(config)); - } - - ExecutableNetwork LoadNetwork(const CNNNetwork& network, const std::map& config) { - PLUGIN_CALL_STATEMENT(return ExecutableNetwork(actual->LoadNetwork(network, config), actual)); - } - - ExecutableNetwork LoadNetwork(const CNNNetwork& network, RemoteContext::Ptr context, const std::map& config) { - PLUGIN_CALL_STATEMENT(return ExecutableNetwork(actual->LoadNetwork(network, config, context), actual)); - } - - ExecutableNetwork LoadNetwork(const std::string& modelPath, const std::map& config) { - PLUGIN_CALL_STATEMENT(return actual->LoadNetwork(modelPath, config)); - } - - QueryNetworkResult QueryNetwork(const CNNNetwork& network, - const std::map& config) const { - QueryNetworkResult res; - PLUGIN_CALL_STATEMENT(res = actual->QueryNetwork(network, config)); - if (res.rc != OK) IE_THROW() << res.resp.msg; - return res; - } - - ExecutableNetwork ImportNetwork(const std::string& modelFileName, - const std::map& config) { - PLUGIN_CALL_STATEMENT(return ExecutableNetwork(actual->ImportNetwork(modelFileName, config), actual)); - } - - ExecutableNetwork ImportNetwork(std::istream& networkModel, - const std::map& config) { - PLUGIN_CALL_STATEMENT(return ExecutableNetwork(actual->ImportNetwork(networkModel, config), actual)); - } - - ExecutableNetwork ImportNetwork(std::istream& networkModel, - const RemoteContext::Ptr& context, - const std::map& config) { - PLUGIN_CALL_STATEMENT(return ExecutableNetwork(actual->ImportNetwork(networkModel, context, config), actual)); - } - - Parameter GetMetric(const std::string& name, const std::map& options) const { - PLUGIN_CALL_STATEMENT(return actual->GetMetric(name, options)); - } - - RemoteContext::Ptr CreateContext(const ParamMap& params) { - PLUGIN_CALL_STATEMENT(return actual->CreateContext(params)); - } - - RemoteContext::Ptr GetDefaultContext(const ParamMap& params) { - PLUGIN_CALL_STATEMENT(return actual->GetDefaultContext(params)); - } - - Parameter GetConfig(const std::string& name, const std::map& options) const { - PLUGIN_CALL_STATEMENT(return actual->GetConfig(name, options)); - } - - /** - * @brief Converts InferenceEngine to InferenceEnginePluginPtr pointer - * - * @return Wrapped object - */ - operator InferenceEngine::InferenceEnginePluginPtr() { - return actual; - } - - /** - * @brief Shared pointer on InferencePlugin object - * - */ - using Ptr = std::shared_ptr; -}; -} // namespace InferenceEngine - -#undef PLUGIN_CALL_STATEMENT - -#if defined __GNUC__ -# pragma GCC diagnostic pop -#endif diff --git a/inference-engine/src/inference_engine/ie_plugin_ptr.hpp b/inference-engine/src/inference_engine/ie_plugin_ptr.hpp deleted file mode 100644 index e12b41fc1c9910..00000000000000 --- a/inference-engine/src/inference_engine/ie_plugin_ptr.hpp +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright (C) 2018-2021 Intel Corporation -// SPDX-License-Identifier: Apache-2.0 -// - -/** - * @brief A header file contains a wrapper class for handling plugin instantiation and releasing resources - * - * @file ie_plugin_ptr.hpp - */ -#pragma once - -#include - -#include "details/ie_so_pointer.hpp" -#include "cpp_interfaces/interface/ie_iplugin_internal.hpp" - -namespace InferenceEngine { -namespace details { - -/** - * @brief This class defines the name of the fabric for creating an IInferencePlugin object in DLL - */ -template <> -class SOCreatorTrait { -public: - /** - * @brief A name of the fabric for creating IInferencePlugin object in DLL - */ - static constexpr auto name = "CreatePluginEngine"; -}; - -} // namespace details - -/** - * @brief A C++ helper to work with objects created by the plugin. - * - * Implements different interfaces. - */ -using InferenceEnginePluginPtr = InferenceEngine::details::SOPointer; - -} // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/ie_system_conf.cpp b/inference-engine/src/inference_engine/ie_system_conf.cpp index d9219597a93799..2626ad7e424407 100644 --- a/inference-engine/src/inference_engine/ie_system_conf.cpp +++ b/inference-engine/src/inference_engine/ie_system_conf.cpp @@ -111,9 +111,4 @@ std::vector getAvailableCoresTypes() { } #endif -std::exception_ptr& CurrentException() { - static thread_local std::exception_ptr currentException = nullptr; - return currentException; -} - } // namespace InferenceEngine diff --git a/inference-engine/src/inference_engine/os/lin/lin_shared_object_loader.cpp b/inference-engine/src/inference_engine/os/lin/lin_shared_object_loader.cpp index 297929aa4ae832..7ce910b158cc0c 100644 --- a/inference-engine/src/inference_engine/os/lin/lin_shared_object_loader.cpp +++ b/inference-engine/src/inference_engine/os/lin/lin_shared_object_loader.cpp @@ -7,6 +7,7 @@ #include "details/ie_so_loader.h" #include "file_utils.h" +#include namespace InferenceEngine { namespace details { @@ -64,6 +65,9 @@ SharedObjectLoader::SharedObjectLoader(const char * pluginName) { SharedObjectLoader::~SharedObjectLoader() {} void* SharedObjectLoader::get_symbol(const char* symbolName) const { + if (_impl == nullptr) { + IE_THROW(NotAllocated) << "SharedObjectLoader is not initialized"; + } return _impl->get_symbol(symbolName); } diff --git a/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp b/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp index 43f72b4a6fa0a3..ec0d5c1526a21f 100644 --- a/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp +++ b/inference-engine/src/inference_engine/os/win/win_shared_object_loader.cpp @@ -266,6 +266,9 @@ SharedObjectLoader::SharedObjectLoader(const wchar_t* pluginName) { #endif void* SharedObjectLoader::get_symbol(const char* symbolName) const { + if (_impl == nullptr) { + IE_THROW(NotAllocated) << "SharedObjectLoader is not initialized"; + } return _impl->get_symbol(symbolName); } diff --git a/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp b/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp index deb3fdff7d68f3..bd5fa6456ea06f 100644 --- a/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp +++ b/inference-engine/src/mkldnn_plugin/mkldnn_extension_mngr.cpp @@ -37,7 +37,7 @@ std::shared_ptr MKLDNNExtensionManager::Crea ResponseDesc responseDesc; StatusCode rc = GENERAL_ERROR; ILayerImplFactory* factory_ptr = nullptr; - if (auto mkldnnExt = std::dynamic_pointer_cast(ext)) + if (auto mkldnnExt = dynamic_cast(ext.get())) rc = mkldnnExt->getFactoryFor(factory_ptr, op, &responseDesc); if (rc != OK) { factory = nullptr; diff --git a/inference-engine/src/mkldnn_plugin/nodes/extract_image_patches.hpp b/inference-engine/src/mkldnn_plugin/nodes/extract_image_patches.hpp index 8cbd9c4f6055a4..8ed62fbca89b0d 100644 --- a/inference-engine/src/mkldnn_plugin/nodes/extract_image_patches.hpp +++ b/inference-engine/src/mkldnn_plugin/nodes/extract_image_patches.hpp @@ -6,6 +6,7 @@ #include "base.hpp" #include #include +#include namespace InferenceEngine { namespace Extensions { diff --git a/inference-engine/src/multi_device/multi_device_async_infer_request.cpp b/inference-engine/src/multi_device/multi_device_async_infer_request.cpp index ca1c98976a2aea..9f845586a55330 100644 --- a/inference-engine/src/multi_device/multi_device_async_infer_request.cpp +++ b/inference-engine/src/multi_device/multi_device_async_infer_request.cpp @@ -28,7 +28,7 @@ MultiDeviceAsyncInferRequest::MultiDeviceAsyncInferRequest( void run(Task task) override { auto workerInferRequest = _this->_workerInferRequest; workerInferRequest->_task = std::move(task); - workerInferRequest->_inferRequest.StartAsync(); + workerInferRequest->_inferRequest->StartAsync(); }; MultiDeviceAsyncInferRequest* _this = nullptr; }; @@ -69,18 +69,11 @@ MultiDeviceAsyncInferRequest::MultiDeviceAsyncInferRequest( }}, // final task in the pipeline: { /*TaskExecutor*/std::make_shared(this), /*task*/ [this] { - auto status = _workerInferRequest->_status; - if (InferenceEngine::StatusCode::OK != status) { - if (nullptr != InferenceEngine::CurrentException()) - std::rethrow_exception(InferenceEngine::CurrentException()); - else - IE_EXCEPTION_SWITCH(status, ExceptionType, - InferenceEngine::details::ThrowNow{} - <<= std::stringstream{} << IE_LOCATION - << InferenceEngine::details::ExceptionTraits::string()); + if (nullptr != _workerInferRequest->_exceptionPtr) { + std::rethrow_exception(_workerInferRequest->_exceptionPtr); } if (_needPerfCounters) - _perfMap = _workerInferRequest->_inferRequest.GetPerformanceCounts(); + _perfMap = _workerInferRequest->_inferRequest->GetPerformanceCounts(); }} }; } 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 9e42cbe080919d..56def8e98fe48e 100644 --- a/inference-engine/src/multi_device/multi_device_exec_network.cpp +++ b/inference-engine/src/multi_device/multi_device_exec_network.cpp @@ -47,7 +47,7 @@ struct IdleGuard { MultiDeviceExecutableNetwork::NotBusyWorkerRequests* _notBusyWorkerRequests = nullptr; }; -MultiDeviceExecutableNetwork::MultiDeviceExecutableNetwork(const DeviceMap& networksPerDevice, +MultiDeviceExecutableNetwork::MultiDeviceExecutableNetwork(const DeviceMap& networksPerDevice, const std::vector& networkDevices, const std::unordered_map& config, const bool needPerfCounters) : @@ -66,7 +66,7 @@ MultiDeviceExecutableNetwork::MultiDeviceExecutableNetwork(const DeviceMap(); + optimalNum = network->GetMetric(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)).as(); } catch (const InferenceEngine::Exception &iie) { IE_THROW() << "Every device used with the Multi-Device should " @@ -82,13 +82,13 @@ MultiDeviceExecutableNetwork::MultiDeviceExecutableNetwork(const DeviceMapCreateInferRequest() }; auto* workerRequestPtr = &workerRequest; IE_ASSERT(idleWorkerRequests.try_push(workerRequestPtr) == true); - workerRequest._inferRequest.SetCompletionCallback>( - [workerRequestPtr, this, device, idleWorkerRequestsPtr] (InferRequest , StatusCode status) mutable { + workerRequest._inferRequest->SetCallback( + [workerRequestPtr, this, device, idleWorkerRequestsPtr] (std::exception_ptr exceptionPtr) mutable { IdleGuard idleGuard{workerRequestPtr, *idleWorkerRequestsPtr}; - workerRequestPtr->_status = status; + workerRequestPtr->_exceptionPtr = exceptionPtr; { auto capturedTask = std::move(workerRequestPtr->_task); capturedTask(); @@ -166,7 +166,7 @@ RemoteContext::Ptr MultiDeviceExecutableNetwork::GetContext() const { devices_names += device.deviceName + " "; const auto& n = _networksPerDevice.at(device.deviceName); try { - return n.GetContext(); + return n->GetContext(); } catch (const NotImplemented&) {} } IE_THROW(NotImplemented) << "None of the devices in the MULTI has an associated remote context." @@ -177,7 +177,7 @@ InferenceEngine::IInferRequestInternal::Ptr MultiDeviceExecutableNetwork::Create InferenceEngine::OutputsDataMap networkOutputs) { auto num = _numRequestsCreated++; size_t sum = 0; - InferenceEngine::InferRequest request_to_share_blobs_with; + InferenceEngine::SoIInferRequestInternal request_to_share_blobs_with; // borrowing device-specific blobs from the underlying requests for the device-agnostic, user-facing requests // this allows to potentially save on the data-copy later (if the requests are scheduled in the same order) for (const auto& device : _devicePrioritiesInitial) { @@ -248,7 +248,7 @@ InferenceEngine::Parameter MultiDeviceExecutableNetwork::GetMetric(const std::st unsigned int res = 0u; for (auto n : _networksPerDevice) { try { - res += n.second.GetMetric(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)).as(); + res += n.second->GetMetric(METRIC_KEY(OPTIMAL_NUMBER_OF_INFER_REQUESTS)).as(); } catch (const InferenceEngine::Exception &iie) { IE_THROW() << "Every device used with the Multi-Device should " @@ -260,7 +260,7 @@ InferenceEngine::Parameter MultiDeviceExecutableNetwork::GetMetric(const std::st } else if (name == METRIC_KEY(NETWORK_NAME)) { auto it = _networksPerDevice.begin(); IE_ASSERT(it != _networksPerDevice.end()); - IE_SET_METRIC_RETURN(NETWORK_NAME, it->second.GetMetric( + IE_SET_METRIC_RETURN(NETWORK_NAME, it->second->GetMetric( METRIC_KEY(NETWORK_NAME)).as()); } else if (name == METRIC_KEY(SUPPORTED_METRICS)) { IE_SET_METRIC_RETURN(SUPPORTED_METRICS, { 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 dce26006b0502b..3a9516d6c3b039 100644 --- a/inference-engine/src/multi_device/multi_device_exec_network.hpp +++ b/inference-engine/src/multi_device/multi_device_exec_network.hpp @@ -99,13 +99,13 @@ class MultiDeviceExecutableNetwork : public InferenceEngine::ExecutableNetworkTh public: using Ptr = std::shared_ptr; struct WorkerInferRequest { - InferenceEngine::InferRequest _inferRequest; - InferenceEngine::Task _task; - InferenceEngine::StatusCode _status = InferenceEngine::StatusCode::OK; + InferenceEngine::SoIInferRequestInternal _inferRequest; + InferenceEngine::Task _task; + std::exception_ptr _exceptionPtr = nullptr; }; using NotBusyWorkerRequests = ThreadSafeBoundedQueue; - explicit MultiDeviceExecutableNetwork(const DeviceMap& networksPerDevice, + explicit MultiDeviceExecutableNetwork(const DeviceMap& networksPerDevice, const std::vector& networkDevices, const std::unordered_map& config, const bool needPerfCounters = false); @@ -130,7 +130,7 @@ class MultiDeviceExecutableNetwork : public InferenceEngine::ExecutableNetworkTh mutable std::mutex _mutex; std::vector _devicePriorities; const std::vector _devicePrioritiesInitial; - DeviceMap _networksPerDevice; + DeviceMap _networksPerDevice; ThreadSafeQueue _inferPipelineTasks; DeviceMap>> _inferPipelineTasksDeviceSpecific; DeviceMap _idleWorkerRequests; diff --git a/inference-engine/src/multi_device/multi_device_infer_request.cpp b/inference-engine/src/multi_device/multi_device_infer_request.cpp index bebf27ec662191..de6540b88f0fc8 100644 --- a/inference-engine/src/multi_device/multi_device_infer_request.cpp +++ b/inference-engine/src/multi_device/multi_device_infer_request.cpp @@ -10,18 +10,20 @@ #include namespace MultiDevicePlugin { - using namespace InferenceEngine; + +using namespace InferenceEngine; + // ------------------------------MultiDeviceInferRequest---------------------------- MultiDeviceInferRequest::MultiDeviceInferRequest(const InputsDataMap& networkInputs, const OutputsDataMap& networkOutputs, - InferRequest request_to_share_blobs_with) + const SoIInferRequestInternal & request_to_share_blobs_with) : IInferRequestInternal(networkInputs, networkOutputs) { if (request_to_share_blobs_with) { // borrow device-friendly blobs from the request for (const auto &it : _networkInputs) - _inputs[it.first] = request_to_share_blobs_with.GetBlob(it.first); + _inputs[it.first] = request_to_share_blobs_with->GetBlob(it.first); for (const auto &it : _networkOutputs) - _outputs[it.first] = request_to_share_blobs_with.GetBlob(it.first); + _outputs[it.first] = request_to_share_blobs_with->GetBlob(it.first); return; } // Allocate all input blobs @@ -46,20 +48,20 @@ MultiDeviceInferRequest::MultiDeviceInferRequest(const InputsDataMap& networkI } } -void MultiDeviceInferRequest::SetBlobsToAnotherRequest(InferRequest& req) { +void MultiDeviceInferRequest::SetBlobsToAnotherRequest(const SoIInferRequestInternal& req) { for (const auto &it : _networkInputs) { auto &name = it.first; // this request is already in BUSY state, so using the internal functions safely auto blob = GetBlob(name); - if (req.GetBlob(name) != blob) - req.SetBlob(name, blob); + if (req->GetBlob(name) != blob) + req->SetBlob(name, blob); } for (const auto &it : _networkOutputs) { auto &name = it.first; // this request is already in BUSY state, so using the internal functions safely auto blob = GetBlob(name); - if (req.GetBlob(name) != blob) - req.SetBlob(name, blob); + if (req->GetBlob(name) != blob) + req->SetBlob(name, blob); } } diff --git a/inference-engine/src/multi_device/multi_device_infer_request.hpp b/inference-engine/src/multi_device/multi_device_infer_request.hpp index 3284b985054fe5..9ec23eda91833e 100644 --- a/inference-engine/src/multi_device/multi_device_infer_request.hpp +++ b/inference-engine/src/multi_device/multi_device_infer_request.hpp @@ -15,8 +15,6 @@ #include #include #include -#include -#include namespace MultiDevicePlugin { @@ -25,11 +23,11 @@ class MultiDeviceInferRequest : public InferenceEngine::IInferRequestInternal { using Ptr = std::shared_ptr; explicit MultiDeviceInferRequest(const InferenceEngine::InputsDataMap& networkInputs, const InferenceEngine::OutputsDataMap& networkOutputs, - InferenceEngine::InferRequest request_to_share_blobs_with); + const InferenceEngine::SoIInferRequestInternal & request_to_share_blobs_with); std::map GetPerformanceCounts() const override; void InferImpl() override; // Multi-Device impl specific: sets the data (blobs from the device-less requests to the specific device request) - void SetBlobsToAnotherRequest(InferenceEngine::InferRequest& req); + void SetBlobsToAnotherRequest(const InferenceEngine::SoIInferRequestInternal& req); }; } // namespace MultiDevicePlugin diff --git a/inference-engine/src/multi_device/multi_device_plugin.cpp b/inference-engine/src/multi_device/multi_device_plugin.cpp index 15b25b59ad08d1..f15db83651ec05 100644 --- a/inference-engine/src/multi_device/multi_device_plugin.cpp +++ b/inference-engine/src/multi_device/multi_device_plugin.cpp @@ -164,7 +164,7 @@ ExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(co std::unordered_map multiNetworkConfig; multiNetworkConfig.insert(*priorities); - DeviceMap executableNetworkPerDevice; + DeviceMap executableNetworkPerDevice; std::mutex load_mutex; std::vector loads; for (auto& p : metaDevices) { @@ -192,7 +192,7 @@ ExecutableNetworkInternal::Ptr MultiDeviceInferencePlugin::LoadExeNetworkImpl(co for (auto n : executableNetworkPerDevice) { try { num_plugins_supporting_perf_counters += - n.second.GetConfig(PluginConfigParams::KEY_PERF_COUNT).as() == + n.second->GetConfig(PluginConfigParams::KEY_PERF_COUNT).as() == PluginConfigParams::YES; } catch (...) { } 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 index d91d24e3e06ccf..d1cd185be9cc50 100644 --- 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 @@ -86,7 +86,7 @@ class ExecutableNetworkInternal : public IExecutableNetworkInternal { * @param[in] plugin The plugin * @note Needed to correctly handle ownership between objects. */ - void SetPointerToPlugin(IInferencePlugin::Ptr plugin) { + virtual void SetPointerToPlugin(IInferencePlugin::Ptr plugin) { _plugin = plugin; } @@ -116,7 +116,6 @@ class ExecutableNetworkInternal : public IExecutableNetworkInternal { IE_THROW(NotImplemented); } - /** * @brief Creates an inference request public implementation. * @return The request public implementation diff --git a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp index 5d98772a65a504..3f5c8b26de20cd 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/impl/ie_infer_async_request_thread_safe_default.hpp @@ -9,7 +9,6 @@ #include #include -#include #include #include @@ -211,7 +210,7 @@ class AsyncInferRequestThreadSafeDefault : public IInferRequestInternal { void Infer() override { DisableCallbackGuard disableCallbackGuard{this}; InferImpl([&] {Infer_ThreadUnsafe();}); - Wait(InferenceEngine::InferRequest::WaitMode::RESULT_READY); + Wait(InferRequest::WaitMode::RESULT_READY); } std::map GetPerformanceCounts() const override { 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 index dcaf4a1e529f65..2afb5f066f6509 100644 --- 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 @@ -72,8 +72,8 @@ class InferencePluginInternal : public IInferencePlugin { return impl; } - ExecutableNetwork LoadNetwork(const std::string& modelPath, - const std::map& config) override { + 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); } 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 fb1b961109d110..da55b2896c24e8 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 @@ -13,9 +13,12 @@ #include #include #include +#include
namespace InferenceEngine { + class IInferRequestInternal; + /** * @interface IExecutableNetworkInternal * @brief An internal API of executable network to be implemented by plugin, @@ -109,4 +112,9 @@ class IExecutableNetworkInternal : public std::enable_shared_from_this; + } // namespace InferenceEngine diff --git a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iinfer_request_internal.hpp b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iinfer_request_internal.hpp index bd43eab73d0a3f..864cd4dc6936e7 100644 --- a/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iinfer_request_internal.hpp +++ b/inference-engine/src/plugin_api/cpp_interfaces/interface/ie_iinfer_request_internal.hpp @@ -15,8 +15,10 @@ #include namespace InferenceEngine { + class IExecutableNetworkInternal; class IVariableStateInternal; + /** * @interface IInferRequestInternal * @brief An internal API of synchronous inference request to be implemented by plugin, @@ -212,7 +214,7 @@ class INFERENCE_ENGINE_API_CLASS(IInferRequestInternal) : public std::enable_sha int m_curBatch = -1; //!< Current batch value used in dynamic batching /** - * @brief A shared pointer to ExecutableNetworkInternal interface + * @brief A shared pointer to IInferRequestInternal * @note Needed to correctly handle ownership between objects. */ std::shared_ptr _exeNetwork; @@ -224,4 +226,9 @@ class INFERENCE_ENGINE_API_CLASS(IInferRequestInternal) : public std::enable_sha ~IInferRequestInternal(); }; +/** + * @brief SOPointer to IInferRequestInternal. + */ +using SoIInferRequestInternal = details::SOPointer; + } // namespace InferenceEngine 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 18f4658d6a4cc4..50ccc72cfbc978 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 @@ -173,8 +173,8 @@ class IInferencePlugin : public std::enable_shared_from_this { * @param config A string-string map of config parameters relevant only for this load operation * @return Created Executable Network object */ - virtual ExecutableNetwork LoadNetwork(const std::string& modelPath, - const std::map& config) = 0; + virtual std::shared_ptr LoadNetwork(const std::string& modelPath, + const std::map& config) = 0; /** * @brief Registers extension within plugin @@ -275,6 +275,14 @@ class IInferencePlugin : public std::enable_shared_from_this { ~IInferencePlugin() = default; }; +namespace details { +template <> +class SOCreatorTrait { +public: + static constexpr auto name = "CreatePluginEngine"; +}; +} // namespace details + } // namespace InferenceEngine /** 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 4f31b57958275f..279ae854f73828 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 @@ -5,6 +5,7 @@ #pragma once #include +#include
#include #include @@ -68,4 +69,9 @@ class IVariableStateInternal { */ using IMemoryStateInternal = IVariableStateInternal; +/** + * @brief SOPointer to IVariableStateInternal. + */ +using SoIVariableStateInternal = details::SOPointer; + } // namespace InferenceEngine diff --git a/inference-engine/src/plugin_api/ie_icore.hpp b/inference-engine/src/plugin_api/ie_icore.hpp index 6c35277726f386..1662b966de86e5 100644 --- a/inference-engine/src/plugin_api/ie_icore.hpp +++ b/inference-engine/src/plugin_api/ie_icore.hpp @@ -15,7 +15,7 @@ #include #include -#include +#include "cpp_interfaces/interface/ie_iexecutable_network_internal.hpp" #include "threading/ie_itask_executor.hpp" @@ -63,8 +63,8 @@ class ICore { * operation * @return An executable network reference */ - virtual ExecutableNetwork LoadNetwork(const CNNNetwork& network, const std::string& deviceName, - const std::map& config = {}) = 0; + virtual SoExecutableNetworkInternal LoadNetwork(const CNNNetwork& network, const std::string& deviceName, + const std::map& config = {}) = 0; /** * @brief Creates an executable network from a model file. @@ -78,8 +78,8 @@ class ICore { * operation * @return An executable network reference */ - virtual ExecutableNetwork LoadNetwork(const std::string& modelPath, const std::string& deviceName, - const std::map& config) = 0; + virtual SoExecutableNetworkInternal LoadNetwork(const std::string& modelPath, const std::string& deviceName, + const std::map& config) = 0; /** * @brief Creates an executable network from a previously exported network @@ -89,8 +89,8 @@ class ICore { * operation* * @return An executable network reference */ - virtual ExecutableNetwork ImportNetwork(std::istream& networkModel, const std::string& deviceName = {}, - const std::map& config = {}) = 0; + virtual SoExecutableNetworkInternal ImportNetwork(std::istream& networkModel, const std::string& deviceName = {}, + const std::map& config = {}) = 0; /** * @brief Query device if it supports specified network with specified configuration diff --git a/inference-engine/src/plugin_api/ie_system_conf.h b/inference-engine/src/plugin_api/ie_system_conf.h index 28c1e155e87fa8..2e4481bf09e204 100644 --- a/inference-engine/src/plugin_api/ie_system_conf.h +++ b/inference-engine/src/plugin_api/ie_system_conf.h @@ -15,12 +15,6 @@ namespace InferenceEngine { -/** - * @brief Provides the reference to static thread_local std::exception_ptr - * @return A an exception pointer - */ -INFERENCE_ENGINE_API_CPP(std::exception_ptr&) CurrentException(); - /** * @brief Checks whether OpenMP environment variables are defined * @ingroup ie_dev_api_system_conf diff --git a/inference-engine/src/preprocessing/ie_preprocess_data.hpp b/inference-engine/src/preprocessing/ie_preprocess_data.hpp index fa097fca02554d..fab055000cac69 100644 --- a/inference-engine/src/preprocessing/ie_preprocess_data.hpp +++ b/inference-engine/src/preprocessing/ie_preprocess_data.hpp @@ -96,7 +96,7 @@ inline PreProcessDataPtr CreatePreprocDataHelper() { << FileUtils::fromFilePath(::FileUtils::makePluginLibraryName({}, libraryName)) << " is in " << getIELibraryPath(); } - return PreProcessDataPtr(preprocLibraryPath); + return {preprocLibraryPath}; } } // 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 947733c3f150f4..287aaedcd0d981 100644 --- a/inference-engine/tests/functional/inference_engine/caching_test.cpp +++ b/inference-engine/tests/functional/inference_engine/caching_test.cpp @@ -12,7 +12,6 @@ #include #include "ie_core.hpp" -#include "ie_plugin_ptr.hpp" #include "ngraph/function.hpp" #include "details/ie_so_loader.h" #include "ie_metric_helpers.hpp" @@ -30,7 +29,7 @@ #include "unit_test_utils/mocks/mock_iinfer_request.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" -#include "ie_plugin_cpp.hpp" +#include "cpp/ie_plugin.hpp" using namespace InferenceEngine; using namespace ::testing; diff --git a/inference-engine/tests/functional/inference_engine/shared_object_loader_test.cpp b/inference-engine/tests/functional/inference_engine/shared_object_loader_test.cpp index 4821910d139110..ef2a2d72feed57 100644 --- a/inference-engine/tests/functional/inference_engine/shared_object_loader_test.cpp +++ b/inference-engine/tests/functional/inference_engine/shared_object_loader_test.cpp @@ -4,9 +4,9 @@ #include -#include #include #include "details/ie_so_loader.h" +#include using namespace std; using namespace InferenceEngine; diff --git a/inference-engine/tests/functional/inference_engine/so_pointer_tests.cpp b/inference-engine/tests/functional/inference_engine/so_pointer_tests.cpp index b18957ed5790e5..9050e72f750081 100644 --- a/inference-engine/tests/functional/inference_engine/so_pointer_tests.cpp +++ b/inference-engine/tests/functional/inference_engine/so_pointer_tests.cpp @@ -12,70 +12,12 @@ #include #include
#include -#include using namespace InferenceEngine; using namespace InferenceEngine::details; using namespace ::testing; using ::testing::InSequence; -class PointedObjHelper { -public: - MOCK_METHOD0(obj_dtor, void()); - - virtual ~PointedObjHelper() { - obj_dtor(); - } -}; - -class SharedObjectLoaderHelper { -public: - MOCK_METHOD0(loader_dtor, void()); - - virtual ~SharedObjectLoaderHelper() { - loader_dtor(); - } -}; - -template -class SoPointerHelper : public SOPointer { -public: - SoPointerHelper(std::shared_ptr&& loader, std::shared_ptr&& object) - : SOPointer() { - SOPointer::_so_loader = std::move(loader); - SOPointer::_pointedObj = std::move(object); - } -}; - -class SoPointerTests : public ::testing::Test { -protected: - SharedObjectLoaderHelper *loader1 = nullptr, *loader2 = nullptr; - PointedObjHelper *obj1 = nullptr, *obj2 = nullptr; -}; - -TEST_F(SoPointerTests, assignObjThenLoader) { - auto loaderPtr1 = std::make_shared(); - auto objPtr1 = std::make_shared(); - auto loaderPtr2 = std::make_shared(); - auto objPtr2 = std::make_shared(); - loader1 = loaderPtr1.get(); - obj1 = objPtr1.get(); - loader2 = loaderPtr2.get(); - obj2 = objPtr2.get(); - SoPointerHelper<> soPointer1(std::move(loaderPtr1), std::move(objPtr1)); - SoPointerHelper<> soPointer2(std::move(loaderPtr2), std::move(objPtr2)); - - { - InSequence dummy; - EXPECT_CALL(*obj1, obj_dtor()); - EXPECT_CALL(*loader1, loader_dtor()); - EXPECT_CALL(*obj2, obj_dtor()); - EXPECT_CALL(*loader2, loader_dtor()); - } - - soPointer1 = soPointer2; -} - namespace InferenceEngine { namespace details { @@ -92,13 +34,15 @@ class SOCreatorTrait { } // namespace InferenceEngine +class SoPointerTests : public ::testing::Test {}; + TEST_F(SoPointerTests, UnknownPlugin) { - ASSERT_THROW(SOPointer("UnknownPlugin"), Exception); + ASSERT_THROW(SOPointer{std::string{"UnknownPlugin"}}, Exception); } TEST_F(SoPointerTests, UnknownPluginExceptionStr) { try { - SOPointer("UnknownPlugin"); + SOPointer(std::string{"UnknownPlugin"}); } catch (Exception &e) { ASSERT_STR_CONTAINS(e.what(), "Cannot load library 'UnknownPlugin':"); 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 7e264217bf999f..7832894a91390e 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 @@ -14,16 +14,16 @@ class MockICore : public InferenceEngine::ICore { MOCK_QUALIFIED_METHOD2(ReadNetwork, const, InferenceEngine::CNNNetwork(const std::string&, const InferenceEngine::Blob::CPtr&)); MOCK_QUALIFIED_METHOD2(ReadNetwork, const, InferenceEngine::CNNNetwork(const std::string&, const std::string&)); - MOCK_METHOD3(LoadNetwork, InferenceEngine::ExecutableNetwork( + MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( const InferenceEngine::CNNNetwork&, const std::string&, const std::map&)); - MOCK_METHOD3(LoadNetwork, InferenceEngine::ExecutableNetwork( + MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( const InferenceEngine::CNNNetwork&, const InferenceEngine::RemoteContext::Ptr &, const std::map&)); - MOCK_METHOD3(LoadNetwork, InferenceEngine::ExecutableNetwork( + MOCK_METHOD3(LoadNetwork, InferenceEngine::SoExecutableNetworkInternal( const std::string &, const std::string &, const std::map&)); - MOCK_METHOD3(ImportNetwork, InferenceEngine::ExecutableNetwork( + MOCK_METHOD3(ImportNetwork, InferenceEngine::SoExecutableNetworkInternal( std::istream&, const std::string&, const std::map&)); - MOCK_METHOD3(ImportNetwork, InferenceEngine::ExecutableNetwork( + MOCK_METHOD3(ImportNetwork, InferenceEngine::SoExecutableNetworkInternal( std::istream&, const InferenceEngine::RemoteContext::Ptr&, const std::map&)); MOCK_QUALIFIED_METHOD3(QueryNetwork, const, InferenceEngine::QueryNetworkResult( 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 7f450f660f37a6..083a529e121493 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 @@ -15,7 +15,7 @@ class MockIInferencePlugin : public InferenceEngine::IInferencePlugin { MOCK_METHOD1(AddExtension, void(InferenceEngine::IExtensionPtr)); MOCK_METHOD2(LoadNetwork, std::shared_ptr( const InferenceEngine::CNNNetwork&, const std::map&)); - MOCK_METHOD2(LoadNetwork, InferenceEngine::ExecutableNetwork( + MOCK_METHOD2(LoadNetwork, std::shared_ptr( const std::string&, const std::map&)); MOCK_METHOD2(ImportNetwork, std::shared_ptr( const std::string&, const std::map&)); diff --git a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp index 73ecba07d82441..d0cde74580cb1b 100644 --- a/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp +++ b/inference-engine/tests/unit/inference_engine/cpp_interfaces/ie_infer_async_request_base_test.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" @@ -173,11 +173,11 @@ TEST_F(InferRequestBaseTests, canReportErrorInSetCompletionCallback) { class InferRequestTests : public ::testing::Test { protected: std::shared_ptr mock_request; - InferRequest request; + IInferRequestInternal::Ptr request; ResponseDesc dsc; std::shared_ptr mockIExeNet; - InferenceEngine::ExecutableNetwork exeNetwork; + InferenceEngine::SoExecutableNetworkInternal exeNetwork; MockIInferencePlugin* mockIPlugin; InferencePlugin plugin; shared_ptr mockInferRequestInternal; @@ -198,11 +198,11 @@ class InferRequestTests : public ::testing::Test { mock_request = make_shared(); mockIExeNet = std::make_shared(); ON_CALL(*mockIExeNet, CreateInferRequest()).WillByDefault(Return(mock_request)); - std::unique_ptr mockIPluginPtr{new MockIInferencePlugin}; + auto mockIPluginPtr = std::make_shared(); ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockIExeNet)); - plugin = InferenceEngine::InferencePlugin{InferenceEngine::details::SOPointer{mockIPluginPtr.release()}}; + plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr}; exeNetwork = plugin.LoadNetwork(CNNNetwork{}, {}); - request = exeNetwork.CreateInferRequest(); + request = exeNetwork->CreateInferRequest(); _incorrectName = "incorrect_name"; _inputName = MockNotEmptyICNNNetwork::INPUT_BLOB_NAME; _failedToFindInOutError = @@ -213,7 +213,7 @@ class InferRequestTests : public ::testing::Test { + _inputName + "\'"; } - InferRequest getInferRequestWithMockImplInside() { + IInferRequestInternal::Ptr getInferRequestWithMockImplInside() { IInferRequest::Ptr inferRequest; InputsDataMap inputsInfo; mockNotEmptyNet.getInputsInfo(inputsInfo); @@ -222,11 +222,11 @@ class InferRequestTests : public ::testing::Test { mockInferRequestInternal = make_shared(inputsInfo, outputsInfo); auto mockIExeNet = std::make_shared(); ON_CALL(*mockIExeNet, CreateInferRequest()).WillByDefault(Return(mockInferRequestInternal)); - std::unique_ptr mockIPluginPtr{new MockIInferencePlugin}; + auto mockIPluginPtr = std::make_shared(); ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockIExeNet)); - auto plugin = InferenceEngine::InferencePlugin{InferenceEngine::details::SOPointer{mockIPluginPtr.release()}}; + auto plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr}; auto exeNetwork = plugin.LoadNetwork(CNNNetwork{}, {}); - return exeNetwork.CreateInferRequest(); + return exeNetwork->CreateInferRequest(); } std::string getExceptionMessage(std::function function) { @@ -238,71 +238,54 @@ class InferRequestTests : public ::testing::Test { } return actualError; } - - BlobMap getBlobMapWithIncorrectName() const { - Blob::Ptr Blob = make_shared_blob({ Precision::FP32, {1, 1, 1, 1}, NCHW }); - Blob->allocate(); - return BlobMap{{_incorrectName, Blob}}; - } - - BlobMap getBlobMapWithNotAllocatedInput() const { - Blob::Ptr Blob = make_shared_blob({ Precision::FP32, {1, 1, 1, 1}, NCHW }); - return BlobMap{{_inputName, Blob}}; - } - - BlobMap getBlobMapWithEmptyDimensions() const { - Blob::Ptr Blob = make_shared_blob({ Precision::FP32, {}, NCHW }); - Blob->allocate(); - return BlobMap{{_inputName, Blob}}; - } }; // StartAsync TEST_F(InferRequestTests, canForwardStartAsync) { EXPECT_CALL(*mock_request.get(), StartAsync()); - ASSERT_NO_THROW(request.StartAsync()); + ASSERT_NO_THROW(request->StartAsync()); } TEST_F(InferRequestTests, throwsIfStartAsyncReturnNotOK) { EXPECT_CALL(*mock_request.get(), StartAsync()).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(request.StartAsync(), Exception); + ASSERT_THROW(request->StartAsync(), Exception); } // Wait TEST_F(InferRequestTests, canForwardWait) { int64_t ms = 0; EXPECT_CALL(*mock_request.get(), Wait(_)).WillOnce(Return(OK)); - ASSERT_TRUE(OK == request.Wait(ms)); + ASSERT_TRUE(OK == request->Wait(ms)); } TEST_F(InferRequestTests, canForwardStatusFromWait) { EXPECT_CALL(*mock_request.get(), Wait(_)).WillOnce(Return(RESULT_NOT_READY)); - ASSERT_EQ(request.Wait(0), RESULT_NOT_READY); + ASSERT_EQ(request->Wait(0), RESULT_NOT_READY); } // Infer TEST_F(InferRequestTests, canForwardInfer) { EXPECT_CALL(*mock_request.get(), Infer()); - ASSERT_NO_THROW(request.Infer()); + ASSERT_NO_THROW(request->Infer()); } TEST_F(InferRequestTests, throwsIfInferReturnNotOK) { EXPECT_CALL(*mock_request.get(), Infer()).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(request.Infer(), Exception); + ASSERT_THROW(request->Infer(), Exception); } // GetPerformanceCounts TEST_F(InferRequestTests, canForwardGetPerformanceCounts) { std::map info; EXPECT_CALL(*mock_request.get(), GetPerformanceCounts()).WillOnce(Return(info)); - ASSERT_NO_THROW(info = request.GetPerformanceCounts()); + ASSERT_NO_THROW(info = request->GetPerformanceCounts()); } TEST_F(InferRequestTests, throwsIfGetPerformanceCountsReturnNotOK) { std::map info; EXPECT_CALL(*mock_request.get(), GetPerformanceCounts()).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(info = request.GetPerformanceCounts(), Exception); + ASSERT_THROW(info = request->GetPerformanceCounts(), Exception); } MATCHER_P(blob_in_map_pointer_is_same, ref_blob, "") { @@ -310,38 +293,6 @@ MATCHER_P(blob_in_map_pointer_is_same, ref_blob, "") { return reinterpret_cast(arg.begin()->second->buffer()) == reinterpret_cast(ref_blob->buffer()); } -// SetInput -TEST_F(InferRequestTests, getInputCallsSetBlob) { - Blob::Ptr inblob; - std::string blobName1 = "blob1"; - std::string blobName2 = "blob2"; - BlobMap blobMap{{blobName1, inblob}, - {blobName2, inblob}}; - - EXPECT_CALL(*mock_request.get(), SetBlob(blobName1, inblob)); - EXPECT_CALL(*mock_request.get(), SetBlob(blobName2, inblob)); - ASSERT_NO_THROW(request.SetInput(blobMap)); -} - -TEST_F(InferRequestTests, throwsIfSetInputReturnNotOK) { - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(GeneralError{""})); - BlobMap blobMap{{{}, {}}}; - ASSERT_THROW(request.SetInput(blobMap), Exception); -} - -// SetOutput -TEST_F(InferRequestTests, getOutputCallsSetBlob) { - Blob::Ptr inblob; - std::string blobName1 = "blob1"; - std::string blobName2 = "blob2"; - BlobMap blobMap{{blobName1, inblob}, - {blobName2, inblob}}; - - EXPECT_CALL(*mock_request.get(), SetBlob(blobName1, inblob)); - EXPECT_CALL(*mock_request.get(), SetBlob(blobName2, inblob)); - ASSERT_NO_THROW(request.SetOutput(blobMap)); -} - // GetBlob TEST_F(InferRequestTests, canForwardGetBlob) { Blob::Ptr blob = make_shared_blob({ Precision::FP32, {}, NCHW }); @@ -349,7 +300,7 @@ TEST_F(InferRequestTests, canForwardGetBlob) { std::string name = "blob1"; EXPECT_CALL(*mock_request.get(), GetBlob(_)).WillOnce(Return(blob)); - ASSERT_NO_THROW(request.GetBlob(name)); + ASSERT_NO_THROW(request->GetBlob(name)); } TEST_F(InferRequestTests, throwsIfGetBlobReturnNotOK) { @@ -357,7 +308,7 @@ TEST_F(InferRequestTests, throwsIfGetBlobReturnNotOK) { std::string name = "blob1"; EXPECT_CALL(*mock_request.get(), GetBlob(_)).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(blob = request.GetBlob(name), Exception); + ASSERT_THROW(blob = request->GetBlob(name), Exception); } // SetBlob @@ -366,7 +317,7 @@ TEST_F(InferRequestTests, canForwardSetBlob) { std::string name = "blob1"; EXPECT_CALL(*mock_request.get(), SetBlob(name, blob)); - ASSERT_NO_THROW(request.SetBlob(name, blob)); + ASSERT_NO_THROW(request->SetBlob(name, blob)); } TEST_F(InferRequestTests, throwsIfSetBlobReturnNotOK) { @@ -374,40 +325,10 @@ TEST_F(InferRequestTests, throwsIfSetBlobReturnNotOK) { std::string name = "blob1"; EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(GeneralError{""})); - ASSERT_THROW(request.SetBlob(name, blob), Exception); -} - -TEST_F(InferRequestTests, throwsIfSetOutputReturnNotOK) { - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(GeneralError{""})); - BlobMap blobMap{{{}, {}}}; - ASSERT_THROW(request.SetOutput(blobMap), Exception); + ASSERT_THROW(request->SetBlob(name, blob), Exception); } TEST_F(InferRequestTests, canForwardAnyCallback) { EXPECT_CALL(*mock_request.get(), SetCallback(_)); - ASSERT_NO_THROW(request.SetCompletionCallback([] {})); -} - -TEST_F(InferRequestTests, failToSetInputWithInCorrectName) { - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(NotFound{""})); - auto blobMap = getBlobMapWithIncorrectName(); - ASSERT_THROW(request.SetInput(blobMap), NotFound); -} - -TEST_F(InferRequestTests, failToSetOutputWithInCorrectName) { - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(NotFound{""})); - auto blobMap = getBlobMapWithIncorrectName(); - ASSERT_THROW(request.SetOutput(blobMap), NotFound); -} - -TEST_F(InferRequestTests, failToSetInputWithNotAllocatedInput) { - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(NotAllocated{""})); - auto blobMap = getBlobMapWithNotAllocatedInput(); - ASSERT_THROW(request.SetInput(blobMap), NotAllocated); -} - -TEST_F(InferRequestTests, failToSetInputWithEmptyDimensions) { - EXPECT_CALL(*mock_request.get(), SetBlob(_, _)).WillOnce(Throw(GeneralError{""})); - auto blobMap = getBlobMapWithEmptyDimensions(); - ASSERT_THROW(request.SetInput(blobMap), GeneralError); + ASSERT_NO_THROW(request->SetCallback([] (std::exception_ptr) {})); } 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 0557ed203b1337..6867cb92b26cce 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 @@ -12,7 +12,7 @@ #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_ivariable_state_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iexecutable_network_internal.hpp" #include "unit_test_utils/mocks/cpp_interfaces/interface/mock_iinference_plugin.hpp" -#include "ie_plugin_cpp.hpp" +#include "cpp/ie_plugin.hpp" using namespace ::testing; using namespace std; @@ -27,19 +27,19 @@ class VariableStateTests : public ::testing::Test { shared_ptr mockVariableStateInternal; MockIInferencePlugin* mockIPlugin; InferencePlugin plugin; - ExecutableNetwork net; - InferRequest req; + SoExecutableNetworkInternal net; + IInferRequestInternal::Ptr req; virtual void SetUp() { mockExeNetworkInternal = make_shared(); mockInferRequestInternal = make_shared(); mockVariableStateInternal = make_shared(); ON_CALL(*mockExeNetworkInternal, CreateInferRequest()).WillByDefault(Return(mockInferRequestInternal)); - std::unique_ptr mockIPluginPtr{new MockIInferencePlugin}; + auto mockIPluginPtr = std::make_shared(); ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockExeNetworkInternal)); - plugin = InferenceEngine::InferencePlugin{InferenceEngine::details::SOPointer{mockIPluginPtr.release()}}; + plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr}; net = plugin.LoadNetwork(CNNNetwork{}, {}); - req = net.CreateInferRequest(); + req = net->CreateInferRequest(); } }; @@ -50,7 +50,7 @@ TEST_F(VariableStateTests, ExecutableNetworkCanConvertOneVariableStateFromCppToA EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - auto state = net.QueryState(); + auto state = net->QueryState(); ASSERT_EQ(state.size(), 1); IE_SUPPRESS_DEPRECATED_END } @@ -61,7 +61,7 @@ TEST_F(VariableStateTests, ExecutableNetworkCanConvertZeroVariableStateFromCppTo EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).WillOnce(Return(toReturn)); - auto state = net.QueryState(); + auto state = net->QueryState(); ASSERT_EQ(state.size(), 0); IE_SUPPRESS_DEPRECATED_END } @@ -74,7 +74,7 @@ TEST_F(VariableStateTests, ExecutableNetworkCanConvert2VariableStatesFromCPPtoAP EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - auto state = net.QueryState(); + auto state = net->QueryState(); ASSERT_EQ(state.size(), 2); IE_SUPPRESS_DEPRECATED_END } @@ -87,8 +87,8 @@ TEST_F(VariableStateTests, VariableStatePropagatesReset) { EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), Reset()).Times(1); - auto state = net.QueryState(); - state.front().Reset(); + auto state = net->QueryState(); + state.front()->Reset(); IE_SUPPRESS_DEPRECATED_END } @@ -100,8 +100,8 @@ TEST_F(VariableStateTests, VariableStatePropagatesExceptionsFromReset) { EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), Reset()).WillOnce(Throw(std::logic_error("some error"))); - auto state = net.QueryState(); - EXPECT_ANY_THROW(state.front().Reset()); + auto state = net->QueryState(); + EXPECT_ANY_THROW(state.front()->Reset()); IE_SUPPRESS_DEPRECATED_END } @@ -113,8 +113,8 @@ TEST_F(VariableStateTests, VariableStatePropagatesGetName) { EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - auto state = net.QueryState(); - EXPECT_STREQ(state.front().GetName().c_str(), "someName"); + auto state = net->QueryState(); + EXPECT_STREQ(state.front()->GetName().c_str(), "someName"); IE_SUPPRESS_DEPRECATED_END } @@ -126,8 +126,8 @@ TEST_F(VariableStateTests, VariableStatePropagatesGetNameWithZeroLen) { EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - auto pState = net.QueryState().front(); - EXPECT_NO_THROW(pState.GetName()); + auto pState = net->QueryState().front(); + EXPECT_NO_THROW(pState->GetName()); IE_SUPPRESS_DEPRECATED_END } @@ -140,9 +140,9 @@ TEST_F(VariableStateTests, VariableStatePropagatesGetNameWithLenOfOne) { EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - auto pState = net.QueryState().front(); + auto pState = net->QueryState().front(); std::string name; - EXPECT_NO_THROW(name = pState.GetName()); + EXPECT_NO_THROW(name = pState->GetName()); EXPECT_EQ(name, "someName"); IE_SUPPRESS_DEPRECATED_END } @@ -155,9 +155,9 @@ TEST_F(VariableStateTests, VariableStatePropagatesGetNameWithLenOfTwo) { EXPECT_CALL(*mockExeNetworkInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - auto pState = net.QueryState().front(); + auto pState = net->QueryState().front(); std::string name; - EXPECT_NO_THROW(name = pState.GetName()); + EXPECT_NO_THROW(name = pState->GetName()); EXPECT_EQ(name, "someName"); IE_SUPPRESS_DEPRECATED_END } @@ -174,7 +174,7 @@ TEST_F(VariableStateTests, VariableStateCanPropagateSetState) { float data[] = {123, 124, 125}; auto stateBlob = make_shared_blob({ Precision::FP32, {3}, C }, data, sizeof(data) / sizeof(*data)); - EXPECT_NO_THROW(net.QueryState().front().SetState(stateBlob)); + EXPECT_NO_THROW(net->QueryState().front()->SetState(stateBlob)); ASSERT_FLOAT_EQ(saver->buffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->buffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->buffer().as()[2], 125); @@ -195,7 +195,7 @@ TEST_F(VariableStateTests, VariableStateCanPropagateGetLastState) { EXPECT_CALL(*mockVariableStateInternal.get(), GetState()).WillOnce(Return(stateBlob)); - auto saver = net.QueryState().front().GetState(); + auto saver = net->QueryState().front()->GetState(); ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); @@ -213,7 +213,6 @@ TEST_F(VariableStateTests, VariableStateInternalCanSaveName) { ASSERT_STREQ(pState->GetName().c_str(), "name"); } - TEST_F(VariableStateTests, VariableStateInternalCanSaveState) { IVariableStateInternal::Ptr pState(new VariableStateInternalMockImpl("name")); float data[] = {123, 124, 125}; @@ -252,7 +251,7 @@ TEST_F(VariableStateTests, InferRequestCanConvertOneVariableStateFromCppToAPI) { EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - auto state = req.QueryState(); + auto state = req->QueryState(); ASSERT_EQ(state.size(), 1); } @@ -261,7 +260,7 @@ TEST_F(VariableStateTests, InferRequestCanConvertZeroVariableStateFromCppToAPI) EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).WillOnce(Return(toReturn)); - auto state = req.QueryState(); + auto state = req->QueryState(); ASSERT_EQ(state.size(), 0); } @@ -272,7 +271,7 @@ TEST_F(VariableStateTests, InferRequestCanConvert2VariableStatesFromCPPtoAPI) { EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - auto state = req.QueryState(); + auto state = req->QueryState(); ASSERT_EQ(state.size(), 2); } @@ -283,8 +282,8 @@ TEST_F(VariableStateTests, InfReqVariableStatePropagatesReset) { EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), Reset()).Times(1); - auto state = req.QueryState(); - state.front().Reset(); + auto state = req->QueryState(); + state.front()->Reset(); } TEST_F(VariableStateTests, InfReqVariableStatePropagatesExceptionsFromReset) { @@ -294,8 +293,8 @@ TEST_F(VariableStateTests, InfReqVariableStatePropagatesExceptionsFromReset) { EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), Reset()).WillOnce(Throw(std::logic_error("some error"))); - auto state = req.QueryState(); - EXPECT_ANY_THROW(state.front().Reset()); + auto state = req->QueryState(); + EXPECT_ANY_THROW(state.front()->Reset()); } TEST_F(VariableStateTests, InfReqVariableStatePropagatesGetName) { @@ -305,58 +304,8 @@ TEST_F(VariableStateTests, InfReqVariableStatePropagatesGetName) { EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - auto state = req.QueryState(); - EXPECT_STREQ(state.front().GetName().c_str(), "someName"); -} - -TEST_F(VariableStateTests, InfReqVariableStatePropagatesGetNameWithZeroLen) { - IE_SUPPRESS_DEPRECATED_START - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - - IVariableState::Ptr pState; - - static_cast(req)->QueryState(pState, 0, nullptr); - char *name = reinterpret_cast(1); - EXPECT_NO_THROW(pState->GetName(name, 0, nullptr)); - IE_SUPPRESS_DEPRECATED_END -} - -TEST_F(VariableStateTests, InfReqVariableStatePropagatesGetNameWithLenOfOne) { - IE_SUPPRESS_DEPRECATED_START - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - - IVariableState::Ptr pState; - - static_cast(req)->QueryState(pState, 0, nullptr); - char name[1]; - EXPECT_NO_THROW(pState->GetName(name, 1, nullptr)); - EXPECT_STREQ(name, ""); - IE_SUPPRESS_DEPRECATED_END -} - -TEST_F(VariableStateTests, InfReqVariableStatePropagatesGetNameWithLenOfTwo) { - IE_SUPPRESS_DEPRECATED_START - std::vector toReturn; - toReturn.push_back(mockVariableStateInternal); - - EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).Times(1).WillRepeatedly(Return(toReturn)); - EXPECT_CALL(*mockVariableStateInternal.get(), GetName()).WillOnce(Return("someName")); - - IVariableState::Ptr pState; - - static_cast(req)->QueryState(pState, 0, nullptr); - char name[2]; - EXPECT_NO_THROW(pState->GetName(name, 2, nullptr)); - EXPECT_STREQ(name, "s"); - IE_SUPPRESS_DEPRECATED_END + auto state = req->QueryState(); + EXPECT_STREQ(state.front()->GetName().c_str(), "someName"); } TEST_F(VariableStateTests, InfReqVariableStateCanPropagateSetState) { @@ -370,7 +319,7 @@ TEST_F(VariableStateTests, InfReqVariableStateCanPropagateSetState) { float data[] = {123, 124, 125}; auto stateBlob = make_shared_blob({ Precision::FP32, {3}, C }, data, sizeof(data) / sizeof(*data)); - EXPECT_NO_THROW(req.QueryState().front().SetState(stateBlob)); + EXPECT_NO_THROW(req->QueryState().front()->SetState(stateBlob)); ASSERT_FLOAT_EQ(saver->buffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->buffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->buffer().as()[2], 125); @@ -387,7 +336,7 @@ TEST_F(VariableStateTests, InfReqVariableStateCanPropagateGetLastState) { EXPECT_CALL(*mockInferRequestInternal.get(), QueryState()).WillRepeatedly(Return(toReturn)); EXPECT_CALL(*mockVariableStateInternal.get(), GetState()).WillOnce(Return(stateBlob)); - auto saver = req.QueryState().front().GetState(); + auto saver = req->QueryState().front()->GetState(); ASSERT_FLOAT_EQ(saver->cbuffer().as()[0], 123); ASSERT_FLOAT_EQ(saver->cbuffer().as()[1], 124); ASSERT_FLOAT_EQ(saver->cbuffer().as()[2], 125); 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 a7dbba29a0670c..92625a5182e957 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 @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include @@ -169,12 +169,6 @@ TEST_F(InferenceEnginePluginInternalTest, pluginInternalEraseMagicAndNameWhenImp } -TEST(InferencePluginTests, throwsOnNullptrCreation) { - InferenceEnginePluginPtr nulptr; - InferencePlugin plugin; - ASSERT_THROW(plugin = InferencePlugin(nulptr), Exception); -} - TEST(InferencePluginTests, throwsOnUninitializedGetVersion) { InferencePlugin plg; ASSERT_THROW(plg.GetVersion(), Exception); @@ -199,8 +193,3 @@ TEST(InferencePluginTests, throwsOnUninitializedSetConfig) { InferencePlugin plg; ASSERT_THROW(plg.SetConfig({{}}), Exception); } - -TEST(InferencePluginTests, nothrowsUninitializedCast) { - InferencePlugin plg; - ASSERT_NO_THROW(auto plgPtr = static_cast(plg)); -} diff --git a/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp b/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp index 1df88845775f3f..2c35e8652dfcc0 100644 --- a/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp +++ b/inference-engine/tests/unit/inference_engine/ie_executable_network_test.cpp @@ -9,7 +9,7 @@ #include "cpp/ie_executable_network.hpp" #include "cpp/ie_executable_network_base.hpp" -#include "ie_plugin_cpp.hpp" +#include "cpp/ie_plugin.hpp" #include "unit_test_utils/mocks/mock_iexecutable_network.hpp" #include "unit_test_utils/mocks/mock_iinfer_request.hpp" @@ -39,10 +39,9 @@ using testing::SetArgReferee; class ExecutableNetworkTests : public ::testing::Test { protected: std::shared_ptr mockIExeNet; - InferenceEngine::ExecutableNetwork exeNetwork; - MockIInferencePlugin* mockIPlugin; - InferencePlugin plugin; - + InferenceEngine::SoExecutableNetworkInternal exeNetwork; + MockIInferencePlugin* mockIPlugin; + InferencePlugin plugin; virtual void TearDown() { mockIExeNet.reset(); @@ -52,9 +51,9 @@ class ExecutableNetworkTests : public ::testing::Test { virtual void SetUp() { mockIExeNet = std::make_shared(); - std::unique_ptr mockIPluginPtr{new MockIInferencePlugin}; + auto mockIPluginPtr = std::make_shared(); ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast(_), _)).WillByDefault(Return(mockIExeNet)); - plugin = InferenceEngine::InferencePlugin{InferenceEngine::details::SOPointer{mockIPluginPtr.release()}}; + plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr}; exeNetwork = plugin.LoadNetwork(CNNNetwork{}, {}); } }; @@ -64,14 +63,13 @@ TEST_F(ExecutableNetworkTests, GetOutputsInfoThrowsIfReturnErr) { .Times(1) .WillOnce(Throw(InferenceEngine::GeneralError{""})); - ASSERT_THROW(exeNetwork.GetOutputsInfo(), InferenceEngine::Exception); + ASSERT_THROW(exeNetwork->GetOutputsInfo(), InferenceEngine::Exception); } TEST_F(ExecutableNetworkTests, GetOutputsInfo) { InferenceEngine::ConstOutputsDataMap data; EXPECT_CALL(*mockIExeNet.get(), GetOutputsInfo()).Times(1).WillRepeatedly(Return(InferenceEngine::ConstOutputsDataMap{})); - - ASSERT_NO_THROW(data = exeNetwork.GetOutputsInfo()); + ASSERT_NO_THROW(data = exeNetwork->GetOutputsInfo()); ASSERT_EQ(data, InferenceEngine::ConstOutputsDataMap{}); } @@ -80,29 +78,24 @@ TEST_F(ExecutableNetworkTests, GetInputsInfoThrowsIfReturnErr) { .Times(1) .WillOnce(Throw(InferenceEngine::GeneralError{""})); - ASSERT_THROW(exeNetwork.GetInputsInfo(), InferenceEngine::Exception); + ASSERT_THROW(exeNetwork->GetInputsInfo(), InferenceEngine::Exception); } TEST_F(ExecutableNetworkTests, GetInputsInfo) { EXPECT_CALL(*mockIExeNet.get(), GetInputsInfo()).Times(1).WillRepeatedly(Return(InferenceEngine::ConstInputsDataMap{})); InferenceEngine::ConstInputsDataMap info; - ASSERT_NO_THROW(info = exeNetwork.GetInputsInfo()); + ASSERT_NO_THROW(info = exeNetwork->GetInputsInfo()); ASSERT_EQ(info, InferenceEngine::ConstInputsDataMap{}); } IE_SUPPRESS_DEPRECATED_START -TEST_F(ExecutableNetworkTests, resetThrowsIfResetToNullptr) { - InferenceEngine::IExecutableNetwork::Ptr mockIExeNet_2{}; - ASSERT_THROW(exeNetwork.reset(mockIExeNet_2), InferenceEngine::Exception); -} - TEST_F(ExecutableNetworkTests, QueryStateThrowsIfReturnErr) { EXPECT_CALL(*mockIExeNet.get(), QueryState()) .Times(1) .WillOnce(Throw(InferenceEngine::GeneralError{""})); - EXPECT_THROW(exeNetwork.QueryState(), InferenceEngine::Exception); + EXPECT_THROW(exeNetwork->QueryState(), InferenceEngine::Exception); } TEST_F(ExecutableNetworkTests, QueryState) { @@ -110,8 +103,8 @@ TEST_F(ExecutableNetworkTests, QueryState) { EXPECT_CALL(*mockIExeNet.get(), QueryState()) .Times(1) .WillOnce(Return(std::vector>(1, mockIMemState_p))); - std::vector MemState_v; - EXPECT_NO_THROW(MemState_v = exeNetwork.QueryState()); + std::vector MemState_v; + EXPECT_NO_THROW(MemState_v = exeNetwork->QueryState()); EXPECT_EQ(MemState_v.size(), 1); } @@ -134,39 +127,17 @@ class ExecutableNetworkWithIInferReqTests : public ExecutableNetworkTests { TEST_F(ExecutableNetworkWithIInferReqTests, CanCreateInferRequest) { EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Return(mockIInferReq_p)); - InferRequest actualInferReq; - ASSERT_NO_THROW(actualInferReq = exeNetwork.CreateInferRequest()); + IInferRequestInternal::Ptr actualInferReq; + ASSERT_NO_THROW(actualInferReq = exeNetwork->CreateInferRequest()); } TEST_F(ExecutableNetworkWithIInferReqTests, CreateInferRequestThrowsIfReturnNotOK) { EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Throw(InferenceEngine::GeneralError{""})); - ASSERT_THROW(exeNetwork.CreateInferRequest(), InferenceEngine::Exception); -} - -TEST_F(ExecutableNetworkWithIInferReqTests, CreateInferRequestThrowsIfSetRequestToNullptr) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()) - .WillOnce(Return(std::shared_ptr{})); - ASSERT_THROW(exeNetwork.CreateInferRequest(), InferenceEngine::Exception); + ASSERT_THROW(exeNetwork->CreateInferRequest(), InferenceEngine::Exception); } IE_SUPPRESS_DEPRECATED_START -// CreateInferRequestPtr -TEST_F(ExecutableNetworkWithIInferReqTests, CanCreateInferRequestPtr) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Return(mockIInferReq_p)); - ASSERT_NO_THROW(exeNetwork.CreateInferRequestPtr()); -} - -TEST_F(ExecutableNetworkWithIInferReqTests, CreateInferRequestPtrThrowsIfReturnNotOK) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Throw(InferenceEngine::GeneralError{""})); - ASSERT_THROW(exeNetwork.CreateInferRequestPtr(), InferenceEngine::Exception); -} - -TEST_F(ExecutableNetworkWithIInferReqTests, CreateInferRequestPtrThrowsIfSetRequestToNullptr) { - EXPECT_CALL(*mockIExeNet.get(), CreateInferRequest()).WillOnce(Return(std::shared_ptr{})); - ASSERT_THROW(exeNetwork.CreateInferRequestPtr(), InferenceEngine::Exception); -} - class ExecutableNetworkBaseTests : public ::testing::Test { protected: std::shared_ptr mock_impl; @@ -220,5 +191,3 @@ TEST_F(ExecutableNetworkBaseTests, canCatchUnknownErrorInExport) { EXPECT_CALL(*mock_impl.get(), Export(_)).WillOnce(Throw(5)); ASSERT_EQ(UNEXPECTED, exeNetwork->Export({}, nullptr)); } - - diff --git a/inference-engine/tests/unit/inference_engine/ie_plugin_ptr.cpp b/inference-engine/tests/unit/inference_engine/ie_plugin_ptr.cpp index 0f66277141e4db..28e4245a6bce6b 100644 --- a/inference-engine/tests/unit/inference_engine/ie_plugin_ptr.cpp +++ b/inference-engine/tests/unit/inference_engine/ie_plugin_ptr.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -#include #include #include "details/ie_so_loader.h" @@ -19,7 +18,7 @@ class PluginTest: public ::testing::Test { protected: unique_ptr sharedObjectLoader; std::function createPluginEngineProxy; - InferenceEnginePluginPtr getPtr(); + InferenceEngine::details::SOPointer getPtr(); std::string get_mock_engine_name() { std::string mockEngineName("mock_engine"); @@ -41,20 +40,20 @@ class PluginTest: public ::testing::Test { }; TEST_F(PluginTest, canCreatePluginUsingSmartPtr) { - ASSERT_NO_THROW(InferenceEnginePluginPtr ptr(get_mock_engine_name())); + ASSERT_NO_THROW(InferenceEngine::details::SOPointer ptr(get_mock_engine_name())); } TEST_F(PluginTest, shouldThrowExceptionIfPluginNotExist) { - EXPECT_THROW(InferenceEnginePluginPtr("unknown_plugin"), Exception); + EXPECT_THROW(InferenceEngine::details::SOPointer(std::string{"unknown_plugin"}), Exception); } -InferenceEnginePluginPtr PluginTest::getPtr() { - InferenceEnginePluginPtr smart_ptr(get_mock_engine_name()); +InferenceEngine::details::SOPointer PluginTest::getPtr() { + InferenceEngine::details::SOPointer smart_ptr(get_mock_engine_name()); return smart_ptr; } TEST_F(PluginTest, canSetConfiguration) { - InferenceEnginePluginPtr ptr = getPtr(); + InferenceEngine::details::SOPointer ptr = getPtr(); // TODO: dynamic->reinterpret because of clang/gcc cannot // dynamically cast this MOCK object ASSERT_TRUE(dynamic_cast(ptr.operator->())->config.empty()); diff --git a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp index 764d0e72df2f08..537713ac6fef24 100644 --- a/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp +++ b/inference-engine/tests_deprecated/behavior/vpu/myriad_tests/vpu_watchdog_tests.cpp @@ -15,7 +15,7 @@ #include "helpers/myriad_devices.hpp" -#include +#include using namespace std; using namespace ::testing;