Deprecated SOPointer (#8711)

* Removed SOPointer

* Updates

* Fixed tests, compilation
This commit is contained in:
Ilya Lavrenov 2021-11-20 18:13:10 +03:00 committed by GitHub
parent 063df47ec9
commit a1e95f4d69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 171 additions and 220 deletions

View File

@ -5,6 +5,7 @@
#include <iterator>
#include <string>
#include <utility>
#include <cassert>
#include <map>
#include <vector>
#include <set>

View File

@ -18,7 +18,6 @@
#include "cpp/ie_cnn_network.h"
#include "cpp/ie_infer_request.hpp"
#include "details/ie_so_loader.h"
#include "ie_iexecutable_network.hpp"
#include "ie_parameter.hpp"
#include "ie_remote_context.hpp"
@ -36,7 +35,7 @@ class IExecutableNetworkInternal;
* @brief This is an interface of an executable network
*/
class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) {
details::SharedObjectLoader _so;
std::shared_ptr<void> _so;
std::shared_ptr<IExecutableNetworkInternal> _impl;
/**
@ -45,7 +44,7 @@ class INFERENCE_ENGINE_API_CLASS(ExecutableNetwork) {
* object is destroyed.
* @param impl Initialized shared pointer
*/
ExecutableNetwork(const details::SharedObjectLoader& so, const std::shared_ptr<IExecutableNetworkInternal>& impl);
ExecutableNetwork(const std::shared_ptr<void>& so, const std::shared_ptr<IExecutableNetworkInternal>& impl);
friend class Core;
friend class ov::runtime::Core;

View File

@ -14,7 +14,6 @@
#include <string>
#include "cpp/ie_memory_state.hpp"
#include "details/ie_so_loader.h"
#include "ie_blob.h"
#include "ie_iinfer_request.hpp"
@ -33,7 +32,7 @@ class ICompletionCallbackWrapper;
* It can throw exceptions safely for the application, where it is properly handled.
*/
class INFERENCE_ENGINE_API_CLASS(InferRequest) {
details::SharedObjectLoader _so;
std::shared_ptr<void> _so;
std::shared_ptr<IInferRequestInternal> _impl;
/**
@ -42,7 +41,7 @@ class INFERENCE_ENGINE_API_CLASS(InferRequest) {
* destroyed.
* @param impl Initialized shared pointer
*/
InferRequest(const details::SharedObjectLoader& so, const std::shared_ptr<IInferRequestInternal>& impl);
InferRequest(const std::shared_ptr<void>& so, const std::shared_ptr<IInferRequestInternal>& impl);
friend class ExecutableNetwork;
public:

View File

@ -13,7 +13,6 @@
#include <memory>
#include <string>
#include "details/ie_so_loader.h"
#include "ie_api.h"
#include "ie_blob.h"
@ -25,7 +24,7 @@ class IVariableStateInternal;
* @brief VariableState class
*/
class INFERENCE_ENGINE_API_CLASS(VariableState) {
details::SharedObjectLoader _so;
std::shared_ptr<void> _so;
std::shared_ptr<IVariableStateInternal> _impl;
/**
@ -34,7 +33,7 @@ class INFERENCE_ENGINE_API_CLASS(VariableState) {
* @param so Optional: Plugin to use. This is required to ensure that VariableState can work properly even if plugin
* object is destroyed.
*/
VariableState(const details::SharedObjectLoader& so, const std::shared_ptr<IVariableStateInternal>& impl);
VariableState(const std::shared_ptr<void>& so, const std::shared_ptr<IVariableStateInternal>& impl);
friend class InferRequest;
friend class ExecutableNetwork;

View File

@ -17,9 +17,11 @@ namespace InferenceEngine {
namespace details {
/**
* @deprecated This is internal stuff. Use Inference Engine Plugin API
* @brief This class provides an OS shared module abstraction
*/
class INFERENCE_ENGINE_API_CLASS(SharedObjectLoader) {
class INFERENCE_ENGINE_DEPRECATED("This is internal stuff. Use Inference Engine Plugin API")
INFERENCE_ENGINE_API_CLASS(SharedObjectLoader) {
std::shared_ptr<void> _so;
public:

View File

@ -35,11 +35,12 @@ using enableIfSupportedChar =
typename std::enable_if<(std::is_same<C, char>::value || std::is_same<C, wchar_t>::value)>::type;
/**
* @deprecated This is internal stuff. Use Inference Engine Plugin API
* @brief This class instantiate object using shared library
* @tparam T An type of object SOPointer can hold
*/
template <class T>
class SOPointer {
class INFERENCE_ENGINE_DEPRECATED("This is internal stuff. Use Inference Engine Plugin API") SOPointer {
template <class U>
friend class SOPointer;

View File

@ -14,27 +14,10 @@
#include <string>
#include <vector>
#include "details/ie_so_pointer.hpp"
#include "ie_iextension.h"
#include "ngraph/opsets/opset.hpp"
namespace InferenceEngine {
namespace details {
/**
* @brief The SOCreatorTrait class specialization for IExtension case, defines the name of the fabric method for
* creating IExtension object in DLL
*/
template <>
class SOCreatorTrait<IExtension> {
public:
/**
* @brief A name of the fabric method for creating an IExtension object in DLL
*/
static constexpr auto name = "CreateExtension";
};
} // namespace details
/**
* @brief This class is a C++ helper to work with objects created using extensions.
@ -46,8 +29,16 @@ public:
*
* @param name Full or relative path to extension library
*/
template <typename C, typename = details::enableIfSupportedChar<C>>
explicit Extension(const std::basic_string<C>& name) : actual(name) {}
explicit Extension(const std::string& name);
#ifdef ENABLE_UNICODE_PATH_SUPPORT
/**
* @brief Loads extension from a shared library
*
* @param name Full or relative path to extension library
*/
explicit Extension(const std::wstring& name);
#endif // ENABLE_UNICODE_PATH_SUPPORT
/**
* @brief Gets the extension version information
@ -55,14 +46,14 @@ public:
* @param versionInfo A pointer to version info, set by the plugin
*/
void GetVersion(const InferenceEngine::Version*& versionInfo) const noexcept override {
actual->GetVersion(versionInfo);
_actual->GetVersion(versionInfo);
}
/**
* @brief Cleans the resources up
*/
void Unload() noexcept override {
actual->Unload();
_actual->Unload();
}
/**
@ -80,7 +71,7 @@ public:
std::vector<std::string> getImplTypes(const std::shared_ptr<ngraph::Node>& node) override {
if (node == nullptr)
IE_THROW() << "Provided ngraph::Node pointer is nullptr.";
return actual->getImplTypes(node);
return _actual->getImplTypes(node);
}
/**
@ -92,14 +83,19 @@ public:
ILayerImpl::Ptr getImplementation(const std::shared_ptr<ngraph::Node>& node, const std::string& implType) override {
if (node == nullptr)
IE_THROW() << "Provided ngraph::Node pointer is nullptr.";
return actual->getImplementation(node, implType);
return _actual->getImplementation(node, implType);
}
protected:
/**
* @brief A SOPointer instance to the loaded templated object
* @brief A shared library
*/
details::SOPointer<IExtension> actual;
std::shared_ptr<void> _so;
/**
* @brief A instance to the loaded templated object
*/
std::shared_ptr<InferenceEngine::IExtension> _actual;
};
/**

View File

@ -33,7 +33,7 @@ namespace InferenceEngine {
OPENVINO_ASSERT(false, "Unexpected exception"); \
}
ExecutableNetwork::ExecutableNetwork(const details::SharedObjectLoader& so, const IExecutableNetworkInternal::Ptr& impl)
ExecutableNetwork::ExecutableNetwork(const std::shared_ptr<void>& so, const IExecutableNetworkInternal::Ptr& impl)
: _so(so),
_impl(impl) {
IE_ASSERT(_impl != nullptr);

View File

@ -0,0 +1,77 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "ie_extension.h"
#include "openvino/util/shared_object.hpp"
using namespace InferenceEngine;
namespace {
template <typename T>
std::shared_ptr<T> CreateExtensionFromLibrary(std::shared_ptr<void> _so) {
std::shared_ptr<T> _ptr = nullptr;
constexpr char createFuncName[] = "CreateExtension";
try {
void* create = nullptr;
try {
create = ov::util::get_symbol(_so, (createFuncName + std::string("Shared")).c_str());
} catch (const std::runtime_error&) {
}
if (create == nullptr) {
create = ov::util::get_symbol(_so, createFuncName);
using CreateF = StatusCode(T*&, ResponseDesc*);
T* object = nullptr;
ResponseDesc desc;
StatusCode sts = reinterpret_cast<CreateF*>(create)(object, &desc);
if (sts != OK) {
IE_EXCEPTION_SWITCH(
sts,
ExceptionType,
details::ThrowNow<ExceptionType>{} <<= std::stringstream{} << IE_LOCATION << desc.msg)
}
IE_SUPPRESS_DEPRECATED_START
_ptr = std::shared_ptr<T>(object, [](T* ptr) {
ptr->Release();
});
IE_SUPPRESS_DEPRECATED_END
} else {
using CreateF = void(std::shared_ptr<T>&);
reinterpret_cast<CreateF*>(create)(_ptr);
}
} catch (...) {
details::Rethrow();
}
return _ptr;
}
} // namespace
Extension::Extension(const std::string& name) {
try {
_so = ov::util::load_shared_object(name.c_str());
} catch (const std::runtime_error&) {
details::Rethrow();
}
_actual = CreateExtensionFromLibrary<IExtension>(_so);
}
#ifdef ENABLE_UNICODE_PATH_SUPPORT
Extension::Extension(const std::wstring& name) {
try {
_so = ov::util::load_shared_object(name.c_str());
} catch (const std::runtime_error&) {
details::Rethrow();
}
_actual = CreateExtensionFromLibrary<IExtension>(_so);
}
#endif // ENABLE_UNICODE_PATH_SUPPORT
std::map<std::string, ngraph::OpSet> Extension::getOpSets() {
return _actual->getOpSets();
}

View File

@ -58,7 +58,7 @@ namespace InferenceEngine {
OPENVINO_ASSERT(false, "Unexpected exception"); \
}
InferRequest::InferRequest(const details::SharedObjectLoader& so, const IInferRequestInternal::Ptr& impl)
InferRequest::InferRequest(const std::shared_ptr<void>& so, const IInferRequestInternal::Ptr& impl)
: _so(so),
_impl(impl) {
IE_ASSERT(_impl != nullptr);

View File

@ -61,17 +61,17 @@ struct InferencePlugin {
PLUGIN_CALL_STATEMENT(_ptr->SetConfig(config));
}
details::SOPointer<IExecutableNetworkInternal> LoadNetwork(const CNNNetwork& network, const std::map<std::string, std::string>& config) {
ov::runtime::SoPtr<IExecutableNetworkInternal> LoadNetwork(const CNNNetwork& network, const std::map<std::string, std::string>& config) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config)});
}
details::SOPointer<IExecutableNetworkInternal> LoadNetwork(const CNNNetwork& network,
ov::runtime::SoPtr<IExecutableNetworkInternal> LoadNetwork(const CNNNetwork& network,
const std::shared_ptr<RemoteContext>& context,
const std::map<std::string, std::string>& config) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(network, config, context)});
}
details::SOPointer<IExecutableNetworkInternal> LoadNetwork(const std::string& modelPath, const std::map<std::string, std::string>& config) {
ov::runtime::SoPtr<IExecutableNetworkInternal> LoadNetwork(const std::string& modelPath, const std::map<std::string, std::string>& config) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->LoadNetwork(modelPath, config)});
}
@ -83,17 +83,17 @@ struct InferencePlugin {
return res;
}
details::SOPointer<IExecutableNetworkInternal> ImportNetwork(const std::string& modelFileName,
ov::runtime::SoPtr<IExecutableNetworkInternal> ImportNetwork(const std::string& modelFileName,
const std::map<std::string, std::string>& config) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(modelFileName, config)});
}
details::SOPointer<IExecutableNetworkInternal> ImportNetwork(std::istream& networkModel,
ov::runtime::SoPtr<IExecutableNetworkInternal> ImportNetwork(std::istream& networkModel,
const std::map<std::string, std::string>& config) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, config)});
}
details::SOPointer<IExecutableNetworkInternal> ImportNetwork(std::istream& networkModel,
ov::runtime::SoPtr<IExecutableNetworkInternal> ImportNetwork(std::istream& networkModel,
const std::shared_ptr<RemoteContext>& context,
const std::map<std::string, std::string>& config) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->ImportNetwork(networkModel, context, config)});
@ -103,11 +103,11 @@ struct InferencePlugin {
PLUGIN_CALL_STATEMENT(return _ptr->GetMetric(name, options));
}
details::SOPointer<RemoteContext> CreateContext(const ParamMap& params) {
ov::runtime::SoPtr<RemoteContext> CreateContext(const ParamMap& params) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->CreateContext(params)});
}
details::SOPointer<RemoteContext> GetDefaultContext(const ParamMap& params) {
ov::runtime::SoPtr<RemoteContext> GetDefaultContext(const ParamMap& params) {
PLUGIN_CALL_STATEMENT(return {_so, _ptr->GetDefaultContext(params)});
}

View File

@ -28,7 +28,7 @@
namespace InferenceEngine {
VariableState::VariableState(const details::SharedObjectLoader& so, const IVariableStateInternal::Ptr& impl)
VariableState::VariableState(const std::shared_ptr<void>& so, const IVariableStateInternal::Ptr& impl)
: _so(so),
_impl(impl) {
if (_impl == nullptr)

View File

@ -52,7 +52,7 @@ namespace InferenceEngine {
namespace {
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = FileUtils::enableIfSupportedChar<C>>
std::basic_string<C> getPathName(const std::basic_string<C>& s) {
size_t i = s.rfind(ov::util::FileTraits<C>::file_separator, s.length());
if (i != std::string::npos) {

View File

@ -40,12 +40,6 @@ std::map<std::string, ngraph::OpSet> IExtension::getOpSets() {
return {};
}
//
// ie_extension.h
//
std::map<std::string, ngraph::OpSet> Extension::getOpSets() {
return actual->getOpSets();
}
namespace details {
void Rethrow() {

View File

@ -1084,7 +1084,7 @@ private:
extensions.emplace_back(extension);
}
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = FileUtils::enableIfSupportedChar<C>>
void TryToRegisterLibraryAsExtensionUnsafe(const std::basic_string<C>& path) const {
try {
const auto extension_ptr = std::make_shared<InferenceEngine::Extension>(path);

View File

@ -13,7 +13,6 @@
#include "cnn_network_ngraph_impl.hpp"
#include "cpp/ie_cnn_network.h"
#include "details/ie_so_pointer.hpp"
#include "file_utils.h"
#include "frontend_manager/frontend_manager.hpp"
#include "ie_api.h"
@ -34,6 +33,8 @@
#include "openvino/core/preprocess/input_tensor_info.hpp"
#include "openvino/core/preprocess/pre_post_process.hpp"
#include "openvino/core/type/element_type.hpp"
#include "openvino/util/shared_object.hpp"
#include "so_ptr.hpp"
#include "transformations/rt_info/old_api_map_order_attribute.hpp"
#include "transformations/utils/utils.hpp"
@ -77,22 +78,6 @@ namespace InferenceEngine {
#ifdef ENABLE_IR_V7_READER
namespace details {
/**
* @brief This class defines the name of the fabric for creating an IReader object in DLL
*/
template <>
class SOCreatorTrait<IReader> {
public:
/**
* @brief A name of the fabric for creating IReader object in DLL
*/
static constexpr auto name = "CreateReader";
};
} // namespace details
/**
* @brief This class is a wrapper for reader interfaces
*/
@ -100,7 +85,7 @@ class Reader : public IReader {
# ifdef OPENVINO_STATIC_LIBRARY
using ReaderPtr = std::shared_ptr<IReader>;
# else
using ReaderPtr = InferenceEngine::details::SOPointer<IReader>;
using ReaderPtr = ov::runtime::SoPtr<IReader>;
# endif
ReaderPtr ptr;
std::once_flag readFlag;
@ -123,7 +108,12 @@ class Reader : public IReader {
<< ov::util::from_file_path(::FileUtils::makePluginLibraryName({}, libraryName)) << " is in "
<< getIELibraryPath();
}
ptr = {readersLibraryPath};
auto so = ov::util::load_shared_object(readersLibraryPath.c_str());
std::shared_ptr<IReader> plugin_impl;
using createFunc = void(std::shared_ptr<IReader>&);
reinterpret_cast<createFunc*>(ov::util::get_symbol(so, "CreateReader"))(plugin_impl);
ptr = {so, plugin_impl};
# endif // OPENVINO_STATIC_LIBRARY
});

View File

@ -7,6 +7,8 @@
#include "openvino/util/file_util.hpp"
#include "openvino/util/shared_object.hpp"
IE_SUPPRESS_DEPRECATED_START
namespace InferenceEngine {
namespace details {
@ -41,3 +43,5 @@ std::shared_ptr<void> SharedObjectLoader::get() const {
} // namespace details
} // namespace InferenceEngine
IE_SUPPRESS_DEPRECATED_END

View File

@ -261,7 +261,7 @@ private:
};
/**
* @brief SOPointer to IInferRequestInternal.
* @brief SoPtr to IInferRequestInternal.
*/
using SoIInferRequestInternal = ov::runtime::SoPtr<IInferRequestInternal>;

View File

@ -16,7 +16,6 @@
#include "blob_factory.hpp"
#include "cpp/ie_cnn_network.h"
#include "details/ie_so_pointer.hpp"
#include "ie_iextension.h"
#include "ie_input_info.hpp"
#include "ie_parameter.hpp"
@ -346,13 +345,6 @@ using CreateExtensionFunc = void(std::shared_ptr<IExtension>&);
*/
constexpr static const auto create_plugin_function = OV_PP_TOSTRING(IE_CREATE_PLUGIN);
namespace details {
template <>
class SOCreatorTrait<IInferencePlugin> {
public:
static constexpr auto name = create_plugin_function;
};
} // namespace details
} // namespace InferenceEngine
/**

View File

@ -14,11 +14,18 @@
#include <cstring>
#include "ie_api.h"
#include "details/ie_so_pointer.hpp"
#include "openvino/util/file_util.hpp"
namespace FileUtils {
/**
* @brief Enables only `char` or `wchar_t` template specializations
* @tparam C A char type
*/
template <typename C>
using enableIfSupportedChar =
typename std::enable_if<(std::is_same<C, char>::value || std::is_same<C, wchar_t>::value)>::type;
/**
* @brief Interface function to get absolute path of file
* @ingroup ie_dev_api_file_utils
@ -74,7 +81,7 @@ inline long long fileSize(const wchar_t* fileName) {
* @param f - string name of the file
* @return size of the file
*/
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = enableIfSupportedChar<C>>
inline long long fileSize(const std::basic_string<C> &f) {
return fileSize(f.c_str());
}
@ -85,7 +92,7 @@ inline long long fileSize(const std::basic_string<C> &f) {
* @param fileName - given filename
* @return true is exists
*/
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = enableIfSupportedChar<C>>
inline bool fileExist(const C * fileName) {
return fileSize(fileName) >= 0;
}
@ -96,7 +103,7 @@ inline bool fileExist(const C * fileName) {
* @param fileName - string with a given filename
* @return true is exists
*/
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = enableIfSupportedChar<C>>
inline bool fileExist(const std::basic_string<C> &fileName) {
return fileExist(fileName.c_str());
}
@ -109,7 +116,7 @@ inline bool fileExist(const std::basic_string<C> &fileName) {
* @return string with combination of the path and the filename divided by file separator
*/
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = enableIfSupportedChar<C>>
inline std::basic_string<C> makePath(const std::basic_string<C> &folder, const std::basic_string<C> &file) {
if (folder.empty())
return file;
@ -122,7 +129,7 @@ inline std::basic_string<C> makePath(const std::basic_string<C> &folder, const s
* @param filename - string with the name of the file which extension should be extracted
* @return string with extracted file extension
*/
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = enableIfSupportedChar<C>>
inline std::basic_string<C> fileExt(const std::basic_string<C> &filename) {
auto pos = filename.rfind(ov::util::FileTraits<C>::dot_symbol);
if (pos == std::string::npos)
@ -130,7 +137,7 @@ inline std::basic_string<C> fileExt(const std::basic_string<C> &filename) {
return filename.substr(pos + 1);
}
template <typename C, typename = InferenceEngine::details::enableIfSupportedChar<C>>
template <typename C, typename = enableIfSupportedChar<C>>
inline std::basic_string<C> makePluginLibraryName(const std::basic_string<C> &path, const std::basic_string<C> &input) {
std::basic_string<C> separator(1, ov::util::FileTraits<C>::file_separator);
if (path.empty())

View File

@ -16,8 +16,6 @@
#include <file_utils.h>
#include <ie_preprocess.hpp>
#include <details/ie_so_pointer.hpp>
namespace InferenceEngine {
/**

View File

@ -14,7 +14,6 @@
#include "ie_core.hpp"
#include "ngraph/function.hpp"
#include "details/ie_so_loader.h"
#include "ie_metric_helpers.hpp"
#include "openvino/op/logical_not.hpp"
@ -168,7 +167,7 @@ public:
class CachingTest : public ::testing::TestWithParam<std::tuple<TestParam, std::string>> {
public:
std::unique_ptr<SharedObjectLoader> sharedObjectLoader;
std::shared_ptr<void> sharedObjectLoader;
std::function<void(IInferencePlugin*)> injectProxyEngine;
std::string modelName = "Caching_test.xml";
std::string weightsName = "Caching_test.bin";
@ -270,7 +269,7 @@ public:
mockPlugin = std::make_shared<MockCachingInferencePlugin>();
setupMock(*mockPlugin);
std::string libraryName = get_mock_engine_name();
sharedObjectLoader.reset(new SharedObjectLoader(libraryName.c_str()));
sharedObjectLoader = ov::util::load_shared_object(libraryName.c_str());
injectProxyEngine = make_std_function<void(IInferencePlugin*)>("InjectProxyEngine");
FuncTestUtils::TestModel::generateTestModel(modelName, weightsName);
@ -337,7 +336,8 @@ public:
private:
template <class T>
std::function<T> make_std_function(const std::string& functionName) {
std::function <T> ptr(reinterpret_cast<T*>(sharedObjectLoader->get_symbol(functionName.c_str())));
std::function <T> ptr(reinterpret_cast<T*>(
ov::util::get_symbol(sharedObjectLoader, functionName.c_str())));
return ptr;
}

View File

@ -5,7 +5,7 @@
#include <gtest/gtest.h>
#include <file_utils.h>
#include "details/ie_so_loader.h"
#include "openvino/util/shared_object.hpp"
#include <cpp/ie_plugin.hpp>
using namespace std;
@ -20,14 +20,15 @@ protected:
}
void loadDll(const string &libraryName) {
sharedObjectLoader.reset(new details::SharedObjectLoader(libraryName.c_str()));
sharedObjectLoader = ov::util::load_shared_object(libraryName.c_str());
}
unique_ptr<SharedObjectLoader> sharedObjectLoader;
std::shared_ptr<void> sharedObjectLoader;
using CreateF = void(std::shared_ptr<IInferencePlugin>&);
std::function<CreateF> make_std_function(const std::string& functionName) {
std::function<CreateF> ptr(reinterpret_cast<CreateF*>(sharedObjectLoader->get_symbol(functionName.c_str())));
std::function<CreateF> ptr(reinterpret_cast<CreateF*>(
ov::util::get_symbol(sharedObjectLoader, functionName.c_str())));
return ptr;
}
};

View File

@ -1,41 +0,0 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include <gmock/gmock-spec-builders.h>
#include <file_utils.h>
#include <memory>
#include <common_test_utils/test_assertions.hpp>
#include <details/ie_so_pointer.hpp>
#include <cpp_interfaces/interface/ie_iplugin_internal.hpp>
using namespace InferenceEngine;
using namespace InferenceEngine::details;
using namespace ::testing;
using ::testing::InSequence;
namespace InferenceEngine {
namespace details {
struct UnknownPlugin : std::enable_shared_from_this<UnknownPlugin> {};
template<>
class SOCreatorTrait<InferenceEngine::details::UnknownPlugin> {
public:
static constexpr auto name = "CreateUnknownPlugin";
};
} // namespace details
} // namespace InferenceEngine
class SoPointerTests : public ::testing::Test {};
TEST_F(SoPointerTests, UnknownPlugin) {
ASSERT_THROW(SOPointer<InferenceEngine::details::UnknownPlugin>{std::string{"UnknownPlugin"}}, Exception);
}

View File

@ -197,7 +197,7 @@ protected:
auto mockIPluginPtr = std::make_shared<MockIInferencePlugin>();
ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast<const CNNNetwork&>(_), _)).WillByDefault(Return(mockIExeNet));
plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr};
exeNetwork = {{}, plugin.LoadNetwork(CNNNetwork{}, {})};
exeNetwork = plugin.LoadNetwork(CNNNetwork{}, {});
request = exeNetwork->CreateInferRequest();
_incorrectName = "incorrect_name";
_inputName = MockNotEmptyICNNNetwork::INPUT_BLOB_NAME;

View File

@ -38,7 +38,7 @@ class InferRequestVariableStateTests : public ::testing::Test {
auto mockIPluginPtr = std::make_shared<MockIInferencePlugin>();
ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast<const CNNNetwork&>(_), _)).WillByDefault(Return(mockExeNetworkInternal));
plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr};
net = {{}, plugin.LoadNetwork(CNNNetwork{}, {})};
net = plugin.LoadNetwork(CNNNetwork{}, {});
req = net->CreateInferRequest();
}
};

View File

@ -53,7 +53,7 @@ protected:
auto mockIPluginPtr = std::make_shared<MockIInferencePlugin>();
ON_CALL(*mockIPluginPtr, LoadNetwork(MatcherCast<const CNNNetwork&>(_), _)).WillByDefault(Return(mockIExeNet));
plugin = InferenceEngine::InferencePlugin{{}, mockIPluginPtr};
exeNetwork = {{}, plugin.LoadNetwork(CNNNetwork{}, {})};
exeNetwork = plugin.LoadNetwork(CNNNetwork{}, {});
}
};

View File

@ -1,71 +0,0 @@
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <common_test_utils/test_constants.hpp>
#include "details/ie_so_loader.h"
#include "details/ie_so_pointer.hpp"
#include "unit_test_utils/mocks/mock_engine/mock_plugin.hpp"
#include "unit_test_utils/mocks/cpp_interfaces/impl/mock_inference_plugin_internal.hpp"
using namespace std;
using namespace InferenceEngine;
using namespace ::testing;
using namespace InferenceEngine::details;
class PluginTest: public ::testing::Test {
protected:
unique_ptr<SharedObjectLoader> sharedObjectLoader;
std::function<IInferencePlugin*(IInferencePlugin*)> createPluginEngineProxy;
InferenceEngine::details::SOPointer<InferenceEngine::IInferencePlugin> getPtr();
std::string get_mock_engine_name() {
std::string mockEngineName("mock_engine");
return CommonTestUtils::pre + mockEngineName + IE_BUILD_POSTFIX + CommonTestUtils::ext;
}
void SetUp() override {
std::string libraryName = get_mock_engine_name();
sharedObjectLoader.reset(new SharedObjectLoader(libraryName.c_str()));
createPluginEngineProxy = make_std_function<IInferencePlugin*(IInferencePlugin*)>("CreatePluginEngineProxy");
}
template <class T>
std::function<T> make_std_function(const std::string& functionName) {
std::function <T> ptr(reinterpret_cast<T*>(sharedObjectLoader->get_symbol(functionName.c_str())));
return ptr;
}
MockInferencePluginInternal2 engine;
};
#ifndef OPENVINO_STATIC_LIBRARY
TEST_F(PluginTest, canCreatePluginUsingSmartPtr) {
ASSERT_NO_THROW(InferenceEngine::details::SOPointer<InferenceEngine::IInferencePlugin> ptr(get_mock_engine_name()));
}
TEST_F(PluginTest, shouldThrowExceptionIfPluginNotExist) {
EXPECT_THROW(InferenceEngine::details::SOPointer<InferenceEngine::IInferencePlugin>(std::string{"unknown_plugin"}), Exception);
}
InferenceEngine::details::SOPointer<InferenceEngine::IInferencePlugin> PluginTest::getPtr() {
InferenceEngine::details::SOPointer<InferenceEngine::IInferencePlugin> smart_ptr(get_mock_engine_name());
return smart_ptr;
}
TEST_F(PluginTest, canSetConfiguration) {
InferenceEngine::details::SOPointer<InferenceEngine::IInferencePlugin> ptr = getPtr();
// TODO: dynamic->reinterpret because of clang/gcc cannot
// dynamically cast this MOCK object
ASSERT_TRUE(dynamic_cast<MockPlugin*>(ptr.operator->())->config.empty());
std::map<std::string, std::string> config = { { "key", "value" } };
ASSERT_NO_THROW(ptr->SetConfig(config));
config.clear();
ASSERT_STREQ(dynamic_cast<MockPlugin*>(ptr.operator->())->config["key"].c_str(), "value");
}
#endif // OPENVINO_STATIC_LIBRARY

View File

@ -44,7 +44,8 @@ function(enable_vpu TARGET_NAME FLAG_NAME PLUGIN_NAME)
${FLAG_NAME}=1)
target_link_libraries(${TARGET_NAME} PRIVATE
IEBehaviorSharedTests)
IEBehaviorSharedTests
openvino::util)
target_include_directories(${TARGET_NAME} PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances/plugin_tests)

View File

@ -11,6 +11,7 @@
#include <thread>
#include <file_utils.h>
#include "vpu_test_data.hpp"
#include "openvino/util/shared_object.hpp"
#include "helpers/myriad_devices.hpp"
@ -126,8 +127,8 @@ TEST_P(MYRIADWatchdog, canDisableWatchdog) {
ASSERT_GE(startup_devices.unbooted, 1);
auto ctime = Time::now();
SharedObjectLoader myriadPlg (make_plugin_name("myriadPlugin").c_str());
void *p = myriadPlg.get_symbol(create_plugin_function);
std::shared_ptr<void> myriadPlg = ov::util::load_shared_object(make_plugin_name("myriadPlugin").c_str());
void *p = ov::util::get_symbol(myriadPlg, create_plugin_function);
bootOneDevice(0, p);
@ -159,8 +160,8 @@ TEST_P(MYRIADWatchdog, canDetectWhenHostSiteStalled) {
auto ctime = Time::now();
SharedObjectLoader myriadPlg (make_plugin_name("myriadPlugin").c_str());
void *p = myriadPlg.get_symbol(create_plugin_function);
std::shared_ptr<void> myriadPlg = ov::util::load_shared_object(make_plugin_name("myriadPlugin").c_str());
void *p = ov::util::get_symbol(myriadPlg, create_plugin_function);
bootOneDevice(20000, p);

View File

@ -5,6 +5,7 @@
#include <samples/classification_results.h>
#include <sys/stat.h>
#include <cassert>
#include <fstream>
#include <inference_engine.hpp>
#include <iostream>