Skip to content

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

[`NPU`] Add support for `ov::cache_encryption_callbacks` property (#34986)

Mircea-Aurelian Dan9d7984313f27
diff --git a/src/plugins/intel_npu/README.md b/src/plugins/intel_npu/README.md
index 0fc9ecc9093..5d4fd596204 100644
--- a/src/plugins/intel_npu/README.md
+++ b/src/plugins/intel_npu/README.md
@@ -202,6 +202,7 @@ The following properties are supported (may differ based on current system confi
| `ov::hint::enable_cpu_pinning`/</br>`ENABLE_CPU_PINNING` | RW | Allows CPU threads pinning during inference. | `YES`/ `NO` /</br>`NO`
| `ov::log::level`/</br>`LOG_LEVEL` | RW | Sets the log level for NPU Plugin. An environment variable is also made available to expose logs from early initialization phase: OV_NPU_LOG_LEVEL. | `LOG_NONE`/</br>`LOG_ERROR`/</br>`LOG_WARNING`/</br>`LOG_INFO`/</br>`LOG_DEBUG`/</br>`LOG_TRACE` | `LOG_NONE` |
| `ov::cache_dir`/</br>`CACHE_DIR` | RW | Folder path to be used by the OpenVINO cache. | Any string pointing towards a valid directory path | empty |
+| `ov::cache_encryption_callbacks`/</br>`CACHE_ENCRYPTION_CALLBACKS` | WO | Encryption/Decryption functions called when exporting or reading the blob. | ov::EncryptionCallbacks structures populated with any function respecting signature `std::string(const std::string&)` for both encryption and decryption callbacks | ov::EncryptionCallbacks{nullptr, nullptr} |
| `ov::cache_mode`/</br>`CACHE_MODE` | RW | If `CACHE_DIR` has been set, then this option indicates whether or not the size of the compiled model binary object will be reduced by decoupling a portion of the weights. | `OPTIMIZE_SIZE` /</br>`OPTIMIZE_SPEED` | `OPTIMIZE_SPEED` |
| `ov::available_devices`/</br>`AVAILABLE_DEVICES` | RO | Returns the list of enumerated NPU devices. </br> NPU plugin does not currently support multiple devices. | `N/A`| `N/A` |
| `ov::device::id`/</br>`DEVICE_ID` | RW | Device identifier. Empty means auto detection. | empty/</br> `3720`/</br> `4000` | empty |
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp
index 92f9bb39754..a85005c909d 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/config.hpp
@@ -289,7 +289,7 @@ struct OptionBase {
return OptionMode::Both;
}
- // Overload this for private options.
+ // Overload this for public options.
static bool isPublic() {
return false;
}
@@ -381,7 +381,8 @@ struct OptionConcept final {
bool (*isValueSupportedImpl)(std::string_view val) =
nullptr; // better make this private, but won't be able to use aggregate initialization anymore in
// "makeOptionModel"
- std::shared_ptr<OptionValue> (*validateAndParse)(std::string_view val) = nullptr;
+ std::shared_ptr<OptionValue> (*validateAndParseFromString)(std::string_view val) = nullptr;
+ std::shared_ptr<OptionValue> (*validateAndParseFromAny)(const ov::Any& val) = nullptr;
std::optional<std::function<bool(std::string_view)>> customValueCheckerOpt = std::nullopt;
bool isValueSupported(std::string_view val) {
if (customValueCheckerOpt.has_value()) {
@@ -392,7 +393,7 @@ struct OptionConcept final {
};
template <class Opt>
-std::shared_ptr<OptionValue> validateAndParse(std::string_view val) {
+std::shared_ptr<OptionValue> validateAndParseFromString(std::string_view val) {
using ValueType = typename Opt::ValueType;
try {
@@ -404,6 +405,19 @@ std::shared_ptr<OptionValue> validateAndParse(std::string_view val) {
}
}
+template <class Opt>
+std::shared_ptr<OptionValue> validateAndParseFromAny(const ov::Any& val) {
+ using ValueType = typename Opt::ValueType;
+
+ try {
+ auto parsedVal = val.as<ValueType>();
+ Opt::validateValue(parsedVal);
+ return std::make_shared<OptionValueImpl<Opt, ValueType>>(std::move(parsedVal), &Opt::toString);
+ } catch (const std::exception& e) {
+ OPENVINO_THROW("Failed to parse '", Opt::key().data(), "' option : ", e.what());
+ }
+}
+
template <class Opt>
OptionConcept makeOptionModel(
std::optional<std::function<bool(std::string_view)>> customValueCheckerOpt = std::nullopt) {
@@ -414,7 +428,8 @@ OptionConcept makeOptionModel(
&Opt::mutability,
&Opt::compilerSupportVersion,
&Opt::isValueSupported,
- &validateAndParse<Opt>,
+ &validateAndParseFromString<Opt>,
+ &validateAndParseFromAny<Opt>,
std::move(customValueCheckerOpt)};
}
@@ -473,6 +488,8 @@ public:
virtual void update(const ConfigMap& options);
+ virtual void updateAny(const ov::AnyMap& options);
+
void parseEnvVars();
template <class Opt>
diff --git a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
index d38968eaff2..375e453d373 100644
--- a/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
+++ b/src/plugins/intel_npu/src/al/include/intel_npu/config/options.hpp
@@ -1539,4 +1539,34 @@ struct SHARED_COMMON_QUEUE final : OptionBase<SHARED_COMMON_QUEUE, bool> {
}
};
+struct CACHE_ENCRYPTION_CALLBACKS final : OptionBase<CACHE_ENCRYPTION_CALLBACKS, ov::EncryptionCallbacks> {
+ static std::string_view key() {
+ return ov::cache_encryption_callbacks.name();
+ }
+
+ static constexpr std::string_view getTypeName() {
+ return "ov::EncryptionCallbacks";
+ }
+
+ static OptionMode mode() {
+ return OptionMode::RunTime;
+ }
+
+ static bool isPublic() {
+ return true;
+ }
+
+ static std::string toString(const ov::EncryptionCallbacks&) {
+ OPENVINO_THROW("Option ", ov::cache_encryption_callbacks.name(), " cannot be converted to string");
+ }
+
+ static ov::EncryptionCallbacks parse(std::string_view) {
+ OPENVINO_THROW("Option ", ov::cache_encryption_callbacks.name(), " cannot be parsed from string");
+ }
+
+ static ov::PropertyMutability mutability() {
+ return ov::PropertyMutability::WO;
+ }
+};
+
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/al/src/config/config.cpp b/src/plugins/intel_npu/src/al/src/config/config.cpp
index a505f3a602f..1f2729d4921 100644
--- a/src/plugins/intel_npu/src/al/src/config/config.cpp
+++ b/src/plugins/intel_npu/src/al/src/config/config.cpp
@@ -245,7 +245,7 @@ void Config::parseEnvVars() {
envVar,
opt.envVar().data());
- _impl[opt.key().data()] = opt.validateAndParse(envVar);
+ _impl[opt.key().data()] = opt.validateAndParseFromString(envVar);
}
}
});
@@ -260,7 +260,16 @@ void Config::update(const ConfigMap& options) {
_log.trace("Update option '%s' to value '%s'", p.first.c_str(), p.second.c_str());
const auto opt = _desc->get(p.first);
- _impl[opt.key().data()] = opt.validateAndParse(p.second);
+ _impl[opt.key().data()] = opt.validateAndParseFromString(p.second);
+ }
+}
+
+void Config::updateAny(const ov::AnyMap& options) {
+ for (const auto& p : options) {
+ _log.trace("Update option '%s' to given 'ov::Any' value", p.first.c_str());
+
+ const auto opt = _desc->get(p.first);
+ _impl[opt.key().data()] = opt.validateAndParseFromAny(p.second);
}
}
diff --git a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp b/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp
index ee5cda6ea5d..da70d6c1dbd 100644
--- a/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp
+++ b/src/plugins/intel_npu/src/common/include/intel_npu/common/filtered_config.hpp
@@ -35,6 +35,14 @@ public:
*/
void update(const ConfigMap& options) override;
+ /**
+ * @brief Additional update method for properties that don't have their values convertible to string objects.
+ * @note In the future, code will be refactored to use only this update method to optimize redundant flow
+ * ov::Any-->std::string-->Opt::ValueType
+ * @param options A map of key-value pairs representing the new configuration options.
+ */
+ void updateAny(const ov::AnyMap& options) override;
+
/**
* @brief Checks if a specific option exists in the configuration's descriptorDesc.
* @param key The key of the option to check.
diff --git a/src/plugins/intel_npu/src/common/src/filtered_config.cpp b/src/plugins/intel_npu/src/common/src/filtered_config.cpp
index 0c3f92995d7..eafe2b4ecf7 100644
--- a/src/plugins/intel_npu/src/common/src/filtered_config.cpp
+++ b/src/plugins/intel_npu/src/common/src/filtered_config.cpp
@@ -32,7 +32,22 @@ void FilteredConfig::update(const ConfigMap& options) {
if (isAvailable(p.first)) {
const auto opt = _desc->get(p.first);
- _impl[opt.key().data()] = opt.validateAndParse(p.second);
+ _impl[opt.key().data()] = opt.validateAndParseFromString(p.second);
+ } else {
+ OPENVINO_THROW("[ NOT_FOUND ] Option '" + p.first + "' is not supported for current configuration");
+ }
+ }
+}
+
+void FilteredConfig::updateAny(const ov::AnyMap& options) {
+ auto log = Logger::global().clone("Config");
+
+ for (const auto& p : options) {
+ log.trace("Update option '%s' to given 'ov::Any' value", p.first.c_str());
+
+ if (isAvailable(p.first)) {
+ const auto opt = _desc->get(p.first);
+ _impl[opt.key().data()] = opt.validateAndParseFromAny(p.second);
} else {
OPENVINO_THROW("[ NOT_FOUND ] Option '" + p.first + "' is not supported for current configuration");
}
diff --git a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
index 735e74e05da..0dd6d4df308 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/include/ze_graph_ext_wrappers.hpp
@@ -40,7 +40,8 @@ public:
GraphDescriptor getGraphDescriptor(SerializedIR serializedIR,
const std::string& buildFlags,
- const bool bypassUmdCache = false) const;
+ const bool bypassUmdCache = false,
+ const bool secureCompile = false) const;
GraphDescriptor getGraphDescriptor(const void* data, size_t size) const;
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp
index a606bdb6bf9..f00aabaf86a 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/driver_compiler_adapter.cpp
@@ -82,7 +82,10 @@ std::shared_ptr<IGraph> DriverCompilerAdapter::compile(const std::shared_ptr<con
_logger.debug("compile start");
// If UMD Caching is requested to be bypassed or if OV cache is enabled, disable driver caching
const bool bypassCache = !updatedConfig.get<CACHE_DIR>().empty() || updatedConfig.get<BYPASS_UMD_CACHING>();
- auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, bypassCache);
+ // If blob encryption is requested, enable secure compilation in the driver
+ const bool secureCompile = updatedConfig.has(CACHE_ENCRYPTION_CALLBACKS::key().data()) &&
+ updatedConfig.get<CACHE_ENCRYPTION_CALLBACKS>().encrypt != nullptr;
+ auto graphDesc = _zeGraphExt->getGraphDescriptor(std::move(serializedIR), buildFlags, bypassCache, secureCompile);
_logger.debug("compile end");
OV_ITT_TASK_NEXT(COMPILE_BLOB, "getNetworkMeta");
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
index 5535698d952..0e7ed6e518d 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/dynamic_graph.cpp
@@ -473,9 +473,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> DynamicGraph::export_b
result = ((result << 7) + result) + static_cast<uint32_t>(*it);
}
- std::stringstream str;
- str << "Blob size: " << blobSize << ", hash: " << std::hex << result;
- _logger.info(str.str().c_str());
+ _logger.info("Blob size: %zu, hash: %x", blobSize, result);
}
size_t size = utils::align_size_to_standard_page_size(blobSize);
@@ -486,7 +484,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> DynamicGraph::export_b
_logger.error("Write padding to stream failed. Blob is broken!");
return std::make_pair(0, std::nullopt);
}
- _logger.info("Blob size with padding: %ld", size);
+ _logger.info("Blob size with padding: %zu", size);
}
_logger.info("Write blob to stream successfully.");
return std::make_pair(size, std::nullopt);
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
index a03d8421bc8..198d019fcdc 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/graph.cpp
@@ -119,10 +119,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> Graph::export_blob(std
for (const uint8_t* it = blobPtr; it != blobPtr + blobSize; ++it) {
result = ((result << 7) + result) + static_cast<uint32_t>(*it);
}
-
- std::stringstream str;
- str << "Blob size: " << blobSize << ", hash: " << std::hex << result;
- _logger.info(str.str().c_str());
+ _logger.info("Blob size: %zu, hash: %x", blobSize, result);
}
size_t size = utils::align_size_to_standard_page_size(blobSize);
@@ -135,7 +132,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> Graph::export_blob(std
return std::make_pair(0, std::nullopt);
}
- _logger.info("Blob size with padding: %ld", size);
+ _logger.info("Blob size with padding: %zu", size);
}
_logger.info("Write blob to stream successfully.");
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
index ca6a73f7d4d..0f8f6e6e119 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/weightless_graph.cpp
@@ -4,6 +4,7 @@
#include "weightless_graph.hpp"
+#include <cinttypes>
#include <condition_variable>
#include <iterator>
#include <mutex>
@@ -235,13 +236,11 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> WeightlessGraph::expor
totalResult += result;
- std::stringstream str;
if (blobIndex == MAIN_SCHEDULE_INDEX) {
- str << "Main blob size " << blobSize << ", hash " << std::hex << result;
+ _wgLogger.info("Main blob size: %" PRIu64 ", hash: %x", blobSize, result);
} else {
- str << "Init part " << blobIndex << " blob size " << blobSize << ", hash " << std::hex << result;
+ _wgLogger.info("Init part %zu blob size %" PRIu64 ", hash: %x", blobIndex, blobSize, result);
}
- _wgLogger.info(str.str().c_str());
}
size_t size = utils::align_size_to_standard_page_size(blobSize);
@@ -254,7 +253,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> WeightlessGraph::expor
return 0;
}
- _wgLogger.info("Blob size with padding: %ld", size);
+ _wgLogger.info("Blob size with padding: %zu", size);
}
return size;
@@ -277,9 +276,7 @@ std::pair<uint64_t, std::optional<std::vector<uint64_t>>> WeightlessGraph::expor
++blobIndex;
}
- std::stringstream str;
- str << "Blob size: " << totalBlobSize << ", hash: " << std::hex << totalResult;
- _wgLogger.info(str.str().c_str());
+ _wgLogger.info("Blob size: %" PRIu64 ", hash: %x", totalBlobSize, totalResult);
_wgLogger.info("Write blob to stream successfully.");
return std::make_pair(totalBlobSize, initSizes);
diff --git a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
index 4be4cd31a00..371e0ea8b44 100644
--- a/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
+++ b/src/plugins/intel_npu/src/compiler_adapter/src/ze_graph_ext_wrappers.cpp
@@ -384,7 +384,8 @@ bool ZeGraphExtWrappers::canCpuVaBeImported(const void* data, size_t size) const
GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR,
const std::string& buildFlags,
- const bool bypassUmdCache) const {
+ const bool bypassUmdCache,
+ const bool secureCompile) const {
ze_graph_handle_t graphHandle = nullptr;
void* pNext = nullptr;
ze_graph_input_hash_t modelHash;
@@ -398,6 +399,15 @@ GraphDescriptor ZeGraphExtWrappers::getGraphDescriptor(SerializedIR serializedIR
_logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_DISABLE_CACHING");
flags |= ZE_GRAPH_FLAG_DISABLE_CACHING;
}
+ if (secureCompile) {
+ if (_graphExtVersion < ZE_MAKE_VERSION(1, 17)) {
+ _logger.warning("Secure compilation was requested, but the current driver version does not support it. "
+ "Ignoring the flag.");
+ } else {
+ _logger.debug("getGraphDescriptor - set ZE_GRAPH_FLAG_SECURE_COMPILE");
+ flags |= ZE_GRAPH_FLAG_SECURE_COMPILE;
+ }
+ }
ze_graph_desc_2_t desc = {ZE_STRUCTURE_TYPE_GRAPH_DESC_2,
pNext,
diff --git a/src/plugins/intel_npu/src/plugin/include/metadata.hpp b/src/plugins/intel_npu/src/plugin/include/metadata.hpp
index fb350ef0246..8b109d3b336 100644
--- a/src/plugins/intel_npu/src/plugin/include/metadata.hpp
+++ b/src/plugins/intel_npu/src/plugin/include/metadata.hpp
@@ -60,6 +60,8 @@ public:
virtual std::optional<uint32_t> get_compiler_version() const;
+ virtual bool is_encrypted_blob() const;
+
virtual ~MetadataBase() = default;
static std::streampos getFileSize(std::istream& stream);
@@ -139,11 +141,12 @@ constexpr uint32_t METADATA_VERSION_2_1{MetadataBase::make_version(2, 1)};
constexpr uint32_t METADATA_VERSION_2_2{MetadataBase::make_version(2, 2)};
constexpr uint32_t METADATA_VERSION_2_3{MetadataBase::make_version(2, 3)};
constexpr uint32_t METADATA_VERSION_2_4{MetadataBase::make_version(2, 4)};
+constexpr uint32_t METADATA_VERSION_2_5{MetadataBase::make_version(2, 5)};
/**
* @brief Current metadata version.
*/
-constexpr uint32_t CURRENT_METADATA_VERSION{METADATA_VERSION_2_4};
+constexpr uint32_t CURRENT_METADATA_VERSION{METADATA_VERSION_2_5};
constexpr uint16_t CURRENT_METADATA_MAJOR_VERSION{MetadataBase::get_major(CURRENT_METADATA_VERSION)};
constexpr uint16_t CURRENT_METADATA_MINOR_VERSION{MetadataBase::get_minor(CURRENT_METADATA_VERSION)};
@@ -274,8 +277,8 @@ class Metadata<METADATA_VERSION_2_2> : public Metadata<METADATA_VERSION_2_1> {
public:
Metadata(uint64_t blobSize,
std::optional<OpenvinoVersion> ovVersion = std::nullopt,
- const std::optional<std::vector<uint64_t>> initSizes = std::nullopt,
- const std::optional<int64_t> batchSize = std::nullopt);
+ const std::optional<std::vector<uint64_t>>& initSizes = std::nullopt,
+ const std::optional<int64_t>& batchSize = std::nullopt);
void read() override;
@@ -299,7 +302,7 @@ public:
Metadata(uint64_t blobSize,
const std::optional<OpenvinoVersion>& ovVersion = std::nullopt,
const std::optional<std::vector<uint64_t>>& initSizes = std::nullopt,
- const std::optional<int64_t> batchSize = std::nullopt,
+ const std::optional<int64_t>& batchSize = std::nullopt,
const std::optional<std::vector<ov::Layout>>& inputLayouts = std::nullopt,
const std::optional<std::vector<ov::Layout>>& outputLayouts = std::nullopt);
@@ -327,10 +330,10 @@ public:
Metadata(uint64_t blobSize,
const std::optional<OpenvinoVersion>& ovVersion = std::nullopt,
const std::optional<std::vector<uint64_t>>& initSizes = std::nullopt,
- const std::optional<int64_t> batchSize = std::nullopt,
+ const std::optional<int64_t>& batchSize = std::nullopt,
const std::optional<std::vector<ov::Layout>>& inputLayouts = std::nullopt,
const std::optional<std::vector<ov::Layout>>& outputLayouts = std::nullopt,
- const std::optional<uint32_t> compilerVersion = std::nullopt);
+ const std::optional<uint32_t>& compilerVersion = std::nullopt);
void read() override;
@@ -344,6 +347,34 @@ private:
std::optional<uint32_t> _compilerVersion;
};
+/**
+ * @brief Checks whether raw blob is encrypted or not.
+ * @details Ignores unencrypted main blob size and stores the size after encryption instead if it is not nullopt.
+ */
+template <>
+class Metadata<METADATA_VERSION_2_5> : public Metadata<METADATA_VERSION_2_4> {
+public:
+ Metadata(uint64_t blobSize,
+ const std::optional<OpenvinoVersion>& ovVersion = std::nullopt,
+ const std::optional<std::vector<uint64_t>>& initSizes = std::nullopt,
+ const std::optional<int64_t>& batchSize = std::nullopt,
+ const std::optional<std::vector<ov::Layout>>& inputLayouts = std::nullopt,
+ const std::optional<std::vector<ov::Layout>>& outputLayouts = std::nullopt,
+ const std::optional<uint32_t>& compilerVersion = std::nullopt,
+ const std::optional<uint64_t>& blobSizeAfterEncryption = std::nullopt);
+
+ void read() override;
+
+ void write(std::ostream& stream) override;
+
+ size_t get_metadata_size() const override;
+
+ bool is_encrypted_blob() const override;
+
+private:
+ bool _isEncryptedBlob;
+};
+
/**
* @brief Creates a Metadata object.
*
diff --git a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
index e813a41d71c..ecf4b7b9168 100644
--- a/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/compiled_model.cpp
@@ -4,6 +4,7 @@
#include "compiled_model.hpp"
+#include <cinttypes>
#include <fstream>
#include <string_view>
@@ -11,6 +12,7 @@
#include "intel_npu/common/itt.hpp"
#include "intel_npu/config/config.hpp"
#include "intel_npu/config/options.hpp"
+#include "intel_npu/utils/utils.hpp"
#include "metadata.hpp"
#include "openvino/pass/constant_folding.hpp"
#include "openvino/runtime/properties.hpp"
@@ -82,7 +84,37 @@ std::shared_ptr<ov::ISyncInferRequest> CompiledModel::create_sync_infer_request(
void CompiledModel::export_model(std::ostream& stream) const {
_logger.debug("CompiledModel::export_model");
- auto [blobSizesBeforeVersioning, initBlobSizes] = _graph->export_blob(stream);
+ uint64_t blobSizesBeforeVersioning;
+ std::optional<uint64_t> blobSizeAfterEncryption = std::nullopt;
+ std::optional<std::vector<uint64_t>> initBlobSizes;
+
+ if (_propertiesManager->getConfig().has(CACHE_ENCRYPTION_CALLBACKS::key().data()) &&
+ _propertiesManager->getConfig().get<CACHE_ENCRYPTION_CALLBACKS>().encrypt != nullptr) {
+ std::string encryptedBlobStr;
+ {
+ std::string tmpBlobStr;
+ {
+ std::stringstream tmpStringStream;
+ std::tie(blobSizesBeforeVersioning, initBlobSizes) =
+ _graph->export_blob(tmpStringStream); // +1x blob size
+ tmpBlobStr = tmpStringStream.str(); // +2x blob size
+ } // -1x blob size when deallocating temporary stringstream
+ encryptedBlobStr =
+ _propertiesManager->getConfig().get<CACHE_ENCRYPTION_CALLBACKS>().encrypt(tmpBlobStr); // +2x blob size
+ blobSizeAfterEncryption = encryptedBlobStr.size();
+ if (blobSizeAfterEncryption.value() % utils::STANDARD_PAGE_SIZE != 0) {
+ _logger.warning("Encrypted blob size %" PRIu64
+ " is not page aligned, memory optimization when reading this blob "
+ "won't be applied",
+ blobSizeAfterEncryption.value());
+ }
+ } // -1x blob size when deallocating temporary blob string
+ stream.write(encryptedBlobStr.c_str(), encryptedBlobStr.size());
+ } // -1x blob size when deallocating encrypted blob string
+ else {
+ // Write blob directly to user's output stream
+ std::tie(blobSizesBeforeVersioning, initBlobSizes) = _graph->export_blob(stream);
+ }
if (!_propertiesManager->getConfig().get<EXPORT_RAW_BLOB>()) {
std::optional<std::vector<ov::Layout>> inputLayouts = std::vector<ov::Layout>();
@@ -104,11 +136,12 @@ void CompiledModel::export_model(std::ostream& stream) const {
Metadata<CURRENT_METADATA_VERSION>(blobSizesBeforeVersioning,
CURRENT_OPENVINO_VERSION,
- std::move(initBlobSizes),
+ initBlobSizes,
_batchSize,
- std::move(inputLayouts),
- std::move(outputLayouts),
- compilerVersion)
+ inputLayouts,
+ outputLayouts,
+ compilerVersion,
+ blobSizeAfterEncryption)
.write(stream);
}
}
diff --git a/src/plugins/intel_npu/src/plugin/src/metadata.cpp b/src/plugins/intel_npu/src/plugin/src/metadata.cpp
index 94c08db06ba..68ad662fed6 100644
--- a/src/plugins/intel_npu/src/plugin/src/metadata.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/metadata.cpp
@@ -76,8 +76,8 @@ Metadata<METADATA_VERSION_2_1>::Metadata(uint64_t blobSize,
Metadata<METADATA_VERSION_2_2>::Metadata(uint64_t blobSize,
std::optional<OpenvinoVersion> ovVersion,
- const std::optional<std::vector<uint64_t>> initSizes,
- const std::optional<int64_t> batchSize)
+ const std::optional<std::vector<uint64_t>>& initSizes,
+ const std::optional<int64_t>& batchSize)
: Metadata<METADATA_VERSION_2_1>{blobSize, ovVersion, initSizes},
_batchSize{batchSize} {
_version = METADATA_VERSION_2_2;
@@ -86,7 +86,7 @@ Metadata<METADATA_VERSION_2_2>::Metadata(uint64_t blobSize,
Metadata<METADATA_VERSION_2_3>::Metadata(uint64_t blobSize,
const std::optional<OpenvinoVersion>& ovVersion,
const std::optional<std::vector<uint64_t>>& initSizes,
- const std::optional<int64_t> batchSize,
+ const std::optional<int64_t>& batchSize,
const std::optional<std::vector<ov::Layout>>& inputLayouts,
const std::optional<std::vector<ov::Layout>>& outputLayouts)
: Metadata<METADATA_VERSION_2_2>{blobSize, ovVersion, initSizes, batchSize},
@@ -98,15 +98,34 @@ Metadata<METADATA_VERSION_2_3>::Metadata(uint64_t blobSize,
Metadata<METADATA_VERSION_2_4>::Metadata(uint64_t blobSize,
const std::optional<OpenvinoVersion>& ovVersion,
const std::optional<std::vector<uint64_t>>& initSizes,
- const std::optional<int64_t> batchSize,
+ const std::optional<int64_t>& batchSize,
const std::optional<std::vector<ov::Layout>>& inputLayouts,
const std::optional<std::vector<ov::Layout>>& outputLayouts,
- const std::optional<uint32_t> compilerVersion)
+ const std::optional<uint32_t>& compilerVersion)
: Metadata<METADATA_VERSION_2_3>{blobSize, ovVersion, initSizes, batchSize, inputLayouts, outputLayouts},
_compilerVersion{compilerVersion} {
_version = METADATA_VERSION_2_4;
}
+Metadata<METADATA_VERSION_2_5>::Metadata(uint64_t blobSize,
+ const std::optional<OpenvinoVersion>& ovVersion,
+ const std::optional<std::vector<uint64_t>>& initSizes,
+ const std::optional<int64_t>& batchSize,
+ const std::optional<std::vector<ov::Layout>>& inputLayouts,
+ const std::optional<std::vector<ov::Layout>>& outputLayouts,
+ const std::optional<uint32_t>& compilerVersion,
+ const std::optional<uint64_t>& blobSizeAfterEncryption)
+ : Metadata<METADATA_VERSION_2_4>{blobSizeAfterEncryption.has_value() ? blobSizeAfterEncryption.value() : blobSize,
+ ovVersion,
+ initSizes,
+ batchSize,
+ inputLayouts,
+ outputLayouts,
+ compilerVersion},
+ _isEncryptedBlob{blobSizeAfterEncryption.has_value()} {
+ _version = METADATA_VERSION_2_5;
+}
+
void MetadataBase::read(std::istream& tensor) {
_source = Source(tensor);
read();
@@ -220,6 +239,15 @@ void Metadata<METADATA_VERSION_2_4>::read() {
_compilerVersion = compilerVersion != 0 ? std::optional(compilerVersion) : std::nullopt;
}
+void Metadata<METADATA_VERSION_2_5>::read() {
+ Metadata<METADATA_VERSION_2_4>::read();
+
+ uint8_t isEncryptedBlob;
+ read_data_from_source(reinterpret_cast<char*>(&isEncryptedBlob), sizeof(isEncryptedBlob));
+
+ _isEncryptedBlob = isEncryptedBlob;
+}
+
void Metadata<METADATA_VERSION_2_0>::write(std::ostream& stream) {
stream.write(reinterpret_cast<const char*>(&_version), sizeof(_version));
_ovVersion.write(stream);
@@ -273,6 +301,13 @@ void Metadata<METADATA_VERSION_2_4>::write(std::ostream& stream) {
uint32_t compilerVersion = _compilerVersion.value_or(0);
stream.write(reinterpret_cast<const char*>(&compilerVersion), sizeof(compilerVersion));
+}
+
+void Metadata<METADATA_VERSION_2_5>::write(std::ostream& stream) {
+ Metadata<METADATA_VERSION_2_4>::write(stream);
+
+ const uint8_t isEncryptedBlob = _isEncryptedBlob;
+ stream.write(reinterpret_cast<const char*>(&isEncryptedBlob), sizeof(isEncryptedBlob));
append_blob_size_and_magic(stream);
}
@@ -301,6 +336,8 @@ std::unique_ptr<MetadataBase> create_metadata(uint32_t version, uint64_t blobSiz
return std::make_unique<Metadata<METADATA_VERSION_2_3>>(blobSize);
case METADATA_VERSION_2_4:
return std::make_unique<Metadata<METADATA_VERSION_2_4>>(blobSize);
+ case METADATA_VERSION_2_5:
+ return std::make_unique<Metadata<METADATA_VERSION_2_5>>(blobSize);
default:
return nullptr;
}
@@ -424,6 +461,10 @@ std::optional<uint32_t> MetadataBase::get_compiler_version() const {
return std::nullopt;
}
+bool MetadataBase::is_encrypted_blob() const {
+ return false;
+}
+
std::optional<std::vector<uint64_t>> Metadata<METADATA_VERSION_2_1>::get_init_sizes() const {
return _initSizes;
}
@@ -444,6 +485,10 @@ std::optional<uint32_t> Metadata<METADATA_VERSION_2_4>::get_compiler_version() c
return _compilerVersion;
}
+bool Metadata<METADATA_VERSION_2_5>::is_encrypted_blob() const {
+ return _isEncryptedBlob;
+}
+
size_t Metadata<METADATA_VERSION_2_0>::get_metadata_size() const {
return sizeof(_version) + _ovVersion.get_openvino_version_size();
}
@@ -488,4 +533,12 @@ size_t Metadata<METADATA_VERSION_2_4>::get_metadata_size() const {
return Metadata<METADATA_VERSION_2_3>::get_metadata_size() + sizeof(_compilerVersion.value());
}
+size_t Metadata<METADATA_VERSION_2_5>::get_metadata_size() const {
+ size_t metadataSize = Metadata<METADATA_VERSION_2_4>::get_metadata_size() +
+ sizeof(uint8_t); // intermediate uint8_t will be used to write bool due to possible platform
+ // different sizes of bool
+
+ return metadataSize;
+}
+
} // namespace intel_npu
diff --git a/src/plugins/intel_npu/src/plugin/src/plugin.cpp b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
index 0fa70372e04..c29be097fb1 100644
--- a/src/plugins/intel_npu/src/plugin/src/plugin.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/plugin.cpp
@@ -4,6 +4,9 @@
#include "plugin.hpp"
+#include <fstream>
+#include <numeric>
+
#include "compiled_model.hpp"
#include "intel_npu/common/compiler_adapter_factory.hpp"
#include "intel_npu/common/device_helpers.hpp"
@@ -253,6 +256,7 @@ void init_config(const IEngineBackend* backend, OptionsDesc& options, FilteredCo
REGISTER_OPTION(MODEL_SERIALIZER_VERSION);
REGISTER_OPTION(ENABLE_STRIDES_FOR);
REGISTER_OPTION(SHARED_COMMON_QUEUE);
+ REGISTER_OPTION(CACHE_ENCRYPTION_CALLBACKS);
if (backend) {
// Options registered only if drivers is present and supports the corresponding extension
@@ -415,8 +419,8 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
}
}
- // ov::hint::model has no corresponding "Config" implementation thus we need to remove it from the
- // list of properties
+ // ov::hint::model has no corresponding "Config" implementation thus we need to
+ // remove it from the list of properties
if (exclude_model_ptr_from_map(localProperties)) {
_logger.warning("Model received in config will be ignored as it was already provided by parameter.");
}
@@ -533,11 +537,11 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
const bool cacheModeOptimizeSize = (localConfig.get<CACHE_MODE>() == ov::CacheMode::OPTIMIZE_SIZE);
if (localConfig.get<ENABLE_WEIGHTLESS>() && !cacheModeOptimizeSize) {
_logger.warning(
- "The cache mode was not set to \"optimize size\" but the \"ENABLE_WEIGHTLESS\" configuration option"
+ "The cache mode was not set to \"optimize size\" but the \"ENABLE_WEIGHTLESS\" configuration option "
"was set to true. Weights separation WILL NOT be performed in this case.");
} else if (!localConfig.get<ENABLE_WEIGHTLESS>() && cacheModeOptimizeSize) {
_logger.warning(
- "The cache mode was set to \"optimize size\" but the \"ENABLE_WEIGHTLESS\" configuration option"
+ "The cache mode was set to \"optimize size\" but the \"ENABLE_WEIGHTLESS\" configuration option "
"was set to false. Weights separation WILL be performed in this case.");
}
@@ -603,6 +607,13 @@ std::shared_ptr<ov::ICompiledModel> Plugin::compile_model(const std::shared_ptr<
}
}
+ if (localConfig.has(CACHE_ENCRYPTION_CALLBACKS::key().data()) &&
+ !localConfig.get<CACHE_ENCRYPTION_CALLBACKS>().encrypt) {
+ _logger.warning("Encryption callbacks were provided for compiled model creation, but the encrypt "
+ "callback is null. Proceeding with unencrypted compilation; encrypted blob export "
+ "will be disabled.");
+ }
+
std::shared_ptr<ov::ICompiledModel> compiledModel;
try {
compiledModel = std::make_shared<CompiledModel>(model, shared_from_this(), device, graph, localConfig, batch);
@@ -681,6 +692,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(std::istream& stream, c
} else {
_logger.info("Blob compatibility check skipped.");
}
+ OPENVINO_ASSERT(blobSize > 0, "Parsed blob size is empty from the given stream!");
ov::Allocator customAllocator{utils::AlignedAllocator{utils::STANDARD_PAGE_SIZE}};
ov::Tensor tensor(ov::element::u8, ov::Shape{blobSize}, customAllocator);
@@ -745,6 +757,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::import_model(const ov::Tensor& compi
} else {
_logger.info("Blob compatibility check skipped.");
}
+ OPENVINO_ASSERT(blobSize > 0, "Parsed blob size is empty from the given buffer!");
const ov::Tensor roiTensor(compiledBlob,
ov::Coordinate{0},
ov::Coordinate{blobSize}); // ROI tensor to skip NPU plugin metadata
@@ -816,8 +829,8 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
auto localProperties = properties;
- // ov::hint::model has no corresponding "Config" implementation thus we need to remove it from the
- // list of properties
+ // ov::hint::model has no corresponding "Config" implementation thus we need to
+ // remove it from the list of properties
auto originalModel = exclude_model_ptr_from_map(localProperties);
std::shared_ptr<IDevice> device =
@@ -836,11 +849,47 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
"The usage of a compiled model can lead to undefined behavior. Please use OpenVINO IR instead!");
}
- uint64_t mainSize = tensorBig.get_byte_size();
+ const bool isNotNullDecryption = localConfig.has(CACHE_ENCRYPTION_CALLBACKS::key().data()) &&
+ localConfig.get<CACHE_ENCRYPTION_CALLBACKS>().decrypt != nullptr;
+ if (!metadata && isNotNullDecryption) {
+ _logger.warning(
+ "Received decryption callback, but metadata parsing is skipped and cannot determine if blob was "
+ "encrypted or not.");
+ }
+
+ ov::Tensor tensor = tensorBig;
+ if (isNotNullDecryption && (metadata == nullptr || (metadata != nullptr && metadata->is_encrypted_blob()))) {
+ {
+ std::string decryptedBlobStr;
+ {
+ std::string encryptedBlobStr(tensor.data<const char>(), tensor.get_byte_size()); // +1x blob size
+ decryptedBlobStr =
+ localConfig.get<CACHE_ENCRYPTION_CALLBACKS>().decrypt(encryptedBlobStr); // +2x blob size
+ } // -1x blob size when deallocating temporary encrypted blob string
+ ov::Allocator customAllocator{utils::AlignedAllocator{utils::STANDARD_PAGE_SIZE}};
+ size_t alignedSize = utils::align_size_to_standard_page_size(decryptedBlobStr.size());
+ size_t paddingSize = alignedSize - decryptedBlobStr.size();
+ tensor = ov::Tensor(ov::element::u8, ov::Shape{alignedSize},
+ customAllocator); // +1x blob size
+ std::memcpy(tensor.data<char>(), decryptedBlobStr.c_str(), decryptedBlobStr.size());
+ if (paddingSize > 0) {
+ // If user altered in some way initial blob during encryption, check if its size is still paged aligned
+ _logger.warning("Decrypted blob size was not page aligned, additional %zu bytes padding will be added",
+ paddingSize);
+ std::memset(tensor.data<char>() + decryptedBlobStr.size(), 0, paddingSize);
+ }
+ } // -1x blob size when deallocating decrypted blob string
+ }
+
+ uint64_t mainSize = tensor.get_byte_size();
std::optional<std::vector<uint64_t>> initSizes;
std::optional<int64_t> batchSize = std::nullopt;
if (metadata) {
+ if (metadata->is_encrypted_blob() && !isNotNullDecryption) {
+ OPENVINO_THROW("Blob is encrypted, but no decryption callback was provided!");
+ }
+
size_t accumulator = 0;
initSizes = metadata->get_init_sizes();
mainSize = initSizes.has_value()
@@ -856,10 +905,11 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
ONEAPI_VERSION_MINOR(compilerVersion.value()));
}
} else {
- _logger.info("Blob compatibility check skipped.");
+ _logger.warning(
+ "Metadata parsing is skipped, if this is a weightless blob, init schedules cannot be parsed from it!");
}
- const ov::Tensor tensorMain(tensorBig,
+ const ov::Tensor tensorMain(tensor,
ov::Coordinate{0},
ov::Coordinate{mainSize}); // ROI tensor to skip NPU plugin metadata
@@ -870,7 +920,7 @@ std::shared_ptr<ov::ICompiledModel> Plugin::parse(const ov::Tensor& tensorBig,
// Read the init compiled models as well
size_t cursorPosition = mainSize;
for (uint64_t initSize : initSizes.value()) {
- const ov::Tensor tensorInit(tensorBig,
+ const ov::Tensor tensorInit(tensor,
ov::Coordinate{cursorPosition},
ov::Coordinate{cursorPosition + initSize});
tensorsInits.push_back(tensorInit);
diff --git a/src/plugins/intel_npu/src/plugin/src/properties.cpp b/src/plugins/intel_npu/src/plugin/src/properties.cpp
index 84d0663012d..9bcc32974e3 100644
--- a/src/plugins/intel_npu/src/plugin/src/properties.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/properties.cpp
@@ -16,10 +16,6 @@ namespace {
std::map<std::string, std::string> any_copy(const ov::AnyMap& params) {
std::map<std::string, std::string> result;
for (auto&& value : params) {
- // The value of cache_encryption_callbacks cannot be converted to std::string
- if (value.first == ov::cache_encryption_callbacks.name()) {
- continue;
- }
result.emplace(value.first, value.second.as<std::string>());
}
return result;
@@ -599,6 +595,18 @@ void Properties::registerPluginProperties() {
return std::shared_ptr<const ov::Model>(nullptr);
});
+ FORCE_REGISTER_CUSTOM_PROPERTY(
+ ov::cache_encryption_callbacks,
+ CACHE_ENCRYPTION_CALLBACKS,
+ true,
+ ov::PropertyMutability::WO,
+ [](const Config& /* unusedConfig */) {
+ return (ov::EncryptionCallbacks{
+ nullptr,
+ nullptr}); // enclosed in parentheses due to warning C4002 treated as error: too many arguments for
+ // function-like macro invocation 'FORCE_REGISTER_CUSTOM_PROPERTY'
+ });
+
// NPUW properties are requested by OV Core during caching and have no effect on the NPU plugin. But we still need
// to enable those for OV Core to query.
for_each_exposed_npuw_option([&](auto tag) {
@@ -788,6 +796,18 @@ void Properties::registerCompiledModelProperties() {
return std::shared_ptr<const ov::Model>(nullptr);
});
+ FORCE_REGISTER_CUSTOM_PROPERTY(
+ ov::cache_encryption_callbacks,
+ CACHE_ENCRYPTION_CALLBACKS,
+ true,
+ ov::PropertyMutability::WO,
+ [](const Config& /* unusedConfig */) {
+ return (ov::EncryptionCallbacks{
+ nullptr,
+ nullptr}); // enclosed in parentheses due to warning C4002 treated as error: too many arguments for
+ // function-like macro invocation 'FORCE_REGISTER_CUSTOM_PROPERTY'
+ });
+
// 2. Metrics (static device and enviroment properties)
// ========
// REGISTER_SIMPLE_METRIC format: (property, public true/false, return value)
@@ -875,6 +895,11 @@ ov::Any Properties::getProperty(const std::string& name) {
auto&& configIterator = _properties.find(name);
if (configIterator != _properties.cend()) {
+ if (std::get<1>(configIterator->second) == ov::PropertyMutability::WO) {
+ _logger.warning("Trying to get WRITE-ONLY property: %s. Returning empty `ov::Any` object",
+ name.c_str()); // throw OV exception instead
+ return ov::Any();
+ }
return std::get<2>(configIterator->second)(_config);
}
try {
@@ -943,6 +968,7 @@ void Properties::setProperty(const ov::AnyMap& properties) {
}
std::map<std::string, std::string> cfgs_to_set;
+ ov::AnyMap special_cfgs_to_set;
for (auto&& value : properties) {
if (_properties.find(value.first) == _properties.end()) {
// property doesn't exist
@@ -960,6 +986,8 @@ void Properties::setProperty(const ov::AnyMap& properties) {
} else {
if (std::get<1>(_properties[value.first]) == ov::PropertyMutability::RO) {
OPENVINO_THROW("READ-ONLY configuration key: ", value.first);
+ } else if (value.first == ov::cache_encryption_callbacks.name()) {
+ special_cfgs_to_set.emplace(value.first, value.second);
} else {
cfgs_to_set.emplace(value.first, value.second.as<std::string>());
}
@@ -969,6 +997,10 @@ void Properties::setProperty(const ov::AnyMap& properties) {
if (!cfgs_to_set.empty()) {
_config.update(cfgs_to_set);
}
+
+ if (!special_cfgs_to_set.empty()) {
+ _config.updateAny(special_cfgs_to_set);
+ }
}
bool Properties::isPropertySupported(const std::string& name) {
@@ -1083,6 +1115,7 @@ FilteredConfig Properties::getConfigForSpecificCompiler(const ov::AnyMap& proper
const std::map<std::string, std::string> rawConfig = any_copy(properties);
std::map<std::string, std::string> cfgsToSet;
+ ov::AnyMap specialCfgsToSet;
for (const auto& [key, value] : rawConfig) {
if (!updatedConfig.hasOpt(key)) {
// not a known config key
@@ -1091,12 +1124,15 @@ FilteredConfig Properties::getConfigForSpecificCompiler(const ov::AnyMap& proper
} else {
updatedConfig.addOrUpdateInternal(key, value);
}
+ } else if (key == ov::cache_encryption_callbacks.name()) {
+ specialCfgsToSet.emplace(key, properties.at(key));
} else {
cfgsToSet.emplace(key, value);
}
}
updatedConfig.update(cfgsToSet);
+ updatedConfig.updateAny(specialCfgsToSet);
return std::move(updatedConfig);
}
@@ -1117,6 +1153,7 @@ FilteredConfig Properties::getConfigWithCompilerPropertiesDisabled(const ov::Any
const std::map<std::string, std::string> rawConfig = any_copy(properties);
std::map<std::string, std::string> cfgsToSet;
+ ov::AnyMap specialCfgsToSet;
for (const auto& [key, value] : rawConfig) {
if (updatedConfig.hasOpt(key)) {
const auto optionMode = updatedConfig.getOpt(key).mode();
@@ -1135,10 +1172,15 @@ FilteredConfig Properties::getConfigWithCompilerPropertiesDisabled(const ov::Any
}
}
- cfgsToSet.emplace(key, value);
+ if (key == ov::cache_encryption_callbacks.name()) {
+ specialCfgsToSet.emplace(key, properties.at(key));
+ } else {
+ cfgsToSet.emplace(key, value);
+ }
}
updatedConfig.update(cfgsToSet);
+ updatedConfig.updateAny(specialCfgsToSet);
return std::move(updatedConfig);
}
diff --git a/src/plugins/intel_npu/src/plugin/src/transformations.cpp b/src/plugins/intel_npu/src/plugin/src/transformations.cpp
index 76209886014..25dd0d397a2 100644
--- a/src/plugins/intel_npu/src/plugin/src/transformations.cpp
+++ b/src/plugins/intel_npu/src/plugin/src/transformations.cpp
@@ -259,7 +259,7 @@ std::tuple<std::shared_ptr<ov::Model>, bool> handlePluginBatching(
updateBatchMode(ov::intel_npu::BatchMode::COMPILER);
}
} else {
- OPENVINO_THROW("Couldn't validate and reshape the model for PLUGIN batch mode. Error: %s", ex.what());
+ OPENVINO_THROW("Couldn't validate and reshape the model for PLUGIN batch mode. Error: ", ex.what());
}
}
diff --git a/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp b/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
index cc264c1c7b8..a39f07534d3 100644
--- a/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
+++ b/src/plugins/intel_npu/src/utils/src/zero/zero_init.cpp
@@ -20,7 +20,7 @@ constexpr uint32_t WIN_DRIVER_NO_MCL_SUPPORT = 2688;
#endif
constexpr uint32_t TARGET_ZE_DRIVER_NPU_EXT_VERSION = ZE_DRIVER_NPU_EXT_VERSION_1_0;
-constexpr uint32_t TARGET_ZE_GRAPH_NPU_EXT_VERSION = ZE_GRAPH_EXT_VERSION_1_16;
+constexpr uint32_t TARGET_ZE_GRAPH_NPU_EXT_VERSION = ZE_GRAPH_EXT_VERSION_1_17;
constexpr uint32_t TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION = ZE_COMMAND_QUEUE_NPU_EXT_VERSION_1_1;
constexpr uint32_t TARGET_ZE_PROFILING_NPU_EXT_VERSION = ZE_PROFILING_DATA_EXT_VERSION_1_0;
constexpr uint32_t TARGET_ZE_CONTEXT_NPU_EXT_VERSION = ZE_CONTEXT_NPU_EXT_VERSION_1_0;
diff --git a/src/plugins/intel_npu/tests/functional/CMakeLists.txt b/src/plugins/intel_npu/tests/functional/CMakeLists.txt
index 3287750219b..0ebe3f7e5dd 100644
--- a/src/plugins/intel_npu/tests/functional/CMakeLists.txt
+++ b/src/plugins/intel_npu/tests/functional/CMakeLists.txt
@@ -36,6 +36,7 @@ ov_add_test_target(
# OpenVINO headers need to be added before the NPU headers
# Otherwise, the compiler may mistake OpenVINO headers for the NPU headers
"${OpenVINO_SOURCE_DIR}/src/tests/functional/base_func_tests/include"
+ "${OpenVINO_SOURCE_DIR}/src/tests/functional/plugin/shared/include"
${CMAKE_CURRENT_SOURCE_DIR}
${OPTIONAL_FUNC_TESTS_INCLUDES}
"${CMAKE_CURRENT_SOURCE_DIR}/shared_tests_instances"
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp
index aa39e52b221..3be9382431a 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.cpp
@@ -6,6 +6,8 @@
#include <gtest/gtest.h>
+#include <openvino/runtime/intel_npu/properties.hpp>
+
#include "common/utils.hpp"
using namespace ov::test::behavior;
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp
index c9eadd14c51..014fb764ab5 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/import_export.hpp
@@ -7,9 +7,11 @@
#include <behavior/compiled_model/import_export.hpp>
#include <sstream>
+#include "common/npu_test_env_cfg.hpp"
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"
#include "intel_npu/npu_private_properties.hpp"
#include "openvino/runtime/make_tensor.hpp"
+#include "openvino/util/codec_xor.hpp"
namespace ov {
@@ -101,6 +103,143 @@ TEST_P(OVCompiledGraphImportExportTestNPU, CheckSizeOfExportedModelIfMultipleOfP
ASSERT_TRUE(size_of_blob % 4096 == 0) << "Size of the blob shall be multiple of 4096";
}
+TEST_P(OVCompiledGraphImportExportTestNPU, SameBlobAfterImportExport) {
+ ov::Core core;
+ std::stringstream blob_stream, test_blob_stream_1, test_blob_stream_2;
+
+ auto model = ov::test::utils::make_conv_pool_relu();
+ core.compile_model(model, target_device, configuration).export_model(blob_stream);
+ configuration.insert(ov::intel_npu::defer_weights_load(true));
+
+ core.import_model(blob_stream, target_device, configuration).export_model(test_blob_stream_1);
+ ASSERT_EQ(blob_stream.str(), test_blob_stream_1.str());
+
+ auto blob_str = blob_stream.str();
+ ov::Tensor blob_tensor(ov::element::u8, ov::Shape{blob_str.size()}, blob_str.c_str());
+ core.import_model(blob_tensor, target_device, configuration).export_model(test_blob_stream_2);
+ ASSERT_EQ(blob_stream.str(), test_blob_stream_2.str());
+}
+
+TEST_P(OVCompiledGraphImportExportTestNPU, ImportingEncryptedBlobThrows) {
+ ov::Core core;
+ std::stringstream encrypted_blob_stream;
+
+ auto model = ov::test::utils::make_conv_pool_relu();
+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));
+ core.compile_model(model, target_device, configuration).export_model(encrypted_blob_stream);
+ auto encrypted_blob_str = encrypted_blob_stream.str();
+ ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());
+ configuration.erase(ov::cache_encryption_callbacks.name());
+
+ OV_EXPECT_THROW(core.import_model(encrypted_blob_stream, target_device, configuration),
+ ov::Exception,
+ ::testing::HasSubstr("Blob is encrypted, but no decryption callback was provided"));
+
+ OV_EXPECT_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration),
+ ov::Exception,
+ ::testing::HasSubstr("Blob is encrypted, but no decryption callback was provided"));
+
+ encrypted_blob_stream.seekg(0, std::ios::beg);
+
+ // Parsing corrupted blob on MTL will throw Access Violation 0xC0000005 SEH exceptions
+ if (ov::intel_npu::Platform::standardize(ov::test::utils::getTestPlatform()) != ov::intel_npu::Platform::NPU3720) {
+ configuration.insert(ov::intel_npu::import_raw_blob(true));
+ OV_EXPECT_THROW(core.import_model(encrypted_blob_stream, target_device, configuration),
+ ov::Exception,
+ ::testing::HasSubstr("ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"));
+
+ OV_EXPECT_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration),
+ ov::Exception,
+ ::testing::HasSubstr("ZE_RESULT_ERROR_INVALID_NATIVE_BINARY"));
+ }
+}
+
+TEST_P(OVCompiledGraphImportExportTestNPU, SameUnencryptedBlobAfterDecryption) {
+ ov::Core core;
+ std::stringstream unencrypted_blob_stream, encrypted_blob_stream, decrypted_blob_stream;
+
+ auto model = ov::test::utils::make_conv_pool_relu();
+ core.compile_model(model, target_device, configuration).export_model(unencrypted_blob_stream);
+ configuration.insert(
+ ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor}));
+ configuration.insert(ov::intel_npu::defer_weights_load(true));
+ core.import_model(unencrypted_blob_stream, target_device, configuration).export_model(encrypted_blob_stream);
+ configuration.erase(ov::cache_encryption_callbacks.name());
+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{nullptr, ov::util::codec_xor}));
+
+ core.import_model(encrypted_blob_stream, target_device, configuration).export_model(decrypted_blob_stream);
+ ASSERT_EQ(unencrypted_blob_stream.str(), decrypted_blob_stream.str());
+
+ decrypted_blob_stream.str(std::string());
+ auto encrypted_blob_str = encrypted_blob_stream.str();
+ ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());
+ core.import_model(encrypted_blob_tensor, target_device, configuration).export_model(decrypted_blob_stream);
+ ASSERT_EQ(unencrypted_blob_stream.str(), decrypted_blob_stream.str());
+}
+
+TEST_P(OVCompiledGraphImportExportTestNPU, SameEncryptedBlobViaExportAndManualFunctionCall) {
+ ov::Core core;
+ std::stringstream unencrypted_blob_stream, encrypted_blob_stream;
+
+ auto model = ov::test::utils::make_conv_pool_relu();
+ // metadata is not encrypted, exclude it from blob
+ configuration.insert(ov::intel_npu::import_raw_blob(true));
+ configuration.insert(ov::intel_npu::export_raw_blob(true));
+
+ configuration.insert(ov::intel_npu::defer_weights_load(true));
+
+ core.compile_model(model, target_device, configuration).export_model(unencrypted_blob_stream);
+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));
+ core.import_model(unencrypted_blob_stream, target_device, configuration).export_model(encrypted_blob_stream);
+
+ std::string manual_encrypted_blob_str = ov::util::codec_xor(unencrypted_blob_stream.str());
+ std::string encrypted_blob_str = encrypted_blob_stream.str();
+
+ ASSERT_EQ(manual_encrypted_blob_str, encrypted_blob_str);
+}
+
+TEST_P(OVCompiledGraphImportExportTestNPU, DifferentSizesOfEncryptedVsDecryptedBlobWorks) {
+ ov::Core core;
+ std::stringstream encrypted_blob_stream;
+
+ std::stringstream model_xml, model_bin;
+ {
+ // Serialize generated model into stringstream to later populate `WeightlessCacheAttribute` runtime information
+ // of constant nodes
+ auto model = ov::test::utils::make_conv_pool_relu();
+ ov::pass::Serialize serializer(model_xml, model_bin);
+ serializer.run_on_model(model);
+ }
+ auto model_bin_str = model_bin.str();
+ ov::Tensor model_weights(ov::element::u8, ov::Shape{model_bin_str.size()});
+ std::memcpy(model_weights.data<char>(), model_bin_str.data(), model_bin_str.size());
+ auto model = core.read_model(model_xml.str(), model_weights);
+
+ configuration.insert(ov::cache_encryption_callbacks(
+ ov::EncryptionCallbacks{[](const std::string& unencrypted_blob) {
+ std::string copy_blob = unencrypted_blob;
+ copy_blob += "<application_flag_to_mark_encryption>";
+ return ov::util::codec_xor(copy_blob);
+ },
+ [](const std::string& encrypted_blob) {
+ std::string decrypted_blob = ov::util::codec_xor(encrypted_blob);
+ decrypted_blob += "<application_flag_to_mark_decryption>";
+ return decrypted_blob;
+ }}));
+
+ auto supported_properties = core.get_property(target_device, ov::supported_properties);
+ if (std::find(supported_properties.begin(), supported_properties.end(), ov::enable_weightless.name()) !=
+ supported_properties.end()) {
+ configuration.insert(ov::enable_weightless(true));
+ }
+ OV_ASSERT_NO_THROW(core.compile_model(model, target_device, configuration).export_model(encrypted_blob_stream));
+
+ auto encrypted_blob_str = encrypted_blob_stream.str();
+ ov::Tensor encrypted_blob_tensor(ov::element::u8, ov::Shape{encrypted_blob_str.size()}, encrypted_blob_str.c_str());
+ OV_ASSERT_NO_THROW(core.import_model(encrypted_blob_stream, target_device, configuration));
+ OV_ASSERT_NO_THROW(core.import_model(encrypted_blob_tensor, target_device, configuration));
+}
+
} // namespace behavior
} // namespace test
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cpp
new file mode 100644
index 00000000000..a05648e1219
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.cpp
@@ -0,0 +1,44 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "model_cache.hpp"
+
+#include <gtest/gtest.h>
+
+#include "common/utils.hpp"
+
+using namespace ov::test::behavior;
+
+namespace {
+
+std::vector<ov::AnyMap> config = {
+ {},
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT),
+ ov::enable_mmap(false)}, // enable_mmap for both `import_model(stream)` and `import_model(tensor)` paths
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT),
+ ov::enable_mmap(true)},
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE),
+ ov::enable_mmap(false)},
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE),
+ ov::enable_mmap(true)}};
+
+} // namespace
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,
+ OVWeightlessCacheAccuracyNPU,
+ ::testing::Combine(::testing::ValuesIn({true, false}), // m_use_compile_model_api
+ ::testing::Values(true), // m_do_encryption
+ ::testing::Values(ov::element::f16), // m_inference_mode
+ ::testing::Values(ov::element::f16), // m_model_dtype
+ ::testing::ValuesIn(config), // config parsed with std::ignore
+ ::testing::Values(ov::test::utils::DEVICE_NPU)), // m_target_device
+ ov::test::utils::appendPlatformTypeTestName<OVWeightlessCacheAccuracyNPU>);
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.hpp
new file mode 100644
index 00000000000..56da09e5276
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/model_cache.hpp
@@ -0,0 +1,192 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <behavior/compiled_model/model_cache.hpp>
+#include <memory>
+
+#include "common_test_utils/test_assertions.hpp"
+#include "functional_test_utils/skip_tests_config.hpp"
+#include "openvino/core/model_util.hpp"
+#include "openvino/core/rt_info/weightless_caching_attributes.hpp"
+#include "openvino/op/add.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/openvino.hpp"
+
+namespace {
+
+std::shared_ptr<ov::Model> createTestModel(const bool addWeightlessCacheAttribute = true,
+ const bool alternativeWeights = false) {
+ constexpr auto precision = ov::element::f32;
+
+ const float weightsValue = !alternativeWeights ? 1.0f : 2.0f;
+ auto weights = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{5}, std::vector<float>{weightsValue});
+ auto input = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1});
+ auto add = std::make_shared<ov::op::v1::Add>(input, weights);
+
+ weights->set_friendly_name("weights");
+ input->set_friendly_name("input");
+ add->set_friendly_name("add");
+
+ if (addWeightlessCacheAttribute) {
+ weights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =
+ ov::WeightlessCacheAttribute(weights->get_byte_size(), 0, weights->get_element_type());
+ }
+
+ auto model = std::make_shared<ov::Model>(ov::OutputVector{add}, ov::ParameterVector{input}, "Simple with weights");
+ ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});
+ return model;
+}
+
+// This is a special model that has weightless constants that are guaranteed
+// to be skipped by weights schedule. This tests cases where compiler
+// produces "blob with weights" when "weightless blob" is requested: in
+// theory, this may happen, and must not cause any errors.
+std::shared_ptr<ov::Model> createTestModelWeightlessWithDummyConstants() {
+ constexpr auto precision = ov::element::f32;
+
+ const auto reshapeWeights =
+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{3}, std::vector<int64_t>{1, 2, 3});
+
+ const auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{6});
+ const auto input2 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 2, 3});
+ const auto reshapedInput1 = std::make_shared<ov::op::v1::Reshape>(input1, reshapeWeights, /*special_zero=*/false);
+ auto add = std::make_shared<ov::op::v1::Add>(reshapedInput1, input2);
+
+ reshapeWeights->set_friendly_name("weights");
+ input1->set_friendly_name("input1");
+ input2->set_friendly_name("input2");
+ reshapedInput1->set_friendly_name("reshapedInput1");
+ add->set_friendly_name("add");
+
+ // Note: Reshape weights with weightless cache attribute satisfy the
+ // basic requirement to create weights schedule. However, since this is
+ // a static reshape, these weights would "disappear" during compilation,
+ // causing the compiler to put nothing into the weights schedule.
+ reshapeWeights->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =
+ ov::WeightlessCacheAttribute(reshapeWeights->get_byte_size(), 0, reshapeWeights->get_element_type());
+
+ auto model = std::make_shared<ov::Model>(ov::OutputVector{add},
+ ov::ParameterVector{input1, input2},
+ "Dummy weightless model");
+ ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});
+ return model;
+}
+
+/**
+ * @brief This model was fine-tuned in order to compile fast and yield a light init schedule.
+ */
+std::shared_ptr<ov::Model> createTestModelLightInitSchedule() {
+ ov::ParameterVector parameter_vector;
+ auto data = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});
+ parameter_vector.push_back(data);
+ auto add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{50}, {0.5});
+ auto add = std::make_shared<ov::op::v1::Add>(data, add_constant);
+
+ for (int i = 0; i < 10; i++) {
+ auto intermediate_input = std::make_shared<ov::op::v0::Parameter>(ov::element::f16, ov::Shape{1});
+ parameter_vector.push_back(intermediate_input);
+ add_constant = ov::op::v0::Constant::create(ov::element::f16, ov::Shape{10, 10, 20, 50}, {i});
+ add_constant->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =
+ ov::WeightlessCacheAttribute(add_constant->get_byte_size(), i, add_constant->get_element_type());
+ add = std::make_shared<ov::op::v1::Add>(add, intermediate_input);
+ add = std::make_shared<ov::op::v1::Add>(add, add_constant);
+ }
+
+ return std::make_shared<ov::Model>(ov::OutputVector{add}, parameter_vector);
+}
+
+// This is a special test model with multiple constants using the same weights buffer.
+std::shared_ptr<ov::Model> createTestModelWeightlessWithDuplicateConstants() {
+ const std::vector<float> sharedData{1.0f, 2.0f, 3.0f, 4.0f};
+ constexpr auto precision = ov::element::f32;
+
+ auto input1 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 1, 4});
+ auto input2 = std::make_shared<ov::op::v0::Parameter>(precision, ov::Shape{1, 4, 1});
+
+ auto weights1 = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{1, 1, 4}, sharedData);
+ auto multiply1 = std::make_shared<ov::op::v1::Multiply>(input1, weights1);
+
+ auto weights2 = std::make_shared<ov::op::v0::Constant>(precision, ov::Shape{1, 4, 1}, sharedData);
+ auto multiply2 = std::make_shared<ov::op::v1::Multiply>(input2, weights2);
+
+ auto reshapeWeights =
+ std::make_shared<ov::op::v0::Constant>(ov::element::i64, ov::Shape{3}, std::vector<int64_t>{1, 4, 1});
+ auto reshape = std::make_shared<ov::op::v1::Reshape>(multiply1, reshapeWeights, false);
+
+ auto add = std::make_shared<ov::op::v1::Add>(reshape, multiply2);
+
+ input1->set_friendly_name("input1");
+ input2->set_friendly_name("input2");
+ weights1->set_friendly_name("weights");
+ multiply1->set_friendly_name("multiply1");
+ weights2->set_friendly_name("weights_new_shape");
+ multiply2->set_friendly_name("multiply2");
+ reshapeWeights->set_friendly_name("reshapeWeights");
+ reshape->set_friendly_name("reshape");
+ add->set_friendly_name("add");
+
+ // Note: if this offset is changed, compiled_model->export_model() =>
+ // core->import_model() would fail as the weightless bin offset is
+ // "reset" through this boundary; right now this is by design
+ constexpr size_t theOnlyFunctioningBinOffset = 0;
+ weights1->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =
+ ov::WeightlessCacheAttribute(weights1->get_byte_size(),
+ theOnlyFunctioningBinOffset,
+ weights1->get_element_type());
+ weights2->get_rt_info()[ov::WeightlessCacheAttribute::get_type_info_static()] =
+ ov::WeightlessCacheAttribute(weights2->get_byte_size(),
+ theOnlyFunctioningBinOffset,
+ weights2->get_element_type());
+
+ auto model = std::make_shared<ov::Model>(ov::OutputVector{add},
+ ov::ParameterVector{input1, input2},
+ "duplicate_weights_model");
+ ov::util::set_tensors_names(ov::AUTO, *model, {}, {{0, {"add"}}});
+ return model;
+}
+
+} // namespace
+
+namespace ov {
+
+namespace test {
+
+namespace behavior {
+
+using OVWeightlessCacheAccuracyNPU = WeightlessCacheAccuracy;
+
+TEST_P(OVWeightlessCacheAccuracyNPU, SimpleTestModel) {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ OV_ASSERT_NO_THROW(m_model = createTestModel());
+ OV_ASSERT_NO_THROW(run());
+}
+
+TEST_P(OVWeightlessCacheAccuracyNPU, TestModelWeightlessWithDummyConstants) {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ OV_ASSERT_NO_THROW(m_model = createTestModelWeightlessWithDummyConstants());
+ OV_ASSERT_NO_THROW(run());
+}
+
+TEST_P(OVWeightlessCacheAccuracyNPU, TestModelLightInitSchedule) {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ OV_ASSERT_NO_THROW(m_model = createTestModelLightInitSchedule());
+ OV_ASSERT_NO_THROW(run());
+}
+
+TEST_P(OVWeightlessCacheAccuracyNPU, TestModelWeightlessWithDuplicateConstants) {
+ SKIP_IF_CURRENT_TEST_IS_DISABLED()
+ OV_ASSERT_NO_THROW(m_model = createTestModelWeightlessWithDuplicateConstants());
+ OV_ASSERT_NO_THROW(run());
+}
+
+} // namespace behavior
+
+} // namespace test
+
+} // namespace ov
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp
index 783cded1285..93e5cc2f764 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.cpp
@@ -5,6 +5,7 @@
#include "property.hpp"
#include <openvino/runtime/intel_npu/properties.hpp>
+#include <openvino/util/codec_xor.hpp>
#include <vector>
#include "common/npu_test_env_cfg.hpp"
@@ -20,6 +21,10 @@ std::vector<std::pair<std::string, ov::Any>> exe_network_supported_properties =
{ov::optimal_number_of_infer_requests.name(), ov::Any(2)},
};
+std::vector<std::pair<std::string, ov::Any>> exe_network_public_mutable_properties = {
+ {ov::cache_encryption_callbacks.name(), ov::Any(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor})},
+};
+
std::vector<std::pair<std::string, ov::Any>> exe_network_immutable_properties = {
{std::make_pair(ov::optimal_number_of_infer_requests.name(), ov::Any(2))},
{std::make_pair(ov::hint::enable_cpu_pinning.name(), ov::Any(false))},
@@ -128,6 +133,12 @@ INSTANTIATE_TEST_SUITE_P(
ov::Any("THISCONFIGVALUENOTEXIST"))})),
ClassPluginPropertiesTestSuite4NPU::getTestCaseName);
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_ClassExecutableNetworkSetPropertiesTestNPU,
+ ClassPluginPropertiesTestSuite5NPU,
+ ::testing::Combine(::testing::Values(ov::test::utils::getDeviceName()),
+ ::testing::ValuesIn(exe_network_public_mutable_properties)),
+ ClassPluginPropertiesTestSuite5NPU::getTestCaseName);
+
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_ClassExecutableNetworkInvalidDeviceIDTestNPU,
ClassExecutableNetworkInvalidDeviceIDTestSuite,
::testing::Combine(::testing::Values(ov::test::utils::getDeviceName()),
diff --git a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
index 6fe11d4d208..bd1b5869d60 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/compiled_model/property.hpp
@@ -237,6 +237,27 @@ TEST_P(ClassPluginPropertiesTestSuite4NPU, CanNotSetGetInexistentProperty) {
ov::Exception); // Expect to throw due to unsupported config
}
+using ClassPluginPropertiesTestSuite5NPU = ClassExecutableNetworkGetPropertiesTestNPU;
+
+TEST_P(ClassPluginPropertiesTestSuite5NPU, CanSetMutablePropertiesToCompiledModel) {
+ // ie.set_property won't call plugin Engine::SetConfig due to empty string-ov::Plugin map from core_impl
+ // workaround to overcome this is to call first ie.get_property which calls get_plugin() from core_impl and
+ // populates plugin map
+ std::vector<ov::PropertyName> properties;
+ OV_ASSERT_NO_THROW(properties = ie.get_property(deviceName, ov::supported_properties));
+
+ OV_ASSERT_NO_THROW(ie.set_property(deviceName, {{configKey, configValue}}));
+
+ OV_ASSERT_NO_THROW(ov::CompiledModel compiled_model1 =
+ ie.compile_model(model, deviceName, {{configKey, configValue}}));
+
+ ov::CompiledModel compiled_model2;
+
+ OV_ASSERT_NO_THROW(compiled_model2 = ie.compile_model(model, deviceName));
+
+ OV_ASSERT_NO_THROW(compiled_model2.set_property({{configKey, configValue}}));
+}
+
using ClassExecutableNetworkInvalidDeviceIDTestSuite = ClassExecutableNetworkGetPropertiesTestNPU;
TEST_P(ClassExecutableNetworkInvalidDeviceIDTestSuite, InvalidNPUdeviceIDTest) {
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp
index 6aa6d6d669f..ec9217d2f7d 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.cpp
@@ -12,7 +12,11 @@ using namespace ov::test::behavior;
namespace {
-std::vector<ov::AnyMap> config = {{}};
+std::vector<ov::AnyMap> config = {
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor})},
+ {ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor})}};
INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,
OVCompileModelLoadFromFileTestBaseNPU,
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp
index 88bf4992241..abeab83c7f2 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/caching_tests.hpp
@@ -4,12 +4,11 @@
#pragma once
-#include <level_zero/ze_api.h> // not redundant, needed for `ze_structure_type_t` structure
-
#include <behavior/ov_plugin/caching_tests.hpp>
#include "intel_npu/utils/zero/zero_init.hpp"
#include "openvino/core/log_util.hpp"
+#include "openvino/runtime/intel_npu/properties.hpp"
namespace ov {
namespace test {
@@ -20,7 +19,7 @@ using OVCompileModelLoadFromFileTestBaseNPU = CompileModelLoadFromFileTestBase;
TEST_P(OVCompileModelLoadFromFileTestBaseNPU, BlobWithOVHeaderAligmentCanBeImported) {
core->set_property(ov::cache_dir(m_cacheFolderName));
- if (!intel_npu::ZeroInitStructsHolder::getInstance()->isExternalMemoryStandardAllocationSupported()) {
+ if (!::intel_npu::ZeroInitStructsHolder::getInstance()->isExternalMemoryStandardAllocationSupported()) {
GTEST_SKIP() << "Standard allocation is not supported by the current configuration.";
}
@@ -47,6 +46,37 @@ TEST_P(OVCompileModelLoadFromFileTestBaseNPU, BlobWithOVHeaderAligmentCanBeImpor
::testing::HasSubstr("getGraphDescriptor - set ZE_GRAPH_FLAG_INPUT_GRAPH_PERSISTENT"));
}
+TEST_P(OVCompileModelLoadFromFileTestBaseNPU, EncryptionCallbacksSetSecureCompileFlag) {
+ core->set_property(ov::cache_dir(m_cacheFolderName));
+
+ if (::intel_npu::ZeroInitStructsHolder::getInstance()->getGraphDdiTable().version() < ZE_MAKE_VERSION(1, 17)) {
+ GTEST_SKIP()
+ << "Secure compilation when blob encryption is requested requires ze_graph_ext version 1.17 or higher.";
+ }
+
+ if (auto it = configuration.find(ov::intel_npu::compiler_type.name()); it != configuration.end()) {
+ if (it->second.as<ov::intel_npu::CompilerType>() == ov::intel_npu::CompilerType::PLUGIN) {
+ GTEST_SKIP() << "Compiler in Plugin doesn't need yet secure compilation when blob encryption is requested.";
+ }
+ }
+
+ std::stringstream custom_logger;
+ ov::util::LogCallback custom_log_callback = [&](std::string_view s) {
+ custom_logger << s << std::endl;
+ };
+ ov::util::set_log_callback(custom_log_callback);
+ struct ResetLogCallbackGuard {
+ ~ResetLogCallbackGuard() {
+ ov::util::reset_log_callback();
+ }
+ } reset_log_callback_guard;
+
+ configuration.emplace(ov::log::level(ov::log::Level::DEBUG));
+ std::ignore = core->compile_model(m_modelName, targetDevice, configuration);
+ EXPECT_THAT(custom_logger.str(), ::testing::HasSubstr("getGraphDescriptor - set ZE_GRAPH_FLAG_SECURE_COMPILE"));
+ configuration.erase(ov::log::level.name());
+}
+
} // namespace behavior
} // namespace test
} // namespace ov
diff --git a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hpp b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hpp
index 16b8cdc4b86..3e7f1831670 100644
--- a/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hpp
+++ b/src/plugins/intel_npu/tests/functional/behavior/ov_plugin/life_time.hpp
@@ -9,6 +9,7 @@
#include "common_test_utils/subgraph_builders/conv_pool_relu.hpp"
#include "intel_npu/utils/zero/zero_init.hpp"
#include "life_time.hpp"
+#include "openvino/util/codec_xor.hpp"
using CompilationParams = std::tuple<std::string, // Device name
ov::AnyMap // Config
@@ -156,6 +157,21 @@ TEST_P(OVHoldersTestNPU, LoadedRemoteContext) {
}
}
+TEST_P(OVHoldersTestNPU, CompileModelWithEncryptionWorksAfterConfigDeallocate) {
+ ov::CompiledModel compiled_model;
+ {
+ ov::AnyMap copy_configuration = configuration;
+ copy_configuration.insert(
+ ov::cache_encryption_callbacks(ov::EncryptionCallbacks{ov::util::codec_xor, nullptr}));
+ ov::Core core = createCoreWithTemplate();
+ compiled_model = core.compile_model(function, target_device, copy_configuration);
+ }
+ std::stringstream str;
+ OV_ASSERT_NO_THROW(compiled_model.export_model(str));
+ configuration.insert(ov::cache_encryption_callbacks(ov::EncryptionCallbacks{nullptr, ov::util::codec_xor}));
+ OV_ASSERT_NO_THROW(ov::Core().import_model(str, target_device, configuration));
+}
+
class OVHoldersTestOnImportedNetworkNPU : public OVPluginTestBase,
public testing::WithParamInterface<CompilationParams> {
protected:
diff --git a/src/plugins/intel_npu/tests/functional/common/utils.cpp b/src/plugins/intel_npu/tests/functional/common/utils.cpp
index ee903aba7f6..5b5288cec08 100644
--- a/src/plugins/intel_npu/tests/functional/common/utils.cpp
+++ b/src/plugins/intel_npu/tests/functional/common/utils.cpp
@@ -48,65 +48,6 @@ std::string removeDeviceNameOnlyID(const std::string& device_name_id) {
return std::string(first_digit, last_digit + 1);
}
-std::vector<ov::AnyMap> getRWMandatoryPropertiesValues(std::vector<ov::AnyMap> props) {
- ov::hint::PerformanceMode performanceModes[] = {ov::hint::PerformanceMode::LATENCY,
- ov::hint::PerformanceMode::THROUGHPUT,
- ov::hint::PerformanceMode::CUMULATIVE_THROUGHPUT};
- for (auto& performanceMode : performanceModes) {
- if (std::find(props.begin(),
- props.end(),
- ov::AnyMap{{ov::hint::performance_mode.name(), ov::Any(performanceMode)}}) != props.end()) {
- continue;
- }
- props.push_back({{ov::hint::performance_mode(performanceMode)}});
- }
-
- if (std::find(props.begin(), props.end(), ov::AnyMap{{ov::hint::num_requests.name(), ov::Any(1)}}) == props.end()) {
- props.push_back({{ov::hint::num_requests(1)}});
- }
-
- ov::hint::ExecutionMode executionModes[] = {ov::hint::ExecutionMode::PERFORMANCE,
- ov::hint::ExecutionMode::ACCURACY};
- for (auto& executionMode : executionModes) {
- if (std::find(props.begin(),
- props.end(),
- ov::AnyMap{{ov::hint::execution_mode.name(), ov::Any(executionMode)}}) != props.end()) {
- continue;
- }
- props.push_back({{ov::hint::execution_mode(executionMode)}});
- }
-
- bool enableProfilingValues[] = {true, false};
- for (auto enableProfilingValue : enableProfilingValues) {
- if (std::find(props.begin(),
- props.end(),
- ov::AnyMap{{ov::enable_profiling.name(), ov::Any(enableProfilingValue)}}) != props.end()) {
- continue;
- }
- props.push_back({{ov::enable_profiling(enableProfilingValue)}});
- }
-
- ov::log::Level logLevels[] = {ov::log::Level::NO,
- ov::log::Level::ERR,
- ov::log::Level::WARNING,
- ov::log::Level::INFO,
- ov::log::Level::DEBUG,
- ov::log::Level::TRACE};
- for (auto& logLevel : logLevels) {
- if (std::find(props.begin(), props.end(), ov::AnyMap{{ov::log::level.name(), ov::Any(logLevel)}}) !=
- props.end()) {
- continue;
- }
- props.push_back({ov::log::level(logLevel)});
- }
-
- if (std::find(props.begin(), props.end(), ov::AnyMap{{ov::streams::num.name(), ov::Any(ov::streams::num(3))}}) !=
- props.end()) {
- props.push_back({ov::streams::num(3)});
- }
- return props;
-}
-
std::shared_ptr<ov::Model> createModelWithStates(ov::element::Type type, const ov::Shape& shape) {
auto input = std::make_shared<ov::op::v0::Parameter>(type, shape);
auto mem_i1 = std::make_shared<ov::op::v0::Constant>(type, shape, 0);
diff --git a/src/plugins/intel_npu/tests/functional/common/utils.hpp b/src/plugins/intel_npu/tests/functional/common/utils.hpp
index c52a1f32433..1499cc58d3d 100644
--- a/src/plugins/intel_npu/tests/functional/common/utils.hpp
+++ b/src/plugins/intel_npu/tests/functional/common/utils.hpp
@@ -23,8 +23,6 @@ std::string modelPriorityToString(const ov::hint::Priority priority);
std::string removeDeviceNameOnlyID(const std::string& device_name_id);
-std::vector<ov::AnyMap> getRWMandatoryPropertiesValues(std::vector<ov::AnyMap> props);
-
std::shared_ptr<ov::Model> createModelWithStates(ov::element::Type type, const ov::Shape& shape);
template <typename C,
@@ -67,10 +65,15 @@ struct GenericTestCaseNameClass {
template <typename, typename = void>
static constexpr bool hasGetTestCaseName = false;
+ template <typename, typename = void>
+ static constexpr bool has_get_test_case_name = false;
+
template <typename T>
static std::string getTestCaseName(const testing::TestParamInfo<typename T::ParamType>& obj) {
if constexpr (hasGetTestCaseName<T>) {
return T::getTestCaseName(obj);
+ } else if constexpr (has_get_test_case_name<T>) {
+ return T::get_test_case_name(obj);
} else {
std::ostringstream result;
::testing::PrintToStringParamName printToStringParamName;
@@ -81,11 +84,14 @@ struct GenericTestCaseNameClass {
};
template <typename T>
-constexpr bool
- GenericTestCaseNameClass::hasGetTestCaseName<T,
- std::void_t<decltype(std::declval<T>().getTestCaseName(
- std::declval<testing::TestParamInfo<typename T::ParamType>>()))>> =
- true;
+constexpr bool GenericTestCaseNameClass::hasGetTestCaseName<
+ T,
+ std::void_t<decltype(T::getTestCaseName(std::declval<testing::TestParamInfo<typename T::ParamType>>()))>> = true;
+
+template <typename T>
+constexpr bool GenericTestCaseNameClass::has_get_test_case_name<
+ T,
+ std::void_t<decltype(T::get_test_case_name(std::declval<testing::TestParamInfo<typename T::ParamType>>()))>> = true;
namespace ov::test::behavior {
inline std::shared_ptr<ov::Model> getDefaultNGraphFunctionForTheDeviceNPU(
diff --git a/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp b/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp
index 97994f4b615..e3fd98d37a5 100644
--- a/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp
+++ b/src/plugins/intel_npu/tests/functional/common/zero_init_mock.hpp
@@ -19,7 +19,7 @@ namespace intel_npu {
namespace test_constants {
inline constexpr uint32_t TARGET_ZE_DRIVER_NPU_EXT_VERSION = ZE_DRIVER_NPU_EXT_VERSION_1_0;
-inline constexpr uint32_t TARGET_ZE_GRAPH_NPU_EXT_VERSION = ZE_GRAPH_EXT_VERSION_1_16;
+inline constexpr uint32_t TARGET_ZE_GRAPH_NPU_EXT_VERSION = ZE_GRAPH_EXT_VERSION_1_17;
inline constexpr uint32_t TARGET_ZE_COMMAND_QUEUE_NPU_EXT_VERSION = ZE_COMMAND_QUEUE_NPU_EXT_VERSION_1_1;
inline constexpr uint32_t TARGET_ZE_PROFILING_NPU_EXT_VERSION = ZE_PROFILING_DATA_EXT_VERSION_1_0;
inline constexpr uint32_t TARGET_ZE_CONTEXT_NPU_EXT_VERSION = ZE_CONTEXT_NPU_EXT_VERSION_1_0;
diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
index 7de01aa89d2..43b466c131a 100644
--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.cpp
@@ -6,14 +6,22 @@
using namespace ov::test::behavior;
-const std::vector<ov::AnyMap> configs = {{{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
- ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
- ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}},
- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
- ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
- {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
- ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}}};
+const std::vector<ov::AnyMap> configs = {
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN),
+ // platform needed only for NPU_COMPILER_TYPE_PLUGIN
+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(
+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::PLUGIN),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER),
+ // platform needed only for NPU_COMPILER_TYPE_PLUGIN
+ ov::intel_npu::platform(ov::intel_npu::Platform::standardize(
+ ov::test::utils::getTestsPlatformFromEnvironmentOr(ov::test::utils::DEVICE_NPU)))}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::PLUGIN)}},
+ {{ov::intel_npu::compiler_type(ov::intel_npu::CompilerType::DRIVER),
+ ov::intel_npu::batch_mode(ov::intel_npu::BatchMode::COMPILER)}}};
+
const std::vector<ov::element::Type> specialTensorDataTypes = {ov::element::boolean};
INSTANTIATE_TEST_SUITE_P(
diff --git a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp
index 5ba68571807..6ccd43fda49 100644
--- a/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp
+++ b/src/plugins/intel_npu/tests/functional/internal/backend/zero_infer_request_tests.hpp
@@ -160,9 +160,7 @@ public:
options->add<::intel_npu::MODEL_SERIALIZER_VERSION>();
options->add<::intel_npu::ENABLE_CPU_PINNING>();
npu_config = std::make_unique<::intel_npu::FilteredConfig>(options);
- ::intel_npu::Config::ConfigMap configMap{
- {::intel_npu::PLATFORM::key().data(),
- ov::intel_npu::Platform::standardize(ov::test::utils::getTestsPlatformFromEnvironmentOr(target_device))}};
+ ::intel_npu::Config::ConfigMap configMap;
npu_config->enable(::intel_npu::PLATFORM::key().data(), true);
npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), true);
npu_config->enable(::intel_npu::ENABLE_CPU_PINNING::key().data(), true);
@@ -227,6 +225,8 @@ TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {
npu_config->update({{::intel_npu::MODEL_SERIALIZER_VERSION::key().data(),
::intel_npu::MODEL_SERIALIZER_VERSION::toString(
ov::intel_npu::ModelSerializerVersion::ALL_WEIGHTS_COPY)}});
+ } else {
+ npu_config->enable(::intel_npu::MODEL_SERIALIZER_VERSION::key().data(), false);
}
// logic for batch
@@ -253,13 +253,13 @@ TEST_P(ZeroInferRequestTests, BooleanSetTensorSetTensorsWork) {
graph->set_batch_size(batch.value());
}
- auto compiledModel =
- std::make_shared<intel_npu::CompiledModel>(ov_model,
- std::make_shared<ov::test::utils::MockPlugin>(),
- device,
- graph,
- *npu_config,
- batch); // MockPlugin needed only to avoid throw for nullptr
+ auto compiledModel = std::make_shared<intel_npu::CompiledModel>(
+ ov_model,
+ std::make_shared<ov::test::utils::MockPlugin>(), // MockPlugin needed only to avoid throw for nullptr
+ device,
+ graph,
+ *npu_config,
+ batch);
OPENVINO_ASSERT(compiledModel->inputs()[0].get_element_type() == element_type);
OPENVINO_ASSERT(compiledModel->inputs()[1].get_element_type() == element_type);
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp
new file mode 100644
index 00000000000..4cf2aacb3f6
--- /dev/null
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/model_cache.cpp
@@ -0,0 +1,45 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "behavior/compiled_model/model_cache.hpp"
+
+#include <common_test_utils/test_constants.hpp>
+
+#include "common/npu_test_env_cfg.hpp"
+#include "common/utils.hpp"
+
+using namespace ov::test::behavior;
+
+namespace {
+
+std::vector<ov::AnyMap> config = {
+ {},
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT),
+ ov::enable_mmap(false)}, // enable_mmap for both `import_model(stream)` and `import_model(tensor)` paths
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ONE_SHOT),
+ ov::enable_mmap(true)},
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE),
+ ov::enable_mmap(false)},
+ {ov::enable_weightless(true),
+ ov::cache_mode(ov::CacheMode::OPTIMIZE_SIZE),
+ ov::intel_npu::separate_weights_version(ov::intel_npu::WSVersion::ITERATIVE),
+ ov::enable_mmap(true)}};
+
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests,
+ WeightlessCacheAccuracy,
+ ::testing::Combine(::testing::ValuesIn({true, false}), // m_use_compile_model_api
+ ::testing::Values(true), // m_do_encryption
+ ::testing::Values(ov::element::f16), // m_inference_mode
+ ::testing::Values(ov::element::f16), // m_model_dtype
+ ::testing::ValuesIn(config), // config parsed with std::ignore
+ ::testing::Values(ov::test::utils::DEVICE_NPU)), // m_target_device
+ ov::test::utils::appendPlatformTypeTestName<WeightlessCacheAccuracy>);
+
+} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp
index d0a3aafe920..c19f63310fb 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/compiled_model/properties.cpp
@@ -4,6 +4,8 @@
#include "behavior/compiled_model/properties.hpp"
+#include <openvino/util/codec_xor.hpp>
+
#include "common/functions.hpp"
#include "common/npu_test_env_cfg.hpp"
#include "common/utils.hpp"
@@ -50,7 +52,9 @@ const std::vector<std::pair<std::string, ov::Any>> compiledModelProperties = {
{ov::hint::model_priority.name(), ov::Any(ov::hint::Priority::HIGH)},
{ov::intel_npu::tiles.name(), ov::Any(2)},
{ov::intel_npu::profiling_type.name(), ov::Any(ov::intel_npu::ProfilingType::INFER)},
- {ov::intel_npu::defer_weights_load.name(), ov::Any(false)}};
+ {ov::intel_npu::defer_weights_load.name(), ov::Any(false)},
+ {ov::cache_encryption_callbacks.name(), ov::Any(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor})},
+};
const std::string& expectedModelName = []() -> std::string {
return ov::test::behavior::getDefaultNGraphFunctionForTheDevice()->get_friendly_name();
@@ -64,7 +68,10 @@ const std::vector<ov::AnyMap> compatibilityPublicCompiledModelConfigs = {
{{ov::model_name.name(), ov::Any(expectedModelName)}},
{{ov::optimal_number_of_infer_requests.name(), ov::Any(1u)}},
{{ov::hint::performance_mode.name(), ov::Any(ov::hint::PerformanceMode::LATENCY)}},
- {{ov::hint::num_requests.name(), ov::Any(1u)}}};
+ {{ov::hint::num_requests.name(), ov::Any(1u)}},
+ {{ov::cache_encryption_callbacks.name(),
+ ov::Any(ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor})}},
+};
const std::vector<ov::AnyMap> publicCompiledModelConfigs = {
// execution_mode isn't supported with PV driver.
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp
index e35701b19a6..fd2247ccd8b 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/caching_tests.cpp
@@ -145,4 +145,9 @@ INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CachingSupportCase_NPU_Check_Config
::testing::ValuesIn(cachingProperties)),
ov::test::utils::appendPlatformTypeTestName<CompileModelLoadFromCacheTest>);
+INSTANTIATE_TEST_SUITE_P(smoke_BehaviorTests_CompileModelWithCacheEncryptionTest_NPU,
+ CompileModelWithCacheEncryptionTest,
+ ::testing::Values(ov::test::utils::DEVICE_NPU),
+ ov::test::utils::appendPlatformTypeTestName<CompileModelWithCacheEncryptionTest>);
+
} // namespace
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp
index 96d100a21ee..b833d813d1f 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/behavior/ov_plugin/properties_tests.cpp
@@ -5,6 +5,7 @@
#include "behavior/ov_plugin/properties_tests.hpp"
#include <array>
+#include <openvino/util/codec_xor.hpp>
#include "common/npu_test_env_cfg.hpp"
#include "common/utils.hpp"
@@ -36,6 +37,18 @@ ov::log::Level getTestsLogLevelFromEnvironmentOr(ov::log::Level instead) {
return instead;
}
+const std::vector<std::string> anyMapVecToStringVec(const std::vector<ov::AnyMap>& anyMaps) {
+ std::vector<std::string> result;
+ for (const auto& anyMap : anyMaps) {
+ for (const auto& keyValue : anyMap) {
+ if (std::find(result.begin(), result.end(), keyValue.first) == result.end()) {
+ result.push_back(keyValue.first);
+ }
+ }
+ }
+ return result;
+}
+
const std::vector<ov::AnyMap> compat_CorrectPluginMutableProperties = {
// OV
{{ov::hint::performance_mode.name(), ov::hint::PerformanceMode::THROUGHPUT}},
@@ -46,6 +59,7 @@ const std::vector<ov::AnyMap> compat_CorrectPluginMutableProperties = {
{{ov::log::level.name(), ov::log::Level::ERR}},
{{ov::device::id.name(), removeDeviceNameOnlyID(ov::test::utils::getTestsPlatformFromEnvironmentOr("3720"))}},
{{ov::enable_profiling.name(), true}},
+ {{ov::cache_encryption_callbacks.name(), ov::EncryptionCallbacks{ov::util::codec_xor, ov::util::codec_xor}}},
};
const std::vector<ov::AnyMap> CorrectPluginMutableProperties = {
@@ -198,7 +212,8 @@ INSTANTIATE_TEST_SUITE_P(
smoke_BehaviorTests_OVCheckSetSupportedRWMetricsPropsTests,
OVCheckSetSupportedRWMetricsPropsTests,
::testing::Combine(::testing::Values(ov::test::utils::DEVICE_NPU),
- ::testing::ValuesIn(getRWMandatoryPropertiesValues(compat_CorrectPluginMutableProperties))),
+ ::testing::ValuesIn(OVCheckSetSupportedRWMetricsPropsTests::getRWMandatoryPropertiesValues(
+ anyMapVecToStringVec(compat_CorrectPluginMutableProperties)))),
(ov::test::utils::appendPlatformTypeTestName<OVCheckSetSupportedRWMetricsPropsTests>));
INSTANTIATE_TEST_SUITE_P(
diff --git a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
index a02375f18b6..4df134f9242 100644
--- a/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
+++ b/src/plugins/intel_npu/tests/functional/shared_tests_instances/npu_skip_func_tests.xml
@@ -739,7 +739,7 @@ Example:
<!-- E###### -->
<skip_config>
- <message>NPU cannot set properties for compiled models</message>
+ <message>NPU cannot set properties for compiled models except CACHE_ENCRYPTION_CALLBACKS, but is not convertible to string</message>
<filters>
<filter>.*OVClassCompiledModelSetCorrectConfigTest.canSetConfig.*</filter>
</filters>
@@ -877,7 +877,43 @@ Example:
<device>3720</device>
</enable_rules>
<filters>
- <filter>.*ZeroGraphTest.SetAlignedBlob.*zeGraphNpuExtVersion=(1.13|1.14|1.15|1.16).*</filter>
+ <filter>.*ZeroGraphTest.SetAlignedBlob.*</filter>
+ </filters>
+ </skip_config>
+
+ <!-- E#213889 -->
+ <skip_config>
+ <message>Cannot use ENABLE_WEIGHTLESS with current driver</message>
+ <enable_rules>
+ <backend>LEVEL0</backend>
+ </enable_rules>
+ <filters>
+ <filter>.*WeightlessCacheAccuracy.*ENABLE_WEIGHTLESS.*NPU3720.*</filter>
+ </filters>
+ </skip_config>
+
+ <skip_config>
+ <message>TiWithLstmCell model won't provide `WeightlessCacheAttribute` in constants' rt_info</message>
+ <enable_rules>
+ <backend>LEVEL0</backend>
+ </enable_rules>
+ <filters>
+ <filter>.*WeightlessCacheAccuracy.TiWithLstmCell.*ENABLE_WEIGHTLESS.*</filter>
+ </filters>
+ </skip_config>
+
+ <!-- C#185847 -->
+ <skip_config>
+ <message>Write only (WO) properties will return empty ov::Any objects</message>
+ <enable_rules>
+ <backend>LEVEL0</backend>
+ </enable_rules>
+ <filters>
+ <filter>.*OVClassCompiledModelPropertiesTests.canCompileModelWithPropertiesAndCheckGetProperty.*CACHE_ENCRYPTION_CALLBACKS.*</filter>
+ <filter>.*OVPropertiesTests.canSetPropertyAndCheckGetProperty.*CACHE_ENCRYPTION_CALLBACKS.*</filter>
+ <filter>.*OVPropertiesDefaultSupportedTests.CanSetDefaultValueBackToPlugin.*</filter>
+ <filter>.*OVClassCompiledModelGetConfigTest.GetConfigNoThrow.*</filter>
+ <filter>.*OVSpecificDeviceGetConfigTest.GetConfigSpecificDeviceNoThrow.*</filter>
</filters>
</skip_config>
diff --git a/src/plugins/intel_npu/thirdparty/level-zero-ext b/src/plugins/intel_npu/thirdparty/level-zero-ext
index 42768cc73e7..c7cb5d218ca 160000
--- a/src/plugins/intel_npu/thirdparty/level-zero-ext
+++ b/src/plugins/intel_npu/thirdparty/level-zero-ext
@@ -1 +1 @@
-Subproject commit 42768cc73e74f6d371bd9dd51b1860b07774e7ec
+Subproject commit c7cb5d218ca14f6a81b3ef0bb89e718e9fcdba8e
diff --git a/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp b/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp
index e403cd506cd..2678c5201ae 100644
--- a/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp
+++ b/src/tests/functional/plugin/shared/src/behavior/compiled_model/model_cache.cpp
@@ -3,28 +3,30 @@
//
#include "behavior/compiled_model/model_cache.hpp"
+
#include "common_test_utils/ov_tensor_utils.hpp"
#include "common_test_utils/subgraph_builders/read_concat_split_assign.hpp"
#include "common_test_utils/subgraph_builders/single_concat_with_constant.hpp"
#include "common_test_utils/subgraph_builders/ti_with_lstm_cell.hpp"
+#include "common_test_utils/subgraph_builders/weights_decompression_builders.hpp"
#include "common_test_utils/test_assertions.hpp"
#include "openvino/op/matmul.hpp"
#include "openvino/runtime/weightless_properties_utils.hpp"
#include "openvino/util/codec_xor.hpp"
#include "shared_test_classes/subgraph/weights_decompression_params.hpp"
-#include "common_test_utils/subgraph_builders/weights_decompression_builders.hpp"
namespace ov {
namespace test {
namespace behavior {
-std::string WeightlessCacheAccuracy::get_test_case_name(const ::testing::TestParamInfo<WeightlessCacheAccuracyTestParams>& obj) {
+std::string WeightlessCacheAccuracy::get_test_case_name(
+ const ::testing::TestParamInfo<WeightlessCacheAccuracyTestParams>& obj) {
std::ostringstream result;
result << "use_compile_model_api=" << utils::bool2str(std::get<0>(obj.param));
- result << "_do_encryption=" << utils::bool2str(std::get<1>(obj.param));
- result << "_inference_mode=" << std::get<2>(obj.param);
- result << "_model_dtype=" << std::get<3>(obj.param);
+ result << "_do_encryption=" << utils::bool2str(std::get<1>(obj.param));
+ result << "_inference_mode=" << std::get<2>(obj.param);
+ result << "_model_dtype=" << std::get<3>(obj.param);
result << "_config=";
for (const auto& [name, value] : std::get<4>(obj.param)) {
result << name << "[" << value.as<std::string>() << "]|";
@@ -50,8 +52,8 @@ void WeightlessCacheAccuracy::TearDown() {
std::remove(m_bin_path.c_str());
std::remove(m_cache_path.c_str());
- ov::test::utils::removeFilesWithExt(m_cache_dir, "blob");
- ov::test::utils::removeFilesWithExt(m_cache_dir, "cl_cache");
+ ov::test::utils::removeFilesWithExt<true>(m_cache_dir, "blob");
+ ov::test::utils::removeFilesWithExt<true>(m_cache_dir, "cl_cache");
ov::test::utils::removeDir(m_cache_dir);
}