Fixed loading old extensions inside the OpenVINO (#13543)
This commit is contained in:
@@ -1995,11 +1995,35 @@ void Core::add_extension(const ie::IExtensionPtr& extension) {
|
||||
}
|
||||
|
||||
void Core::add_extension(const std::string& library_path) {
|
||||
add_extension(ov::detail::load_extensions(library_path));
|
||||
try {
|
||||
add_extension(ov::detail::load_extensions(library_path));
|
||||
} catch (const std::runtime_error&) {
|
||||
try {
|
||||
// Try to load legacy extension
|
||||
const auto extension_ptr = std::make_shared<InferenceEngine::Extension>(library_path);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
add_extension(extension_ptr);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
} catch (const std::runtime_error&) {
|
||||
throw ov::Exception("Cannot add extension. Cannot find entry point to the extension library");
|
||||
}
|
||||
}
|
||||
}
|
||||
#ifdef OPENVINO_ENABLE_UNICODE_PATH_SUPPORT
|
||||
void Core::add_extension(const std::wstring& library_path) {
|
||||
add_extension(ov::detail::load_extensions(library_path));
|
||||
try {
|
||||
add_extension(ov::detail::load_extensions(library_path));
|
||||
} catch (const std::runtime_error&) {
|
||||
try {
|
||||
// Try to load legacy extension
|
||||
const auto extension_ptr = std::make_shared<InferenceEngine::Extension>(library_path);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
add_extension(extension_ptr);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
} catch (const std::runtime_error&) {
|
||||
throw ov::Exception("Cannot add extension. Cannot find entry point to the extension library");
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,13 +10,14 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "common_test_utils/test_common.hpp"
|
||||
#include "common_test_utils/file_utils.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
#include "common_test_utils/test_common.hpp"
|
||||
#include "ie_iextension.h"
|
||||
#include "ngraph/op/op.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/core/op_extension.hpp"
|
||||
#include "openvino/runtime/core.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
|
||||
using namespace testing;
|
||||
using namespace InferenceEngine;
|
||||
@@ -176,7 +177,17 @@ namespace {
|
||||
|
||||
std::string getOVExtensionPath() {
|
||||
return ov::util::make_plugin_library_name(CommonTestUtils::getExecutableDirectory(),
|
||||
std::string("openvino_template_extension") + IE_BUILD_POSTFIX);
|
||||
std::string("openvino_template_extension") + IE_BUILD_POSTFIX);
|
||||
}
|
||||
|
||||
std::string getOldExtensionPath() {
|
||||
return ov::util::make_plugin_library_name(CommonTestUtils::getExecutableDirectory(),
|
||||
std::string("template_extension") + IE_BUILD_POSTFIX);
|
||||
}
|
||||
|
||||
std::string getIncorrectExtensionPath() {
|
||||
return ov::util::make_plugin_library_name(CommonTestUtils::getExecutableDirectory(),
|
||||
std::string("incorrect") + IE_BUILD_POSTFIX);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
@@ -334,3 +345,15 @@ TEST_F(OVExtensionTests, ReshapeIRWithSeveralNewOps) {
|
||||
core.add_extension<CustomNewIdentity, CustomReLU>();
|
||||
test_two_op();
|
||||
}
|
||||
|
||||
TEST_F(OVExtensionTests, load_new_extension) {
|
||||
EXPECT_NO_THROW(core.add_extension(getOVExtensionPath()));
|
||||
}
|
||||
|
||||
TEST_F(OVExtensionTests, load_old_extension) {
|
||||
EXPECT_NO_THROW(core.add_extension(getOldExtensionPath()));
|
||||
}
|
||||
|
||||
TEST_F(OVExtensionTests, load_incorrect_extension) {
|
||||
EXPECT_THROW(core.add_extension(getIncorrectExtensionPath()), ov::Exception);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user