Skip to content

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

[GPU] Support weightless blob when ov::Model is passed to compile_model (#29375)

Tomasz Krupab8d29f3225ee
diff --git a/src/common/util/include/openvino/util/weights_path.hpp b/src/common/util/include/openvino/util/weights_path.hpp
index 11215d8eee1..7ac81190766 100644
--- a/src/common/util/include/openvino/util/weights_path.hpp
+++ b/src/common/util/include/openvino/util/weights_path.hpp
@@ -9,7 +9,7 @@
namespace ov {
namespace util {
-bool validate_weights_path(std::string& weights_path);
+bool validate_weights_path(const std::string& weights_path);
} // namespace util
} // namespace ov
diff --git a/src/common/util/src/weights_path.cpp b/src/common/util/src/weights_path.cpp
index 56d0b56d643..d6dffbc9b84 100644
--- a/src/common/util/src/weights_path.cpp
+++ b/src/common/util/src/weights_path.cpp
@@ -4,7 +4,7 @@
#include "openvino/util/weights_path.hpp"
-bool ov::util::validate_weights_path(std::string& weights_path) {
+bool ov::util::validate_weights_path(const std::string& weights_path) {
if (weights_path.empty() || !ov::util::ends_with(weights_path, ".bin")) {
return false;
}
diff --git a/src/inference/src/dev/core_impl.cpp b/src/inference/src/dev/core_impl.cpp
index e3150c1ce4e..2b05e70ba8a 100644
--- a/src/inference/src/dev/core_impl.cpp
+++ b/src/inference/src/dev/core_impl.cpp
@@ -777,6 +777,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
if (cacheManager && device_supports_model_caching(plugin, parsed._config) && !is_proxy_device(plugin)) {
CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};
cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));
+ cacheContent.model = std::const_pointer_cast<ov::Model>(model);
std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
res = load_model_from_cache(cacheContent, plugin, parsed._config, ov::SoPtr<ov::IRemoteContext>{}, [&]() {
return compile_model_and_cache(plugin,
@@ -812,6 +813,7 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::compile_model(const std::shared_ptr<
CacheContent cacheContent{cacheManager, parsed._core_config.get_enable_mmap()};
cacheContent.blobId = ov::ModelCache::compute_hash(model, create_compile_config(plugin, parsed._config));
std::unique_ptr<CacheGuardEntry> lock = cacheGuard.get_hash_lock(cacheContent.blobId);
+ cacheContent.model = std::const_pointer_cast<ov::Model>(model);
res = load_model_from_cache(cacheContent, plugin, parsed._config, context, [&]() {
return compile_model_and_cache(plugin, model, parsed._config, context, cacheContent);
});
@@ -1473,14 +1475,15 @@ ov::SoPtr<ov::ICompiledModel> ov::CoreImpl::load_model_from_cache(
update_config[ov::loaded_from_cache.name()] = true;
if (util::contains(plugin.get_property(ov::supported_properties), ov::weights_path)) {
- std::string weights_path = cacheContent.modelPath;
- auto pos = weights_path.rfind('.');
- if (pos != weights_path.npos && weights_path.substr(pos) == ".xml") {
- weights_path = weights_path.substr(0, pos);
- weights_path += ".bin";
- }
- if (ov::util::file_exists(weights_path)) {
- update_config[ov::weights_path.name()] = weights_path;
+ if (cacheContent.model) {
+ update_config[ov::hint::model.name()] = cacheContent.model;
+ } else {
+ std::filesystem::path weights_path = cacheContent.modelPath;
+ weights_path.replace_extension(".bin");
+
+ if (ov::util::file_exists(weights_path)) {
+ update_config[ov::weights_path.name()] = weights_path.string();
+ }
}
}
if (model_buffer) {
diff --git a/src/inference/src/dev/core_impl.hpp b/src/inference/src/dev/core_impl.hpp
index 5c09a32aa54..62af69586dd 100644
--- a/src/inference/src/dev/core_impl.hpp
+++ b/src/inference/src/dev/core_impl.hpp
@@ -161,6 +161,7 @@ private:
std::shared_ptr<ov::ICacheManager> cacheManager;
std::string blobId = {};
std::string modelPath = {};
+ std::shared_ptr<ov::Model> model = nullptr;
bool mmap_enabled = false;
};
diff --git a/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp b/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
index 2469a02a0b5..580b04c6851 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
+++ b/src/plugins/intel_gpu/include/intel_gpu/primitives/data.hpp
@@ -5,14 +5,17 @@
#pragma once
#include <algorithm>
#include <climits>
+#include <variant>
#include "intel_gpu/graph/network.hpp"
#include "intel_gpu/primitives/input_layout.hpp"
#include "intel_gpu/primitives/reorder.hpp"
#include "intel_gpu/runtime/engine.hpp"
#include "intel_gpu/runtime/memory.hpp"
+#include "openvino/core/rt_info/weightless_caching_attributes.hpp"
#include "openvino/op/constant.hpp"
#include "openvino/op/convert.hpp"
+#include "openvino/op/tensor_iterator.hpp"
#include "openvino/op/util/op_types.hpp"
#include "openvino/pass/constant_folding.hpp"
#include "openvino/pass/manager.hpp"
@@ -21,6 +24,11 @@
#include "primitive.hpp"
#include "transformations/convert_precision.hpp"
+using weights_memory_ptr = std::variant<std::shared_ptr<ov::MappedMemory>, std::shared_ptr<ov::Model>>;
+using offset_const_map_t = std::map<size_t, std::shared_ptr<ov::op::v0::Constant>>;
+using shared_mapped_memory_ptr = std::shared_ptr<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>;
+using constant_memory_ptr = std::variant<shared_mapped_memory_ptr, std::shared_ptr<ov::op::v0::Constant>>;
+
namespace {
bool is_alloc_host_accessible(const cldnn::allocation_type& alloc_type) {
@@ -43,6 +51,55 @@ void copy_to_dst_mem(cldnn::memory::ptr mem_ptr, const uint8_t* data_ptr) {
namespace cldnn {
+class WeightsMemory {
+public:
+ WeightsMemory(std::shared_ptr<ov::Model> model) : weights_memory(model) {
+ fill_offset_to_constant_map(model);
+ }
+
+ WeightsMemory(std::shared_ptr<ov::MappedMemory> mapped_memory) : weights_memory(mapped_memory) {}
+
+ constant_memory_ptr get_constant_buf(size_t bin_offset, size_t original_size) {
+ if (std::holds_alternative<std::shared_ptr<ov::MappedMemory>>(weights_memory)) {
+ auto mapped_memory = std::get<std::shared_ptr<ov::MappedMemory>>(weights_memory);
+ return std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>(
+ mapped_memory->data() + bin_offset,
+ original_size,
+ mapped_memory);
+ } else {
+ auto model_ptr = std::get<std::shared_ptr<ov::Model>>(weights_memory);
+ auto const_it = offset_to_constant_map.find(bin_offset);
+ if (const_it == offset_to_constant_map.end()) {
+ OPENVINO_THROW("Constant with bin_offset ", bin_offset, " not found in the model");
+ }
+ auto const_ptr = const_it->second;
+ return const_ptr;
+ }
+ }
+
+private:
+ void fill_offset_to_constant_map(std::shared_ptr<ov::Model> model) {
+ const auto& ops = model->get_ops();
+ for (const auto& node : ops) {
+ if (ov::op::util::is_constant(node)) {
+ auto rt_info = node->get_rt_info();
+ auto weightless_cache_attr = rt_info.find(ov::WeightlessCacheAttribute::get_type_info_static());
+ if (weightless_cache_attr != rt_info.end()) {
+ auto& attr = weightless_cache_attr->second.as<ov::WeightlessCacheAttribute>();
+ auto const_ptr = std::dynamic_pointer_cast<ov::op::v0::Constant>(node);
+ offset_to_constant_map.emplace(attr.bin_offset, const_ptr);
+ }
+ } else if (auto ti = ov::as_type<const ov::op::v0::TensorIterator>(node.get())) {
+ auto ti_body = ti->get_body();
+ fill_offset_to_constant_map(ti_body);
+ }
+ }
+ }
+
+ weights_memory_ptr weights_memory;
+ offset_const_map_t offset_to_constant_map{};
+};
+
struct reorder_replication {
std::shared_ptr<cldnn::layout> input_layout = nullptr;
std::shared_ptr<cldnn::reorder> reorder = nullptr;
@@ -100,14 +157,12 @@ struct weightless_cache_manager {
return true;
}
- bool load(BinaryInputBuffer& ib, memory::ptr dst_mem, std::shared_ptr<ov::MappedMemory> mapped_weights) {
+ bool load(BinaryInputBuffer& ib, memory::ptr dst_mem, std::shared_ptr<WeightsMemory> weights_memory) {
ib >> do_weightless_caching;
if (!do_weightless_caching) {
return false;
}
- OPENVINO_ASSERT(mapped_weights != nullptr, "mmap object is null");
-
ib >> bin_offset;
ib >> do_precision_conversion;
if (do_precision_conversion) {
@@ -132,15 +187,18 @@ struct weightless_cache_manager {
ib >> *reorder_rep.reorder;
}
- auto shared_buf =
- std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>(mapped_weights->data() + bin_offset,
- original_size,
- mapped_weights);
+ auto constant_ptr = weights_memory->get_constant_buf(bin_offset, original_size);
if (should_run_transformations()) {
- run_transformations(ib.get_engine(), dst_mem, shared_buf);
+ run_transformations(ib.get_engine(), dst_mem, constant_ptr);
} else {
- copy_to_dst_mem(dst_mem, shared_buf->get_ptr<uint8_t>());
+ if (std::holds_alternative<std::shared_ptr<ov::op::v0::Constant>>(constant_ptr)) {
+ auto cptr = std::get<std::shared_ptr<ov::op::v0::Constant>>(constant_ptr);
+ copy_to_dst_mem(dst_mem, reinterpret_cast<const uint8_t*>(cptr->get_data_ptr()));
+ } else {
+ auto shared_buf = std::get<shared_mapped_memory_ptr>(constant_ptr);
+ copy_to_dst_mem(dst_mem, shared_buf->get_ptr<uint8_t>());
+ }
}
return true;
}
@@ -167,7 +225,7 @@ private:
void run_transformations(engine& engine,
memory::ptr dst_mem,
- std::shared_ptr<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>> shared_buf) {
+ constant_memory_ptr constant_ptr) {
std::shared_ptr<ov::op::v0::Constant> transformed_constant = nullptr;
// Note: this works only until the data is copied to dst_mem.
@@ -175,7 +233,14 @@ private:
if (transformed_constant) {
return reinterpret_cast<const uint8_t*>(transformed_constant->get_data_ptr());
}
- return shared_buf->get_ptr<uint8_t>();
+
+ if (std::holds_alternative<std::shared_ptr<ov::op::v0::Constant>>(constant_ptr)) {
+ auto cptr = std::get<std::shared_ptr<ov::op::v0::Constant>>(constant_ptr);
+ return reinterpret_cast<const uint8_t*>(cptr->get_data_ptr());
+ } else {
+ auto shared_buf = std::get<shared_mapped_memory_ptr>(constant_ptr);
+ return shared_buf->get_ptr<uint8_t>();
+ }
};
// Note: this works only until the data is copied to dst_mem.
@@ -187,10 +252,14 @@ private:
};
if (do_precision_conversion) {
- auto orig_constant = std::make_shared<ov::op::v0::Constant>(original_dtype,
- shape,
- get_intermediate_data(),
- shared_buf);
+ std::shared_ptr<ov::op::v0::Constant> orig_constant = nullptr;
+ if (std::holds_alternative<std::shared_ptr<ov::op::v0::Constant>>(constant_ptr)) {
+ orig_constant = std::get<std::shared_ptr<ov::op::v0::Constant>>(constant_ptr);
+ } else {
+ auto shared_buf = std::get<shared_mapped_memory_ptr>(constant_ptr);
+ orig_constant =
+ std::make_shared<ov::op::v0::Constant>(original_dtype, shape, get_intermediate_data(), shared_buf);
+ }
ov::ParameterVector inputParams;
ov::ResultVector results;
@@ -315,7 +384,7 @@ struct data : public primitive_base<data> {
primitive_base<data>::load(ib);
}
- void load_weights(BinaryInputBuffer& ib, std::shared_ptr<ov::MappedMemory> mapped_weights) {
+ void load_weights(BinaryInputBuffer& ib, std::shared_ptr<WeightsMemory> weights_memory) {
layout output_layout = layout();
ib >> output_layout;
@@ -327,7 +396,7 @@ struct data : public primitive_base<data> {
mem = ib.get_engine().allocate_memory(output_layout, _allocation_type, false);
- bool is_weightless_caching = cache_info->load(ib, mem, mapped_weights);
+ bool is_weightless_caching = cache_info->load(ib, mem, weights_memory);
if (!is_weightless_caching) {
if (is_alloc_host_accessible(_allocation_type)) {
diff --git a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
index 63726527401..9696208be8f 100644
--- a/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
+++ b/src/plugins/intel_gpu/include/intel_gpu/runtime/options.inl
@@ -32,6 +32,7 @@ OV_CONFIG_RELEASE_OPTION(ov, weights_path, "", "Path to the model weights file u
OV_CONFIG_RELEASE_OPTION(ov::hint, activations_scale_factor, -1.0f, "Scalar floating point value that is used for runtime activation tensor scaling with fp16 inference precision")
OV_CONFIG_RELEASE_OPTION(ov::internal, enable_lp_transformations, false, "Enable/Disable Low precision transformations set")
OV_CONFIG_RELEASE_OPTION(ov::intel_gpu, config_file, "", "Path to custom layers config file")
+OV_CONFIG_RELEASE_OPTION(ov::hint, model, nullptr, "Shared pointer to the ov::Model")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, shape_predictor_settings, {10, 16 * 1024, 2, 1.1f}, "Preallocation settings")
OV_CONFIG_RELEASE_INTERNAL_OPTION(ov::intel_gpu, queue_type, QueueTypes::out_of_order, "Type of the queue that must be used for model execution. May be in-order or out-of-order")
diff --git a/src/plugins/intel_gpu/src/graph/program.cpp b/src/plugins/intel_gpu/src/graph/program.cpp
index 1e275f379ec..feeaa786966 100644
--- a/src/plugins/intel_gpu/src/graph/program.cpp
+++ b/src/plugins/intel_gpu/src/graph/program.cpp
@@ -1848,11 +1848,18 @@ void program::save(cldnn::BinaryOutputBuffer& ob) const {
void program::load(cldnn::BinaryInputBuffer& ib) {
init_program();
- std::shared_ptr<ov::MappedMemory> mapped_memory = nullptr;
+ std::shared_ptr<WeightsMemory> weights_memory = nullptr;
std::string weights_path = _config.get_weights_path();
- if (_config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE &&
- ov::util::validate_weights_path(weights_path)) {
- mapped_memory = ov::load_mmap_object(weights_path);
+ auto model_ptr = _config.get_model();
+ if (_config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (model_ptr) {
+ weights_memory = std::make_shared<WeightsMemory>(model_ptr);
+ } else if (!weights_path.empty()) {
+ ov::util::validate_weights_path(weights_path);
+ weights_memory = std::make_shared<WeightsMemory>(ov::load_mmap_object(weights_path));
+ } else {
+ OPENVINO_THROW("Weights path or model is required for cache mode OPTIMIZE_SIZE");
+ }
}
size_t num_nodes;
@@ -1866,7 +1873,7 @@ void program::load(cldnn::BinaryInputBuffer& ib) {
std::shared_ptr<cldnn::primitive> prim;
ib >> prim;
if (auto data_prim = dynamic_cast<cldnn::data*>(prim.get())) {
- data_prim->load_weights(ib, mapped_memory);
+ data_prim->load_weights(ib, weights_memory);
}
get_or_create(prim);
}
diff --git a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp
index eb6952eaed2..2be5e58f381 100644
--- a/src/plugins/intel_gpu/src/plugin/compiled_model.cpp
+++ b/src/plugins/intel_gpu/src/plugin/compiled_model.cpp
@@ -179,12 +179,14 @@ std::shared_ptr<ov::IAsyncInferRequest> CompiledModel::create_infer_request() co
// [ ov::intel_gpu::Graph ]
void CompiledModel::export_model(std::ostream& model) const {
// If ov::CacheMode::OPTIMIZE_SIZE is set, do the export iff it's possible to do weightless caching
- // which requires the weights_path.
+ // which requires the weights_path or ov::Model ptr.
ov::CacheMode cache_mode = m_config.get_cache_mode();
std::string weights_path = m_config.get_weights_path();
- if (cache_mode == ov::CacheMode::OPTIMIZE_SIZE &&
- !ov::util::validate_weights_path(weights_path))
+ auto model_ptr = m_config.get_model();
+ if (cache_mode == ov::CacheMode::OPTIMIZE_SIZE && !ov::util::validate_weights_path(weights_path) &&
+ model_ptr == nullptr) {
return;
+ }
OV_ITT_SCOPED_TASK(itt::domains::intel_gpu_plugin, "CompiledModel::export_model");
OPENVINO_ASSERT(!m_graphs.empty(), "[GPU] Model not loaded");
diff --git a/src/plugins/intel_gpu/src/plugin/plugin.cpp b/src/plugins/intel_gpu/src/plugin/plugin.cpp
index f14db8994a5..d14b0a45eef 100644
--- a/src/plugins/intel_gpu/src/plugin/plugin.cpp
+++ b/src/plugins/intel_gpu/src/plugin/plugin.cpp
@@ -335,8 +335,8 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
std::unique_ptr<cldnn::BinaryInputBuffer> ib_ptr =
encryption_enabled ? std::make_unique<cldnn::EncryptedBinaryInputBuffer>(model,
- context_impl->get_engine(),
- encryption_callbacks.decrypt)
+ context_impl->get_engine(),
+ encryption_callbacks.decrypt)
: std::make_unique<cldnn::BinaryInputBuffer>(model, context_impl->get_engine());
auto& ib = *ib_ptr;
@@ -348,8 +348,10 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& model,
}
std::string weights_path = config.get_weights_path();
- if (config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE && !ov::util::validate_weights_path(weights_path)) {
- return nullptr;
+ if (config.get_cache_mode() == ov::CacheMode::OPTIMIZE_SIZE) {
+ if (!ov::util::validate_weights_path(weights_path) && config.get_model() == nullptr) {
+ return nullptr;
+ }
}
return std::make_shared<CompiledModel>(ib, shared_from_this(), context_impl, config, loaded_from_cache);
diff --git a/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp b/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp
index e6d015079f4..24a613bc101 100644
--- a/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp
+++ b/src/plugins/intel_gpu/tests/functional/behavior/model_cache.cpp
@@ -27,20 +27,40 @@
#endif
namespace {
-typedef std::tuple<bool, bool, ov::element::Type, ov::element::Type> testParams;
+
+enum class Import_API {
+ IMPORT_EXPORT,
+ COMPILE_FILEPATH,
+ COMPILE_MODEL
+};
+
+std::string import_api_to_string(Import_API api) {
+ switch (api) {
+ case Import_API::IMPORT_EXPORT:
+ return "import_export";
+ case Import_API::COMPILE_FILEPATH:
+ return "compile_filepath";
+ case Import_API::COMPILE_MODEL:
+ return "compile_model";
+ default:
+ return "";
+ }
+}
+
+typedef std::tuple<Import_API, bool, ov::element::Type, ov::element::Type> testParams;
class CheckWeightlessCacheAccuracy : public ::testing::Test, public ::testing::WithParamInterface<testParams> {
public:
static std::string get_test_case_name(::testing::TestParamInfo<testParams> obj) {
- bool use_compile_model_api_;
+ Import_API import_api_;
bool do_encryption_;
ov::element::Type inference_mode_;
ov::element::Type model_dtype_;
- std::tie(use_compile_model_api_, do_encryption_, inference_mode_, model_dtype_) = obj.param;
+ std::tie(import_api_, do_encryption_, inference_mode_, model_dtype_) = obj.param;
std::ostringstream result;
const char separator = '_';
- result << "use_compile_model_api=" << use_compile_model_api_ << separator;
+ result << "import_api=" << import_api_to_string(import_api_) << separator;
result << "do_encryption=" << do_encryption_ << separator;
result << "inference_mode=" << inference_mode_ << separator;
result << "model_dtype=" << model_dtype_;
@@ -53,7 +73,7 @@ protected:
std::string bin_path;
std::string cache_path;
std::string cache_dir;
- bool use_compile_model_api; // for loading from cache
+ Import_API import_api;
bool do_encryption;
ov::element::Type inference_mode;
ov::element::Type model_dtype;
@@ -70,7 +90,7 @@ void CheckWeightlessCacheAccuracy::SetUp() {
cache_path = filePrefix + ".blob";
cache_dir = filePrefix + "_cache_dir";
- std::tie(use_compile_model_api, do_encryption, inference_mode, model_dtype) = GetParam();
+ std::tie(import_api, do_encryption, inference_mode, model_dtype) = GetParam();
}
void CheckWeightlessCacheAccuracy::TearDown() {
@@ -102,17 +122,23 @@ void CheckWeightlessCacheAccuracy::run() {
ov::pass::Serialize(xml_path, bin_path).run_on_model(model);
ov::CompiledModel compiled_model;
- compiled_model = core->compile_model(xml_path, ov::test::utils::DEVICE_GPU, config);
-
- if (!use_compile_model_api) {
+ if (import_api == Import_API::IMPORT_EXPORT) {
+ compiled_model = core->compile_model(xml_path, ov::test::utils::DEVICE_GPU, config);
auto ofstr = std::ofstream(cache_path, std::ofstream::binary);
compiled_model.export_model(ofstr);
ofstr.close();
+ } else if (import_api == Import_API::COMPILE_FILEPATH) {
+ compiled_model = core->compile_model(xml_path, ov::test::utils::DEVICE_GPU, config);
+ } else if (import_api == Import_API::COMPILE_MODEL) {
+ auto model = core->read_model(xml_path);
+ compiled_model = core->compile_model(model, ov::test::utils::DEVICE_GPU, config);
+ } else {
+ OPENVINO_THROW("Unknown import API");
}
auto get_cache_path = [&]() {
std::string path;
- if (use_compile_model_api) {
+ if (import_api == Import_API::COMPILE_FILEPATH || import_api == Import_API::COMPILE_MODEL) {
auto blobs = ov::test::utils::listFilesWithExt(cache_dir, "blob");
EXPECT_EQ(blobs.size(), 1);
path = blobs[0];
@@ -135,8 +161,11 @@ void CheckWeightlessCacheAccuracy::run() {
ASSERT_NE(first_mod_time, static_cast<time_t>(0));
ov::CompiledModel imported_model;
- if (use_compile_model_api) {
+ if (import_api == Import_API::COMPILE_FILEPATH) {
imported_model = core->compile_model(xml_path, ov::test::utils::DEVICE_GPU, config);
+ } else if (import_api == Import_API::COMPILE_MODEL) {
+ auto model = core->read_model(xml_path);
+ imported_model = core->compile_model(model, ov::test::utils::DEVICE_GPU, config);
} else {
auto ifstr = std::ifstream(cache_path, std::ifstream::binary);
imported_model = core->import_model(ifstr, ov::test::utils::DEVICE_GPU, config_with_weights_path);
@@ -218,6 +247,12 @@ TEST_P(CheckWeightlessCacheAccuracyLowPrecision, MatmulWeightsDecompression) {
OV_ASSERT_NO_THROW(run());
}
+const std::vector<Import_API> import_api_types = {
+ Import_API::IMPORT_EXPORT,
+ Import_API::COMPILE_FILEPATH,
+ Import_API::COMPILE_MODEL,
+};
+
const std::vector<ov::element::Type> inference_modes = {
ov::element::f32,
ov::element::f16,
@@ -237,7 +272,7 @@ const std::vector<ov::element::Type> low_precision_dtypes = {
INSTANTIATE_TEST_SUITE_P(smoke_CheckWeightlessCacheAccuracy,
CheckWeightlessCacheAccuracy,
- ::testing::Combine(::testing::Bool(),
+ ::testing::Combine(::testing::ValuesIn(import_api_types),
::testing::Bool(),
::testing::ValuesIn(inference_modes),
::testing::ValuesIn(model_dtypes)),
@@ -245,7 +280,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_CheckWeightlessCacheAccuracy,
INSTANTIATE_TEST_SUITE_P(smoke_CheckWeightlessCacheAccuracyLowPrecision,
CheckWeightlessCacheAccuracyLowPrecision,
- ::testing::Combine(::testing::Bool(),
+ ::testing::Combine(::testing::ValuesIn(import_api_types),
::testing::Bool(),
::testing::ValuesIn(inference_modes),
::testing::ValuesIn(low_precision_dtypes)),