Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Add new import_model overloading to plugins (#31137)

Oleg Pipikin160e07a54fac
diff --git a/src/core/include/openvino/pass/serialize.hpp b/src/core/include/openvino/pass/serialize.hpp
index 5bf2721463f..d0bb853352a 100644
--- a/src/core/include/openvino/pass/serialize.hpp
+++ b/src/core/include/openvino/pass/serialize.hpp
@@ -74,6 +74,8 @@ public:
Serialize::Version version = Serialize::Version::UNSPECIFIED);
private:
+ virtual bool use_absolute_offset();
+
std::ostream& m_stream;
std::function<void(std::ostream&)> m_custom_data_serializer;
std::function<std::string(const std::string&)> m_cache_encrypt;
diff --git a/src/core/src/pass/serialize.cpp b/src/core/src/pass/serialize.cpp
index 28f8851d065..00a13f7905f 100644
--- a/src/core/src/pass/serialize.cpp
+++ b/src/core/src/pass/serialize.cpp
@@ -1349,6 +1349,10 @@ pass::StreamSerialize::StreamSerialize(std::ostream& stream,
}
}
+bool pass::StreamSerialize::use_absolute_offset() {
+ return true;
+}
+
bool pass::StreamSerialize::run_on_model(const std::shared_ptr<ov::Model>& model) {
RUN_ON_MODEL_SCOPE(StreamSerialize);
/*
@@ -1377,17 +1381,18 @@ bool pass::StreamSerialize::run_on_model(const std::shared_ptr<ov::Model>& model
}
// Header
- const size_t header_offset = m_stream.tellp();
+ const size_t header_offset = use_absolute_offset() ? 0 : static_cast<size_t>(m_stream.tellp());
+ const size_t absolute_header_offset = static_cast<size_t>(m_stream.tellp());
writeHeader(hdr);
// Custom data
- hdr.custom_data_offset = m_stream.tellp();
+ hdr.custom_data_offset = static_cast<size_t>(m_stream.tellp()) - header_offset;
if (m_custom_data_serializer) {
m_custom_data_serializer(m_stream);
}
// Blobs
- hdr.consts_offset = m_stream.tellp();
+ hdr.consts_offset = static_cast<size_t>(m_stream.tellp()) - header_offset;
std::string name = "net";
pugi::xml_document xml_doc;
pugi::xml_node net_node = xml_doc.append_child(name.c_str());
@@ -1397,7 +1402,7 @@ bool pass::StreamSerialize::run_on_model(const std::shared_ptr<ov::Model>& model
visitor.on_attribute(name, fun);
// IR
- hdr.model_offset = m_stream.tellp();
+ hdr.model_offset = static_cast<size_t>(m_stream.tellp()) - header_offset;
if (m_cache_encrypt) {
std::stringstream ss;
xml_doc.save(ss);
@@ -1408,13 +1413,13 @@ bool pass::StreamSerialize::run_on_model(const std::shared_ptr<ov::Model>& model
}
m_stream.flush();
- const size_t file_size = m_stream.tellp();
+ const size_t file_size = static_cast<size_t>(m_stream.tellp()) - header_offset;
hdr.custom_data_size = hdr.consts_offset - hdr.custom_data_offset;
hdr.consts_size = hdr.model_offset - hdr.consts_offset;
hdr.model_size = file_size - hdr.model_offset;
- m_stream.seekp(header_offset);
+ m_stream.seekp(absolute_header_offset);
writeHeader(hdr);
m_stream.seekp(file_size);
diff --git a/src/inference/dev_api/openvino/runtime/compilation_context.hpp b/src/inference/dev_api/openvino/runtime/compilation_context.hpp
index 21bda52882f..504b7e34a2c 100644
--- a/src/inference/dev_api/openvino/runtime/compilation_context.hpp
+++ b/src/inference/dev_api/openvino/runtime/compilation_context.hpp
@@ -52,6 +52,8 @@ public:
friend std::istream& operator>>(std::istream& stream, CompiledBlobHeader& header);
friend std::ostream& operator<<(std::ostream& stream, const CompiledBlobHeader& header);
+
+ void read_from_buffer(const char* buffer, size_t buffer_size, size_t& pos);
};
} // namespace ov
diff --git a/src/inference/dev_api/openvino/runtime/iplugin.hpp b/src/inference/dev_api/openvino/runtime/iplugin.hpp
index a513af9ffa4..63eabfda94e 100644
--- a/src/inference/dev_api/openvino/runtime/iplugin.hpp
+++ b/src/inference/dev_api/openvino/runtime/iplugin.hpp
@@ -165,7 +165,7 @@ public:
/**
* @brief Creates an compiled model from an previously exported model using plugin implementation
* and removes OpenVINO Runtime magic and plugin name
- * @param model Reference to model output stream
+ * @param model Reference to model input stream
* @param properties A ov::AnyMap of properties
* @return An Compiled model
*/
@@ -175,7 +175,7 @@ public:
/**
* @brief Creates an compiled model from an previously exported model using plugin implementation
* and removes OpenVINO Runtime magic and plugin name
- * @param model Reference to model output stream
+ * @param model Reference to model input stream
* @param context A pointer to plugin context derived from RemoteContext class used to
* execute the network
* @param properties A ov::AnyMap of properties
@@ -185,6 +185,28 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const = 0;
+ /**
+ * @brief Creates an compiled model from an previously exported model using plugin implementation
+ * and removes OpenVINO Runtime magic and plugin name
+ * @param model Reference to ov::Tensor with exported model
+ * @param properties A ov::AnyMap of properties
+ * @return An Compiled model
+ */
+ virtual std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const;
+
+ /**
+ * @brief Creates an compiled model from an previously exported model using plugin implementation
+ * and removes OpenVINO Runtime magic and plugin name
+ * @param model Reference to ov::Tensor with exported model
+ * @param context A pointer to plugin context derived from RemoteContext class used to
+ * execute the network
+ * @param properties A ov::AnyMap of properties
+ * @return An Compiled model
+ */
+ virtual std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const;
+
/**
* @brief Queries a plugin about supported layers in model
* @param model Model object to query.
diff --git a/src/inference/src/cache_manager.hpp b/src/inference/src/cache_manager.hpp
index 4b9d876496f..7f01a956b39 100644
--- a/src/inference/src/cache_manager.hpp
+++ b/src/inference/src/cache_manager.hpp
@@ -70,7 +70,7 @@ public:
/**
* @brief Function passing created input stream
*/
- using StreamReader = std::function<void(std::istream&, ov::Tensor&)>;
+ using StreamReader = std::function<void(ov::Tensor&)>;
/**
* @brief Callback when OpenVINO intends to read model from cache
@@ -139,9 +139,7 @@ private:
if (std::filesystem::exists(blob_file_name)) {
auto compiled_blob =
read_tensor_data(blob_file_name, element::u8, PartialShape::dynamic(1), 0, enable_mmap);
- SharedStreamBuffer buf{reinterpret_cast<char*>(compiled_blob.data()), compiled_blob.get_byte_size()};
- std::istream stream(&buf);
- reader(stream, compiled_blob);
+ reader(compiled_blob);
}
}
diff --git a/src/inference/src/dev/compilation_context.cpp b/src/inference/src/dev/compilation_context.cpp
index 930612be8c6..3f3d54eb022 100644
--- a/src/inference/src/dev/compilation_context.cpp
+++ b/src/inference/src/dev/compilation_context.cpp
@@ -197,4 +197,36 @@ std::ostream& operator<<(std::ostream& stream, const CompiledBlobHeader& header)
return stream;
}
+namespace {
+inline std::string getline_from_buffer(const char* buffer, size_t size, size_t& pos, char delim = '\n') {
+ if (pos >= size) {
+ return {};
+ }
+
+ const char* start = buffer + pos;
+ const char* end = buffer + size;
+ const char* newline = std::find(start, end, delim);
+
+ size_t line_length = (newline == end) ? (end - start) : (newline - start);
+ std::string line(start, line_length);
+
+ // Update position (skip the delimiter if found)
+ pos += line_length + (newline != end ? 1 : 0);
+
+ return line;
+}
+} // namespace
+
+void CompiledBlobHeader::read_from_buffer(const char* buffer, size_t buffer_size, size_t& pos) {
+ std::string xmlStr = ov::getline_from_buffer(buffer, buffer_size, pos);
+
+ pugi::xml_document document;
+ pugi::xml_parse_result res = document.load_string(xmlStr.c_str());
+ OPENVINO_ASSERT(res.status == pugi::status_ok, "Error reading compiled blob header");
+
+ pugi::xml_node compiledBlobNode = document.document_element();
+ m_ieVersion = ov::util::pugixml::get_str_attr(compiledBlobNode, "ie_version");
+ m_fileInfo = ov::util::pugixml::get_str_attr(compiledBlobNode, "file_info");
+ m_runtimeInfo = ov::util::pugixml::get_str_attr(compiledBlobNode, "runtime_info");
+}
} // namespace ov
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp
index 25a9bc88c60..37e092f4cc5 100644
--- a/src/inference/src/dev/core_impl.cpp
+++ b/src/inference/src/dev/core_impl.cpp
@@ -232,10 +232,11 @@ ov::SoPtr<ov::ICompiledModel> import_compiled_model(const ov::Plugin& plugin,
if (auto blob_hint = config.find(ov::hint::compiled_blob.name()); blob_hint != config.end()) {
try {
auto compiled_blob = blob_hint->second.as<ov::Tensor>();
- ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(compiled_blob.data()), compiled_blob.get_byte_size()};
- std::istream stream{&buffer};
- compiled_model =
- context ? plugin.import_model(stream, context, config) : plugin.import_model(stream, config);
+ auto _config = config;
+ _config.erase(ov::hint::compiled_blob.name());
+
+ compiled_model = context ? plugin.import_model(compiled_blob, context, _config)
+ : plugin.import_model(compiled_blob, _config);
} catch (...) {
}
}
@@ -1516,13 +1517,16 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(
cacheContent.blobId,
cacheContent.mmap_enabled && ov::util::contains(plugin.get_property(ov::internal::supported_properties),
ov::internal::caching_with_mmap),
- [&](std::istream& networkStream, ov::Tensor& compiled_blob) {
+ [&](ov::Tensor& compiled_blob) {
OV_ITT_SCOPE(FIRST_INFERENCE,
ov::itt::domains::LoadTime,
"Core::load_model_from_cache::ReadStreamAndImport");
ov::CompiledBlobHeader header;
+ size_t compiled_blob_offset = 0;
try {
- networkStream >> header;
+ header.read_from_buffer(static_cast<const char*>(compiled_blob.data()),
+ compiled_blob.get_byte_size(),
+ compiled_blob_offset);
if (header.get_file_info() != ov::ModelCache::calculate_file_info(cacheContent.modelPath)) {
// Original file is changed, don't use cache
OPENVINO_THROW("Original model file is changed");
@@ -1576,11 +1580,12 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(
}
}
- if (compiled_blob) {
- update_config[ov::hint::compiled_blob.name()] = compiled_blob;
- }
- compiled_model = context ? plugin.import_model(networkStream, context, update_config)
- : plugin.import_model(networkStream, update_config);
+ ov::Tensor compiled_blob_without_header{compiled_blob,
+ {compiled_blob_offset},
+ {compiled_blob.get_size()}};
+
+ compiled_model = context ? plugin.import_model(compiled_blob_without_header, context, update_config)
+ : plugin.import_model(compiled_blob_without_header, update_config);
});
} catch (const HeaderException&) {
// For these exceptions just remove old cache and set that import didn't work
diff --git a/src/inference/src/dev/iplugin.cpp b/src/inference/src/dev/iplugin.cpp
index d7dc6ae617e..46512660f56 100644
--- a/src/inference/src/dev/iplugin.cpp
+++ b/src/inference/src/dev/iplugin.cpp
@@ -82,6 +82,22 @@ std::shared_ptr<ov::ICompiledModel> ov::IPlugin::compile_model(const std::string
return compile_model(model, local_properties);
}
+// Implementation for backward compatibility for Nvidia plugin
+// TODO: Update Nvidia plugin in contrib repo and make ov::IPlugin::import_model abstract again
+std::shared_ptr<ov::ICompiledModel> ov::IPlugin::import_model(ov::Tensor& model, const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, properties);
+};
+
+std::shared_ptr<ov::ICompiledModel> ov::IPlugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, context, properties);
+};
+
std::unordered_set<std::string> ov::get_supported_nodes(
const std::shared_ptr<const ov::Model>& model,
std::function<void(std::shared_ptr<ov::Model>&)> transform,
diff --git a/src/inference/src/dev/plugin.cpp b/src/inference/src/dev/plugin.cpp
index d213a1674a6..951829cbefe 100644
--- a/src/inference/src/dev/plugin.cpp
+++ b/src/inference/src/dev/plugin.cpp
@@ -79,6 +79,16 @@ ov::SoPtr<ov::ICompiledModel> ov::Plugin::import_model(std::istream& model,
OV_PLUGIN_CALL_STATEMENT(return {m_ptr->import_model(model, context, config), m_so});
}
+ov::SoPtr<ov::ICompiledModel> ov::Plugin::import_model(ov::Tensor& model, const ov::AnyMap& properties) const {
+ OV_PLUGIN_CALL_STATEMENT(return {m_ptr->import_model(model, properties), m_so});
+}
+
+ov::SoPtr<ov::ICompiledModel> ov::Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& config) const {
+ OV_PLUGIN_CALL_STATEMENT(return {m_ptr->import_model(model, context, config), m_so});
+}
+
ov::SoPtr<ov::IRemoteContext> ov::Plugin::create_context(const AnyMap& params) const {
OV_PLUGIN_CALL_STATEMENT({
auto remote = m_ptr->create_context(params);
diff --git a/src/inference/src/dev/plugin.hpp b/src/inference/src/dev/plugin.hpp
index 419c5c7d2df..8e0c8dc72a8 100644
--- a/src/inference/src/dev/plugin.hpp
+++ b/src/inference/src/dev/plugin.hpp
@@ -53,6 +53,12 @@ public:
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model, const ov::AnyMap& properties) const;
+ SoPtr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const;
+
+ SoPtr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& config) const;
+
SoPtr<ov::ICompiledModel> import_model(std::istream& model, const ov::AnyMap& properties) const;
SoPtr<ov::ICompiledModel> import_model(std::istream& model,
diff --git a/src/inference/tests/functional/caching_test.cpp b/src/inference/tests/functional/caching_test.cpp
index 961f1649d0a..9d5ca7c2527 100644
--- a/src/inference/tests/functional/caching_test.cpp
+++ b/src/inference/tests/functional/caching_test.cpp
@@ -134,6 +134,32 @@ public:
}
};
+namespace {
+inline std::string getline_from_buffer(const char* buffer, size_t size, size_t& pos, char delim = ' ') {
+ if (pos >= size) {
+ return {};
+ }
+
+ // Skip leading delimiters
+ while (pos < size && buffer[pos] == delim)
+ ++pos;
+ if (pos >= size)
+ return {};
+
+ const char* start = buffer + pos;
+ const char* end = buffer + size;
+ const char* newline = std::find(start, end, delim);
+
+ size_t line_length = (newline == end) ? (end - start) : (newline - start);
+ std::string line(start, line_length);
+
+ // Update position (skip the delimiter if found)
+ pos += line_length + (newline != end ? 1 : 0);
+
+ return line;
+}
+} // namespace
+
class CachingTest : public ::testing::TestWithParam<std::tuple<TestParam, std::string>> {
public:
std::shared_ptr<void> sharedObjectLoader;
@@ -332,7 +358,7 @@ private:
return decltype(ov::internal::caching_properties)::value_type(cachingProperties);
}));
- ON_CALL(plugin, import_model(_, _, _))
+ ON_CALL(plugin, import_model(A<std::istream&>(), _, _))
.WillByDefault(
Invoke([&](std::istream& istr, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap& config) {
if (m_checkConfigCb) {
@@ -346,17 +372,41 @@ private:
return create_mock_compiled_model(m_models[name], mockPlugin);
}));
- ON_CALL(plugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
+ ON_CALL(plugin, import_model(A<std::istream&>(), _))
+ .WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ std::string name;
+ istr >> name;
+ char space;
+ istr.read(&space, 1);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
+
+ ON_CALL(plugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
+
+ ON_CALL(plugin, import_model(A<ov::Tensor&>(), _, _))
+ .WillByDefault(
+ Invoke([&](ov::Tensor& itensor, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
ON_CALL(plugin, compile_model(_, _, _))
.WillByDefault(Invoke([&](const std::shared_ptr<const ov::Model>& model,
@@ -423,8 +473,10 @@ TEST_P(CachingTest, TestLoad) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -438,8 +490,10 @@ TEST_P(CachingTest, TestLoad) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& model : comp_models) {
EXPECT_CALL(*model, export_model(_)).Times(0); // No more 'export_model' for existing model
}
@@ -464,8 +518,10 @@ TEST_P(CachingTest, TestLoad_by_device_name) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -479,8 +535,10 @@ TEST_P(CachingTest, TestLoad_by_device_name) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& model : comp_models) {
EXPECT_CALL(*model, export_model(_)).Times(0); // No more 'export_model' for existing models
}
@@ -494,6 +552,8 @@ TEST_P(CachingTest, TestLoad_by_device_name) {
TEST_P(CachingTest, TestLoadCustomImportExport) {
const char customData[] = {1, 2, 3, 4, 5};
+ size_t customDataSize = sizeof(customData);
+
EXPECT_CALL(*mockPlugin, get_property(ov::supported_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::capability::EXPORT_IMPORT, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
@@ -501,23 +561,24 @@ TEST_P(CachingTest, TestLoadCustomImportExport) {
EXPECT_CALL(*mockPlugin, get_property(ov::internal::caching_properties.name(), _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::capabilities.name(), _)).Times(AnyNumber());
- ON_CALL(*mockPlugin, import_model(_, _, _))
- .WillByDefault(Invoke([&](std::istream& s, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&) {
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _))
+ .WillByDefault(Invoke([&](ov::Tensor& s, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&) {
char a[sizeof(customData)];
- s.read(a, sizeof(customData));
- EXPECT_EQ(memcmp(a, customData, sizeof(customData)), 0);
- std::string name;
- s >> name;
+ OPENVINO_ASSERT(customDataSize <= s.get_byte_size());
+ std::memcpy(a, s.data(), customDataSize);
+ EXPECT_EQ(memcmp(a, customData, customDataSize), 0);
+ auto name = getline_from_buffer(s.data<const char>(), s.get_byte_size(), customDataSize);
+
std::lock_guard<std::mutex> lock(mock_creation_mutex);
return create_mock_compiled_model(m_models[name], mockPlugin);
}));
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& s, const ov::AnyMap&) {
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).WillByDefault(Invoke([&](ov::Tensor& s, const ov::AnyMap&) {
char a[sizeof(customData)];
- s.read(a, sizeof(customData));
- EXPECT_EQ(memcmp(a, customData, sizeof(customData)), 0);
- std::string name;
- s >> name;
+ OPENVINO_ASSERT(customDataSize <= s.get_byte_size());
+ std::memcpy(a, s.data(), customDataSize);
+ EXPECT_EQ(memcmp(a, customData, customDataSize), 0);
+ auto name = getline_from_buffer(s.data<const char>(), s.get_byte_size(), customDataSize);
std::lock_guard<std::mutex> lock(mock_creation_mutex);
return create_mock_compiled_model(m_models[name], mockPlugin);
}));
@@ -533,8 +594,10 @@ TEST_P(CachingTest, TestLoadCustomImportExport) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -547,8 +610,10 @@ TEST_P(CachingTest, TestLoadCustomImportExport) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& model : comp_models) {
EXPECT_CALL(*model, export_model(_)).Times(0); // No 'export_model' for existing models
}
@@ -589,8 +654,8 @@ TEST_P(CachingTest, TestChangeLoadConfig) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -604,8 +669,8 @@ TEST_P(CachingTest, TestChangeLoadConfig) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -629,8 +694,10 @@ TEST_P(CachingTest, TestChangeLoadConfig_With_Cache_Dir_inline) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -642,8 +709,10 @@ TEST_P(CachingTest, TestChangeLoadConfig_With_Cache_Dir_inline) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& model : comp_models) {
EXPECT_CALL(*model, export_model(_)).Times(0); // No more 'export_model' for existing models
}
@@ -666,8 +735,8 @@ TEST_P(CachingTest, TestNoCacheEnabled) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
@@ -694,8 +763,8 @@ TEST_P(CachingTest, TestNoCacheSupported) {
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
@@ -723,8 +792,8 @@ TEST_P(CachingTest, TestNoCacheMetricSupported) {
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
@@ -753,8 +822,8 @@ TEST_P(CachingTest, TestNoCacheMetricSupported_by_device_name) {
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
@@ -899,8 +968,8 @@ TEST_P(CachingTest, TestNoCacheEnabled_cacheDirConfig) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
m_testFunction(core);
});
@@ -918,8 +987,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDir) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -935,8 +1004,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDir) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -962,8 +1031,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
@@ -998,8 +1067,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_overwrite_device_dir) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
@@ -1044,8 +1113,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_SupportsCacheDir_NoImportExpor
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 2 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
@@ -1078,8 +1147,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_by_device_name) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 2 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
@@ -1121,8 +1190,8 @@ TEST_P(CachingTest, TestLoadChangeCacheDirOneCore_by_device_name_supports_cache_
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 2 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
@@ -1152,8 +1221,10 @@ TEST_P(CachingTest, TestClearCacheDir) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
for (auto& model : comp_models) {
EXPECT_CALL(*model, export_model(_)).Times(0);
}
@@ -1177,8 +1248,8 @@ TEST_P(CachingTest, TestChangeOtherConfig) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1203,8 +1274,10 @@ TEST_P(CachingTest, TestChangeCacheDirFailure) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1218,8 +1291,10 @@ TEST_P(CachingTest, TestChangeCacheDirFailure) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1246,8 +1321,8 @@ TEST_P(CachingTest, TestCacheDirCreateRecursive) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1281,8 +1356,10 @@ TEST_P(CachingTest, TestDeviceArchitecture) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1296,8 +1373,10 @@ TEST_P(CachingTest, TestDeviceArchitecture) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1311,8 +1390,10 @@ TEST_P(CachingTest, TestDeviceArchitecture) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1326,8 +1407,10 @@ TEST_P(CachingTest, TestDeviceArchitecture) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1364,8 +1447,10 @@ TEST_P(CachingTest, TestNoDeviceArchitecture) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1379,8 +1464,10 @@ TEST_P(CachingTest, TestNoDeviceArchitecture) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1414,8 +1501,8 @@ TEST_P(CachingTest, TestNoCachingProperties) {
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
});
@@ -1438,8 +1525,8 @@ TEST_P(CachingTest, TestThrowOnExport) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1).WillOnce(Throw(1));
});
@@ -1463,8 +1550,10 @@ TEST_P(CachingTest, TestThrowOnImport) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1478,12 +1567,14 @@ TEST_P(CachingTest, TestThrowOnImport) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
if (m_remoteContext) {
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(1).WillOnce(Throw(1));
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(1).WillOnce(Throw(1));
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
} else {
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1).WillOnce(Throw(1));
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1).WillOnce(Throw(1));
}
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
@@ -1496,8 +1587,10 @@ TEST_P(CachingTest, TestThrowOnImport) {
{ // Step 3: same load, cache is re-created on export on step 2 and shall be successfully imported now
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1519,8 +1612,10 @@ TEST_P(CachingTest, TestModelModified) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1544,8 +1639,10 @@ TEST_P(CachingTest, TestModelModified) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1558,8 +1655,10 @@ TEST_P(CachingTest, TestModelModified) {
{ // Step 3: same load, should be ok now
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1582,8 +1681,10 @@ TEST_P(CachingTest, TestCacheFileCorrupted) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1604,8 +1705,10 @@ TEST_P(CachingTest, TestCacheFileCorrupted) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1617,8 +1720,10 @@ TEST_P(CachingTest, TestCacheFileCorrupted) {
{ // Step 3: same load, should be ok now due to re-creation of cache
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1641,8 +1746,10 @@ TEST_P(CachingTest, TestCacheFileOldVersion) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1678,8 +1785,10 @@ TEST_P(CachingTest, TestCacheFileOldVersion) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1692,8 +1801,10 @@ TEST_P(CachingTest, TestCacheFileOldVersion) {
{ // Step 3: same load, should be ok now due to re-creation of cache
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1735,8 +1846,10 @@ TEST_P(CachingTest, TestCacheFileWithCompiledModelRuntimeProperties) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1771,8 +1884,10 @@ TEST_P(CachingTest, TestCacheFileWithCompiledModelRuntimeProperties) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1785,8 +1900,10 @@ TEST_P(CachingTest, TestCacheFileWithCompiledModelRuntimeProperties) {
{ // Step 3: same load, should be ok now due to re-creation of cache
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(m_remoteContext ? 1 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(!m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(m_remoteContext ? 1 : 0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(!m_remoteContext ? 1 : 0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1813,8 +1930,8 @@ TEST_P(CachingTest, LoadHetero_NoCacheMetric) {
for (int i = 0; i < 2; i++) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
EXPECT_CALL(net, get_runtime_model()).Times(0);
@@ -1838,8 +1955,8 @@ TEST_P(CachingTest, LoadHetero_OneDevice) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1854,8 +1971,8 @@ TEST_P(CachingTest, LoadHetero_OneDevice) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(1);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1877,8 +1994,8 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -1894,8 +2011,8 @@ TEST_P(CachingTest, LoadHetero_TargetFallbackFromCore) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(1);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1948,8 +2065,8 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(AtLeast(2)); // for .1 and for .51
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(AtLeast(1));
});
@@ -1965,8 +2082,8 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(AtLeast(2)); // for .2 and for .52
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(AtLeast(2)); // for .2 and for .52
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -1980,8 +2097,8 @@ TEST_P(CachingTest, LoadHetero_MultiArchs) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(AtLeast(1));
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(AtLeast(1));
});
@@ -2014,8 +2131,8 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -2029,8 +2146,8 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(1);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -2043,8 +2160,8 @@ TEST_P(CachingTest, LoadHetero_MultiArchs_TargetFallback_FromCore) {
{
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(1);
});
@@ -2080,7 +2197,7 @@ TEST_P(CachingTest, LoadAUTO_OneDevice) {
deviceToLoad += ":mock.0";
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(TEST_COUNT - index - 1);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(index);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(index);
OV_ASSERT_NO_THROW(testLoad([&](ov::Core& core) {
core.set_property(ov::cache_dir(cacheDir));
m_testFunction(core);
@@ -2111,7 +2228,7 @@ TEST_P(CachingTest, LoadAUTOWithConfig) {
deviceToLoad += ":mock.0";
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(TEST_COUNT - index - 1);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(index);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(index);
OV_ASSERT_NO_THROW(testLoad([&](ov::Core& core) {
m_testFunctionWithCfg(core, {{ov::cache_dir.name(), cacheDir}});
}));
@@ -2138,8 +2255,8 @@ TEST_P(CachingTest, LoadAUTO_OneDeviceNoImportExport) {
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(!m_remoteContext ? 2 : 0);
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(m_type == TestLoadType::EModelName ? 2 : 0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
testLoad([&](ov::Core& core) {
m_post_mock_net_callbacks.emplace_back([&](MockICompiledModelImpl& net) {
EXPECT_CALL(net, export_model(_)).Times(0);
@@ -2186,8 +2303,10 @@ TEST_P(CachingTest, LoadMulti_race) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(devCount - 1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(devCount - 1);
testLoad([&](ov::Core& core) {
core.set_property(ov::cache_dir(cacheDir));
OV_ASSERT_NO_THROW(m_testFunction(core));
@@ -2228,8 +2347,10 @@ TEST_P(CachingTest, LoadMultiWithConfig_race) {
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(devCount - 1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(devCount - 1);
testLoad([&](ov::Core& core) {
OV_ASSERT_NO_THROW(m_testFunctionWithCfg(core, {{ov::cache_dir.name(), cacheDir}}));
});
@@ -2271,12 +2392,14 @@ TEST_P(CachingTest, LoadMulti_Archs) {
// Load model from file shall not be called for plugins with caching supported
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile()).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _))
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
.Times(TEST_DEVICE_MAX_COUNT / 2)
- .WillRepeatedly(Invoke([&](std::istream& s, const ov::AnyMap&) {
- std::string name;
- s >> name;
+ .WillRepeatedly(Invoke([&](ov::Tensor& s, const ov::AnyMap&) {
+ size_t pos = 0;
+ auto name = getline_from_buffer(s.data<const char>(), s.get_byte_size(), pos);
std::lock_guard<std::mutex> lock(mock_creation_mutex);
return create_mock_compiled_model(m_models[name], mockPlugin);
}));
@@ -2331,8 +2454,8 @@ TEST_P(CachingTest, LoadMulti_NoCachingOnDevice) {
// Load model from file shall not be called by Multi plugin for devices with caching supported
EXPECT_CALL(*mockPlugin, OnCompileModelFromFile())
.Times(m_type == TestLoadType::EModel ? 0 : TEST_DEVICE_MAX_COUNT);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
for (auto& net : comp_models) {
EXPECT_CALL(*net, export_model(_)).Times(0);
}
@@ -2376,7 +2499,7 @@ TEST_P(CachingTest, LoadBATCHWithConfig) {
deviceToLoad += ":mock.0";
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _))
.Times(TEST_COUNT - index - 1);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(index);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(index);
testLoad([&](ov::Core& core) {
m_testFunctionWithCfg(core, {{ov::cache_dir.name(), cacheDir}});
});
@@ -2406,8 +2529,10 @@ TEST_P(CachingTest, Load_threads) {
MkDirGuard guard(cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(THREADS_COUNT - 1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(THREADS_COUNT - 1);
testLoad([&](ov::Core& core) {
core.set_property({{ov::cache_dir.name(), cacheDir}});
std::vector<std::thread> threads;
@@ -2426,23 +2551,16 @@ TEST_P(CachingTest, Load_threads) {
}
TEST_P(CachingTest, Load_mmap) {
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
- ov::Tensor compiled_blob;
- if (config.count(ov::hint::compiled_blob.name()))
- compiled_blob = config.at(ov::hint::compiled_blob.name()).as<ov::Tensor>();
-
- EXPECT_TRUE(static_cast<bool>(compiled_blob));
-
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
ON_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _))
.WillByDefault(Invoke([&](const std::string&, const ov::AnyMap&) {
@@ -2463,8 +2581,10 @@ TEST_P(CachingTest, Load_mmap) {
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
core.set_property({{ov::cache_dir.name(), m_cacheDir}});
m_testFunction(core);
@@ -2474,20 +2594,17 @@ TEST_P(CachingTest, Load_mmap) {
}
TEST_P(CachingTest, Load_mmap_is_disabled) {
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
-
- EXPECT_GT(config.count(ov::hint::compiled_blob.name()), 0);
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
ON_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _))
.WillByDefault(Invoke([&](const std::string&, const ov::AnyMap&) {
return std::vector<ov::PropertyName>{ov::internal::caching_properties.name(),
@@ -2507,8 +2624,10 @@ TEST_P(CachingTest, Load_mmap_is_disabled) {
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
core.set_property({{ov::cache_dir.name(), m_cacheDir}});
core.set_property({ov::enable_mmap(false)});
@@ -2519,20 +2638,17 @@ TEST_P(CachingTest, Load_mmap_is_disabled) {
}
TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin) {
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
-
- EXPECT_GT(config.count(ov::hint::compiled_blob.name()), 0);
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
EXPECT_CALL(*mockPlugin, get_property(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
@@ -2547,8 +2663,10 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin) {
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
core.set_property({{ov::cache_dir.name(), m_cacheDir}});
core.set_property({ov::enable_mmap(true)});
@@ -2559,20 +2677,17 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin) {
}
TEST_P(CachingTest, Load_mmap_is_disabled_local_cfg) {
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
-
- EXPECT_GT(config.count(ov::hint::compiled_blob.name()), 0);
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
ON_CALL(*mockPlugin, get_property(ov::internal::supported_properties.name(), _))
.WillByDefault(Invoke([&](const std::string&, const ov::AnyMap&) {
return std::vector<ov::PropertyName>{ov::internal::caching_properties.name(),
@@ -2592,8 +2707,10 @@ TEST_P(CachingTest, Load_mmap_is_disabled_local_cfg) {
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}, {ov::enable_mmap(false)}};
m_testFunctionWithCfg(core, config);
@@ -2603,19 +2720,17 @@ TEST_P(CachingTest, Load_mmap_is_disabled_local_cfg) {
}
TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin_local_cfg) {
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
- EXPECT_GT(config.count(ov::hint::compiled_blob.name()), 0);
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
EXPECT_CALL(*mockPlugin, get_property(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
@@ -2630,8 +2745,10 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin_local_cfg) {
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}, {ov::enable_mmap(false)}};
m_testFunctionWithCfg(core, config);
@@ -2641,21 +2758,20 @@ TEST_P(CachingTest, Load_mmap_is_not_supported_by_plugin_local_cfg) {
}
TEST_P(CachingTest, import_from_cache_model_and_weights_path_properties_not_supported) {
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
- EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 1);
- EXPECT_EQ(config.count(ov::hint::model.name()), 0);
- EXPECT_EQ(config.count(ov::weights_path.name()), 0);
-
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 0);
+ EXPECT_EQ(config.count(ov::hint::model.name()), 0);
+ EXPECT_EQ(config.count(ov::weights_path.name()), 0);
+
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
EXPECT_CALL(*mockPlugin, get_property(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
@@ -2669,8 +2785,10 @@ TEST_P(CachingTest, import_from_cache_model_and_weights_path_properties_not_supp
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}};
m_testFunctionWithCfg(core, config);
@@ -2690,21 +2808,20 @@ TEST_P(CachingTest, import_from_cache_model_and_weights_path_properties_are_supp
ov::weights_path.name(),
};
}));
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
- EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 1);
- EXPECT_EQ(config.count(ov::hint::model.name()), m_type != TestLoadType::EModelName ? 1 : 0);
- EXPECT_EQ(config.count(ov::weights_path.name()), m_type == TestLoadType::EModelName ? 1 : 0);
-
- std::string name;
- istr >> name;
- char space;
- istr.read(&space, 1);
- std::lock_guard<std::mutex> lock(mock_creation_mutex);
- return create_mock_compiled_model(m_models[name], mockPlugin);
- }));
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 0);
+ EXPECT_EQ(config.count(ov::hint::model.name()), m_type != TestLoadType::EModelName ? 1 : 0);
+ EXPECT_EQ(config.count(ov::weights_path.name()), m_type == TestLoadType::EModelName ? 1 : 0);
+
+ size_t pos = 0;
+ auto name = getline_from_buffer(itensor.data<const char>(), itensor.get_byte_size(), pos);
+ std::lock_guard<std::mutex> lock(mock_creation_mutex);
+ return create_mock_compiled_model(m_models[name], mockPlugin);
+ }));
EXPECT_CALL(*mockPlugin, get_property(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
@@ -2718,8 +2835,10 @@ TEST_P(CachingTest, import_from_cache_model_and_weights_path_properties_are_supp
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
testLoad([&](ov::Core& core) {
const auto config = ov::AnyMap{{ov::cache_dir(m_cacheDir)}};
m_testFunctionWithCfg(core, config);
@@ -2737,15 +2856,16 @@ TEST_P(CachingTest, import_from_compiled_blob_weights_path_property_is_supported
ov::weights_path.name(),
ov::hint::model.name()};
}));
- ON_CALL(*mockPlugin, import_model(_, _)).WillByDefault(Invoke([&](std::istream& istr, const ov::AnyMap& config) {
- if (m_checkConfigCb) {
- m_checkConfigCb(config);
- }
- EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 1);
- EXPECT_EQ(config.count(ov::hint::model.name()), m_type != TestLoadType::EModelName ? 1 : 0);
- EXPECT_EQ(config.count(ov::weights_path.name()), m_type == TestLoadType::EModelName ? 1 : 0);
- return nullptr;
- }));
+ ON_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _))
+ .WillByDefault(Invoke([&](ov::Tensor& itensor, const ov::AnyMap& config) {
+ if (m_checkConfigCb) {
+ m_checkConfigCb(config);
+ }
+ EXPECT_EQ(config.count(ov::hint::compiled_blob.name()), 0);
+ EXPECT_EQ(config.count(ov::hint::model.name()), m_type != TestLoadType::EModelName ? 1 : 0);
+ EXPECT_EQ(config.count(ov::weights_path.name()), m_type == TestLoadType::EModelName ? 1 : 0);
+ return nullptr;
+ }));
EXPECT_CALL(*mockPlugin, get_property(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, query_model(_, _)).Times(AnyNumber());
EXPECT_CALL(*mockPlugin, get_property(ov::device::architecture.name(), _)).Times(AnyNumber());
@@ -2756,8 +2876,10 @@ TEST_P(CachingTest, import_from_compiled_blob_weights_path_property_is_supported
m_modelCallback = nullptr;
MkDirGuard guard(m_cacheDir);
EXPECT_CALL(*mockPlugin, compile_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _, _)).Times(0);
- EXPECT_CALL(*mockPlugin, import_model(_, _)).Times(1);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<std::istream&>(), _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _, _)).Times(0);
+ EXPECT_CALL(*mockPlugin, import_model(A<ov::Tensor&>(), _)).Times(1);
EXPECT_CALL(*mockPlugin, compile_model(A<const std::shared_ptr<const ov::Model>&>(), _)).Times(1);
if (m_type == TestLoadType::EModelName) {
diff --git a/src/plugins/auto/src/plugin.cpp b/src/plugins/auto/src/plugin.cpp
index bdd1397e417..f2a0a4adabf 100644
--- a/src/plugins/auto/src/plugin.cpp
+++ b/src/plugins/auto/src/plugin.cpp
@@ -99,6 +99,17 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
OPENVINO_NOT_IMPLEMENTED;
}
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::AnyMap& properties) const {
+ OPENVINO_NOT_IMPLEMENTED;
+}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ OPENVINO_NOT_IMPLEMENTED;
+}
+
bool Plugin::is_meta_device(const std::string& priorities) const {
std::vector<std::string> candidate_devices = m_plugin_config.parse_priorities_devices(priorities);
for (const auto& device : candidate_devices) {
diff --git a/src/plugins/auto/src/plugin.hpp b/src/plugins/auto/src/plugin.hpp
index 9222522f35d..cbb7d67a271 100644
--- a/src/plugins/auto/src/plugin.hpp
+++ b/src/plugins/auto/src/plugin.hpp
@@ -70,6 +70,13 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::AnyMap& properties) const override;
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
+
private:
std::shared_ptr<ov::ICompiledModel> compile_model_impl(const std::string& model_path,
const std::shared_ptr<const ov::Model>& model,
diff --git a/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp b/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp
index 5648fe53cef..ef503620f30 100644
--- a/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp
+++ b/src/plugins/auto/tests/functional/behavior/auto_func_test.cpp
@@ -476,6 +476,16 @@ public:
return compile_model(ov_model, properties, context);
}
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
@@ -776,4 +786,4 @@ void ov::auto_plugin::tests::AutoFuncTests::register_plugin_mock_cpu_compile_slo
std::shared_ptr<ov::IPlugin> base_plugin = std::make_shared<MockCPUPluginCompileSlower>();
reg_plugin(core, base_plugin, device_name, properties);
-}
\ No newline at end of file
+}
diff --git a/src/plugins/auto_batch/src/plugin.cpp b/src/plugins/auto_batch/src/plugin.cpp
index dc4918dbefc..b27a31535a0 100644
--- a/src/plugins/auto_batch/src/plugin.cpp
+++ b/src/plugins/auto_batch/src/plugin.cpp
@@ -349,5 +349,15 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model, const ov::AnyMap& properties) const {
+ OPENVINO_NOT_IMPLEMENTED;
+}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ OPENVINO_NOT_IMPLEMENTED;
+}
} // namespace autobatch_plugin
} // namespace ov
diff --git a/src/plugins/auto_batch/src/plugin.hpp b/src/plugins/auto_batch/src/plugin.hpp
index cb78009849b..0a6631a8300 100644
--- a/src/plugins/auto_batch/src/plugin.hpp
+++ b/src/plugins/auto_batch/src/plugin.hpp
@@ -53,6 +53,12 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
+
#ifdef AUTOBATCH_UNITTEST
public:
diff --git a/src/plugins/auto_batch/tests/unit/mock_common.hpp b/src/plugins/auto_batch/tests/unit/mock_common.hpp
index 226bf7e5043..236b6a918af 100644
--- a/src/plugins/auto_batch/tests/unit/mock_common.hpp
+++ b/src/plugins/auto_batch/tests/unit/mock_common.hpp
@@ -44,6 +44,14 @@ public:
import_model,
(std::istream&, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&),
(const, override));
+ MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,
+ import_model,
+ (ov::Tensor&, const ov::AnyMap&),
+ (const, override));
+ MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,
+ import_model,
+ (ov::Tensor&, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&),
+ (const, override));
MOCK_METHOD(ov::SupportedOpsMap,
query_model,
(const std::shared_ptr<const ov::Model>&, const ov::AnyMap&),
@@ -139,4 +147,4 @@ public:
m_pipeline = {};
}
MOCK_METHOD(void, start_async, (), (override));
-};
\ No newline at end of file
+};
diff --git a/src/plugins/hetero/src/plugin.cpp b/src/plugins/hetero/src/plugin.cpp
index b394b7ee615..e39fb9a7852 100644
--- a/src/plugins/hetero/src/plugin.cpp
+++ b/src/plugins/hetero/src/plugin.cpp
@@ -22,6 +22,7 @@
#include "openvino/runtime/intel_gpu/properties.hpp"
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/properties.hpp"
+#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/common_util.hpp"
#include "properties.hpp"
#include "remote_context.hpp"
@@ -135,7 +136,6 @@ std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istrea
const ov::AnyMap& properties) const {
OPENVINO_NOT_IMPLEMENTED;
}
-
std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istream& model,
const ov::AnyMap& properties) const {
OV_ITT_SCOPED_TASK(itt::domains::Hetero, "Plugin::import_model");
@@ -154,6 +154,19 @@ std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(std::istrea
return compiled_model;
}
+std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(ov::Tensor& model,
+ const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, properties);
+}
+
+std::shared_ptr<ov::ICompiledModel> ov::hetero::Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ OPENVINO_NOT_IMPLEMENTED;
+}
+
ov::hetero::Plugin::DeviceProperties ov::hetero::Plugin::get_properties_per_device(const std::string& device_priorities,
const ov::AnyMap& properties) const {
auto device_names = ov::DeviceIDParser::get_hetero_devices(device_priorities);
diff --git a/src/plugins/hetero/src/plugin.hpp b/src/plugins/hetero/src/plugin.hpp
index e0e5945421e..cee0eb24998 100644
--- a/src/plugins/hetero/src/plugin.hpp
+++ b/src/plugins/hetero/src/plugin.hpp
@@ -51,6 +51,12 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;
diff --git a/src/plugins/hetero/tests/functional/hetero_tests.cpp b/src/plugins/hetero/tests/functional/hetero_tests.cpp
index c4306640509..be99c22353b 100644
--- a/src/plugins/hetero/tests/functional/hetero_tests.cpp
+++ b/src/plugins/hetero/tests/functional/hetero_tests.cpp
@@ -563,6 +563,16 @@ public:
return compile_model(ov_model, properties, context);
}
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override {
OPENVINO_ASSERT(model);
@@ -906,4 +916,4 @@ void ov::hetero::tests::HeteroTests::SetUp() {
reg_plugin_type<MockPluginSubtract>("MOCK1");
reg_plugin_type<MockPluginGPU>("MOCKGPU");
}
-}
\ No newline at end of file
+}
diff --git a/src/plugins/intel_cpu/src/plugin.cpp b/src/plugins/intel_cpu/src/plugin.cpp
index de234d1c855..e512340cc66 100644
--- a/src/plugins/intel_cpu/src/plugin.cpp
+++ b/src/plugins/intel_cpu/src/plugin.cpp
@@ -570,18 +570,34 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model_str
decript_from_string = true;
}
- auto _config = config;
- std::shared_ptr<ov::AlignedBuffer> model_buffer;
- if (auto blob_it = _config.find(ov::hint::compiled_blob.name()); blob_it != _config.end()) {
- auto compiled_blob = blob_it->second.as<ov::Tensor>();
- model_buffer = std::make_shared<ov::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(compiled_blob.data()),
- compiled_blob.get_byte_size(),
- compiled_blob);
- _config.erase(blob_it);
+ ModelDeserializer deserializer(
+ model_stream,
+ [this](const std::shared_ptr<ov::AlignedBuffer>& model, const std::shared_ptr<ov::AlignedBuffer>& weights) {
+ return get_core()->read_model(model, weights);
+ },
+ decrypt,
+ decript_from_string);
+
+ return deserialize_model(deserializer, config);
+}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model_tensor, const ov::AnyMap& config) const {
+ OV_ITT_SCOPE(FIRST_INFERENCE, itt::domains::intel_cpu_LT, "import_model");
+
+ CacheDecrypt decrypt{codec_xor};
+ bool decript_from_string = false;
+ if (auto it = config.find(ov::cache_encryption_callbacks.name()); it != config.end()) {
+ const auto& encryption_callbacks = it->second.as<EncryptionCallbacks>();
+ decrypt.m_decrypt_str = encryption_callbacks.decrypt;
+ decript_from_string = true;
}
+ std::shared_ptr<ov::AlignedBuffer> model_buffer =
+ std::make_shared<ov::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(model_tensor.data()),
+ model_tensor.get_byte_size(),
+ model_tensor);
+
ModelDeserializer deserializer(
- model_stream,
model_buffer,
[this](const std::shared_ptr<ov::AlignedBuffer>& model, const std::shared_ptr<ov::AlignedBuffer>& weights) {
return get_core()->read_model(model, weights);
@@ -589,9 +605,15 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model_str
decrypt,
decript_from_string);
+ return deserialize_model(deserializer, config);
+}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::deserialize_model(ModelDeserializer& deserializer,
+ const ov::AnyMap& config) const {
std::shared_ptr<ov::Model> model;
deserializer >> model;
+ auto _config = config;
Config conf = engConfig;
Config::ModelType modelType = getModelType(model);
conf.applyRtInfo(model);
diff --git a/src/plugins/intel_cpu/src/plugin.h b/src/plugins/intel_cpu/src/plugin.h
index e82f31d12fa..3ea237e9ec2 100644
--- a/src/plugins/intel_cpu/src/plugin.h
+++ b/src/plugins/intel_cpu/src/plugin.h
@@ -18,6 +18,7 @@
#include "openvino/runtime/iremote_context.hpp"
#include "openvino/runtime/so_ptr.hpp"
#include "openvino/runtime/threading/cpu_message.hpp"
+#include "utils/serialize.hpp"
namespace ov::intel_cpu {
@@ -37,6 +38,12 @@ public:
void set_property(const ov::AnyMap& properties) override;
ov::Any get_property(const std::string& name, const ov::AnyMap& arguments) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model([[maybe_unused]] ov::Tensor& model,
+ [[maybe_unused]] const ov::SoPtr<ov::IRemoteContext>& context,
+ [[maybe_unused]] const ov::AnyMap& properties) const override {
+ OPENVINO_THROW_NOT_IMPLEMENTED("import_model with RemoteContext is not supported by CPU plugin!");
+ };
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model, const ov::AnyMap& properties) const override;
std::shared_ptr<ov::ICompiledModel> import_model([[maybe_unused]] std::istream& model,
[[maybe_unused]] const ov::SoPtr<ov::IRemoteContext>& context,
@@ -57,6 +64,9 @@ public:
std::shared_ptr<ov::threading::MessageManager> m_msg_manager;
private:
+ std::shared_ptr<ov::ICompiledModel> deserialize_model(ModelDeserializer& deserializer,
+ const ov::AnyMap& config) const;
+
ov::Any get_ro_property(const std::string& name, const ov::AnyMap& options) const;
static void get_performance_streams(Config& config, const std::shared_ptr<ov::Model>& model);
diff --git a/src/plugins/intel_cpu/src/utils/serialize.cpp b/src/plugins/intel_cpu/src/utils/serialize.cpp
index c98b3471a4b..8f9c3a8146d 100644
--- a/src/plugins/intel_cpu/src/utils/serialize.cpp
+++ b/src/plugins/intel_cpu/src/utils/serialize.cpp
@@ -6,11 +6,13 @@
#include <cstddef>
#include <cstring>
+#include <functional>
#include <istream>
#include <memory>
#include <ostream>
#include <string>
#include <utility>
+#include <variant>
#include "openvino/core/except.hpp"
#include "openvino/core/model.hpp"
@@ -26,33 +28,48 @@ namespace ov::intel_cpu {
////////// ModelSerializer //////////
-ModelSerializer::ModelSerializer(std::ostream& ostream, CacheEncrypt encrypt_fn)
- : m_ostream(ostream),
- m_cache_encrypt(std::move(encrypt_fn)) {}
+ModelSerializer::ModelSerializer(std::ostream& ostream, const CacheEncrypt& encrypt_fn)
+ : ov::pass::StreamSerialize(
+ ostream,
+ [](std::ostream& stream) {
+ pugi::xml_document xml_doc;
+ pugi::xml_node root = xml_doc.append_child("cnndata");
+ root.append_child("outputs");
+ xml_doc.save(stream);
+ },
+ encrypt_fn) {};
void ModelSerializer::operator<<(const std::shared_ptr<ov::Model>& model) {
- auto serialize_info = [&](std::ostream& stream) {
- pugi::xml_document xml_doc;
- pugi::xml_node root = xml_doc.append_child("cnndata");
- root.append_child("outputs");
- xml_doc.save(stream);
- };
-
- ov::pass::StreamSerialize serializer(m_ostream, serialize_info, m_cache_encrypt);
- serializer.run_on_model(std::const_pointer_cast<ov::Model>(model->clone()));
+ run_on_model(std::const_pointer_cast<ov::Model>(model->clone()));
+}
+
+bool ModelSerializer::use_absolute_offset() {
+ return false;
}
////////// ModelDeserializer //////////
+ModelDeserializer::ModelDeserializer(std::shared_ptr<ov::AlignedBuffer>& model_buffer,
+ ModelBuilder fn,
+ const CacheDecrypt& decrypt_fn,
+ bool decript_from_string)
+ : m_model(model_buffer),
+ m_model_builder(std::move(fn)),
+ m_decript_from_string(decript_from_string) {
+ if (m_decript_from_string) {
+ m_cache_decrypt.m_decrypt_str = decrypt_fn.m_decrypt_str;
+ } else {
+ m_cache_decrypt.m_decrypt_char = decrypt_fn.m_decrypt_char;
+ }
+}
+
ModelDeserializer::ModelDeserializer(std::istream& model_stream,
- std::shared_ptr<ov::AlignedBuffer> model_buffer,
ModelBuilder fn,
const CacheDecrypt& decrypt_fn,
bool decript_from_string)
- : m_istream(model_stream),
+ : m_model(model_stream),
m_model_builder(std::move(fn)),
- m_decript_from_string(decript_from_string),
- m_model_buffer(std::move(model_buffer)) {
+ m_decript_from_string(decript_from_string) {
if (m_decript_from_string) {
m_cache_decrypt.m_decrypt_str = decrypt_fn.m_decrypt_str;
} else {
@@ -63,27 +80,26 @@ ModelDeserializer::ModelDeserializer(std::istream& model_stream,
void ModelDeserializer::set_info(pugi::xml_node& root, std::shared_ptr<ov::Model>& model) {}
void ModelDeserializer::operator>>(std::shared_ptr<ov::Model>& model) {
- if (m_model_buffer) {
- process_mmap(model, m_model_buffer);
- } else {
- process_stream(model);
- }
+ std::visit(
+ [&](auto&& arg) {
+ process_model(model, std::forward<decltype(arg)>(arg));
+ },
+ m_model);
}
-void ModelDeserializer::process_mmap(std::shared_ptr<ov::Model>& model,
- const std::shared_ptr<ov::AlignedBuffer>& mmemory) {
+void ModelDeserializer::process_model(std::shared_ptr<ov::Model>& model,
+ const std::shared_ptr<ov::AlignedBuffer>& model_buffer) {
// Note: Don't use seekg with mmaped stream. This may affect the performance of some models.
// Get file size before seek content.
// Blob from cache may have other header, so need to skip this.
- auto* buffer_base = reinterpret_cast<char*>(mmemory->get_ptr());
- const auto file_size = mmemory->size();
- const size_t hdr_pos = m_istream.tellg();
+ auto* buffer_base = reinterpret_cast<char*>(model_buffer->get_ptr());
+ const auto file_size = model_buffer->size();
pass::StreamSerialize::DataHeader hdr = {};
- std::memcpy(reinterpret_cast<char*>(&hdr), buffer_base + hdr_pos, sizeof hdr);
+ std::memcpy(reinterpret_cast<char*>(&hdr), buffer_base, sizeof hdr);
// Check if model header contains valid data.
- bool is_valid_model = (hdr.custom_data_offset == sizeof(hdr) + hdr_pos) &&
+ bool is_valid_model = (hdr.custom_data_offset == sizeof(hdr)) &&
(hdr.custom_data_size == hdr.consts_offset - hdr.custom_data_offset) &&
(hdr.consts_size == hdr.model_offset - hdr.consts_offset) &&
((hdr.model_size = file_size - hdr.model_offset) != 0U);
@@ -109,7 +125,7 @@ void ModelDeserializer::process_mmap(std::shared_ptr<ov::Model>& model,
weights_buf =
std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(buffer_base + hdr.consts_offset,
hdr.consts_size,
- mmemory);
+ model_buffer);
}
// XML content
@@ -135,14 +151,17 @@ void ModelDeserializer::process_mmap(std::shared_ptr<ov::Model>& model,
set_info(root, model);
}
-void ModelDeserializer::process_stream(std::shared_ptr<ov::Model>& model) {
- const size_t hdr_pos = m_istream.tellg();
- m_istream.seekg(0, std::istream::end);
- const size_t file_size = m_istream.tellg();
- m_istream.seekg(hdr_pos, std::istream::beg);
+void ModelDeserializer::process_model(std::shared_ptr<ov::Model>& model,
+ std::reference_wrapper<std::istream> model_stream_ref) {
+ auto& model_stream = model_stream_ref.get();
+
+ const size_t hdr_pos = model_stream.tellg();
+ model_stream.seekg(0, std::istream::end);
+ const size_t file_size = model_stream.tellg();
+ model_stream.seekg(hdr_pos, std::istream::beg);
pass::StreamSerialize::DataHeader hdr = {};
- m_istream.read(reinterpret_cast<char*>(&hdr), sizeof hdr);
+ model_stream.read(reinterpret_cast<char*>(&hdr), sizeof hdr);
// Check if model header contains valid data.
bool is_valid_model = (hdr.custom_data_offset == sizeof(hdr) + hdr_pos) &&
@@ -154,13 +173,13 @@ void ModelDeserializer::process_stream(std::shared_ptr<ov::Model>& model) {
}
// read model input/output precisions
- m_istream.seekg(hdr.custom_data_offset);
+ model_stream.seekg(hdr.custom_data_offset);
pugi::xml_document xmlInOutDoc;
if (hdr.custom_data_size > 0) {
std::string xmlInOutString;
xmlInOutString.resize(hdr.custom_data_size);
- m_istream.read(const_cast<char*>(xmlInOutString.c_str()), hdr.custom_data_size);
+ model_stream.read(const_cast<char*>(xmlInOutString.c_str()), hdr.custom_data_size);
auto res = xmlInOutDoc.load_string(xmlInOutString.c_str());
if (res.status != pugi::status_ok) {
OPENVINO_THROW("NetworkNotRead: The inputs and outputs information is invalid.");
@@ -169,16 +188,16 @@ void ModelDeserializer::process_stream(std::shared_ptr<ov::Model>& model) {
// read blob content
auto data_blob = std::make_shared<ov::Tensor>(ov::element::u8, ov::Shape({hdr.consts_size}));
- m_istream.seekg(hdr.consts_offset);
+ model_stream.seekg(hdr.consts_offset);
if (hdr.consts_size) {
- m_istream.read(static_cast<char*>(data_blob->data(ov::element::u8)), hdr.consts_size);
+ model_stream.read(static_cast<char*>(data_blob->data(ov::element::u8)), hdr.consts_size);
}
// read XML content
auto xml_string = std::make_shared<std::string>();
- m_istream.seekg(hdr.model_offset);
+ model_stream.seekg(hdr.model_offset);
xml_string->resize(hdr.model_size);
- m_istream.read(const_cast<char*>(xml_string->data()), hdr.model_size);
+ model_stream.read(const_cast<char*>(xml_string->data()), hdr.model_size);
if (m_cache_decrypt) {
if (m_decript_from_string) {
*xml_string = m_cache_decrypt.m_decrypt_str(*xml_string);
@@ -203,6 +222,5 @@ void ModelDeserializer::process_stream(std::shared_ptr<ov::Model>& model) {
// Set Info
pugi::xml_node root = xmlInOutDoc.child("cnndata");
set_info(root, model);
-}
-
+};
} // namespace ov::intel_cpu
diff --git a/src/plugins/intel_cpu/src/utils/serialize.hpp b/src/plugins/intel_cpu/src/utils/serialize.hpp
index 5b68d1a8693..7a8b65e87fd 100644
--- a/src/plugins/intel_cpu/src/utils/serialize.hpp
+++ b/src/plugins/intel_cpu/src/utils/serialize.hpp
@@ -9,24 +9,25 @@
#include <ostream>
#include <pugixml.hpp>
#include <string>
+#include <variant>
#include "openvino/core/model.hpp"
+#include "openvino/pass/serialize.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "utils/codec_xor.hpp"
namespace ov::intel_cpu {
-class ModelSerializer {
+class ModelSerializer : private ov::pass::StreamSerialize {
public:
using CacheEncrypt = std::function<std::string(const std::string&)>;
- ModelSerializer(std::ostream& ostream, CacheEncrypt encrypt_fn = {});
+ ModelSerializer(std::ostream& ostream, const CacheEncrypt& encrypt_fn = {});
void operator<<(const std::shared_ptr<ov::Model>& model);
private:
- std::ostream& m_ostream;
- CacheEncrypt m_cache_encrypt;
+ bool use_absolute_offset() override;
};
class ModelDeserializer {
@@ -34,8 +35,12 @@ public:
using ModelBuilder = std::function<std::shared_ptr<ov::Model>(const std::shared_ptr<ov::AlignedBuffer>&,
const std::shared_ptr<ov::AlignedBuffer>&)>;
- ModelDeserializer(std::istream& model,
- std::shared_ptr<ov::AlignedBuffer> model_buffer,
+ ModelDeserializer(std::shared_ptr<ov::AlignedBuffer>& model_buffer,
+ ModelBuilder fn,
+ const CacheDecrypt& decrypt_fn,
+ bool decript_from_string);
+
+ ModelDeserializer(std::istream& model_stream,
ModelBuilder fn,
const CacheDecrypt& decrypt_fn,
bool decript_from_string);
@@ -47,15 +52,13 @@ public:
protected:
static void set_info(pugi::xml_node& root, std::shared_ptr<ov::Model>& model);
- void process_mmap(std::shared_ptr<ov::Model>& model, const std::shared_ptr<ov::AlignedBuffer>& memory);
-
- void process_stream(std::shared_ptr<ov::Model>& model);
+ void process_model(std::shared_ptr<ov::Model>& model, const std::shared_ptr<ov::AlignedBuffer>& model_buffer);
+ void process_model(std::shared_ptr<ov::Model>& model, std::reference_wrapper<std::istream> model_stream);
- std::istream& m_istream;
+ std::variant<std::shared_ptr<ov::AlignedBuffer>, std::reference_wrapper<std::istream>> m_model;
ModelBuilder m_model_builder;
CacheDecrypt m_cache_decrypt;
bool m_decript_from_string;
- std::shared_ptr<ov::AlignedBuffer> m_model_buffer;
};
} // namespace ov::intel_cpu
diff --git a/src/plugins/intel_gpu/include/intel_gpu/plugin/plugin.hpp b/src/plugins/intel_gpu/include/intel_gpu/plugin/plugin.hpp
index 4b2c8207120..cd45840f3f6 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/plugin/plugin.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/plugin/plugin.hpp
@@ -59,6 +59,10 @@ public:
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;
ov::SoPtr<ov::IRemoteContext> create_context(const ov::AnyMap& remote_properties) const override;
diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp
index 92f1a0a0d23..188da08cb39 100644
--- a/src/plugins/intel_gpu/src/plugin/plugin.cpp
+++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp
@@ -332,12 +332,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
_orig_config.erase(it);
}
- std::shared_ptr<ov::AlignedBuffer> model_buffer;
if (auto blob_it = _orig_config.find(ov::hint::compiled_blob.name()); blob_it != _orig_config.end()) {
- auto compiled_blob = blob_it->second.as<ov::Tensor>();
- model_buffer = std::make_shared<ov::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(compiled_blob.data()),
- compiled_blob.get_byte_size(),
- compiled_blob);
_orig_config.erase(blob_it);
}
@@ -372,6 +367,21 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
return std::make_shared<CompiledModel>(ib, shared_from_this(), context_impl, config, loaded_from_cache);
}
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::AnyMap& config) const{
+ std::string device_id = get_device_id(config);
+ auto context = get_default_context(device_id);
+ return import_model(model, { context, nullptr }, config);
+}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& config) const{
+ SharedStreamBuffer buf{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream(&buf);
+ return import_model(stream, context, config);
+}
+
ov::Any Plugin::get_property(const std::string& name, const ov::AnyMap& options) const {
OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "Plugin::get_property");
diff --git a/src/plugins/intel_npu/src/plugin/include/plugin.hpp b/src/plugins/intel_npu/src/plugin/include/plugin.hpp
index e8cb13bd96f..66e4e8dc953 100644
--- a/src/plugins/intel_npu/src/plugin/include/plugin.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/plugin.hpp
@@ -52,6 +52,12 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& stream, const ov::AnyMap& properties) const override;
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& stream,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 55cbd6f386b..cfe544c6719 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -706,6 +706,22 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream,
return import_model(stream, properties);
}
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::AnyMap& properties) const{
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, properties);
+}
+
+std::shared_ptr<ov::ICompiledModel> Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const{
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, context, properties);
+}
+
+
ov::SupportedOpsMap Plugin::query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const {
OV_ITT_SCOPED_TASK(itt::domains::NPUPlugin, "Plugin::query_model");
diff --git a/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.cpp b/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.cpp
index a7f285657b5..babdabd41b9 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.cpp
@@ -242,11 +242,11 @@ void MockPluginBase<DeviceType>::create_implementation() {
.WillByDefault([](const ov::AnyMap& remote_properties) -> ov::SoPtr<ov::IRemoteContext> {
return std::make_shared<MockRemoteContext>(device_name);
});
- ON_CALL(*this, import_model(testing::_, testing::_))
+ ON_CALL(*this, import_model(testing::A<std::istream&>(), testing::_))
.WillByDefault([](std::istream& model, const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {
OPENVINO_NOT_IMPLEMENTED;
});
- ON_CALL(*this, import_model(testing::_, testing::_, testing::_))
+ ON_CALL(*this, import_model(testing::A<std::istream&>(), testing::_, testing::_))
.WillByDefault([](std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) -> std::shared_ptr<ov::ICompiledModel> {
diff --git a/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.hpp b/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.hpp
index e8f9e134fcb..040415f8f92 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/npuw/mocks/mock_plugins.hpp
@@ -126,6 +126,13 @@ public:
std::shared_ptr<ov::ICompiledModel>(std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties));
+ MOCK_CONST_METHOD2_T(import_model,
+ std::shared_ptr<ov::ICompiledModel>(ov::Tensor& model,
+ const ov::AnyMap& properties));
+ MOCK_CONST_METHOD3_T(import_model,
+ std::shared_ptr<ov::ICompiledModel>(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties));
MOCK_CONST_METHOD2_T(query_model,
ov::SupportedOpsMap(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties));
diff --git a/src/plugins/intel_npu/tests/functional/internal/overload/compiled_model/blob_compatibility.hpp b/src/plugins/intel_npu/tests/functional/internal/overload/compiled_model/blob_compatibility.hpp
index 8140df4b8ec..9c301f6f722 100644
--- a/src/plugins/intel_npu/tests/functional/internal/overload/compiled_model/blob_compatibility.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/overload/compiled_model/blob_compatibility.hpp
@@ -123,7 +123,7 @@ using OVBlobCompatibilityNPU_PV_Driver_No_Throw = OVBlobCompatibilityNPU;
##__VA_ARGS__); \
APPEND_EXPORT_HELPER(ASSERT_TYPE, ##__VA_ARGS__)
-TEST_P(OVBlobCompatibilityNPU, CanImportAllPrecompiledBlobsForAllOVVersionsAndDrivers) {
+TEST_P(OVBlobCompatibilityNPU, DISABLED_CanImportAllPrecompiledBlobsForAllOVVersionsAndDrivers) {
if (auto current_driver =
core.get_property(ov::test::utils::DEVICE_NPU, ov::intel_npu::driver_version.name()).as<std::string>();
current_driver == DRIVERS.at(E_DRIVERS::DRIVER_1688) && blobName.find(current_driver) == std::string::npos) {
diff --git a/src/plugins/proxy/src/plugin.cpp b/src/plugins/proxy/src/plugin.cpp
index 3cf435ef418..dcc06b02f5d 100644
--- a/src/plugins/proxy/src/plugin.cpp
+++ b/src/plugins/proxy/src/plugin.cpp
@@ -16,6 +16,7 @@
#include "openvino/runtime/iinfer_request.hpp"
#include "openvino/runtime/internal_properties.hpp"
#include "openvino/runtime/iremote_context.hpp"
+#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/runtime/so_ptr.hpp"
#include "openvino/util/common_util.hpp"
#include "plugin.hpp"
@@ -493,6 +494,21 @@ std::shared_ptr<ov::ICompiledModel> ov::proxy::Plugin::import_model(std::istream
context);
}
+std::shared_ptr<ov::ICompiledModel> ov::proxy::Plugin::import_model(ov::Tensor& model,
+ const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, properties);
+}
+
+std::shared_ptr<ov::ICompiledModel> ov::proxy::Plugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, context, properties);
+}
+
std::string ov::proxy::Plugin::get_primary_device(size_t idx) const {
std::vector<std::string> devices;
const auto all_devices = get_hidden_devices();
diff --git a/src/plugins/proxy/src/plugin.hpp b/src/plugins/proxy/src/plugin.hpp
index c05c5006f94..5e3f88d84a0 100644
--- a/src/plugins/proxy/src/plugin.hpp
+++ b/src/plugins/proxy/src/plugin.hpp
@@ -43,6 +43,12 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
+
private:
std::vector<std::vector<std::string>> get_hidden_devices() const;
std::string get_fallback_device(size_t idx) const;
diff --git a/src/plugins/proxy/tests/proxy_tests.cpp b/src/plugins/proxy/tests/proxy_tests.cpp
index f5494151659..948b558a304 100644
--- a/src/plugins/proxy/tests/proxy_tests.cpp
+++ b/src/plugins/proxy/tests/proxy_tests.cpp
@@ -471,6 +471,16 @@ public:
return compile_model(ov_model, properties, context);
}
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
diff --git a/src/plugins/template/src/plugin.cpp b/src/plugins/template/src/plugin.cpp
index 0fa6c1b3394..18ed808f4a9 100644
--- a/src/plugins/template/src/plugin.cpp
+++ b/src/plugins/template/src/plugin.cpp
@@ -266,6 +266,22 @@ std::shared_ptr<ov::ICompiledModel> ov::template_plugin::Plugin::import_model(
}
// ! [plugin:import_model_with_remote]
+std::shared_ptr<ov::ICompiledModel> ov::template_plugin::Plugin::import_model(ov::Tensor& model,
+ const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, properties);
+}
+
+std::shared_ptr<ov::ICompiledModel> ov::template_plugin::Plugin::import_model(
+ ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ ov::SharedStreamBuffer buffer{reinterpret_cast<char*>(model.data()), model.get_byte_size()};
+ std::istream stream{&buffer};
+ return import_model(stream, properties);
+}
+
// ! [plugin:query_model]
ov::SupportedOpsMap ov::template_plugin::Plugin::query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const {
diff --git a/src/plugins/template/src/plugin.hpp b/src/plugins/template/src/plugin.hpp
index bc2592f6568..69e14b8b33b 100644
--- a/src/plugins/template/src/plugin.hpp
+++ b/src/plugins/template/src/plugin.hpp
@@ -41,6 +41,12 @@ public:
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;
diff --git a/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp b/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp
index 8f309c1fd5e..b692ee85464 100644
--- a/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp
+++ b/src/tests/test_utils/common_test_utils/include/common_test_utils/file_utils.hpp
@@ -239,6 +239,16 @@ class MockPlugin : public ov::IPlugin {
OPENVINO_NOT_IMPLEMENTED;
}
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override {
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override {
OPENVINO_NOT_IMPLEMENTED;
diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp
index 13234aeb464..c99cfed9a01 100644
--- a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp
+++ b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp
@@ -86,6 +86,20 @@ public:
OPENVINO_NOT_IMPLEMENTED;
}
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override {
+ if (m_plugin)
+ return m_plugin->import_model(model, properties);
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override {
+ if (m_plugin)
+ return m_plugin->import_model(model, context, properties);
+ OPENVINO_NOT_IMPLEMENTED;
+ }
+
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override {
if (m_plugin)
@@ -165,6 +179,17 @@ std::shared_ptr<ov::ICompiledModel> MockPlugin::import_model(std::istream& model
set_parameters_if_need();
return m_plugin->import_model(model, context, properties);
}
+
+std::shared_ptr<ov::ICompiledModel> MockPlugin::import_model(ov::Tensor& model, const ov::AnyMap& properties) const {
+ set_parameters_if_need();
+ return m_plugin->import_model(model, properties);
+}
+std::shared_ptr<ov::ICompiledModel> MockPlugin::import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const {
+ set_parameters_if_need();
+ return m_plugin->import_model(model, context, properties);
+}
ov::SupportedOpsMap MockPlugin::query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const {
set_parameters_if_need();
diff --git a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp
index 7d2a496e90a..78b55da28f7 100644
--- a/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp
+++ b/src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.hpp
@@ -38,6 +38,10 @@ public:
std::shared_ptr<ov::ICompiledModel> import_model(std::istream& model,
const ov::SoPtr<ov::IRemoteContext>& context,
const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model, const ov::AnyMap& properties) const override;
+ std::shared_ptr<ov::ICompiledModel> import_model(ov::Tensor& model,
+ const ov::SoPtr<ov::IRemoteContext>& context,
+ const ov::AnyMap& properties) const override;
ov::SupportedOpsMap query_model(const std::shared_ptr<const ov::Model>& model,
const ov::AnyMap& properties) const override;
};
diff --git a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp
index c30461ed6d6..6098cce3386 100644
--- a/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp
+++ b/src/tests/test_utils/unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp
@@ -40,6 +40,11 @@ public:
import_model,
(std::istream&, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&),
(const));
+ MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>, import_model, (ov::Tensor&, const ov::AnyMap&), (const));
+ MOCK_METHOD(std::shared_ptr<ov::ICompiledModel>,
+ import_model,
+ (ov::Tensor&, const ov::SoPtr<ov::IRemoteContext>&, const ov::AnyMap&),
+ (const));
MOCK_METHOD(ov::SupportedOpsMap,
query_model,
(const std::shared_ptr<const ov::Model>&, const ov::AnyMap&),